From: "charliesome (Charlie Somerville)" <charliesome@...> Date: 2013-06-29T00:09:04+09:00 Subject: [ruby-core:55688] [ruby-trunk - Bug #8576] Add optimized method type for constant value methods Issue #8576 has been updated by charliesome (Charlie Somerville). Assignee set to ko1 (Koichi Sasada) Feedback would be appreciated! ---------------------------------------- Bug #8576: Add optimized method type for constant value methods https://bugs.ruby-lang.org/issues/8576#change-40189 Author: charliesome (Charlie Somerville) Status: Open Priority: Normal Assignee: ko1 (Koichi Sasada) Category: Target version: ruby -v: ruby 2.1.0dev (2013-06-28 trunk 41688) [x86_64-darwin11.4.0] Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN 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 -- http://bugs.ruby-lang.org/