YJIT Benchmarks

2022-09-15 20:11:37

As of 2022-09-15 20:11:37:

Overall YJIT is 36.8% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.9% 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.3 0.64% 181.4 4.69% 103.3 0.66% 0.83x 4.74% 1.46x 0.92% 85.28%
hexapdf 3191.9 1.09% 2331.6 0.64% 1.37x 1.26% 83.90%
liquid-render 190.0 2.31% 168.4 1.22% 112.7 1.81% 1.13x 2.61% 1.69x 2.94% 85.97%
mail 176.5 0.14% 173.1 2.65% 155.5 0.26% 1.02x 2.66% 1.13x 0.29% 99.32%
psych-load 2434.2 0.02% 2142.3 0.03% 1908.3 0.03% 1.14x 0.04% 1.28x 0.04% 88.89%
railsbench 2752.6 0.72% 2980.8 0.53% 2056.5 0.84% 0.92x 0.89% 1.34x 1.10% 86.12%
binarytrees 470.5 0.05% 309.2 0.05% 364.4 0.04% 1.52x 0.07% 1.29x 0.07% 84.57%
chunky_png 962.9 0.12% 788.5 0.05% 653.3 0.04% 1.22x 0.13% 1.47x 0.13% 99.95%
erubi 336.4 0.64% 315.5 0.54% 295.1 0.67% 1.07x 0.83% 1.14x 0.93% 100.00%
erubi_rails 26.7 2.62% 28.2 10.26% 19.2 3.41% 0.94x 10.59% 1.39x 4.30% 86.35%
fannkuchredux 5370.1 0.03% 5368.6 0.11% 2317.2 0.07% 1.00x 0.11% 2.32x 0.07% 77.42%
lee 1233.2 1.34% 1060.0 0.25% 944.7 1.77% 1.16x 1.36% 1.31x 2.22% 99.97%
nbody 121.4 0.13% 76.1 0.04% 91.1 0.09% 1.60x 0.14% 1.33x 0.16% 100.00%
optcarrot 6240.6 0.41% 2719.8 0.63% 3530.1 0.62% 2.29x 0.75% 1.77x 0.74% 96.16%
rubykon 12402.3 0.55% 9111.2 0.41% 6842.0 0.52% 1.36x 0.69% 1.81x 0.75% 99.61%
30k_ifelse 2369.0 0.01% 4326.2 2.62% 358.8 0.12% 0.55x 2.62% 6.60x 0.12% 100.00%
30k_methods 6647.6 0.01% 12782.0 4.08% 785.9 0.03% 0.52x 4.08% 8.46x 0.03% 100.00%
cfunc_itself 108.2 0.18% 99.8 0.33% 46.3 0.72% 1.09x 0.37% 2.34x 0.74% 100.00%
fib 245.7 0.06% 79.2 0.18% 62.9 0.04% 3.10x 0.18% 3.91x 0.07% 100.00%
getivar 106.3 0.15% 105.4 0.29% 42.7 0.05% 1.01x 0.32% 2.49x 0.15% 98.73%
keyword_args 286.7 0.05% 224.2 0.07% 55.0 0.15% 1.28x 0.09% 5.22x 0.16% 100.00%
respond_to 276.3 0.12% 256.8 0.18% 30.8 0.41% 1.08x 0.22% 8.97x 0.43% 100.00%
setivar 75.5 0.17% 77.6 0.09% 45.8 0.39% 0.97x 0.20% 1.65x 0.43% 98.15%
str_concat 86.2 1.06% 54.6 9.01% 46.3 1.23% 1.58x 9.07% 1.86x 1.63% 99.96%

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-15T14:14:27Z master cc7f6fe734) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-15T14:14:27Z master cc7f6fe734) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 72 76
hexapdf 282 421
liquid-render 31 34 38
mail 49 53 56
psych-load 36 43 41
railsbench 104 122 131
binarytrees 30 32 33
chunky_png 39 46 43
erubi 71 117 96
erubi_rails 101 105 122
fannkuchredux 24 25 27
lee 32 39 41
nbody 25 26 27
optcarrot 63 70 70
rubykon 51 63 55
30k_ifelse 67 148 124
30k_methods 57 169 76
cfunc_itself 25 26 27
fib 24 26 27
getivar 25 26 27
keyword_args 24 26 27
respond_to 25 26 27
setivar 24 26 27
str_concat 113 119 93

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 178 75 178 20 178
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 1040 75 1040 20 1040
fannkuchredux 5 15 55 15 20 15
lee 5 21 75 21 20 21
nbody 5 266 75 266 20 266
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 55 71 55 20 55
30k_methods 5 25 23 25 20 25
cfunc_itself 5 427 75 427 20 427
fib 5 318 75 318 20 318
getivar 5 467 75 467 20 467
keyword_args 5 371 75 371 20 371
respond_to 5 667 75 667 20 667
setivar 5 435 75 435 20 435
str_concat 5 425 75 425 20 425

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) 1066679 777211 131 1285 0 0% 0 0 0
hexapdf (click) 1175223 916800 683 8045 10 0% 0 0 0
liquid-render (click) 524087 396957 150 1669 2 0% 0 0 0
mail (click) 960311 668482 374 5728 17 0% 0 0 0
psych-load (click) 353783 259181 68 472 1 0% 0 0 0
railsbench (click) 2721911 1957745 1436 10018 16 0% 0 0 0
binarytrees (click) 175863 126906 13 60 0 0% 0 0 0
chunky_png (click) 397367 287598 88 1004 0 0% 0 0 0
erubi (click) 341175 250589 10 79 0 0% 0 0 0
erubi_rails (click) 2012535 1420638 300 2033 4 0% 0 0 0
fannkuchredux (click) 189431 136049 10 196 0 0% 0 0 0
lee (click) 394615 286942 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) 328951 254847 144 1572 1 0% 0 0 0
30k_ifelse (click) 5664247 4347294 9265 57804 0 0% 0 0 0
30k_methods (click) 2208119 1655496 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174327 125549 10 49 0 0% 0 0 0
fib (click) 172663 125157 10 38 0 0% 0 0 0
getivar (click) 174071 126984 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.