YJIT Benchmarks

2022-09-17 20:11:31

As of 2022-09-17 20:11:31:

Overall YJIT is 35.3% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 31.6% faster than CRuby!

The basic "faster" measurement is the geomean of all "headlining" benchmarks on this page.

Headlining Benchmarks

These are "headlining" because the "overall" speedup above is based on these benchmarks specifically.

0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 No JIT MJIT YJIT activerecord hexapdf liquid-render mail psych-load railsbench Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

MicroBenchmarks

0.0 2.0 4.0 6.0 8.0 No JIT MJIT YJIT 30k_ifelse 30k_methods cfunc_itself fib getivar keyword_args respond_to setivar str_concat Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

Other Benchmarks

0.0 0.5 1.0 1.5 2.0 No JIT MJIT YJIT binarytrees chunky_png erubi erubi_rails fannkuchredux lee nbody optcarrot rubykon Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

Want Raw Graphs and CSV?

Benchmarks Speed Details

The y axis is CRuby's pure-interpreter time for the benchmark divided by the named interpreter's time (YJIT, MJIT, TruffleRuby). Taller bars mean better performance. Each benchmark is scaled to the CRuby's interpreter's mean result, so CRuby's results are always exactly 1.0.

bench No JIT (ms) No JIT RSD MJIT (ms) MJIT RSD YJIT (ms) YJIT RSD MJIT spd MJIT spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 150.2 0.36% 176.2 4.32% 102.4 0.66% 0.85x 4.33% 1.47x 0.75% 85.28%
hexapdf 3188.8 0.97% 2336.6 2.16% 1.36x 2.37% 82.21%
liquid-render 191.0 1.95% 165.9 1.22% 115.6 1.86% 1.15x 2.30% 1.65x 2.70% 85.97%
mail 173.0 0.41% 177.0 2.35% 155.5 0.17% 0.98x 2.39% 1.11x 0.44% 99.33%
psych-load 2426.5 0.03% 2109.4 0.02% 1913.6 0.02% 1.15x 0.03% 1.27x 0.03% 88.89%
railsbench 2736.6 0.36% 2998.5 0.50% 2079.7 1.41% 0.91x 0.61% 1.32x 1.46% 86.28%
binarytrees 464.9 0.06% 313.6 0.18% 240.1 0.07% 1.48x 0.19% 1.94x 0.09% 100.00%
chunky_png 963.0 0.12% 787.5 0.05% 652.8 0.20% 1.22x 0.13% 1.48x 0.23% 99.95%
erubi 343.3 0.59% 328.0 0.56% 303.8 0.74% 1.05x 0.82% 1.13x 0.95% 100.00%
erubi_rails 26.4 2.48% 28.0 9.87% 19.3 3.38% 0.94x 10.18% 1.36x 4.19% 86.35%
fannkuchredux 5340.3 0.07% 5345.7 0.28% 2372.4 0.22% 1.00x 0.29% 2.25x 0.23% 77.42%
lee 1239.1 0.83% 1063.0 0.10% 944.1 0.99% 1.17x 0.84% 1.31x 1.29% 99.97%
nbody 119.5 0.10% 75.3 0.05% 91.0 0.13% 1.59x 0.11% 1.31x 0.16% 100.00%
optcarrot 6163.4 0.41% 2794.6 0.62% 3524.9 0.62% 2.21x 0.74% 1.75x 0.74% 96.16%
rubykon 12496.3 0.47% 9031.7 0.78% 7239.3 0.46% 1.38x 0.91% 1.73x 0.66% 99.75%
30k_ifelse 2370.2 0.01% 4373.1 2.77% 358.2 0.11% 0.54x 2.77% 6.62x 0.11% 100.00%
30k_methods 6526.9 0.01% 13255.0 3.86% 785.3 0.02% 0.49x 3.86% 8.31x 0.02% 100.00%
cfunc_itself 106.7 0.15% 98.4 0.15% 47.0 0.76% 1.08x 0.21% 2.27x 0.77% 100.00%
fib 244.4 0.05% 79.2 0.03% 62.9 0.10% 3.08x 0.06% 3.89x 0.11% 100.00%
getivar 105.5 0.10% 27.8 3.24% 42.8 0.05% 3.80x 3.24% 2.47x 0.11% 98.73%
keyword_args 289.4 0.07% 237.2 0.04% 53.8 0.16% 1.22x 0.08% 5.38x 0.17% 100.00%
respond_to 276.1 0.07% 257.7 0.14% 30.5 0.51% 1.07x 0.15% 9.06x 0.52% 100.00%
setivar 75.4 0.10% 75.6 0.17% 46.3 0.53% 1.00x 0.20% 1.63x 0.54% 98.01%
str_concat 83.8 1.07% 54.4 8.17% 46.5 1.24% 1.54x 8.24% 1.80x 1.64% 99.91%

