YJIT Benchmarks

2022-09-16 05:38:07

As of 2022-09-16 05:38:07:

Overall YJIT is 36.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 31.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 151.2 0.32% 191.3 4.87% 105.4 0.67% 0.79x 4.88% 1.43x 0.74% 85.28%
hexapdf 3232.7 1.13% 2303.3 1.37% 1.40x 1.78% 83.84%
liquid-render 191.3 0.89% 169.5 1.28% 112.3 1.81% 1.13x 1.56% 1.70x 2.02% 85.97%
mail 176.2 0.15% 175.5 2.63% 157.2 0.25% 1.00x 2.64% 1.12x 0.29% 99.33%
psych-load 2461.1 0.03% 2150.2 0.11% 1904.4 0.03% 1.14x 0.11% 1.29x 0.04% 88.89%
railsbench 2728.0 0.64% 3228.3 0.43% 2076.9 1.02% 0.85x 0.77% 1.31x 1.21% 86.12%
binarytrees 470.7 0.06% 324.4 0.08% 239.8 0.07% 1.45x 0.10% 1.96x 0.09% 100.00%
chunky_png 961.9 0.12% 786.8 0.04% 672.0 0.20% 1.22x 0.13% 1.43x 0.23% 99.95%
erubi 343.4 0.65% 317.6 0.50% 297.7 0.72% 1.08x 0.82% 1.15x 0.97% 100.00%
erubi_rails 26.3 2.62% 27.6 9.98% 19.2 3.54% 0.95x 10.32% 1.37x 4.40% 86.35%
fannkuchredux 5350.7 0.29% 5340.0 0.09% 2376.1 0.17% 1.00x 0.30% 2.25x 0.33% 74.79%
lee 1240.0 0.69% 1065.5 0.61% 944.0 0.96% 1.16x 0.92% 1.31x 1.18% 99.97%
nbody 119.4 0.10% 75.1 0.05% 91.0 0.12% 1.59x 0.11% 1.31x 0.16% 100.00%
optcarrot 6208.9 0.41% 2676.9 0.64% 3555.5 0.65% 2.32x 0.76% 1.75x 0.77% 96.16%
rubykon 12421.3 0.42% 9220.7 0.36% 6872.1 0.59% 1.35x 0.55% 1.81x 0.72% 99.84%
30k_ifelse 2256.1 0.01% 4439.4 2.78% 357.6 0.12% 0.51x 2.78% 6.31x 0.12% 100.00%
30k_methods 6380.9 0.01% 12656.2 3.52% 794.4 0.02% 0.50x 3.52% 8.03x 0.02% 100.00%
cfunc_itself 106.2 0.18% 98.3 0.09% 46.4 0.71% 1.08x 0.20% 2.29x 0.73% 100.00%
fib 243.4 0.06% 79.6 0.03% 62.9 0.05% 3.06x 0.07% 3.87x 0.08% 100.00%
getivar 105.5 0.38% 117.5 1.36% 42.8 0.07% 0.90x 1.41% 2.47x 0.38% 98.73%
keyword_args 291.5 0.44% 225.5 0.03% 53.8 0.15% 1.29x 0.44% 5.41x 0.46% 100.00%
respond_to 278.2 0.10% 256.8 0.21% 32.7 0.80% 1.08x 0.24% 8.51x 0.81% 100.00%
setivar 75.4 0.21% 75.6 0.18% 46.0 0.49% 1.00x 0.28% 1.64x 0.54% 98.16%
str_concat 83.8 1.10% 54.4 8.10% 47.0 1.20% 1.54x 8.17% 1.78x 1.63% 99.71%

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-16T04:37:37Z master 3ff65dcd8b) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-16T04:37:37Z master 3ff65dcd8b) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 73 76
hexapdf 297 427
liquid-render 31 34 38
mail 49 54 56
psych-load 36 43 40
railsbench 102 122 131
binarytrees 30 30 33
chunky_png 38 46 43
erubi 79 112 94
erubi_rails 101 107 122
fannkuchredux 24 25 27
lee 33 39 40
nbody 24 25 27
optcarrot 63 70 70
rubykon 51 59 55
30k_ifelse 67 148 124
30k_methods 57 156 75
cfunc_itself 24 26 27
fib 25 25 27
getivar 24 25 27
keyword_args 25 25 27
respond_to 25 26 27
setivar 24 25 27
str_concat 113 119 98

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 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 177 75 177 20 177
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 30 75 30 20 30
erubi 5 67 75 67 20 67
erubi_rails 5 1041 75 1041 20 1041
fannkuchredux 5 15 55 15 20 15
lee 5 21 75 21 20 21
nbody 5 262 75 262 20 262
optcarrot 5 15 75 15 20 15
rubykon 5 15 32 15 20 15
30k_ifelse 5 55 69 55 20 55
30k_methods 5 25 23 25 20 25
cfunc_itself 5 431 75 431 20 431
fib 5 317 75 317 20 317
getivar 5 467 75 467 20 467
keyword_args 5 363 75 363 20 363
respond_to 5 649 75 649 20 649
setivar 5 436 75 436 20 436
str_concat 5 431 75 431 20 431

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) 1065335 776033 131 1267 0 0% 0 0 0
hexapdf (click) 1178679 919760 682 8046 9 0% 0 0 0
liquid-render (click) 522423 395966 150 1652 2 0% 0 0 0
mail (click) 952567 662640 374 5632 17 0% 0 0 0
psych-load (click) 355447 260672 68 474 1 0% 0 0 0
railsbench (click) 2723511 1958999 1436 10024 16 0% 0 0 0
binarytrees (click) 176695 127145 13 64 0 0% 0 0 0
chunky_png (click) 399543 288590 88 1030 0 0% 0 0 0
erubi (click) 340727 250259 10 79 0 0% 0 0 0
erubi_rails (click) 2013239 1422453 300 2031 4 0% 0 0 0
fannkuchredux (click) 189879 136594 10 196 0 0% 0 0 0
lee (click) 396407 288628 58 634 0 0% 0 0 0
nbody (click) 186615 135761 12 171 0 0% 0 0 0
optcarrot (click) 531831 441312 207 3592 20 0% 0 0 0
rubykon (click) 331383 256597 144 1593 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) 174135 127034 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) 174391 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.