Project

General

Profile

Actions

Bug #13167

closed

Dir.glob is 25x slower since Ruby 2.2

Added by ahorek (Pavel Rosický) about 7 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
[ruby-core:79304]

Description

Hello,
we've found a huge speed regression in our Rails app. After some digging the reason is in Dir.glob method which is much slower since Ruby 2.2.6. This is probably Windows only!

This code is used heavily in Rails for partial lookups:

Dir.glob('c:/test/myapp/app/views/common/_menu_stats{.en,}{.html,}{}{.erb,.builder,.raw,.ruby,.jbuilder,.coffee,}')

Comparsion (x64):
jruby 9.1.7.0 2540 i/s
ruby 2.1.5 2568 i/s
ruby 2.1.9 2569 i/s
ruby 2.2.6 99 i/s 25 times slower!
ruby 2.3.3 102 i/s
ruby 2.4.0 103 i/s

I would like to help, but I don't know much about Ruby C internals. Please let me know if you need any additional info. Now we're stuck at 2.1.9 because this issue makes the development on more recent versions unusable.


Files

logruby24.txt (484 KB) logruby24.txt ahorek (Pavel Rosický), 07/24/2017 07:34 PM
logruby21.txt (10.8 KB) logruby21.txt ahorek (Pavel Rosický), 07/24/2017 07:34 PM
bench_dir_glob.rb (880 Bytes) bench_dir_glob.rb h.shirosaki (Hiroshi Shirosaki), 09/11/2017 09:58 AM
0001-dir.c-performance-fix-with-braces-using-cache.patch (5.84 KB) 0001-dir.c-performance-fix-with-braces-using-cache.patch h.shirosaki (Hiroshi Shirosaki), 09/11/2017 02:23 PM
0001-dir.c-performance-fix-with-braces.patch (8.64 KB) 0001-dir.c-performance-fix-with-braces.patch h.shirosaki (Hiroshi Shirosaki), 02/06/2018 02:09 AM
linux_braces.png (24.1 KB) linux_braces.png ahorek (Pavel Rosický), 08/05/2018 04:26 PM
linux_list.png (23.5 KB) linux_list.png ahorek (Pavel Rosický), 08/05/2018 04:26 PM
linux_recursive.png (26.6 KB) linux_recursive.png ahorek (Pavel Rosický), 08/05/2018 04:26 PM
windows_braces.png (23.6 KB) windows_braces.png ahorek (Pavel Rosický), 08/05/2018 04:26 PM
windows_list.png (23.1 KB) windows_list.png ahorek (Pavel Rosický), 08/05/2018 04:26 PM
windows_recursive.png (28 KB) windows_recursive.png ahorek (Pavel Rosický), 08/05/2018 04:26 PM
bench_dir_glob2.rb (982 Bytes) bench_dir_glob2.rb ahorek (Pavel Rosický), 08/05/2018 04:45 PM

Related issues 3 (0 open3 closed)

Related to Ruby master - Bug #10015: Performance regression in Dir#[]ClosedActions
Related to Ruby master - Feature #13873: Optimize Dir.glob with FNM_EXTGLOBClosedActions
Related to Ruby master - Bug #19042: Bug: Dir.glob ignores subdirectories in alternation when alternation is preceded by recursive directory patternClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0