RSD is relative standard deviation - the standard deviation divided by the mean, expressed as a percentage.
% in YJIT is the percentage of instructions that complete in YJIT rather than exiting to the non-JITted interpreter. YJIT performs better when this is higher.
Speedup is relative to interpreted CRuby. So an "MJIT speedup" of 1.21x means MJIT runs at 1.21 times the iters/second of CRuby with JIT disabled.

You can find our benchmark code in the yjit-bench Github repo and the yjit-extra-benchmarks Github repo.
Our benchmark-runner and reporting code is in the yjit-metrics Github repo.

Tested Ruby version for YJIT and No-JIT: ruby 3.2.0dev (2022-09-17T15:10:30Z master 67417e795a) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-17T15:10:30Z master 67417e795a) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 71 76
hexapdf 271 415
liquid-render 31 33 38
mail 49 54 56
psych-load 39 43 43
railsbench 102 122 131
binarytrees 30 32 33
chunky_png 39 45 43
erubi 80 126 106
erubi_rails 101 105 122
fannkuchredux 24 25 27
lee 33 38 40
nbody 25 26 27
optcarrot 63 70 70
rubykon 51 62 63
30k_ifelse 67 149 123
30k_methods 57 172 75
cfunc_itself 24 26 27
fib 25 25 27
getivar 25 26 27
keyword_args 24 26 27
respond_to 25 26 27
setivar 25 26 27
str_concat 113 110 97

Memory is shown in mebibytes (1024 * 1024 bytes.)

Older YJIT allocated an additional 256MiB for generated code. Current YJIT allocates executable memory on demand, so this overhead should no longer be present.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT warmups MJIT iters YJIT warmups YJIT iters
activerecord 5 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 179 75 179 20 179
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 83 75 83 20 83
chunky_png 5 30 75 30 20 30
erubi 5 66 75 66 20 66
erubi_rails 5 1042 75 1042 20 1042
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 266 75 266 20 266
optcarrot 5 15 75 15 20 15
rubykon 5 15 32 15 20 15
30k_ifelse 5 55 72 55 20 55
30k_methods 5 25 23 25 20 25
cfunc_itself 5 428 75 428 20 428
fib 5 317 75 317 20 317
getivar 5 467 75 467 20 467
keyword_args 5 368 75 368 20 368
respond_to 5 667 75 667 20 667
setivar 5 402 75 402 20 402
str_concat 5 428 75 428 20 428

Different Ruby configurations want different amounts of warmup. With no JIT, CRuby needs hardly any. YJIT and MJIT 3.0 both warm up quite quickly, while MJIT in 3.1 often slows down for a time as it compiles, after an unpredictable delay.

Benchmark YJIT Stats

Hover your cursor over the column headings for descriptions of each statistic.

bench Exit Report Inline Outlined Comp iSeqs Comp Blocks Inval Inval Ratio Bind Alloc Bind Set Const Bumps
activerecord (click) 1065463 776147 131 1267 0 0% 0 0 0
hexapdf (click) 1176695 918258 682 8044 9 0% 0 0 0
liquid-render (click) 522551 396623 150 1696 2 0% 0 0 0
mail (click) 952823 663055 374 5629 17 0% 0 0 0
psych-load (click) 355447 260647 68 474 1 0% 0 0 0
railsbench (click) 2720311 1954945 1436 10017 16 0% 0 0 0
binarytrees (click) 177143 127690 13 64 0 0% 0 0 0
chunky_png (click) 402807 290451 88 1063 0 0% 0 0 0
erubi (click) 341111 250544 10 79 0 0% 0 0 0
erubi_rails (click) 2014135 1422704 300 2028 4 0% 0 0 0
fannkuchredux (click) 189815 136544 10 196 0 0% 0 0 0
lee (click) 396407 288653 58 634 0 0% 0 0 0
nbody (click) 186935 135971 12 171 0 0% 0 0 0
optcarrot (click) 531639 441194 207 3592 20 0% 0 0 0
rubykon (click) 329335 255139 144 1577 1 0% 0 0 0
30k_ifelse (click) 5664247 4347294 9265 57804 0 0% 0 0 0
30k_methods (click) 2208503 1655756 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174391 125599 10 49 0 0% 0 0 0
fib (click) 172343 124947 10 38 0 0% 0 0 0
getivar (click) 174519 127294 10 65 0 0% 0 0 0
keyword_args (click) 174647 125930 11 51 0 0% 0 0 0
respond_to (click) 173367 126110 10 64 0 0% 0 0 0
setivar (click) 174327 126064 10 38 0 0% 0 0 0
str_concat (click) 173111 125743 12 62 0 0% 0 0 0

YJIT stats correspond to the YJIT stats exit report.

Raw JSON data files

All graphs and table data in this page comes from processing these data files, which come from benchmark runs.