Project

General

Profile

Feature #8576

Add optimized method type for constant value methods

Added by charliesome (Charlie Somerville) over 4 years ago. Updated 6 months ago.

Status:
Assigned
Priority:
Normal
Target version:
[ruby-core:55687]

Description

I've written a patch adding a new method type (VM_METHOD_TYPE_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 [ruby-core:55688] Updated by charliesome (Charlie Somerville) over 4 years ago

  • Assignee set to ko1 (Koichi Sasada)

Feedback would be appreciated!

#2 Updated by charliesome (Charlie Somerville) over 4 years ago

  • Tracker changed from Bug to Feature

#4 [ruby-core:57485] Updated by ko1 (Koichi Sasada) about 4 years ago

  • Category set to core
  • Target version set to 2.1.0

#5 [ruby-core:59043] Updated by ko1 (Koichi Sasada) almost 4 years ago

  • Target version changed from 2.1.0 to next minor

#6 [ruby-core:79447] Updated by ko1 (Koichi Sasada) 8 months ago

Actually, I tried this approach, but I couldn't find good improvement. I'll try it again.

#7 Updated by shyouhei (Shyouhei Urabe) 6 months ago

  • Status changed from Open to Assigned

Also available in: Atom PDF