YJIT Benchmarks

2022-06-19 05:14:35

As of 2022-06-19 05:14:35:

Overall YJIT is 34.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 32.5% 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 155.5 2.21% 155.0 0.69% 104.7 0.57% 1.00x 2.31% 1.49x 2.28% 85.54%
hexapdf 3225.0 1.32% 2316.2 1.95% 1.39x 2.35% 83.12%
liquid-render 198.8 1.27% 171.9 1.97% 129.0 2.09% 1.16x 2.35% 1.54x 2.45% 85.70%
mail 182.2 2.12% 180.2 0.98% 161.7 1.16% 1.01x 2.34% 1.13x 2.42% 99.34%
psych-load 2566.3 0.07% 2130.3 0.05% 2048.1 0.03% 1.20x 0.09% 1.25x 0.08% 88.45%
railsbench 2813.6 0.94% 2817.3 1.02% 2122.8 1.42% 1.00x 1.39% 1.33x 1.70% 86.12%
binarytrees 474.2 0.11% 299.3 0.34% 358.6 0.06% 1.58x 0.36% 1.32x 0.12% 84.27%
chunky_png 971.9 0.05% 799.1 0.39% 658.8 0.08% 1.22x 0.39% 1.48x 0.09% 99.95%
discourse 547.6 1.48% 557.6 1.44% 477.9 1.50% 0.98x 2.06% 1.15x 2.10% 73.59%
erubi 461.2 1.79% 419.6 0.89% 391.8 0.65% 1.10x 2.00% 1.18x 1.91% 100.00%
erubi_rails 27.3 2.45% 27.5 2.32% 20.0 3.60% 0.99x 3.37% 1.37x 4.36% 86.30%
fannkuchredux 8754.7 0.13% 5725.3 0.03% 8852.6 0.14% 1.53x 0.13% 0.99x 0.19% 0.02%
lee 1269.0 0.07% 1024.3 1.21% 942.9 0.05% 1.24x 1.21% 1.35x 0.08% 99.97%
nbody 122.2 0.07% 72.9 0.27% 90.6 0.08% 1.68x 0.28% 1.35x 0.11% 100.00%
optcarrot 6310.9 0.43% 2593.3 0.59% 3427.0 0.59% 2.43x 0.73% 1.84x 0.73% 96.13%
rubykon 13254.4 2.89% 9022.2 3.40% 7613.9 4.51% 1.47x 4.46% 1.74x 5.35% 99.65%
30k_ifelse 2403.9 0.01% 3612.9 4.06% 355.4 0.08% 0.67x 4.06% 6.76x 0.08% 100.00%
30k_methods 6470.5 0.02% 10048.2 17.03% 876.9 0.02% 0.64x 17.03% 7.38x 0.02% 100.00%
cfunc_itself 105.0 0.19% 70.3 0.55% 45.3 0.73% 1.49x 0.59% 2.32x 0.76% 100.00%
fib 244.6 0.05% 86.2 0.20% 63.3 0.04% 2.84x 0.21% 3.86x 0.06% 100.00%
getivar 112.2 0.65% 26.3 68.87% 42.5 0.05% 4.27x 68.88% 2.64x 0.65% 99.21%
keyword_args 290.6 0.11% 226.9 0.26% 53.0 0.15% 1.28x 0.28% 5.49x 0.18% 100.00%
respond_to 276.8 0.17% 226.1 0.97% 188.3 0.18% 1.22x 0.98% 1.47x 0.25% 100.00%
setivar 83.9 0.71% 10.7 103.13% 54.0 0.25% 7.87x 103.14% 1.55x 0.75% 99.55%
str_concat 132.6 0.77% 101.6 0.95% 109.6 0.77% 1.30x 1.22% 1.21x 1.09% 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-19T02:06:43Z master 5f8c73405e) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-19T02:06:43Z master 5f8c73405e) +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 65 76
hexapdf 233 368
liquid-render 30 35 37
mail 49 53 56
psych-load 38 51 43
railsbench 103 106 131
binarytrees 31 33 32
chunky_png 40 48 45
discourse 398 417 473
erubi 84 95 76
erubi_rails 102 102 124
fannkuchredux 25 27 27
lee 33 42 38
nbody 25 26 27
optcarrot 59 66 65
rubykon 54 61 59
30k_ifelse 66 171 126
30k_methods 58 179 78
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 24 27 26
respond_to 24 27 26
setivar 25 26 27
str_concat 115 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 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 154 75 154 20 154
mail 5 125 75 125 20 125
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 67 75 67 20 67
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 1004 75 1004 20 1004
fannkuchredux 5 15 52 15 20 15
lee 5 21 75 21 20 21
nbody 5 274 75 274 20 274
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 442 75 442 20 442
fib 5 311 75 311 20 311
getivar 5 763 75 763 20 763
keyword_args 5 377 75 377 20 377
respond_to 5 106 75 106 20 106
setivar 5 1866 75 1866 20 1866
str_concat 5 197 75 197 20 197

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) 1011803 752758 131 1242 0 0% 0 0 0
hexapdf (click) 1121691 880122 682 7764 9 0% 0 0 0
liquid-render (click) 514459 394407 150 1632 2 0% 0 0 0
mail (click) 911835 658609 374 5524 15 0% 0 0 0
psych-load (click) 340123 255508 68 462 1 0% 0 0 0
railsbench (click) 2626203 1919640 1436 9870 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 378267 282775 88 977 0 0% 0 0 0
discourse (click) 5912539 4392776 3198 25411 85 0% 2 0 0
erubi (click) 319259 242668 10 79 0 0% 0 0 0
erubi_rails (click) 1928731 1389888 300 1975 4 0% 0 0 0
fannkuchredux (click) 188251 141143 10 188 0 0% 0 0 0
lee (click) 378395 283802 58 622 0 0% 0 0 0
nbody (click) 183707 137646 12 158 0 0% 0 0 0
optcarrot (click) 514907 442895 207 3571 20 0% 0 0 0
rubykon (click) 320731 252879 144 1550 2 0% 0 0 0
30k_ifelse (click) 5563291 4350769 9265 57804 0 0% 0 0 0
30k_methods (click) 2178459 1659231 5784 19361 0 0% 0 0 0
cfunc_itself (click) 172763 129074 10 49 0 0% 0 0 0
fib (click) 170331 128117 10 38 0 0% 0 0 0
getivar (click) 173019 131193 10 65 0 0% 0 0 0
keyword_args (click) 172187 128854 11 51 0 0% 0 0 0
respond_to (click) 173979 129963 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.