From: "Юрий Соколов" Date: 2013-04-04T16:44:05+09:00 Subject: [ruby-core:53988] Re: [ruby-trunk - Bug #8211] Performance regression of method calls --047d7bb03a5070bf5404d984223a Content-Type: text/plain; charset=ISO-8859-1 Is your platform 32bit? Than it is cause of -fPIE 2013/4/4 bitsweat (Jeremy Kemper) > > Issue #8211 has been updated by bitsweat (Jeremy Kemper). > > > David, this looks a lot like the CFLAGS issues folks were hitting with > rvm. Essentially, getting unoptimized Ruby builds. > > Take a close look at the differences in RbConfig::CONFIG between your Ruby > builds. > > ruby -e 'puts RUBY_DESCRIPTION, RbConfig::CONFIG["cflags"], > RbConfig::CONFIG["CFLAGS"]' > > How did you build Ruby? > ---------------------------------------- > Bug #8211: Performance regression of method calls > https://bugs.ruby-lang.org/issues/8211#change-38202 > > 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/ > > --047d7bb03a5070bf5404d984223a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Is your platform 32bit? Than it is cause of -fPIE


2013/4/4 bitswea= t (Jeremy Kemper) <jeremy@bitsweat.net>

Issue #8211 has been updated by bitsweat (Jeremy Kemper).


David, this looks a lot like the CFLAGS issues folks were hitting with rvm.= Essentially, getting unoptimized Ruby builds.

Take a close look at the differences in RbConfig::CONFIG between your Ruby = builds.

ruby -e 'puts RUBY_DESCRIPTION, RbConfig::CONFIG["cflags"], R= bConfig::CONFIG["CFLAGS"]'

How did you build Ruby?
----------------------------------------
Bug #8211: Performance regression of method calls
https://bugs.ruby-lang.org/issues/8211#change-38202

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 ab= out 3 times slower !

Benchmarking results:
_____________________________________________________________
Ruby 1.9.3p392
=A0 =A0 =A0 =A0user =A0 =A0 system =A0 =A0 =A0total =A0 =A0 =A0 =A0real
lambda: =A08.310000 =A0 0.000000 =A0 8.310000 ( =A08.315247)
instance method: =A05.210000 =A0 0.000000 =A0 5.210000 ( =A05.219299)
class method: =A05.040000 =A0 0.000000 =A0 5.040000 ( =A05.037483)

Ruby 2.0.0-p0
=A0 =A0 =A0 =A0user =A0 =A0 system =A0 =A0 =A0total =A0 =A0 =A0 =A0real
lambda: 25.310000 =A0 0.010000 =A025.320000 ( 25.339897)
instance method: 17.870000 =A0 0.000000 =A017.870000 ( 17.882656)
class method: 17.630000 =A0 0.010000 =A017.640000 ( 17.650515)

Ruby 2.1.0-dev
=A0 =A0 =A0 =A0user =A0 =A0 system =A0 =A0 =A0total =A0 =A0 =A0 =A0real
lambda: 19.210000 =A0 0.000000 =A019.210000 ( 19.227314)
instance method: 13.930000 =A0 0.000000 =A013.930000 ( 13.936974)
class method: 14.000000 =A0 0.000000 =A014.000000 ( 14.001582)
_____________________________________________________________


The code:
_____________________________________________________________
require 'benchmark'

do_custom_stuff =3D lambda { 1 + 1 + 1 }

class CustomStuff
=A0 def self.do
=A0 =A0 1 + 1 + 1
=A0 end

=A0 def do
=A0 =A0 1 + 1 + 1
=A0 end
end

custom_stuff =3D CustomStuff.new

Benchmark.bm { |b|
=A0 =A0MANY =3D 50_000_000
=A0 =A0b.report("lambda:") =A0 =A0 =A0 =A0 =A0{ MANY.times { do_c= ustom_stuff.call }}
=A0 =A0b.report("instance method:") { MANY.times { custom_stuff.d= o =A0 =A0 =A0}}
=A0 =A0b.report("class method:") =A0 =A0{ MANY.times { CustomStuf= f.do =A0 =A0 =A0 }}
}
_____________________________________________________________


--
http://bugs.ruby-l= ang.org/


--047d7bb03a5070bf5404d984223a--