YJIT Benchmarks

2022-08-04 20:15:30

As of 2022-08-04 20:15:30:

Overall YJIT is 34.2% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.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 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 151.5 0.96% 154.9 0.52% 103.7 0.57% 0.98x 1.09% 1.46x 1.11% 85.93%
hexapdf 3183.9 1.00% 2377.1 2.26% 1.34x 2.47% 83.46%
liquid-render 194.8 0.97% 171.5 1.55% 125.3 1.71% 1.14x 1.83% 1.55x 1.97% 85.90%
mail 175.9 0.15% 172.9 1.81% 157.1 0.14% 1.02x 1.82% 1.12x 0.20% 99.36%
psych-load 2532.8 0.12% 2162.9 0.03% 1988.7 0.03% 1.17x 0.12% 1.27x 0.12% 88.89%
railsbench 2780.8 0.50% 2826.5 0.46% 2065.4 0.74% 0.98x 0.68% 1.35x 0.90% 86.54%
binarytrees 465.1 0.10% 303.4 0.32% 356.6 0.05% 1.53x 0.34% 1.30x 0.11% 84.27%
chunky_png 964.4 0.05% 782.1 0.37% 646.2 0.04% 1.23x 0.37% 1.49x 0.06% 99.95%
erubi 370.3 0.60% 342.9 0.70% 316.6 0.67% 1.08x 0.92% 1.17x 0.89% 100.00%
erubi_rails 27.3 2.66% 27.2 2.52% 19.8 3.50% 1.00x 3.66% 1.38x 4.40% 86.40%
fannkuchredux 7009.9 0.10% 3926.7 0.04% 6964.1 0.12% 1.79x 0.11% 1.01x 0.16% 0.02%
lee 1264.8 0.17% 1039.9 1.71% 937.8 0.53% 1.22x 1.72% 1.35x 0.56% 99.97%
nbody 125.2 0.11% 76.4 0.19% 90.3 0.08% 1.64x 0.22% 1.39x 0.13% 100.00%
optcarrot 6146.6 0.44% 2762.6 0.63% 3426.4 0.59% 2.22x 0.76% 1.79x 0.73% 96.16%
rubykon 12566.3 0.60% 8076.5 0.44% 6836.8 0.81% 1.56x 0.74% 1.84x 1.01% 99.67%
30k_ifelse 2323.7 0.01% 3685.6 3.91% 355.0 0.09% 0.63x 3.91% 6.54x 0.09% 100.00%
30k_methods 6574.3 0.01% 10269.1 19.15% 878.6 0.02% 0.64x 19.15% 7.48x 0.02% 100.00%
cfunc_itself 109.7 0.31% 69.9 0.56% 45.0 0.78% 1.57x 0.64% 2.44x 0.84% 100.00%
fib 246.7 0.04% 86.2 0.20% 63.5 0.07% 2.86x 0.21% 3.89x 0.09% 100.00%
getivar 111.5 0.36% 32.8 57.52% 44.3 0.13% 3.40x 57.52% 2.52x 0.38% 99.02%
keyword_args 296.1 0.07% 228.5 1.48% 52.8 0.15% 1.30x 1.49% 5.61x 0.16% 100.00%
respond_to 274.2 0.10% 230.5 0.58% 186.7 0.17% 1.19x 0.59% 1.47x 0.20% 100.00%
setivar 78.7 0.30% 20.8 63.43% 46.4 0.13% 3.79x 63.43% 1.70x 0.33% 99.14%
str_concat 84.7 0.95% 50.4 1.22% 43.5 1.59% 1.68x 1.54% 1.95x 1.85% 99.97%

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-08-04T16:19:14Z master 1e7a2415a4) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-04T16:19:14Z master 1e7a2415a4) +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 65 65 76
hexapdf 274 411
liquid-render 31 35 37
mail 49 53 57
psych-load 34 47 41
railsbench 104 106 133
binarytrees 30 33 32
chunky_png 44 49 48
erubi 69 105 93
erubi_rails 103 106 122
fannkuchredux 25 27 27
lee 32 43 39
nbody 25 26 27
optcarrot 58 67 65
rubykon 53 58 56
30k_ifelse 68 173 127
30k_methods 57 176 76
cfunc_itself 24 27 27
fib 25 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 123 110 107

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 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 156 75 156 20 156
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 31 75 31 20 31
erubi 5 62 75 62 20 62
erubi_rails 5 1048 75 1048 20 1048
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 261 75 261 20 261
optcarrot 5 15 75 15 20 15
rubykon 5 15 36 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 430 75 430 20 430
fib 5 314 75 314 20 314
getivar 5 613 75 613 20 613
keyword_args 5 379 75 379 20 379
respond_to 5 100 75 100 20 100
setivar 5 954 75 954 20 954
str_concat 5 439 75 439 20 439

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) 1034203 778015 131 1273 0 0% 0 0 0
hexapdf (click) 1150107 923957 682 8014 9 0% 0 0 0
liquid-render (click) 516443 401419 150 1667 2 0% 0 0 0
mail (click) 910747 657289 374 5423 17 0% 0 0 0
psych-load (click) 347419 263273 68 482 1 0% 0 0 0
railsbench (click) 2661787 1969927 1436 10067 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 383259 286585 88 998 0 0% 0 0 0
erubi (click) 322843 245939 10 79 0 0% 0 0 0
erubi_rails (click) 1960987 1428403 300 2026 4 0% 0 0 0
fannkuchredux (click) 185755 138378 10 188 0 0% 0 0 0
lee (click) 385243 290684 58 632 0 0% 0 0 0
nbody (click) 182555 137443 12 171 0 0% 0 0 0
optcarrot (click) 513947 442610 207 3588 20 0% 0 0 0
rubykon (click) 321691 257221 144 1578 1 0% 0 0 0
30k_ifelse (click) 5560987 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2176155 1657178 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170459 127021 10 49 0 0% 0 0 0
fib (click) 168923 126629 10 38 0 0% 0 0 0
getivar (click) 170651 128716 10 65 0 0% 0 0 0
keyword_args (click) 171291 127662 11 51 0 0% 0 0 0
respond_to (click) 172571 128475 10 64 0 0% 0 0 0
setivar (click) 170587 127536 10 38 0 0% 0 0 0
str_concat (click) 170587 127868 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.