YJIT Benchmarks

2022-06-15 05:15:12

As of 2022-06-15 05:15:12:

Overall YJIT is 33.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.8% 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 154.0 0.66% 174.2 3.48% 104.5 0.55% 0.88x 3.54% 1.47x 0.86% 85.54%
hexapdf 3190.7 0.87% 2388.9 2.40% 1.34x 2.55% 83.01%
liquid-render 198.6 1.64% 189.2 1.72% 130.2 2.19% 1.05x 2.38% 1.52x 2.74% 85.70%
mail 181.5 0.13% 181.0 1.73% 160.6 0.18% 1.00x 1.73% 1.13x 0.22% 99.35%
psych-load 2519.1 0.14% 2307.1 0.09% 2068.4 0.08% 1.09x 0.17% 1.22x 0.17% 88.45%
railsbench 2810.1 1.36% 3079.7 1.19% 2099.8 1.29% 0.91x 1.80% 1.34x 1.87% 86.29%
binarytrees 469.2 0.04% 304.4 0.31% 368.4 0.10% 1.54x 0.31% 1.27x 0.11% 84.27%
chunky_png 990.5 0.03% 792.9 0.26% 661.3 0.05% 1.25x 0.26% 1.50x 0.06% 99.95%
discourse 542.7 1.46% 566.9 9.65% 479.1 1.45% 0.96x 9.76% 1.13x 2.06% 73.60%
erubi 463.0 0.52% 430.4 0.67% 396.5 0.59% 1.08x 0.85% 1.17x 0.79% 100.00%
erubi_rails 28.9 2.55% 30.0 4.08% 21.3 3.40% 0.96x 4.81% 1.36x 4.25% 86.30%
fannkuchredux 8668.5 0.16% 3974.2 0.04% 8866.9 0.13% 2.18x 0.17% 0.98x 0.21% 0.02%
lee 1268.5 0.21% 1026.8 0.13% 923.3 0.06% 1.24x 0.25% 1.37x 0.22% 99.97%
nbody 124.6 0.08% 72.7 0.24% 87.1 0.06% 1.71x 0.25% 1.43x 0.10% 100.00%
optcarrot 6313.5 0.44% 2596.8 0.62% 3477.0 0.60% 2.43x 0.76% 1.82x 0.75% 96.13%
rubykon 13454.4 1.21% 9489.3 3.67% 7851.8 5.00% 1.42x 3.87% 1.71x 5.14% 99.66%
30k_ifelse 2310.5 0.03% 3554.7 3.75% 355.2 0.09% 0.65x 3.75% 6.50x 0.09% 100.00%
30k_methods 6403.6 0.03% 10101.2 17.10% 872.6 0.02% 0.63x 17.10% 7.34x 0.03% 100.00%
cfunc_itself 110.8 0.23% 68.8 2.88% 45.7 0.82% 1.61x 2.89% 2.43x 0.86% 100.00%
fib 253.6 0.06% 86.1 0.03% 63.3 0.04% 2.94x 0.06% 4.01x 0.07% 100.00%
getivar 122.7 0.05% 25.9 71.65% 42.5 0.06% 4.73x 71.65% 2.88x 0.08% 99.21%
keyword_args 305.1 0.07% 225.2 0.37% 52.7 0.32% 1.35x 0.37% 5.79x 0.33% 100.00%
respond_to 279.2 0.42% 230.3 0.99% 194.6 0.21% 1.21x 1.07% 1.43x 0.47% 100.00%
setivar 77.5 0.25% 10.8 101.17% 60.0 6.51% 7.16x 101.17% 1.29x 6.52% 99.54%
str_concat 131.6 0.98% 102.1 1.38% 108.5 0.77% 1.29x 1.69% 1.21x 1.24% 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-14T20:42:26Z master 788a5e14fa) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-14T20:42:26Z master 788a5e14fa) +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 72 76
hexapdf 295 389
liquid-render 30 35 37
mail 49 54 57
psych-load 39 52 43
railsbench 103 132 131
binarytrees 31 33 33
chunky_png 40 47 45
discourse 398 427 473
erubi 66 111 81
erubi_rails 102 108 121
fannkuchredux 25 28 27
lee 33 39 38
nbody 25 27 27
optcarrot 59 67 65
rubykon 53 61 59
30k_ifelse 66 172 126
30k_methods 57 185 78
cfunc_itself 25 27 26
fib 24 27 26
getivar 25 27 27
keyword_args 25 28 27
respond_to 25 27 27
setivar 25 26 27
str_concat 100 93 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 189 75 189 20 189
hexapdf 5 15 20 15
liquid-render 5 155 75 155 20 155
mail 5 124 75 124 20 124
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 969 75 969 20 969
fannkuchredux 5 15 51 15 20 15
lee 5 21 75 21 20 21
nbody 5 275 75 275 20 275
optcarrot 5 15 75 15 20 15
rubykon 5 15 32 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 438 75 438 20 438
fib 5 315 75 315 20 315
getivar 5 763 75 763 20 763
keyword_args 5 380 75 380 20 380
respond_to 5 101 75 101 20 101
setivar 5 1822 75 1822 20 1822
str_concat 5 198 75 198 20 198

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 755878 131 1255 0 0% 0 0 0
hexapdf (click) 1121499 879921 682 7758 9 0% 0 0 0
liquid-render (click) 510363 390957 150 1598 2 0% 0 0 0
mail (click) 940251 678958 374 5798 15 0% 0 0 0
psych-load (click) 339675 255124 68 457 1 0% 0 0 0
railsbench (click) 2623259 1918830 1436 9865 16 0% 0 0 0
binarytrees (click) 174107 130445 13 58 0 0% 0 0 0
chunky_png (click) 383003 285544 88 1023 0 0% 0 0 0
discourse (click) 5994779 4450512 3270 26093 87 0% 2 0 0
erubi (click) 319515 242761 10 79 0 0% 0 0 0
erubi_rails (click) 1929691 1389820 300 1978 4 0% 0 0 0
fannkuchredux (click) 188251 141143 10 188 0 0% 0 0 0
lee (click) 378395 283852 58 622 0 0% 0 0 0
nbody (click) 183579 137511 12 158 0 0% 0 0 0
optcarrot (click) 514907 442895 207 3571 20 0% 0 0 0
rubykon (click) 319323 251483 144 1534 1 0% 0 0 0
30k_ifelse (click) 5563035 4350634 9265 57804 0 0% 0 0 0
30k_methods (click) 2178459 1659231 5784 19361 0 0% 0 0 0
cfunc_itself (click) 171355 128213 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) 173595 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.