YJIT Benchmarks

2022-06-20 05:16:25

As of 2022-06-20 05:16:25:

Overall YJIT is 34.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.0% 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 152.4 0.45% 156.2 0.36% 105.4 0.52% 0.98x 0.58% 1.45x 0.69% 85.54%
hexapdf 3198.2 1.17% 2340.8 2.67% 1.37x 2.92% 83.13%
liquid-render 198.4 1.25% 173.5 1.95% 128.4 2.10% 1.14x 2.31% 1.55x 2.44% 85.70%
mail 181.3 0.32% 178.4 1.82% 159.3 0.19% 1.02x 1.85% 1.14x 0.37% 99.37%
psych-load 2620.1 0.44% 2170.5 0.05% 2045.8 0.12% 1.21x 0.45% 1.28x 0.46% 88.45%
railsbench 2830.0 0.91% 2797.5 0.85% 2111.9 1.56% 1.01x 1.25% 1.34x 1.81% 86.29%
binarytrees 478.0 0.05% 299.4 0.33% 357.5 0.05% 1.60x 0.34% 1.34x 0.07% 84.27%
chunky_png 972.6 0.09% 798.3 0.42% 664.6 0.06% 1.22x 0.43% 1.46x 0.10% 99.95%
discourse 546.6 7.19% 547.1 1.20% 477.9 1.68% 1.00x 7.29% 1.14x 7.38% 74.37%
erubi 463.2 0.54% 429.1 0.86% 398.5 0.91% 1.08x 1.01% 1.16x 1.05% 100.00%
erubi_rails 28.1 2.64% 28.2 2.23% 20.0 2.99% 1.00x 3.46% 1.41x 3.99% 86.30%
fannkuchredux 8670.6 0.14% 5701.3 0.13% 8870.9 0.19% 1.52x 0.19% 0.98x 0.24% 0.02%
lee 1283.3 0.07% 1056.8 1.26% 928.0 1.25% 1.21x 1.26% 1.38x 1.25% 99.97%
nbody 123.5 0.11% 73.0 0.26% 90.7 0.06% 1.69x 0.28% 1.36x 0.13% 100.00%
optcarrot 6201.1 0.45% 2619.7 0.84% 3479.9 0.58% 2.37x 0.95% 1.78x 0.73% 96.13%
rubykon 13289.2 3.17% 9031.8 3.19% 7622.4 3.93% 1.47x 4.49% 1.74x 5.04% 99.80%
30k_ifelse 2262.7 0.07% 3544.9 4.02% 357.8 0.08% 0.64x 4.02% 6.32x 0.10% 100.00%
30k_methods 6336.4 0.01% 10112.3 19.27% 877.4 0.03% 0.63x 19.27% 7.22x 0.03% 100.00%
cfunc_itself 115.1 0.29% 69.5 0.37% 45.4 0.76% 1.66x 0.47% 2.54x 0.81% 100.00%
fib 243.2 0.04% 86.2 0.22% 63.3 0.04% 2.82x 0.22% 3.84x 0.05% 100.00%
getivar 112.5 0.50% 26.5 70.77% 42.5 0.06% 4.25x 70.77% 2.65x 0.51% 99.21%
keyword_args 298.4 0.21% 227.2 0.20% 52.9 0.38% 1.31x 0.29% 5.64x 0.43% 100.00%
respond_to 275.8 0.37% 232.9 1.54% 186.5 0.16% 1.18x 1.58% 1.48x 0.40% 100.00%
setivar 83.7 0.67% 10.7 103.09% 54.0 0.29% 7.83x 103.09% 1.55x 0.73% 99.56%
str_concat 133.8 0.91% 101.6 0.90% 109.6 0.77% 1.32x 1.28% 1.22x 1.20% 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-20T03:11:41Z master ec5c56412f) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-20T03:11:41Z master ec5c56412f) +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 65 65 76
hexapdf 244 405
liquid-render 30 35 37
mail 49 54 57
psych-load 37 53 43
railsbench 103 108 131
binarytrees 31 33 32
chunky_png 41 46 45
discourse 394 419 471
erubi 69 90 114
erubi_rails 105 103 121
fannkuchredux 25 27 27
lee 33 39 39
nbody 25 26 27
optcarrot 58 66 65
rubykon 54 61 58
30k_ifelse 67 169 126
30k_methods 57 179 78
cfunc_itself 25 27 27
fib 24 27 26
getivar 25 26 27
keyword_args 25 27 27
respond_to 25 27 27
setivar 25 26 27
str_concat 100 92 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 156 75 156 20 156
mail 5 124 75 124 20 124
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
discourse 5 41 75 41 20 41
erubi 5 50 75 50 20 50
erubi_rails 5 996 75 996 20 996
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 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 446 75 446 20 446
fib 5 315 75 315 20 315
getivar 5 764 75 764 20 764
keyword_args 5 372 75 372 20 372
respond_to 5 105 75 105 20 105
setivar 5 1884 75 1884 20 1884
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) 1014107 754509 131 1242 0 0% 0 0 0
hexapdf (click) 1121755 880127 682 7767 9 0% 0 0 0
liquid-render (click) 507739 388945 150 1598 2 0% 0 0 0
mail (click) 915611 661105 374 5544 15 0% 0 0 0
psych-load (click) 340123 255458 68 462 1 0% 0 0 0
railsbench (click) 2621403 1916845 1436 9851 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 375835 280559 88 990 0 0% 0 0 0
discourse (click) 5945435 4414294 3237 25701 85 0% 2 0 0
erubi (click) 319515 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1928347 1389521 300 1978 4 0% 0 0 0
fannkuchredux (click) 188251 141143 10 188 0 0% 0 0 0
lee (click) 378395 283827 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) 319067 251385 144 1531 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) 170331 128117 10 38 0 0% 0 0 0
getivar (click) 173019 131193 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.