unused space code readonly data unused space code readonly data unused space code readonly data When it reaches --jit-max-cache, it fires "JIT compaction"
unused space code readonly data unused space code readonly data unused space code readonly data unused space code code code readonly data readonly data readonly data
unused space code readonly data unused space code readonly data unused space code readonly data unused space code code code readonly data readonly data readonly data L2, ... cache
Method dispatch on Ruby VM foo.bar Method search (slow) Verify cache Ruby method C function attr_reader alias Method entry Foo#bar has cache redefined?
Method dispatch on Ruby VM foo.bar Method search (slow) Verify cache Ruby method C function attr_reader alias Method entry Foo#bar has cache redefined?
Method dispatch on JIT foo.bar Verify cache Ruby method Method entry Foo#bar has cache Cancel JIT! Less branches Less memory access redefined? some inlining
Reading instance variable on VM Search index (many branches, slow) self.class. instance_variables[index = 2] @foo different class? has cache Verify cache
Reading instance variable on VM Search index (many branches, slow) self.class. instance_variables[index = 2] @foo different class? has cache Verify cache
Reading instance variable on JIT self.class. instance_variables[2] @foo different class? has cache Verify cache Cancel JIT! inlined index Less branches Less memory access
Conclusion • Ruby 2.6.0-preview3 JIT is still early days - Small --jit-max-cache might be an option for now • We still have chance to make Ruby 2.6.0 better - Benchmarks are wanted!!!