YJIT Benchmarks

2022-06-17 20:15:08

As of 2022-06-17 20:15:08:

Overall YJIT is 34.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 32.1% 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 No JIT MJIT3.1 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 1.0 2.0 3.0 4.0 5.0 6.0 7.0 No JIT MJIT3.1 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 MJIT3.1 YJIT binarytrees chunky_png discourse 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 MJIT3.1 (ms) MJIT3.1 RSD YJIT (ms) YJIT RSD MJIT3.1 spd MJIT3.1 spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 151.6 0.52% 155.8 0.84% 103.7 0.56% 0.97x 0.99% 1.46x 0.76% 85.54%
hexapdf 3166.5 0.93% 2319.2 1.54% 1.37x 1.79% 84.15%
liquid-render 198.3 1.23% 171.8 1.95% 128.3 2.02% 1.15x 2.30% 1.55x 2.37% 85.70%
mail 180.8 0.20% 177.3 1.83% 159.3 0.17% 1.02x 1.84% 1.13x 0.26% 99.38%
psych-load 2637.5 0.11% 2154.0 0.04% 2041.6 0.06% 1.22x 0.12% 1.29x 0.12% 88.45%
railsbench 2823.5 0.84% 2801.2 0.90% 2137.6 1.85% 1.01x 1.23% 1.32x 2.03% 86.29%
binarytrees 476.0 0.29% 299.1 0.34% 359.1 0.06% 1.59x 0.45% 1.33x 0.30% 84.27%
chunky_png 980.0 0.08% 797.5 0.43% 660.0 0.09% 1.23x 0.44% 1.48x 0.12% 99.95%
discourse 540.5 1.55% 560.4 7.65% 542.8 2.69% 0.96x 7.80% 1.00x 3.10% 73.57%
erubi 462.6 0.54% 422.7 0.83% 393.3 0.65% 1.09x 0.98% 1.18x 0.84% 100.00%
erubi_rails 28.3 2.53% 27.8 2.26% 20.6 3.20% 1.02x 3.39% 1.37x 4.08% 86.30%
fannkuchredux 8713.4 0.13% 5686.6 0.30% 8947.8 0.17% 1.53x 0.33% 0.97x 0.21% 0.02%
lee 1274.1 0.07% 1024.6 0.43% 937.4 0.05% 1.24x 0.44% 1.36x 0.09% 99.97%
nbody 122.5 0.05% 73.2 0.32% 91.9 0.07% 1.67x 0.32% 1.33x 0.09% 100.00%
optcarrot 6280.6 0.42% 2618.9 0.60% 3430.0 0.60% 2.40x 0.73% 1.83x 0.74% 96.13%
rubykon 13238.8 2.51% 9106.1 3.40% 7513.0 5.05% 1.45x 4.22% 1.76x 5.64% 99.80%
30k_ifelse 2246.8 0.01% 3650.8 4.08% 359.3 0.09% 0.62x 4.08% 6.25x 0.09% 100.00%
30k_methods 6572.3 0.01% 10025.5 16.85% 889.5 0.02% 0.66x 16.85% 7.39x 0.02% 100.00%
cfunc_itself 104.2 0.18% 80.9 6.28% 44.8 0.73% 1.29x 6.28% 2.32x 0.75% 100.00%
fib 241.9 0.02% 86.2 0.19% 63.3 0.05% 2.81x 0.20% 3.82x 0.06% 100.00%
getivar 113.2 0.08% 26.5 71.24% 42.5 0.07% 4.28x 71.24% 2.66x 0.11% 99.20%
keyword_args 310.6 0.08% 226.6 0.53% 52.9 0.19% 1.37x 0.54% 5.87x 0.20% 100.00%
respond_to 279.6 0.12% 232.8 2.14% 191.5 0.10% 1.20x 2.14% 1.46x 0.16% 100.00%
setivar 75.7 0.16% 10.9 101.33% 53.8 0.19% 6.98x 101.33% 1.41x 0.24% 99.55%
str_concat 134.4 0.96% 101.0 0.68% 109.6 0.77% 1.33x 1.17% 1.23x 1.23% 99.68%

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 it 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.
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-06-17T19:17:19Z master 566c5447ae) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-17T19:17:19Z master 566c5447ae) +MJIT [x86_64-linux]
(We got much better MJIT results with released than prerelease, so we used those.)

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT3.1 mem (MiB) YJIT mem (MiB)
activerecord 64 65 76
hexapdf 283 394
liquid-render 30 35 37
mail 49 54 56
psych-load 38 53 43
railsbench 103 105 131
binarytrees 30 33 32
chunky_png 40 47 45
discourse 400 419 474
erubi 68 99 83
erubi_rails 104 102 121
fannkuchredux 25 27 27
lee 33 42 37
nbody 24 26 27
optcarrot 59 66 65
rubykon 56 63 61
30k_ifelse 67 172 126
30k_methods 57 179 79
cfunc_itself 25 27 27
fib 25 27 27
getivar 25 27 27
keyword_args 24 27 27
respond_to 24 27 27
setivar 24 26 27
str_concat 100 93 93

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

