Project

General

Profile

« Previous | Next » 

Revision 1f0888ab

Added by peterzhu2118 (Peter Zhu) over 2 years ago

Speed up shape transitions

This commit significantly speeds up shape transitions as it changes
get_next_shape_internal to not perform a lookup (and instead require
the caller to perform the lookup). This avoids double lookups during
shape transitions.

There is a significant (~2x) speedup in the following micro-benchmark:

puts(Benchmark.measure do
  o = Object.new

  100_000.times do |i|
    o.instance_variable_set(:"@a#{i}", 0)
  end
end)

Before:

22.393194   0.201639  22.594833 ( 22.684237)

After:

11.323086   0.022284  11.345370 ( 11.389346)