YJIT Benchmarks

2022-09-18 20:11:32

As of 2022-09-18 20:11:32:

Overall YJIT is 36.3% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.3% 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 1.6 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 2.0 4.0 6.0 8.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 148.2 0.46% 180.4 3.98% 103.6 0.62% 0.82x 4.01% 1.43x 0.77% 85.28%
hexapdf 3188.2 1.28% 2317.7 1.90% 1.38x 2.29% 82.22%
liquid-render 197.4 0.95% 176.4 1.08% 116.6 1.91% 1.12x 1.44% 1.69x 2.14% 85.97%
mail 174.6 0.80% 175.0 2.57% 155.7 0.25% 1.00x 2.69% 1.12x 0.83% 99.36%
psych-load 2474.3 0.04% 2128.9 0.04% 1920.7 0.03% 1.16x 0.06% 1.29x 0.05% 88.89%
railsbench 2755.7 0.57% 2987.3 0.46% 2067.2 1.09% 0.92x 0.73% 1.33x 1.23% 86.28%
binarytrees 477.3 0.03% 316.7 0.13% 238.0 0.05% 1.51x 0.13% 2.01x 0.06% 100.00%
chunky_png 970.3 0.06% 786.7 0.04% 655.1 0.05% 1.23x 0.07% 1.48x 0.08% 99.95%
erubi 342.4 0.55% 313.6 0.56% 291.7 0.70% 1.09x 0.78% 1.17x 0.89% 100.00%
erubi_rails 26.5 2.66% 28.6 9.45% 18.9 3.61% 0.92x 9.82% 1.40x 4.48% 86.35%
fannkuchredux 5308.9 0.25% 5309.2 0.08% 2331.3 0.53% 1.00x 0.27% 2.28x 0.59% 77.42%
lee 1272.3 0.93% 1077.5 0.55% 967.5 1.24% 1.18x 1.08% 1.32x 1.55% 99.97%
nbody 120.8 0.15% 75.7 0.05% 91.9 0.11% 1.60x 0.16% 1.31x 0.19% 100.00%
optcarrot 6076.4 0.44% 2708.6 0.63% 3541.7 0.62% 2.24x 0.76% 1.72x 0.76% 96.16%
rubykon 12560.1 0.53% 9107.5 1.00% 6824.3 0.59% 1.38x 1.13% 1.84x 0.79% 99.75%
30k_ifelse 2254.1 0.05% 4234.6 2.81% 359.0 0.10% 0.53x 2.81% 6.28x 0.11% 100.00%
30k_methods 6504.6 0.01% 12915.8 3.88% 784.8 0.02% 0.50x 3.88% 8.29x 0.02% 100.00%
cfunc_itself 107.7 0.16% 99.0 0.11% 46.5 0.78% 1.09x 0.20% 2.32x 0.80% 100.00%
fib 243.0 0.13% 79.2 0.04% 62.7 0.04% 3.07x 0.13% 3.88x 0.13% 100.00%
getivar 104.2 0.17% 102.9 0.11% 42.8 0.05% 1.01x 0.20% 2.44x 0.18% 98.73%
keyword_args 288.8 0.07% 224.4 0.04% 53.8 0.16% 1.29x 0.09% 5.36x 0.17% 100.00%
respond_to 278.3 0.11% 261.7 0.22% 30.1 0.61% 1.06x 0.25% 9.24x 0.62% 100.00%
setivar 77.8 0.18% 77.8 0.19% 49.7 0.38% 1.00x 0.26% 1.57x 0.42% 98.01%
str_concat 83.3 0.84% 54.6 7.74% 47.4 1.43% 1.53x 7.78% 1.76x 1.66% 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-09-18T12:21:37Z master e2e1058e66) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-18T12:21:37Z master e2e1058e66) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 72 76
hexapdf 281 421
liquid-render 30 33 37
mail 49 53 57
psych-load 38 45 40
railsbench 103 123 131
binarytrees 30 32 33
chunky_png 44 41 49
erubi 67 100 95
erubi_rails 103 105 122
fannkuchredux 24 26 27
lee 33 39 39
nbody 24 26 27
optcarrot 57 65 65
rubykon 50 65 55
30k_ifelse 67 141 128
30k_methods 58 166 79
cfunc_itself 24 26 27
fib 24 26 27
getivar 25 26 27
keyword_args 25 26 27
respond_to 24 25 27
setivar 25 26 27
str_concat 98 114 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 191 75 191 20 191
hexapdf 5 15 20 15
liquid-render 5 170 75 170 20 170
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 84 75 84 20 84
chunky_png 5 30 75 30 20 30
erubi 5 67 75 67 20 67
erubi_rails 5 1050 75 1050 20 1050
fannkuchredux 5 15 56 15 20 15
lee 5 20 75 20 20 20
nbody 5 264 75 264 20 264
optcarrot 5 15 75 15 20 15
rubykon 5 15 32 15 20 15
30k_ifelse 5 54 69 54 20 54
30k_methods 5 25 23 25 20 25
cfunc_itself 5 423 75 423 20 423
fib 5 318 75 318 20 318
getivar 5 467 75 467 20 467
keyword_args 5 364 75 364 20 364
respond_to 5 665 75 665 20 665
setivar 5 402 75 402 20 402
str_concat 5 418 75 418 20 418

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) 1064759 775290 131 1289 0 0% 0 0 0
hexapdf (click) 1176823 918540 682 8043 10 0% 0 0 0
liquid-render (click) 520119 394381 150 1664 2 0% 0 0 0
mail (click) 926135 646302 374 5373 17 0% 0 0 0
psych-load (click) 354103 259329 68 474 1 0% 0 0 0
railsbench (click) 2722935 1956343 1436 10035 16 0% 0 0 0
binarytrees (click) 177463 128043 13 64 0 0% 0 0 0
chunky_png (click) 397239 287412 88 996 0 0% 0 0 0
erubi (click) 341111 250569 10 79 0 0% 0 0 0
erubi_rails (click) 2016375 1424308 300 2052 4 0% 0 0 0
fannkuchredux (click) 189815 136544 10 196 0 0% 0 0 0
lee (click) 394807 287182 58 634 0 0% 0 0 0
nbody (click) 186999 136021 12 171 0 0% 0 0 0
optcarrot (click) 531831 441312 207 3592 20 0% 0 0 0
rubykon (click) 330103 255778 144 1582 1 0% 0 0 0
30k_ifelse (click) 5664247 4347294 9265 57804 0 0% 0 0 0
30k_methods (click) 2208503 1655756 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174391 125599 10 49 0 0% 0 0 0
fib (click) 172727 125207 10 38 0 0% 0 0 0
getivar (click) 174839 127647 10 65 0 0% 0 0 0
keyword_args (click) 175095 126240 11 51 0 0% 0 0 0
respond_to (click) 174647 126813 10 64 0 0% 0 0 0
setivar (click) 174455 126114 10 38 0 0% 0 0 0
str_concat (click) 174391 126446 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.