YJIT Benchmarks

2022-08-06 20:13:59

As of 2022-08-06 20:13:59:

Overall YJIT is 35.9% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 32.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 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 153.3 0.35% 155.5 0.31% 103.3 0.59% 0.99x 0.47% 1.48x 0.69% 85.93%
hexapdf 3228.6 0.85% 2365.6 1.74% 1.36x 1.94% 83.21%
liquid-render 196.0 0.98% 170.5 1.59% 125.6 1.73% 1.15x 1.87% 1.56x 1.99% 85.90%
mail 179.1 0.15% 172.8 2.21% 155.3 0.17% 1.04x 2.21% 1.15x 0.23% 99.38%
psych-load 2537.9 0.03% 2152.7 0.10% 1933.2 0.02% 1.18x 0.11% 1.31x 0.04% 88.89%
railsbench 2787.0 0.55% 2806.5 0.57% 2111.9 0.91% 0.99x 0.79% 1.32x 1.07% 86.54%
binarytrees 476.7 0.06% 305.5 0.32% 367.9 0.08% 1.56x 0.33% 1.30x 0.10% 84.27%
chunky_png 974.4 0.05% 784.2 0.41% 648.8 0.06% 1.24x 0.41% 1.50x 0.08% 99.95%
erubi 375.3 0.62% 343.5 0.69% 321.6 0.64% 1.09x 0.93% 1.17x 0.89% 100.00%
erubi_rails 27.0 2.56% 27.4 2.39% 19.6 3.50% 0.98x 3.50% 1.37x 4.34% 86.39%
fannkuchredux 7075.9 0.11% 3979.9 0.11% 6932.6 0.10% 1.78x 0.15% 1.02x 0.15% 0.02%
lee 1247.0 1.27% 1039.3 0.38% 931.3 0.32% 1.20x 1.33% 1.34x 1.31% 99.97%
nbody 129.4 0.26% 76.4 0.24% 90.7 0.07% 1.69x 0.35% 1.43x 0.27% 100.00%
optcarrot 6403.3 0.42% 2774.3 0.62% 3445.0 0.60% 2.31x 0.74% 1.86x 0.73% 96.16%
rubykon 12623.8 0.65% 8362.0 0.85% 6811.0 0.71% 1.51x 1.07% 1.85x 0.97% 99.89%
30k_ifelse 2293.0 0.04% 3690.1 4.11% 358.9 0.07% 0.62x 4.11% 6.39x 0.08% 100.00%
30k_methods 6578.9 0.01% 9889.2 20.29% 870.8 0.02% 0.67x 20.29% 7.55x 0.02% 100.00%
cfunc_itself 111.4 0.20% 69.4 0.61% 45.8 0.62% 1.60x 0.64% 2.43x 0.65% 100.00%
fib 258.0 0.13% 86.2 0.27% 63.5 0.06% 2.99x 0.30% 4.06x 0.15% 100.00%
getivar 105.8 0.50% 32.7 56.01% 44.3 0.12% 3.23x 56.01% 2.39x 0.51% 99.01%
keyword_args 300.0 0.10% 223.9 0.63% 54.6 0.11% 1.34x 0.63% 5.50x 0.15% 100.00%
respond_to 275.9 0.17% 228.2 0.47% 188.9 0.20% 1.21x 0.50% 1.46x 0.26% 100.00%
setivar 76.7 0.24% 20.9 63.34% 49.7 0.11% 3.67x 63.34% 1.54x 0.27% 99.14%
str_concat 83.6 0.97% 50.3 1.22% 43.2 1.61% 1.66x 1.56% 1.94x 1.88% 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-06T15:03:21Z master 6d742c9412) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-06T15:03:21Z master 6d742c9412) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 65 76
hexapdf 288 401
liquid-render 31 35 37
mail 49 53 57
psych-load 39 44 41
railsbench 104 106 131
binarytrees 31 33 33
chunky_png 44 50 49
erubi 69 114 95
erubi_rails 103 104 122
fannkuchredux 25 27 27
lee 34 42 39
nbody 24 26 27
optcarrot 59 66 65
rubykon 51 59 57
30k_ifelse 68 173 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 26 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 122 110 107

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 179 75 179 20 179
hexapdf 5 15 20 15
liquid-render 5 158 75 158 20 158
mail 5 128 75 128 20 128
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 31 75 31 20 31
erubi 5 61 75 61 20 61
erubi_rails 5 1021 75 1021 20 1021
fannkuchredux 5 15 73 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 437 75 437 20 437
fib 5 315 75 315 20 315
getivar 5 608 75 608 20 608
keyword_args 5 379 75 379 20 379
respond_to 5 103 75 103 20 103
setivar 5 957 75 957 20 957
str_concat 5 460 75 460 20 460

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) 1037851 780586 131 1292 0 0% 0 0 0
hexapdf (click) 1150107 923787 683 8014 9 0% 0 0 0
liquid-render (click) 521819 405680 150 1701 2 0% 0 0 0
mail (click) 907291 654634 374 5395 17 0% 0 0 0
psych-load (click) 347419 263273 68 482 1 0% 0 0 0
railsbench (click) 2654875 1965597 1436 10025 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 389211 290535 88 1027 0 0% 0 0 0
erubi (click) 322907 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1961435 1428821 300 2025 4 0% 0 0 0
fannkuchredux (click) 185755 138378 10 188 0 0% 0 0 0
lee (click) 385243 290684 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) 321371 257161 144 1573 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) 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 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.