YJIT Benchmarks

2022-08-05 05:22:31

As of 2022-08-05 05:22:31:

Overall YJIT is 34.3% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 35.9% 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 149.9 0.38% 154.7 0.45% 103.3 0.56% 0.97x 0.59% 1.45x 0.68% 85.93%
hexapdf 3223.4 1.15% 2406.7 2.32% 1.34x 2.58% 83.45%
liquid-render 197.0 1.27% 171.7 1.56% 134.0 1.77% 1.15x 2.02% 1.47x 2.18% 85.90%
mail 179.2 0.13% 176.5 2.04% 154.8 0.15% 1.02x 2.05% 1.16x 0.20% 99.36%
psych-load 2506.1 0.03% 2151.2 0.20% 1921.0 0.02% 1.17x 0.20% 1.30x 0.03% 88.89%
railsbench 2823.1 0.76% 2819.8 0.54% 2076.9 0.48% 1.00x 0.93% 1.36x 0.90% 86.54%
binarytrees 479.5 0.05% 304.9 0.32% 369.0 0.06% 1.57x 0.33% 1.30x 0.08% 84.27%
chunky_png 977.1 0.05% 784.1 0.37% 649.1 0.06% 1.25x 0.38% 1.51x 0.07% 99.95%
erubi 377.7 0.54% 339.0 0.72% 318.2 0.69% 1.11x 0.90% 1.19x 0.88% 100.00%
erubi_rails 27.4 2.59% 27.7 3.04% 19.4 3.80% 0.99x 3.99% 1.41x 4.60% 86.40%
fannkuchredux 6951.6 0.13% 3974.1 0.10% 6916.9 0.26% 1.75x 0.16% 1.01x 0.29% 0.02%
lee 1268.2 0.82% 1041.0 0.31% 936.3 1.19% 1.22x 0.88% 1.35x 1.45% 99.97%
nbody 128.6 0.57% 85.8 0.21% 90.7 0.09% 1.50x 0.61% 1.42x 0.58% 100.00%
optcarrot 6378.1 0.42% 2771.4 0.61% 3441.1 0.60% 2.30x 0.74% 1.85x 0.73% 96.16%
rubykon 12506.5 0.76% 8051.9 0.60% 6997.0 0.35% 1.55x 0.97% 1.79x 0.84% 99.61%
30k_ifelse 2367.1 0.02% 3722.9 4.10% 363.0 0.09% 0.64x 4.10% 6.52x 0.09% 100.00%
30k_methods 6485.7 0.01% 10211.7 18.36% 870.6 0.02% 0.64x 18.36% 7.45x 0.02% 100.00%
cfunc_itself 111.3 0.14% 68.6 0.45% 45.6 0.69% 1.62x 0.48% 2.44x 0.70% 100.00%
fib 260.3 0.33% 86.2 0.20% 63.5 0.07% 3.02x 0.38% 4.10x 0.33% 100.00%
getivar 105.9 0.53% 32.8 55.97% 44.2 0.10% 3.23x 55.97% 2.39x 0.53% 99.02%
keyword_args 286.3 0.08% 229.9 0.39% 52.8 0.11% 1.25x 0.40% 5.43x 0.14% 100.00%
respond_to 272.6 0.12% 226.9 0.83% 188.3 0.31% 1.20x 0.84% 1.45x 0.33% 100.00%
setivar 76.6 0.28% 20.8 62.93% 49.7 0.10% 3.68x 62.93% 1.54x 0.30% 99.14%
str_concat 82.9 0.95% 49.7 1.69% 43.6 1.58% 1.67x 1.94% 1.90x 1.84% 99.69%

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-08-05T00:55:49Z master 73f0573cb3) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-05T00:55:49Z master 73f0573cb3) +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 306 401
liquid-render 31 36 37
mail 49 53 56
psych-load 36 45 40
railsbench 104 106 133
binarytrees 31 33 32
chunky_png 44 50 48
erubi 78 89 95
erubi_rails 102 103 122
fannkuchredux 25 27 27
lee 33 42 39
nbody 25 27 27
optcarrot 58 66 64
rubykon 52 60 57
30k_ifelse 68 174 127
30k_methods 57 176 76
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 26 27
keyword_args 25 27 26
respond_to 24 27 27
setivar 25 26 27
str_concat 123 110 107

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 192 75 192 20 192
hexapdf 5 15 20 15
liquid-render 5 159 75 159 20 159
mail 5 127 75 127 20 127
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 65 75 65 20 65
chunky_png 5 30 75 30 20 30
erubi 5 63 75 63 20 63
erubi_rails 5 1007 75 1007 20 1007
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 261 75 261 20 261
optcarrot 5 15 75 15 20 15
rubykon 5 15 37 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 314 75 314 20 314
getivar 5 610 75 610 20 610
keyword_args 5 378 75 378 20 378
respond_to 5 107 75 107 20 107
setivar 5 962 75 962 20 962
str_concat 5 459 75 459 20 459

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) 1036699 779928 131 1280 0 0% 0 0 0
hexapdf (click) 1150363 924037 682 8015 9 0% 0 0 0
liquid-render (click) 517659 403164 150 1657 2 0% 0 0 0
mail (click) 931291 670692 374 5645 17 0% 0 0 0
psych-load (click) 348379 264154 68 482 1 0% 0 0 0
railsbench (click) 2659163 1968950 1436 10041 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 390299 291278 88 1038 0 0% 0 0 0
erubi (click) 322907 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1961627 1428785 300 2026 4 0% 0 0 0
fannkuchredux (click) 185755 138378 10 188 0 0% 0 0 0
lee (click) 386267 291590 58 632 0 0% 0 0 0
nbody (click) 182555 137443 12 171 0 0% 0 0 0
optcarrot (click) 513947 442610 207 3588 20 0% 0 0 0
rubykon (click) 322651 258175 144 1588 1 0% 0 0 0
30k_ifelse (click) 5560987 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2176155 1657178 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170459 127021 10 49 0 0% 0 0 0
fib (click) 168923 126629 10 38 0 0% 0 0 0
getivar (click) 170651 128716 10 65 0 0% 0 0 0
keyword_args (click) 170843 127366 11 51 0 0% 0 0 0
respond_to (click) 172123 128179 10 64 0 0% 0 0 0
setivar (click) 170587 127536 10 38 0 0% 0 0 0
str_concat (click) 170587 127868 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.