YJIT Benchmarks

2022-08-07 20:14:18

As of 2022-08-07 20:14:18:

Overall YJIT is 36.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 35.8% 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 MJIT 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 MJIT 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 MJIT 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 MJIT (ms) MJIT RSD YJIT (ms) YJIT RSD MJIT spd MJIT spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 152.0 0.37% 152.1 0.96% 101.9 0.62% 1.00x 1.03% 1.49x 0.72% 85.93%
hexapdf 3295.7 1.01% 2354.8 3.15% 1.40x 3.31% 82.49%
liquid-render 194.4 0.97% 170.8 1.62% 125.9 1.77% 1.14x 1.89% 1.54x 2.02% 85.90%
mail 178.2 0.11% 174.0 2.21% 154.9 0.15% 1.02x 2.21% 1.15x 0.18% 99.36%
psych-load 2468.8 0.02% 2128.9 0.02% 1920.6 0.02% 1.16x 0.03% 1.29x 0.02% 88.89%
railsbench 2814.0 0.45% 2844.4 0.57% 2071.8 1.30% 0.99x 0.72% 1.36x 1.37% 86.38%
binarytrees 475.8 0.05% 306.7 0.33% 366.8 0.05% 1.55x 0.33% 1.30x 0.07% 84.27%
chunky_png 972.7 0.04% 791.6 0.33% 644.1 0.05% 1.23x 0.33% 1.51x 0.06% 99.95%
erubi 368.1 0.61% 339.8 0.60% 319.8 0.67% 1.08x 0.86% 1.15x 0.90% 100.00%
erubi_rails 27.5 2.59% 27.4 2.52% 19.4 3.50% 1.00x 3.61% 1.42x 4.36% 86.39%
fannkuchredux 6921.3 0.14% 3963.9 0.16% 7082.2 0.22% 1.75x 0.21% 0.98x 0.26% 0.02%
lee 1243.7 1.35% 1038.0 0.69% 931.8 0.26% 1.20x 1.52% 1.33x 1.38% 99.97%
nbody 128.1 0.30% 76.4 0.23% 91.3 0.08% 1.68x 0.38% 1.40x 0.31% 100.00%
optcarrot 6415.5 0.43% 2758.6 0.62% 3472.7 0.65% 2.33x 0.75% 1.85x 0.78% 96.16%
rubykon 12522.6 0.42% 8069.2 0.63% 6832.1 0.30% 1.55x 0.76% 1.83x 0.52% 99.84%
30k_ifelse 2231.2 0.02% 3550.3 4.04% 357.9 0.08% 0.63x 4.04% 6.23x 0.08% 100.00%
30k_methods 6295.2 0.00% 10016.6 19.31% 869.7 0.02% 0.63x 19.31% 7.24x 0.02% 100.00%
cfunc_itself 112.8 0.12% 68.5 0.33% 44.8 0.64% 1.65x 0.35% 2.52x 0.65% 100.00%
fib 258.6 0.17% 86.2 0.21% 63.4 0.07% 3.00x 0.27% 4.08x 0.18% 100.00%
getivar 105.9 0.51% 32.6 54.37% 44.3 0.13% 3.25x 54.37% 2.39x 0.52% 99.02%
keyword_args 295.5 0.07% 223.9 0.85% 52.7 0.32% 1.32x 0.85% 5.61x 0.33% 100.00%
respond_to 272.7 0.11% 225.1 0.38% 188.0 0.05% 1.21x 0.40% 1.45x 0.12% 100.00%
setivar 76.7 0.19% 20.8 63.14% 50.3 0.35% 3.68x 63.15% 1.52x 0.40% 99.14%
str_concat 82.9 0.98% 50.0 1.36% 43.0 1.74% 1.66x 1.68% 1.93x 2.00% 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 MJIT 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 and the yjit-extra-benchmarks 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-07T16:13:54Z master 40f2078d48) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-07T16:13:54Z master 40f2078d48) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 290 367
liquid-render 31 35 37
mail 49 53 56
psych-load 37 46 42
railsbench 104 106 133
binarytrees 31 33 33
chunky_png 44 49 48
erubi 48 82 89
erubi_rails 102 103 122
fannkuchredux 25 27 27
lee 35 42 39
nbody 24 26 27
optcarrot 58 66 65
rubykon 52 60 56
30k_ifelse 68 170 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 25 27 27
getivar 25 26 27
keyword_args 25 27 27
respond_to 25 27 27
setivar 25 26 27
str_concat 125 110 116

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

Older YJIT allocated an additional 256MiB for generated code. Current YJIT allocates executable memory on demand, so this overhead should no longer be present.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT warmups MJIT iters YJIT warmups YJIT iters
activerecord 5 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 157 75 157 20 157
mail 5 129 75 129 20 129
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 62 75 62 20 62
erubi_rails 5 1041 75 1041 20 1041
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 30 22 20 22
cfunc_itself 5 436 75 436 20 436
fib 5 314 75 314 20 314
getivar 5 612 75 612 20 612
keyword_args 5 381 75 381 20 381
respond_to 5 106 75 106 20 106
setivar 5 957 75 957 20 957
str_concat 5 467 75 467 20 467

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) 1035099 779112 131 1272 0 0% 0 0 0
hexapdf (click) 1152155 925251 683 8028 9 0% 0 0 0
liquid-render (click) 516379 401098 150 1644 2 0% 0 0 0
mail (click) 897947 648474 374 5318 17 0% 0 0 0
psych-load (click) 346651 262713 68 482 1 0% 0 0 0
railsbench (click) 2653211 1965098 1436 10004 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 386459 288857 88 1005 0 0% 0 0 0
erubi (click) 322971 245939 10 79 0 0% 0 0 0
erubi_rails (click) 1958555 1426562 300 1995 4 0% 0 0 0
fannkuchredux (click) 185563 138093 10 188 0 0% 0 0 0
lee (click) 385307 290797 58 632 0 0% 0 0 0
nbody (click) 182683 137556 12 171 0 0% 0 0 0
optcarrot (click) 514075 442723 207 3588 20 0% 0 0 0
rubykon (click) 320667 256574 144 1568 1 0% 0 0 0
30k_ifelse (click) 5560539 4348420 9265 57804 0 0% 0 0 0
30k_methods (click) 2176667 1657507 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170587 127134 10 49 0 0% 0 0 0
fib (click) 169051 126742 10 38 0 0% 0 0 0
getivar (click) 170651 128716 10 65 0 0% 0 0 0
keyword_args (click) 171803 127991 11 51 0 0% 0 0 0
respond_to (click) 172507 128303 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.