Background
In CRuby, many methods are written in C. This contributes to the warmup speed and the performance of the interpreter, but this could sometimes be a problem for YJIT:
- Having a C frame in between Ruby frames prevents inlining (apply callsite-specific optimization across different methods, and possibly skip pushing/popping a CFP in inline code)
- Not only it incurs a setjmp cost on
vm_exec for every Ruby call from C, but it also causes interp_return exits on leave insn.
Idea
Rewrite C methods that call Ruby methods/blocks frequently in Ruby if that makes YJIT faster and doesn't slow down the interpreter too much in headline benchmarks. Past successful examples: ruby#3281, ruby#6983
Ones with large "block calls from C" in ruby/ruby-bench#168, e.g. Array#each, might be promising targets.