Related: Benchmark for performance testing, Taxonomy of Ruby Calls for optimization strategies, Ractor for parallel execution
Code Patching
Global Invalidation
def number one
one = 1
one
end
TracePoint.new(:line) do
it.binding.local_variable_set(:one, 5 * 10 ** 15)
end.enable
p number $ 5000000000000000Invalidated on Escaped Locals
def nuber
one = 1
do_something
one
end
def do_something
require 'binding_of_caller'
binding.of_caller(1).local_variable_set(:one, 5 * 10 ** 15)
end
p numberTest array
class Array
with_yjit do
undef :each
def each
Primitive.attr! :inline_block, :c_trace
end
end