[ruby-dev:50233] [Ruby trunk Bug#13861] Performance regressoion in Hash literal in Ruby 2.5.0-dev
From:
watson1978@...
Date:
2017-09-10 10:04:13 UTC
List:
ruby-dev #50233
Issue #13861 has been updated by watson1978 (Shizuo Fujita).
Seems this regression was fixed by https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=59744&view=revision
Thank you for fixing!!!
### before
```
$ ./miniruby -v -Ilib -I../benchmark-ips/lib ~/tmp/bench.rb
ruby 2.5.0dev (2017-09-05 trunk 59753) [x86_64-linux]
/home/watson/tmp/bench.rb:7: warning: assigned but unused variable - hash
/home/watson/tmp/bench.rb:15: warning: assigned but unused variable - string
Warming up --------------------------------------
Hash 96.137k i/100ms
String 219.522k i/100ms
Calculating -------------------------------------
Hash 1.723M (賊 0.6%) i/s - 8.652M in 5.021705s
String 16.975M (賊 0.3%) i/s - 84.955M in 5.004690s
```
### after
```
$ ./miniruby -v -Ilib -I../benchmark-ips/lib ~/tmp/bench.rb
ruby 2.5.0dev (2017-09-06 trunk 59810) [x86_64-linux]
/home/watson/tmp/bench.rb:7: warning: assigned but unused variable - hash
/home/watson/tmp/bench.rb:15: warning: assigned but unused variable - string
Warming up --------------------------------------
Hash 135.385k i/100ms
String 234.168k i/100ms
Calculating -------------------------------------
Hash 2.863M (賊 0.1%) i/s - 14.351M in 5.012065s
String 16.869M (賊 7.1%) i/s - 83.832M in 5.010604s
```
----------------------------------------
Bug #13861: Performance regressoion in Hash literal in Ruby 2.5.0-dev
https://bugs.ruby-lang.org/issues/13861#change-66577
* Author: watson1978 (Shizuo Fujita)
* Status: Third Party's Issue
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0dev (2017-09-02 trunk 59626) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Seems Ruby 2.5.0-dev has performance regressoion in Hash literal.
I've confirmed it with below benchmark script
Hash literal performance -> 35.7 % slow down since Ruby 2.4.1
### Environment
* Ubuntu 17.04
* gcc version 7.0.1
### Ruby 2.5.0-dev
```
$ ./miniruby -v -Ilib -I../benchmark-ips/lib ~/tmp/bench.rb
ruby 2.5.0dev (2017-09-02 trunk 59626) [x86_64-linux]
/home/watson/tmp/bench.rb:7: warning: assigned but unused variable - hash
/home/watson/tmp/bench.rb:15: warning: assigned but unused variable - string
Warming up --------------------------------------
Hash 93.650k i/100ms
String 226.366k i/100ms
Calculating -------------------------------------
Hash 1.713M (賊 0.2%) i/s - 8.616M in 5.030997s
String 16.477M (賊 0.1%) i/s - 82.397M in 5.000892s
```
### Ruby 2.4.1
```
$ ruby -v -Ilib -I../benchmark-ips/lib ~/tmp/bench.rb
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
/home/watson/tmp/bench.rb:7: warning: assigned but unused variable - hash
/home/watson/tmp/bench.rb:15: warning: assigned but unused variable - string
Warming up --------------------------------------
Hash 117.135k i/100ms
String 259.608k i/100ms
Calculating -------------------------------------
Hash 2.663M (賊 0.3%) i/s - 13.353M in 5.014087s
String 17.259M (賊 0.2%) i/s - 86.449M in 5.009036s
```
### Benchmark code
```ruby
require 'benchmark/ips'
Benchmark.ips do |x|
x.report "Hash" do |loop|
count = 0
while count < loop
hash = {foo: 12, bar: 34, baz: 56}
count += 1
end
end
x.report "String" do |loop|
count = 0
while count < loop
string = "hello world"
count += 1
end
end
end
```
---Files--------------------------------
tmp2.png (70.4 KB)
--
https://bugs.ruby-lang.org/