Files
ruby/zjit
Steven Webb 7ec1f13c07 ZJIT: Skip eliminate_empty_inline_frames if no inlining (#18871)
Resolves https://github.com/Shopify/ruby/issues/1035

If nothing has been inlined skip the eliminate empty inline optimisation pass. We can only do this if no inlining has occurred on any pass. In subsequent passes it's possible for no inlining to occur, but redundant code to be removed, resulting in empty inline frames. By definition of the loop, if `iteration > 0` then inlining has occurred. This is covered by [test_eliminate_empty_inline_frames_with_dead_snapshot](https://github.com/ruby/ruby/blob/1c391ebaeb16b733d7d9900d3b57082bf4c429a3/zjit/src/hir/opt_tests.rs#L2238).

It cuts ~4ms off the compile time:

    build❯ for i in $(seq 0 5); do WARMUP_ITRS=0 MIN_BENCH_ITRS=2 MIN_BENCH_TIME=0 ./ruby --zjit --zjit-stats ruby-bench/benchmarks/lobsters/benchmark.rb 2>&1 | grep eliminate_empty_inline; done
    compile_hir_eliminate_empty_inline_frames_time:                      8ms
    compile_hir_eliminate_empty_inline_frames_time:                      9ms
    compile_hir_eliminate_empty_inline_frames_time:                      9ms
    compile_hir_eliminate_empty_inline_frames_time:                      9ms
    compile_hir_eliminate_empty_inline_frames_time:                      9ms
    compile_hir_eliminate_empty_inline_frames_time:                      9ms

vs master:

    build❯ for i in $(seq 0 5); do WARMUP_ITRS=0 MIN_BENCH_ITRS=2 MIN_BENCH_TIME=0 ./ruby --zjit --zjit-stats ruby-bench/benchmarks/lobsters/benchmark.rb 2>&1 | grep eliminate_empty_inline; done
    compile_hir_eliminate_empty_inline_frames_time:                    13ms
    compile_hir_eliminate_empty_inline_frames_time:                    14ms
    compile_hir_eliminate_empty_inline_frames_time:                    14ms
    compile_hir_eliminate_empty_inline_frames_time:                    13ms
    compile_hir_eliminate_empty_inline_frames_time:                    13ms
    compile_hir_eliminate_empty_inline_frames_time:                    14ms

To measure the change this PR also adds compile_hir_eliminate_empty_inline_frames_time_ns to the statistics displayed.
2026-10-19 16:22:49 -04:00
..