By default, YJIT allocates an additional 256MiB for generated code. The additional size allocated can be tuned with a command-line parameter, but allocating too little memory will result in YJIT no longer JITting new functions, so performance reverts toward interpreter speeds.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT3.1 warmups MJIT3.1 iters YJIT warmups YJIT iters
activerecord 5 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 153 75 153 20 153
mail 5 124 75 124 20 124
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 64 75 64 20 64
chunky_png 5 30 75 30 20 30
discourse 5 41 75 41 20 41
erubi 5 51 75 51 20 51
erubi_rails 5 972 75 972 20 972
fannkuchredux 5 15 51 15 20 15
lee 5 21 75 21 20 21
nbody 5 274 75 274 20 274
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 444 75 444 20 444
fib 5 315 75 315 20 315
getivar 5 758 75 758 20 758
keyword_args 5 378 75 378 20 378
respond_to 5 102 75 102 20 102
setivar 5 1845 75 1845 20 1845
str_concat 5 193 75 193 20 193

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) 1012571 753276 131 1246 0 0% 0 0 0
hexapdf (click) 1120027 878983 682 7748 9 0% 0 0 0
liquid-render (click) 516187 395555 150 1658 2 0% 0 0 0
mail (click) 910811 658109 374 5512 15 0% 0 0 0
psych-load (click) 339675 255149 68 457 1 0% 0 0 0
railsbench (click) 2625435 1919578 1436 9871 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 384155 286522 88 1035 0 0% 0 0 0
discourse (click) 5924443 4399862 3195 25463 85 0% 2 0 0
erubi (click) 319515 242761 10 79 0 0% 0 0 0
erubi_rails (click) 1929435 1390550 300 1980 4 0% 0 0 0
fannkuchredux (click) 186843 140282 10 188 0 0% 0 0 0
lee (click) 378971 284454 58 622 0 0% 0 0 0
nbody (click) 183707 137646 12 158 0 0% 0 0 0
optcarrot (click) 514907 442895 207 3571 20 0% 0 0 0
rubykon (click) 318619 251178 144 1530 1 0% 0 0 0
30k_ifelse (click) 5563291 4350769 9265 57804 0 0% 0 0 0
30k_methods (click) 2178459 1659231 5784 19361 0 0% 0 0 0
cfunc_itself (click) 172763 129074 10 49 0 0% 0 0 0
fib (click) 169819 127821 10 38 0 0% 0 0 0
getivar (click) 172123 130628 10 65 0 0% 0 0 0
keyword_args (click) 173595 129715 11 51 0 0% 0 0 0
respond_to (click) 174875 130528 10 64 0 0% 0 0 0
setivar (click) 172955 129717 10 38 0 0% 0 0 0
str_concat (click) 172955 130037 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.