YJIT Benchmarks

2022-06-17 05:16:44

As of 2022-06-17 05:16:44:

Overall YJIT is 34.8% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.6% 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 discourse 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 152.2 0.42% 157.0 0.36% 103.6 0.57% 0.97x 0.55% 1.47x 0.71% 85.55%
hexapdf 3184.9 0.75% 2324.0 2.79% 1.37x 2.89% 82.79%
liquid-render 198.5 1.24% 173.1 2.08% 129.9 2.06% 1.15x 2.42% 1.53x 2.41% 85.70%
mail 185.5 0.17% 177.8 1.70% 160.2 0.17% 1.04x 1.70% 1.16x 0.24% 99.35%
psych-load 2567.4 0.09% 2156.2 0.07% 2035.1 0.06% 1.19x 0.12% 1.26x 0.11% 88.45%
railsbench 2810.1 1.07% 2826.5 0.95% 2103.1 1.92% 0.99x 1.43% 1.34x 2.20% 86.12%
binarytrees 470.6 0.09% 311.7 0.33% 365.9 0.06% 1.51x 0.34% 1.29x 0.11% 84.27%
chunky_png 976.4 0.04% 779.1 0.03% 654.6 0.05% 1.25x 0.05% 1.49x 0.06% 99.95%
discourse 581.9 13.73% 621.0 15.03% 476.5 1.63% 0.94x 20.36% 1.22x 13.83% 73.57%
erubi 464.4 0.56% 422.7 0.86% 390.4 0.62% 1.10x 1.03% 1.19x 0.84% 100.00%
erubi_rails 27.6 2.49% 28.0 2.17% 20.6 3.17% 0.99x 3.30% 1.34x 4.03% 86.30%
fannkuchredux 8639.7 0.09% 5783.3 0.13% 8775.2 0.15% 1.49x 0.16% 0.98x 0.18% 0.02%
lee 1255.6 0.90% 1024.8 0.21% 920.5 0.06% 1.23x 0.93% 1.36x 0.90% 99.97%
nbody 125.8 0.05% 72.8 0.30% 86.6 0.09% 1.73x 0.31% 1.45x 0.10% 100.00%
optcarrot 6271.0 0.43% 2622.0 0.59% 3487.6 0.64% 2.39x 0.73% 1.80x 0.77% 96.13%
rubykon 13192.4 2.21% 8852.0 4.28% 7731.7 5.14% 1.49x 4.82% 1.71x 5.59% 99.73%
30k_ifelse 2278.2 0.01% 3661.7 4.06% 354.0 0.09% 0.62x 4.06% 6.44x 0.09% 100.00%
30k_methods 6262.5 0.01% 10208.1 16.57% 875.8 0.02% 0.61x 16.57% 7.15x 0.02% 100.00%
cfunc_itself 105.8 0.13% 69.4 0.57% 45.0 0.62% 1.52x 0.58% 2.35x 0.64% 100.00%
fib 243.3 0.05% 86.2 0.20% 63.3 0.05% 2.82x 0.21% 3.84x 0.07% 100.00%
getivar 113.8 0.23% 26.4 70.67% 42.5 0.06% 4.32x 70.67% 2.68x 0.24% 99.20%
keyword_args 285.2 0.09% 223.5 0.40% 52.8 0.31% 1.28x 0.41% 5.40x 0.32% 100.00%
respond_to 285.2 0.54% 231.5 0.77% 194.7 0.13% 1.23x 0.94% 1.47x 0.56% 100.00%
setivar 76.1 0.22% 10.8 100.87% 50.5 0.42% 7.03x 100.87% 1.51x 0.47% 99.55%
str_concat 132.1 0.90% 103.4 0.83% 108.8 0.76% 1.28x 1.23% 1.21x 1.18% 99.68%

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-06-17T03:02:50Z master 420f3ced4d) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-17T03:02:50Z master 420f3ced4d) +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 64 65 76
hexapdf 267 387
liquid-render 30 35 37
mail 50 54 56
psych-load 38 51 43
railsbench 103 105 131
binarytrees 31 33 33
chunky_png 41 43 45
discourse 393 373 471
erubi 65 97 72
erubi_rails 104 102 121
fannkuchredux 25 27 27
lee 33 40 38
nbody 25 26 27
optcarrot 59 66 65
rubykon 57 62 58
30k_ifelse 66 173 126
30k_methods 58 179 78
cfunc_itself 25 27 26
fib 25 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 27 27
str_concat 100 95 93

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 190 75 190 20 190
hexapdf 5 15 20 15
liquid-render 5 157 75 157 20 157
mail 5 125 75 125 20 125
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
discourse 5 41 75 41 20 41
erubi 5 50 75 50 20 50
erubi_rails 5 989 75 989 20 989
fannkuchredux 5 15 52 15 20 15
lee 5 21 75 21 20 21
nbody 5 274 75 274 20 274
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 410 75 410 20 410
fib 5 315 75 315 20 315
getivar 5 754 75 754 20 754
keyword_args 5 371 75 371 20 371
respond_to 5 106 75 106 20 106
setivar 5 1858 75 1858 20 1858
str_concat 5 200 75 200 20 200

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) 1016219 755566 131 1258 0 0% 0 0 0
hexapdf (click) 1122459 880721 682 7774 10 0% 0 0 0
liquid-render (click) 513563 393180 150 1628 2 0% 0 0 0
mail (click) 894619 646840 375 5343 15 0% 0 0 0
psych-load (click) 339675 255124 68 457 1 0% 0 0 0
railsbench (click) 2624603 1919627 1436 9869 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 387099 288100 88 1068 0 0% 0 0 0
discourse (click) 5914651 4392705 3197 25420 85 0% 2 0 0
erubi (click) 319515 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1929115 1390433 300 1980 4 0% 0 0 0
fannkuchredux (click) 188251 141143 10 188 0 0% 0 0 0
lee (click) 378139 283709 58 622 0 0% 0 0 0
nbody (click) 183707 137646 12 158 0 0% 0 0 0
optcarrot (click) 514907 442895 207 3571 20 0% 0 0 0
rubykon (click) 319195 251400 144 1533 1 0% 0 0 0
30k_ifelse (click) 5563291 4350769 9265 57804 0 0% 0 0 0
30k_methods (click) 2178459 1659231 5784 19361 0 0% 0 0 0
cfunc_itself (click) 172763 129074 10 49 0 0% 0 0 0
fib (click) 171227 128682 10 38 0 0% 0 0 0
getivar (click) 173019 131193 10 65 0 0% 0 0 0
keyword_args (click) 173467 129715 11 51 0 0% 0 0 0
respond_to (click) 174875 130528 10 64 0 0% 0 0 0
setivar (click) 172955 129717 10 38 0 0% 0 0 0
str_concat (click) 172955 130037 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.