From: layon1993@... Date: 2016-04-06T14:54:39+00:00 Subject: [ruby-core:74832] [Ruby trunk Bug#10015] Performance regression in Dir#[] Issue #10015 has been updated by Layon Ferreira. ruby -v changed from ruby 2.2.0dev (2014-02-04 trunk 44802) [x86_64-darwin13.0] to ruby 2.3.0 [x86_64-darwin13.0] Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: UNKNOWN, 2.3: UNKNOWN The problem seems to persist Mac OS X, although is better on 2.3.0, is still a lot slower than 2.1.x. I have run the benchmark require "benchmark" time = [] 5.times do result = Benchmark.realtime { 800000.times do Dir['/tmp'] end } puts result time << result end average = time.inject{ |sum, el| sum + el }.to_f / time.size puts "average of: #{average}" On this machine: ``` ProductName: Mac OS X ProductVersion: 10.11.4 BuildVersion: 15E65 File System Personality: Case-sensitive Journaled HFS+ Type (Bundle): hfs Name (User Visible): Mac OS Extended (Case-sensitive, Journaled) Journal: Journal size 40960 KB at offset 0xe8e000 Owners: Enabled ``` On the all releases after 2.1.7 and got this results: ``` ===================================================== 2.1.7: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.1.7 2.86774 3.012784 2.867388 2.873973 3.127474 average of: 2.9498717999999995 ===================================================== 2.1.8: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.1.8 3.095918 2.981513 2.998208 3.142286 3.048603 average of: 3.0533056000000003 ===================================================== 2.1.9: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.1.9 3.022291 2.983054 2.931454 2.944659 3.051114 average of: 2.9865144 ===================================================== 2.2.0: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.2.0 4.985971766000148 5.047520838999844 5.066739754000082 5.005606599001112 5.0079711159996805 average of: 5.022762014800174 ===================================================== 2.2.1: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.2.1 5.0500176069999725 5.031266175999917 5.011832148000394 5.043594308999673 5.0333263849988725 average of: 5.034007324999766 ===================================================== 2.2.2: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.2.2 4.983856856000784 4.975439867999739 5.112457198998527 4.985339404000115 4.961809472000823 average of: 5.003780559799997 ===================================================== 2.2.3: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.2.3 4.832416973000363 4.970395954000196 5.007825999999113 4.891315167000357 4.913950877999014 average of: 4.923180994399809 ===================================================== 2.2.4: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.2.4 5.083285558999705 5.07147571600035 5.153286901999309 5.110161799999332 5.192000732999077 average of: 5.122042141999555 ===================================================== 2.3.0: benchmarking ===================================================== Using /Users/admin/.rvm/gems/ruby-2.3.0 3.785227087999374 3.9434133479990123 4.052104171998508 3.844644614999197 3.88892919600039 average of: 3.9028636837992963 ``` ---------------------------------------- Bug #10015: Performance regression in Dir#[] https://bugs.ruby-lang.org/issues/10015#change-57959 * Author: Aaron Patterson * Status: Closed * Priority: Normal * Assignee: * ruby -v: ruby 2.3.0 [x86_64-darwin13.0] * Backport: 2.0.0: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- r44802 seems to have introduced a performance regression in Dir#[]. Here is the test program: ~~~ruby require 'benchmark' puts Benchmark.realtime { glob = "minitest/*_plugin.rb{,.rb,.bundle}" $LOAD_PATH.map { |load_path| Dir["#{File.expand_path glob, load_path}"] }.flatten.select { |file| File.file? file.untaint } } ~~~ Here is the test time for me: ~~~ $ ruby -v test.rb ruby 2.2.0dev (2014-02-04 trunk 44801) [x86_64-darwin13.0] 0.000341 $ ruby -v test.rb ruby 2.2.0dev (2014-02-04 trunk 44802) [x86_64-darwin13.0] 0.009333 ~~~ r44801 seems much faster than r44802. -- https://bugs.ruby-lang.org/ Unsubscribe: