Actions
Feature #8576
open 
    Add optimized method type for constant value methods
    Feature #8576:
    Add optimized method type for constant value methods
  
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
        
           Updated by Anonymous over 12 years ago
          Updated by Anonymous over 12 years ago
          
          
        
        
      
      - Assignee set to ko1 (Koichi Sasada)
Feedback would be appreciated!
        
           Updated by Anonymous over 12 years ago
          Updated by Anonymous over 12 years ago
          
          
        
        
      
      - Tracker changed from Bug to Feature
        
           Updated by ko1 (Koichi Sasada) about 12 years ago
          Updated by ko1 (Koichi Sasada) about 12 years ago
          
          
        
        
      
      Memo - Discussion on twitter:
https://twitter.com/charliesome/status/350901225010638850
        
           Updated by ko1 (Koichi Sasada) about 12 years ago
          Updated by ko1 (Koichi Sasada) about 12 years ago
          
          
        
        
      
      - Category set to core
- Target version set to 2.1.0
        
           Updated by ko1 (Koichi Sasada) almost 12 years ago
          Updated by ko1 (Koichi Sasada) almost 12 years ago
          
          
        
        
      
      - Target version changed from 2.1.0 to 2.6
        
           Updated by ko1 (Koichi Sasada) over 8 years ago
          Updated by ko1 (Koichi Sasada) over 8 years ago
          
          
        
        
      
      Actually, I tried this approach, but I couldn't find good improvement. I'll try it again.
        
           Updated by shyouhei (Shyouhei Urabe) over 8 years ago
          Updated by shyouhei (Shyouhei Urabe) over 8 years ago
          
          
        
        
      
      - Status changed from Open to Assigned
        
           Updated by naruse (Yui NARUSE) almost 8 years ago
          Updated by naruse (Yui NARUSE) almost 8 years ago
          
          
        
        
      
      - Target version deleted (2.6)
Actions