YJIT Benchmarks

2022-08-03 20:14:07

As of 2022-08-03 20:14:07:

Overall YJIT is 34.6% 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 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.9 0.35% 156.9 0.37% 103.0 0.65% 0.99x 0.51% 1.50x 0.74% 85.94%
hexapdf 3229.3 1.03% 2365.0 1.32% 1.37x 1.68% 83.68%
liquid-render 196.6 0.98% 170.4 1.59% 131.8 1.72% 1.15x 1.87% 1.49x 1.98% 85.90%
mail 177.2 0.14% 174.2 1.78% 156.6 0.18% 1.02x 1.79% 1.13x 0.23% 99.34%
psych-load 2475.2 0.04% 2192.0 0.05% 1925.8 0.03% 1.13x 0.07% 1.29x 0.06% 88.89%
railsbench 2774.7 0.95% 2823.1 0.45% 2076.7 0.94% 0.98x 1.05% 1.34x 1.34% 86.54%
binarytrees 470.5 0.05% 310.1 0.33% 363.7 0.06% 1.52x 0.34% 1.29x 0.08% 84.27%
chunky_png 940.0 0.07% 763.8 0.37% 637.2 0.05% 1.23x 0.38% 1.48x 0.09% 99.95%
erubi 368.4 0.51% 342.3 0.75% 318.0 0.64% 1.08x 0.90% 1.16x 0.82% 100.00%
erubi_rails 27.4 2.69% 27.3 2.32% 19.5 3.54% 1.00x 3.56% 1.40x 4.45% 86.39%
fannkuchredux 6895.0 0.05% 3955.5 0.03% 6878.2 0.05% 1.74x 0.06% 1.00x 0.07% 0.02%
lee 1271.4 0.57% 1066.4 1.15% 944.6 0.70% 1.19x 1.28% 1.35x 0.90% 99.97%
nbody 122.0 0.08% 76.6 0.23% 94.1 0.12% 1.59x 0.25% 1.30x 0.15% 100.00%
optcarrot 6299.8 0.44% 2790.0 0.61% 3567.1 0.58% 2.26x 0.75% 1.77x 0.73% 96.16%
rubykon 12595.7 0.71% 8203.2 0.51% 6913.2 0.41% 1.54x 0.88% 1.82x 0.82% 99.89%
30k_ifelse 2325.2 0.01% 3577.5 3.79% 358.8 0.07% 0.65x 3.79% 6.48x 0.07% 100.00%
30k_methods 6369.6 0.01% 10048.7 18.78% 871.5 0.02% 0.63x 18.78% 7.31x 0.02% 100.00%
cfunc_itself 103.5 0.30% 67.9 0.34% 46.6 0.52% 1.52x 0.45% 2.22x 0.60% 100.00%
fib 251.6 0.05% 86.2 0.20% 63.5 0.08% 2.92x 0.21% 3.96x 0.10% 100.00%
getivar 114.9 0.70% 32.7 57.35% 44.3 0.12% 3.51x 57.36% 2.60x 0.71% 99.01%
keyword_args 287.3 0.08% 226.2 1.74% 52.6 0.35% 1.27x 1.74% 5.46x 0.36% 100.00%
respond_to 281.2 0.07% 235.1 0.40% 200.4 0.13% 1.20x 0.40% 1.40x 0.15% 100.00%
setivar 76.2 0.17% 20.9 63.43% 43.3 0.48% 3.64x 63.43% 1.76x 0.51% 99.14%
str_concat 84.5 0.92% 51.7 1.63% 44.4 1.53% 1.63x 1.87% 1.90x 1.79% 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-03T08:59:13Z master 4406cb1bf1) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-03T08:59:13Z master 4406cb1bf1) +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 66 76
hexapdf 293 400
liquid-render 31 35 37
mail 49 53 56
psych-load 39 45 41
railsbench 103 106 133
binarytrees 31 33 32
chunky_png 43 48 48
erubi 73 82 88
erubi_rails 102 104 122
fannkuchredux 25 27 27
lee 34 40 39
nbody 24 26 27
optcarrot 58 66 65
rubykon 53 60 56
30k_ifelse 68 170 127
30k_methods 57 176 75
cfunc_itself 25 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 122 110 101

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 192 75 192 20 192
hexapdf 5 15 20 15
liquid-render 5 155 75 155 20 155
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 1035 75 1035 20 1035
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 55 75 55 20 55
30k_methods 5 22 30 22 20 22
cfunc_itself 5 430 75 430 20 430
fib 5 315 75 315 20 315
getivar 5 609 75 609 20 609
keyword_args 5 379 75 379 20 379
respond_to 5 99 75 99 20 99
setivar 5 960 75 960 20 960
str_concat 5 451 75 451 20 451

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) 1035931 779583 131 1279 0 0% 0 0 0
hexapdf (click) 1150235 924970 682 8016 10 0% 0 0 0
liquid-render (click) 515803 401500 150 1642 2 0% 0 0 0
mail (click) 911131 657823 374 5427 17 0% 0 0 0
psych-load (click) 347099 263105 68 480 1 0% 0 0 0
railsbench (click) 2656027 1967573 1436 10028 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 386587 289262 88 1004 0 0% 0 0 0
erubi (click) 322843 246264 10 79 0 0% 0 0 0
erubi_rails (click) 1961499 1429496 300 2025 4 0% 0 0 0
fannkuchredux (click) 185755 138378 10 188 0 0% 0 0 0
lee (click) 385179 290859 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) 320731 256877 145 1568 2 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) 170331 127251 10 38 0 0% 0 0 0
str_concat (click) 170587 127943 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.