YJIT Benchmarks

2022-05-09 19:15:18

As of 2022-05-09 19:15:18:

Overall YJIT is 30.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 27.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 154.1 0.37% 178.2 4.34% 104.9 0.57% 0.86x 4.36% 1.47x 0.68% 85.01%
hexapdf 3218.8 1.46% 2385.7 2.71% 1.35x 3.08% 83.29%
liquid-render 211.3 1.13% 206.1 1.29% 145.6 1.74% 1.03x 1.72% 1.45x 2.07% 85.70%
mail 203.5 2.48% 204.8 3.21% 187.7 2.76% 0.99x 4.05% 1.08x 3.71% 99.39%
psych-load 2775.8 0.06% 2436.0 0.19% 2235.9 0.06% 1.14x 0.20% 1.24x 0.08% 88.45%
railsbench 3129.5 1.08% 3485.2 0.39% 2454.1 1.01% 0.90x 1.14% 1.28x 1.47% 86.09%
binarytrees 478.6 0.05% 308.1 0.32% 369.7 0.16% 1.55x 0.32% 1.29x 0.17% 84.27%
chunky_png 982.0 0.29% 798.9 0.68% 670.9 0.49% 1.23x 0.74% 1.46x 0.57% 99.95%
discourse 584.8 15.42% 631.5 14.61% 534.9 18.29% 0.93x 21.24% 1.09x 23.92% 73.12%
erubi 492.0 2.32% 467.2 1.10% 439.9 0.78% 1.05x 2.57% 1.12x 2.45% 100.00%
erubi_rails 32.2 40.79% 35.4 42.29% 24.7 53.18% 0.91x 58.76% 1.31x 67.02% 86.29%
fannkuchredux 7256.7 9.75% 4065.6 0.03% 8897.6 0.36% 1.78x 9.75% 0.82x 9.76% 0.02%
lee 1232.5 2.25% 1026.8 1.36% 903.9 1.56% 1.20x 2.63% 1.36x 2.74% 99.97%
nbody 125.1 0.07% 72.7 0.17% 89.1 0.50% 1.72x 0.19% 1.40x 0.50% 100.00%
optcarrot 6057.8 0.43% 2581.6 0.63% 3418.3 0.61% 2.35x 0.76% 1.77x 0.75% 96.13%
rubykon 13842.2 2.11% 11533.4 1.21% 8128.2 2.51% 1.20x 2.43% 1.70x 3.28% 99.73%
30k_ifelse 2311.9 0.02% 3414.0 3.60% 380.0 0.17% 0.68x 3.60% 6.08x 0.17% 100.00%
30k_methods 6386.8 0.01% 10142.0 15.42% 874.9 0.06% 0.63x 15.42% 7.30x 0.06% 100.00%
cfunc_itself 107.7 0.15% 69.9 0.58% 45.3 1.06% 1.54x 0.60% 2.38x 1.07% 100.00%
fib 245.2 0.92% 86.1 0.03% 62.5 0.63% 2.85x 0.92% 3.92x 1.11% 100.00%
getivar 114.7 0.12% 26.2 68.49% 42.6 0.71% 4.38x 68.49% 2.69x 0.72% 99.21%
keyword_args 285.4 0.10% 222.2 0.19% 52.5 0.70% 1.28x 0.21% 5.44x 0.71% 100.00%
respond_to 277.1 0.18% 228.5 0.81% 195.2 1.14% 1.21x 0.83% 1.42x 1.16% 100.00%
setivar 79.0 0.56% 10.8 101.90% 53.9 0.61% 7.34x 101.90% 1.47x 0.83% 99.55%
str_concat 134.4 0.79% 103.2 1.18% 110.3 1.51% 1.30x 1.42% 1.22x 1.70% 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-05-09T18:20:49Z master 2999eb8846) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-09T18:20:49Z master 2999eb8846) +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 72 330
hexapdf 248 605
liquid-render 30 35 292
mail 49 54 311
psych-load 39 50 298
railsbench 102 136 382
binarytrees 30 33 288
chunky_png 42 48 302
discourse 388 405 706
erubi 39 43 298
erubi_rails 103 107 378
fannkuchredux 25 28 283
lee 34 40 295
nbody 24 27 283
optcarrot 58 67 320
rubykon 50 80 310
30k_ifelse 67 165 375
30k_methods 57 184 331
cfunc_itself 24 27 282
fib 24 27 282
getivar 25 27 283
keyword_args 24 28 282
respond_to 25 27 282
setivar 25 27 283
str_concat 111 93 349

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 190 75 190 20 190
hexapdf 5 15 20 15
liquid-render 5 156 75 156 20 156
mail 5 124 75 124 20 124
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 61 75 61 20 61
chunky_png 5 30 75 30 20 30
discourse 5 40 75 40 20 40
erubi 5 47 75 47 20 47
erubi_rails 5 1008 75 1008 20 1008
fannkuchredux 5 15 73 15 20 15
lee 5 22 75 22 20 22
nbody 5 274 75 274 20 274
optcarrot 5 15 75 15 20 15
rubykon 5 15 28 15 20 15
30k_ifelse 5 54 75 54 20 54
30k_methods 5 22 29 22 20 22
cfunc_itself 5 449 75 449 20 449
fib 5 319 75 319 20 319
getivar 5 764 75 764 20 764
keyword_args 5 377 75 377 20 377
respond_to 5 109 75 109 20 109
setivar 5 1849 75 1849 20 1849
str_concat 5 196 75 196 20 196

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) 1011099 751111 131 1231 0 0% 0 0 0
hexapdf (click) 1115611 874696 682 7711 10 0% 0 0 0
liquid-render (click) 509467 390723 150 1606 2 0% 0 0 0
mail (click) 909659 657329 374 5504 15 0% 0 0 0
psych-load (click) 339547 255149 68 457 1 0% 0 0 0
railsbench (click) 2623707 1914979 1435 9844 16 0% 0 0 0
binarytrees (click) 171803 128729 13 58 0 0% 0 0 0
chunky_png (click) 375451 280836 88 961 0 0% 0 0 0
discourse (click) 5926555 4391257 3221 25564 84 0% 2 0 0
erubi (click) 322715 242987 10 79 0 0% 0 0 0
erubi_rails (click) 1932635 1390320 300 2002 4 0% 0 0 0
fannkuchredux (click) 185819 139427 10 188 0 0% 0 0 0
lee (click) 377947 283430 58 618 0 0% 0 0 0
nbody (click) 181339 135930 12 158 0 0% 0 0 0
optcarrot (click) 512475 441179 207 3571 20 0% 0 0 0
rubykon (click) 317403 250267 144 1541 1 0% 0 0 0
30k_ifelse (click) 5560923 4349053 9265 57804 0 0% 0 0 0
30k_methods (click) 2175579 1657219 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170395 127358 10 49 0 0% 0 0 0
fib (click) 168859 126966 10 38 0 0% 0 0 0
getivar (click) 170651 129477 10 65 0 0% 0 0 0
keyword_args (click) 171163 127999 11 51 0 0% 0 0 0
respond_to (click) 172507 128812 10 64 0 0% 0 0 0
setivar (click) 170587 128001 10 38 0 0% 0 0 0
str_concat (click) 170587 128321 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.