YJIT Benchmarks

2022-06-18 05:14:57

As of 2022-06-18 05:14:57:

Overall YJIT is 35.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 31.3% 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 153.2 0.34% 158.5 2.67% 104.6 0.60% 0.97x 2.69% 1.46x 0.69% 85.54%
hexapdf 3210.1 0.77% 2353.0 1.75% 1.36x 1.92% 83.05%
liquid-render 197.8 1.23% 172.3 1.89% 128.8 2.05% 1.15x 2.26% 1.54x 2.39% 85.70%
mail 181.3 0.15% 179.2 1.91% 159.9 0.18% 1.01x 1.91% 1.13x 0.23% 99.33%
psych-load 2695.8 0.09% 2121.9 0.03% 2034.0 0.10% 1.27x 0.10% 1.33x 0.14% 88.45%
railsbench 2824.2 0.72% 2825.1 0.65% 2150.6 1.75% 1.00x 0.97% 1.31x 1.90% 86.29%
binarytrees 468.5 0.05% 299.9 0.35% 363.9 0.06% 1.56x 0.35% 1.29x 0.08% 84.27%
chunky_png 976.9 0.04% 789.1 0.05% 658.6 0.06% 1.24x 0.06% 1.48x 0.07% 99.95%
discourse 583.4 13.75% 540.9 1.43% 489.2 1.25% 1.08x 13.82% 1.19x 13.80% 74.23%
erubi 464.4 0.80% 418.1 0.65% 390.3 0.68% 1.11x 1.03% 1.19x 1.05% 100.00%
erubi_rails 28.3 4.74% 28.0 2.44% 20.2 3.97% 1.01x 5.33% 1.40x 6.18% 86.30%
fannkuchredux 8717.9 0.14% 5688.9 0.13% 8887.6 0.18% 1.53x 0.19% 0.98x 0.23% 0.02%
lee 1256.9 0.19% 1028.4 0.15% 929.4 1.29% 1.22x 0.24% 1.35x 1.31% 99.97%
nbody 121.4 0.05% 73.3 0.32% 90.7 0.08% 1.66x 0.33% 1.34x 0.09% 100.00%
optcarrot 6087.7 0.46% 2597.9 0.62% 3436.3 0.60% 2.34x 0.77% 1.77x 0.75% 96.13%
rubykon 13192.9 3.00% 9128.2 2.82% 7659.9 3.75% 1.45x 4.12% 1.72x 4.80% 99.66%
30k_ifelse 2368.5 1.40% 3514.8 3.95% 352.4 0.09% 0.67x 4.19% 6.72x 1.40% 100.00%
30k_methods 6294.3 0.01% 10085.9 19.09% 880.1 0.01% 0.62x 19.09% 7.15x 0.02% 100.00%
cfunc_itself 105.1 0.16% 68.2 0.78% 44.9 0.70% 1.54x 0.80% 2.34x 0.71% 100.00%
fib 251.3 0.04% 86.2 0.23% 63.3 0.04% 2.91x 0.23% 3.97x 0.06% 100.00%
getivar 113.2 0.07% 26.5 71.30% 42.5 0.07% 4.28x 71.30% 2.66x 0.10% 99.20%
keyword_args 287.8 0.15% 225.5 0.78% 53.0 0.13% 1.28x 0.80% 5.43x 0.20% 100.00%
respond_to 282.0 0.19% 233.7 0.64% 191.9 0.31% 1.21x 0.67% 1.47x 0.37% 100.00%
setivar 75.7 0.16% 10.9 101.50% 53.8 0.19% 6.96x 101.50% 1.41x 0.25% 99.55%
str_concat 134.4 0.70% 101.7 0.58% 109.6 0.69% 1.32x 0.91% 1.23x 0.98% 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-18T04:40:46Z master e711711539) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-18T04:40:46Z master e711711539) +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 218 402
liquid-render 30 35 37
mail 49 54 56
psych-load 38 50 43
railsbench 102 105 132
binarytrees 31 33 33
chunky_png 40 45 45
discourse 368 415 470
erubi 87 124 80
erubi_rails 102 105 122
fannkuchredux 25 27 27
lee 33 42 39
nbody 24 26 27
optcarrot 59 66 65
rubykon 55 65 58
30k_ifelse 67 168 126
30k_methods 57 179 79
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 24 26 27
str_concat 91 92 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 192 75 192 20 192
hexapdf 5 15 20 15
liquid-render 5 155 75 155 20 155
mail 5 125 75 125 20 125
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 66 75 66 20 66
chunky_png 5 30 75 30 20 30
discourse 5 37 75 37 20 37
erubi 5 50 75 50 20 50
erubi_rails 5 968 75 968 20 968
fannkuchredux 5 15 52 15 20 15
lee 5 21 75 21 20 21
nbody 5 273 75 273 20 273
optcarrot 5 15 75 15 20 15
rubykon 5 15 32 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 22 29 22 20 22
cfunc_itself 5 446 75 446 20 446
fib 5 315 75 315 20 315
getivar 5 755 75 755 20 755
keyword_args 5 378 75 378 20 378
respond_to 5 104 75 104 20 104
setivar 5 1842 75 1842 20 1842
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) 1013787 754402 131 1246 0 0% 0 0 0
hexapdf (click) 1120475 879276 682 7751 9 0% 0 0 0
liquid-render (click) 512603 393394 150 1615 2 0% 0 0 0
mail (click) 915547 660836 374 5546 15 0% 0 0 0
psych-load (click) 339675 255174 68 457 1 0% 0 0 0
railsbench (click) 2620635 1916451 1436 9829 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 376155 281016 88 998 0 0% 0 0 0
discourse (click) 5939931 4410224 3235 25693 85 0% 2 0 0
erubi (click) 319515 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1929563 1390463 300 1974 4 0% 0 0 0
fannkuchredux (click) 188251 141143 10 188 0 0% 0 0 0
lee (click) 377755 283405 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) 318299 250786 144 1525 1 0% 0 0 0
30k_ifelse (click) 5562395 4350204 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) 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.