YJIT Benchmarks

2022-08-03 05:29:26

As of 2022-08-03 05:29:26:

Overall YJIT is 34.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 36.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 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 153.6 0.33% 157.1 0.40% 103.9 0.65% 0.98x 0.52% 1.48x 0.73% 85.94%
hexapdf 3094.2 1.06% 2315.4 1.50% 1.34x 1.83% 83.44%
liquid-render 194.7 0.96% 170.2 1.57% 128.5 1.67% 1.14x 1.84% 1.51x 1.93% 85.90%
mail 177.4 0.58% 173.3 1.88% 155.8 0.17% 1.02x 1.97% 1.14x 0.60% 99.35%
psych-load 2476.3 0.02% 2168.7 0.02% 1918.6 0.02% 1.14x 0.03% 1.29x 0.03% 88.89%
railsbench 2784.5 0.57% 2823.0 0.65% 2046.1 0.83% 0.99x 0.86% 1.36x 1.01% 86.54%
binarytrees 469.9 0.23% 309.6 0.32% 364.7 0.06% 1.52x 0.40% 1.29x 0.24% 84.27%
chunky_png 965.1 0.05% 753.5 0.05% 628.7 0.05% 1.28x 0.07% 1.54x 0.08% 99.95%
erubi 372.4 0.59% 344.3 0.70% 320.7 0.66% 1.08x 0.92% 1.16x 0.89% 100.00%
erubi_rails 26.8 2.72% 26.9 2.59% 19.3 3.28% 1.00x 3.75% 1.39x 4.26% 86.39%
fannkuchredux 6943.4 0.13% 3954.6 0.06% 6904.9 0.12% 1.76x 0.15% 1.01x 0.18% 0.02%
lee 1265.3 0.87% 1058.5 1.08% 944.6 1.13% 1.20x 1.39% 1.34x 1.42% 99.97%
nbody 122.4 0.07% 76.5 0.23% 94.1 0.12% 1.60x 0.24% 1.30x 0.14% 100.00%
optcarrot 6304.9 0.40% 2852.1 0.60% 3464.4 0.60% 2.21x 0.73% 1.82x 0.72% 96.16%
rubykon 12797.9 0.63% 8178.6 0.84% 6788.9 1.26% 1.56x 1.05% 1.89x 1.41% 99.84%
30k_ifelse 2267.8 0.01% 3569.0 3.94% 362.1 0.06% 0.64x 3.94% 6.26x 0.06% 100.00%
30k_methods 6386.9 0.01% 9957.0 18.25% 878.0 0.02% 0.64x 18.25% 7.27x 0.02% 100.00%
cfunc_itself 103.7 0.15% 68.7 0.47% 46.5 0.59% 1.51x 0.50% 2.23x 0.61% 100.00%
fib 250.4 0.06% 86.2 0.20% 63.3 0.05% 2.90x 0.21% 3.96x 0.08% 100.00%
getivar 115.2 0.91% 32.8 59.13% 44.2 0.11% 3.51x 59.13% 2.60x 0.92% 99.02%
keyword_args 283.3 0.08% 223.0 0.34% 52.7 0.34% 1.27x 0.35% 5.38x 0.35% 100.00%
respond_to 281.0 0.12% 235.9 0.46% 200.1 0.92% 1.19x 0.48% 1.40x 0.93% 100.00%
setivar 76.2 0.15% 20.8 63.36% 40.4 0.53% 3.66x 63.36% 1.89x 0.55% 99.14%
str_concat 85.5 0.90% 51.7 1.24% 44.3 1.47% 1.65x 1.53% 1.93x 1.72% 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-03T04:14:10Z master 71794a75db) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-03T04:14:10Z master 71794a75db) +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 288 422
liquid-render 30 36 37
mail 49 53 56
psych-load 36 45 41
railsbench 104 106 133
binarytrees 31 33 33
chunky_png 44 46 49
erubi 69 98 89
erubi_rails 103 103 122
fannkuchredux 25 27 27
lee 33 40 39
nbody 25 26 27
optcarrot 59 66 65
rubykon 53 59 57
30k_ifelse 68 172 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 25 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 25 27 27
setivar 25 26 27
str_concat 122 109 101

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 188 75 188 20 188
hexapdf 5 15 20 15
liquid-render 5 160 75 160 20 160
mail 5 128 75 128 20 128
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 31 75 31 20 31
erubi 5 61 75 61 20 61
erubi_rails 5 1039 75 1039 20 1039
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 36 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 30 22 20 22
cfunc_itself 5 418 75 418 20 418
fib 5 316 75 316 20 316
getivar 5 614 75 614 20 614
keyword_args 5 379 75 379 20 379
respond_to 5 102 75 102 20 102
setivar 5 957 75 957 20 957
str_concat 5 451 75 451 20 451

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) 1037531 780843 131 1294 0 0% 0 0 0
hexapdf (click) 1150363 924945 682 8016 10 0% 0 0 0
liquid-render (click) 522267 406878 150 1709 2 0% 0 0 0
mail (click) 922459 665282 374 5577 17 0% 0 0 0
psych-load (click) 347419 263248 68 482 1 0% 0 0 0
railsbench (click) 2658779 1969912 1436 10042 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 387227 289579 88 1011 0 0% 0 0 0
erubi (click) 322907 246264 10 79 0 0% 0 0 0
erubi_rails (click) 1962459 1430135 300 2029 4 0% 0 0 0
fannkuchredux (click) 185307 138082 10 188 0 0% 0 0 0
lee (click) 386139 291740 58 632 0 0% 0 0 0
nbody (click) 182107 137147 12 171 0 0% 0 0 0
optcarrot (click) 513947 442610 207 3588 20 0% 0 0 0
rubykon (click) 320667 256597 144 1575 2 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) 171291 127662 11 51 0 0% 0 0 0
respond_to (click) 172571 128475 10 64 0 0% 0 0 0
setivar (click) 170587 127536 10 38 0 0% 0 0 0
str_concat (click) 170587 127943 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.