YJIT Benchmarks

2022-08-04 05:21:17

As of 2022-08-04 05:21:17:

Overall YJIT is 35.1% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 36.1% 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.9 0.35% 154.9 1.03% 103.3 0.63% 0.98x 1.09% 1.47x 0.72% 85.94%
hexapdf 3196.5 0.87% 2335.8 3.24% 1.37x 3.35% 82.59%
liquid-render 195.2 1.90% 172.1 1.59% 127.9 1.70% 1.13x 2.48% 1.53x 2.55% 85.90%
mail 175.3 0.14% 175.9 1.75% 155.4 0.19% 1.00x 1.75% 1.13x 0.23% 99.36%
psych-load 2457.2 0.03% 2146.6 0.02% 1908.8 0.02% 1.14x 0.04% 1.29x 0.03% 88.89%
railsbench 2819.1 0.60% 2830.2 0.61% 2070.6 0.92% 1.00x 0.86% 1.36x 1.10% 86.54%
binarytrees 470.3 0.05% 308.4 0.35% 363.7 0.06% 1.52x 0.36% 1.29x 0.08% 84.27%
chunky_png 942.6 0.05% 757.2 0.06% 629.5 0.05% 1.24x 0.08% 1.50x 0.07% 99.95%
erubi 372.2 0.52% 339.1 0.79% 319.8 0.70% 1.10x 0.94% 1.16x 0.87% 100.00%
erubi_rails 27.3 3.56% 27.4 2.84% 19.1 3.70% 1.00x 4.55% 1.43x 5.14% 86.39%
fannkuchredux 6951.7 0.27% 3953.1 0.06% 6965.7 0.12% 1.76x 0.28% 1.00x 0.30% 0.02%
lee 1266.7 0.35% 1054.9 1.20% 950.5 0.40% 1.20x 1.25% 1.33x 0.53% 99.97%
nbody 123.0 0.08% 76.5 0.21% 93.8 0.17% 1.61x 0.22% 1.31x 0.18% 100.00%
optcarrot 6187.2 0.44% 2779.0 0.61% 3435.1 0.60% 2.23x 0.75% 1.80x 0.74% 96.16%
rubykon 12863.7 0.57% 8181.7 0.49% 6792.9 1.25% 1.57x 0.75% 1.89x 1.38% 99.84%
30k_ifelse 2255.8 0.01% 3551.0 3.89% 354.2 0.09% 0.64x 3.89% 6.37x 0.09% 100.00%
30k_methods 6562.0 0.01% 10205.5 16.98% 874.6 0.02% 0.64x 16.98% 7.50x 0.02% 100.00%
cfunc_itself 103.7 0.19% 71.6 1.19% 46.4 0.60% 1.45x 1.20% 2.23x 0.63% 100.00%
fib 251.2 0.05% 86.2 0.21% 63.5 0.05% 2.91x 0.22% 3.96x 0.08% 100.00%
getivar 112.4 0.18% 32.6 57.63% 44.2 0.10% 3.45x 57.63% 2.54x 0.20% 99.02%
keyword_args 293.0 0.08% 226.5 0.63% 52.7 0.32% 1.29x 0.64% 5.56x 0.33% 100.00%
respond_to 280.4 0.37% 234.3 0.33% 199.9 0.14% 1.20x 0.49% 1.40x 0.39% 100.00%
setivar 76.3 0.17% 21.0 63.38% 42.8 0.23% 3.64x 63.38% 1.78x 0.28% 99.14%
str_concat 84.6 0.73% 52.3 1.23% 45.5 1.47% 1.62x 1.43% 1.86x 1.65% 99.69%

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-04T04:36:45Z master 542040fb83) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-04T04:36:45Z master 542040fb83) +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 244 395
liquid-render 31 35 37
mail 49 53 56
psych-load 36 45 42
railsbench 104 105 132
binarytrees 31 33 33
chunky_png 43 46 50
erubi 69 84 94
erubi_rails 103 103 122
fannkuchredux 25 27 27
lee 32 42 39
nbody 24 26 27
optcarrot 58 66 65
rubykon 52 60 57
30k_ifelse 68 167 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 98 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 194 75 194 20 194
hexapdf 5 15 20 15
liquid-render 5 151 75 151 20 151
mail 5 127 75 127 20 127
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 1024 75 1024 20 1024
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 29 22 20 22
cfunc_itself 5 429 75 429 20 429
fib 5 314 75 314 20 314
getivar 5 611 75 611 20 611
keyword_args 5 379 75 379 20 379
respond_to 5 99 75 99 20 99
setivar 5 955 75 955 20 955
str_concat 5 450 75 450 20 450

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) 1038043 780802 131 1294 0 0% 0 0 0
hexapdf (click) 1150619 925000 682 8016 9 0% 0 0 0
liquid-render (click) 519003 404411 150 1678 2 0% 0 0 0
mail (click) 943195 679127 374 5765 17 0% 0 0 0
psych-load (click) 347419 263248 68 482 1 0% 0 0 0
railsbench (click) 2657819 1968987 1436 10045 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 386779 289012 88 1006 0 0% 0 0 0
erubi (click) 322907 246264 10 79 0 0% 0 0 0
erubi_rails (click) 1962907 1430123 300 2025 4 0% 0 0 0
fannkuchredux (click) 185755 138378 10 188 0 0% 0 0 0
lee (click) 385243 290809 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) 321243 257011 144 1575 1 0% 0 0 0
30k_ifelse (click) 5560987 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2175707 1656882 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 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.