From: "dunric (David Unric)" Date: 2013-04-05T00:39:51+09:00 Subject: [ruby-core:53998] [ruby-trunk - Bug #8211] Performance regression of method calls Issue #8211 has been updated by dunric (David Unric). Asking to close this issue (reason: suboptimal compiler flags). I've rebuilt Ruby with the following options and now get the expected performance: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux] -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC user system total real lambda: 7.650000 0.000000 7.650000 ( 7.651665) instance method: 4.350000 0.000000 4.350000 ( 4.352077) class method: 4.290000 0.000000 4.290000 ( 4.296082) ---------------------------------------- Bug #8211: Performance regression of method calls https://bugs.ruby-lang.org/issues/8211#change-38232 Author: dunric (David Unric) Status: Open Priority: Normal Assignee: Category: core Target version: ruby -v: 2.0.0p0 There are significant performance regressions in the newer Ruby versions. When compared to the last 1.9 patch build, method & lambda calls are about 3 times slower ! Benchmarking results: _____________________________________________________________ Ruby 1.9.3p392 user system total real lambda: 8.310000 0.000000 8.310000 ( 8.315247) instance method: 5.210000 0.000000 5.210000 ( 5.219299) class method: 5.040000 0.000000 5.040000 ( 5.037483) Ruby 2.0.0-p0 user system total real lambda: 25.310000 0.010000 25.320000 ( 25.339897) instance method: 17.870000 0.000000 17.870000 ( 17.882656) class method: 17.630000 0.010000 17.640000 ( 17.650515) Ruby 2.1.0-dev user system total real lambda: 19.210000 0.000000 19.210000 ( 19.227314) instance method: 13.930000 0.000000 13.930000 ( 13.936974) class method: 14.000000 0.000000 14.000000 ( 14.001582) _____________________________________________________________ The code: _____________________________________________________________ require 'benchmark' do_custom_stuff = lambda { 1 + 1 + 1 } class CustomStuff def self.do 1 + 1 + 1 end def do 1 + 1 + 1 end end custom_stuff = CustomStuff.new Benchmark.bm { |b| MANY = 50_000_000 b.report("lambda:") { MANY.times { do_custom_stuff.call }} b.report("instance method:") { MANY.times { custom_stuff.do }} b.report("class method:") { MANY.times { CustomStuff.do }} } _____________________________________________________________ -- http://bugs.ruby-lang.org/