YJIT Benchmarks

2022-06-22 10:43:52

As of 2022-06-22 10:43:52:

Overall YJIT is 33.8% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 31.3% 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 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.4 0.38% 156.1 0.33% 102.0 0.63% 0.97x 0.50% 1.48x 0.74% 85.54%
hexapdf 3201.9 0.77% 2315.0 2.14% 1.38x 2.28% 83.46%
liquid-render 196.6 1.20% 173.0 1.88% 127.6 2.13% 1.14x 2.24% 1.54x 2.45% 85.70%
mail 181.6 0.12% 179.7 1.77% 169.6 0.17% 1.01x 1.77% 1.07x 0.21% 99.39%
psych-load 2444.4 0.05% 2164.2 0.06% 1893.9 0.08% 1.13x 0.07% 1.29x 0.09% 88.45%
railsbench 2793.9 0.88% 2825.1 0.81% 2127.9 1.36% 0.99x 1.19% 1.31x 1.62% 86.29%
binarytrees 466.1 0.04% 297.9 0.33% 351.8 0.06% 1.56x 0.33% 1.32x 0.07% 84.27%
chunky_png 976.3 0.17% 788.6 0.40% 657.8 0.06% 1.24x 0.43% 1.48x 0.18% 99.95%
erubi 454.9 0.69% 416.3 0.72% 390.0 0.86% 1.09x 1.00% 1.17x 1.10% 100.00%
erubi_rails 27.7 2.34% 27.7 2.38% 19.9 3.19% 1.00x 3.34% 1.39x 3.96% 86.30%
fannkuchredux 8686.3 0.19% 5729.8 0.21% 8815.6 0.14% 1.52x 0.29% 0.99x 0.23% 0.02%
lee 1242.1 0.31% 1016.4 0.87% 904.6 0.43% 1.22x 0.92% 1.37x 0.53% 99.97%
nbody 125.1 0.04% 73.0 0.27% 91.9 0.08% 1.71x 0.27% 1.36x 0.09% 100.00%
optcarrot 6124.4 0.44% 2586.0 0.61% 3398.0 0.57% 2.37x 0.75% 1.80x 0.72% 96.13%
rubykon 13175.7 2.00% 8958.0 4.67% 7499.2 4.84% 1.47x 5.08% 1.76x 5.24% 99.73%
30k_ifelse 2287.1 0.01% 3566.3 3.92% 354.1 0.19% 0.64x 3.92% 6.46x 0.20% 100.00%
30k_methods 6456.2 0.01% 10082.7 16.33% 884.1 0.02% 0.64x 16.33% 7.30x 0.02% 100.00%
cfunc_itself 107.5 0.14% 68.3 0.38% 46.6 0.64% 1.57x 0.40% 2.31x 0.65% 100.00%
fib 245.4 0.16% 86.2 0.18% 63.3 0.04% 2.85x 0.24% 3.88x 0.17% 100.00%
getivar 113.3 0.12% 26.1 69.04% 42.5 0.05% 4.34x 69.04% 2.67x 0.13% 99.20%
keyword_args 281.7 0.08% 221.8 0.93% 52.9 0.18% 1.27x 0.94% 5.32x 0.20% 100.00%
respond_to 275.7 0.16% 231.6 0.38% 189.3 0.06% 1.19x 0.41% 1.46x 0.17% 100.00%
setivar 83.8 0.38% 10.6 101.80% 51.0 0.33% 7.89x 101.80% 1.64x 0.50% 99.56%
str_concat 129.2 0.93% 97.1 0.62% 104.6 0.71% 1.33x 1.12% 1.23x 1.17% 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-22T09:32:22Z master e6f92cada1) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-22T09:32:22Z master e6f92cada1) +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 64 75
hexapdf 298 362
liquid-render 30 35 37
mail 49 53 55
psych-load 40 51 44
railsbench 102 107 131
binarytrees 30 33 33
chunky_png 42 45 47
erubi 72 86 118
erubi_rails 101 102 121
fannkuchredux 25 27 27
lee 34 42 39
nbody 25 26 27
optcarrot 59 66 65
rubykon 53 61 64
30k_ifelse 67 168 126
30k_methods 58 179 79
cfunc_itself 24 27 27
fib 24 27 27
getivar 24 26 27
keyword_args 25 27 26
respond_to 25 27 27
setivar 25 26 27
str_concat 115 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 189 75 189 20 189
hexapdf 5 15 20 15
liquid-render 5 155 75 155 20 155
mail 5 125 75 125 20 125
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 66 75 66 20 66
chunky_png 5 30 75 30 20 30
erubi 5 50 75 50 20 50
erubi_rails 5 1000 75 1000 20 1000
fannkuchredux 5 15 52 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 55 75 55 20 55
30k_methods 5 22 29 22 20 22
cfunc_itself 5 440 75 440 20 440
fib 5 315 75 315 20 315
getivar 5 755 75 755 20 755
keyword_args 5 377 75 377 20 377
respond_to 5 107 75 107 20 107
setivar 5 1872 75 1872 20 1872
str_concat 5 196 75 196 20 196

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) 1012443 753310 131 1250 0 0% 0 0 0
hexapdf (click) 1117851 877510 682 7749 10 0% 0 0 0
liquid-render (click) 504155 386752 150 1597 2 0% 0 0 0
mail (click) 914011 660413 374 5550 15 0% 0 0 0
psych-load (click) 339931 255621 68 457 1 0% 0 0 0
railsbench (click) 2620315 1916354 1436 9845 16 0% 0 0 0
binarytrees (click) 173211 129800 13 58 0 0% 0 0 0
chunky_png (click) 379163 283360 88 996 0 0% 0 0 0
erubi (click) 317083 240990 10 79 0 0% 0 0 0
erubi_rails (click) 1927067 1389059 300 1956 4 0% 0 0 0
fannkuchredux (click) 186715 140202 10 188 0 0% 0 0 0
lee (click) 377755 283368 58 622 0 0% 0 0 0
nbody (click) 182683 137001 12 158 0 0% 0 0 0
optcarrot (click) 513883 442250 207 3571 20 0% 0 0 0
rubykon (click) 317275 250372 144 1531 1 0% 0 0 0
30k_ifelse (click) 5561755 4349828 9265 57804 0 0% 0 0 0
30k_methods (click) 2176923 1658290 5784 19361 0 0% 0 0 0
cfunc_itself (click) 171227 128133 10 49 0 0% 0 0 0
fib (click) 170203 128037 10 38 0 0% 0 0 0
getivar (click) 171995 130548 10 65 0 0% 0 0 0
keyword_args (click) 172059 128774 11 51 0 0% 0 0 0
respond_to (click) 173339 129587 10 64 0 0% 0 0 0
setivar (click) 171931 129072 10 38 0 0% 0 0 0
str_concat (click) 171931 129392 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.