Feature #8576

Add optimized method type for constant value methods

Added by Charlie Somerville 10 months ago. Updated 4 months ago.

[ruby-core:55687]
Status:Open
Priority:Normal
Assignee:Koichi Sasada
Category:core
Target version:next minor

Description

I've written a patch adding a new method type (VMMETHODTYPE_CONSTVAL) for methods that only return a constant value. The patch significantly improves the performance of calls to these types of methods.

I've written a small benchmark script:

require "benchmark"

def foo
  1234
end

puts Benchmark.measure {
  1_000_000.times do
    foo; foo; foo; foo; foo
    foo; foo; foo; foo; foo
  end
}

Before patch:

$ ./rb x.rb
  0.620000   0.000000   0.620000 (  0.625130)

After patch:

$ ./rb x.rb
  0.300000   0.000000   0.300000 (  0.296528)

The patch is here: https://github.com/charliesome/ruby/compare/constant-value-methods

History

#1 Updated by Charlie Somerville 10 months ago

  • Assignee set to Koichi Sasada

Feedback would be appreciated!

#2 Updated by Charlie Somerville 10 months ago

  • Tracker changed from Bug to Feature

#4 Updated by Koichi Sasada 7 months ago

  • Category set to core
  • Target version set to 2.1.0

#5 Updated by Koichi Sasada 4 months ago

  • Target version changed from 2.1.0 to next minor

Also available in: Atom PDF