YJIT Benchmarks

2022-07-31 20:13:59

As of 2022-07-31 20:13:59:

Overall YJIT is 35.3% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.7% 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 152.0 0.56% 152.6 0.44% 104.7 0.59% 1.00x 0.71% 1.45x 0.81% 85.94%
hexapdf 3130.1 1.18% 2343.8 1.18% 1.34x 1.67% 82.96%
liquid-render 198.4 1.10% 171.1 1.56% 125.8 1.80% 1.16x 1.91% 1.58x 2.11% 85.90%
mail 179.6 0.12% 175.1 1.96% 156.1 0.13% 1.03x 1.96% 1.15x 0.18% 99.36%
psych-load 2533.6 0.04% 2187.5 0.06% 1955.9 0.03% 1.16x 0.07% 1.30x 0.05% 88.89%
railsbench 2817.9 0.67% 2780.2 0.72% 2091.7 1.48% 1.01x 0.99% 1.35x 1.62% 86.38%
binarytrees 465.1 0.52% 311.9 0.29% 369.0 0.06% 1.49x 0.60% 1.26x 0.52% 84.27%
chunky_png 959.7 0.03% 768.0 0.03% 638.6 0.07% 1.25x 0.04% 1.50x 0.08% 99.95%
erubi 369.5 0.88% 338.9 0.67% 320.9 0.65% 1.09x 1.11% 1.15x 1.09% 100.00%
erubi_rails 27.0 2.70% 27.1 2.58% 19.4 3.66% 0.99x 3.74% 1.39x 4.55% 86.39%
fannkuchredux 6984.4 0.30% 4056.9 0.06% 6959.0 0.31% 1.72x 0.31% 1.00x 0.44% 0.02%
lee 1296.3 0.84% 1060.4 1.55% 937.3 1.20% 1.22x 1.77% 1.38x 1.47% 99.97%
nbody 125.5 0.13% 76.2 0.23% 93.4 0.09% 1.65x 0.26% 1.34x 0.16% 100.00%
optcarrot 6518.8 0.42% 2763.7 0.61% 3448.8 0.59% 2.36x 0.74% 1.89x 0.73% 96.16%
rubykon 12664.7 0.50% 7996.7 0.93% 6789.3 0.73% 1.58x 1.06% 1.87x 0.89% 99.75%
30k_ifelse 2216.1 0.01% 3563.2 4.07% 355.9 0.09% 0.62x 4.07% 6.23x 0.10% 100.00%
30k_methods 6361.2 0.00% 9912.2 21.47% 865.6 0.02% 0.64x 21.47% 7.35x 0.02% 100.00%
cfunc_itself 107.2 0.11% 68.3 0.33% 45.7 0.67% 1.57x 0.35% 2.35x 0.68% 100.00%
fib 252.4 0.09% 86.2 0.21% 63.3 0.04% 2.93x 0.23% 3.99x 0.10% 100.00%
getivar 116.8 0.12% 32.8 59.63% 44.2 0.12% 3.56x 59.63% 2.64x 0.16% 99.01%
keyword_args 289.9 0.09% 221.2 0.48% 52.4 0.10% 1.31x 0.48% 5.53x 0.14% 100.00%
respond_to 275.8 0.11% 228.5 0.67% 191.5 0.12% 1.21x 0.67% 1.44x 0.17% 100.00%
setivar 77.4 0.07% 20.9 63.24% 46.4 0.11% 3.70x 63.24% 1.67x 0.13% 99.14%
str_concat 85.5 0.96% 51.4 1.23% 42.8 1.54% 1.66x 1.56% 2.00x 1.82% 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-07-31T16:31:40Z master 3b8279e91f) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-07-31T16:31:40Z master 3b8279e91f) +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 279 403
liquid-render 31 36 37
mail 49 53 57
psych-load 36 45 41
railsbench 103 106 132
binarytrees 31 33 33
chunky_png 44 46 48
erubi 66 89 95
erubi_rails 102 103 123
fannkuchredux 25 27 27
lee 33 40 39
nbody 25 26 27
optcarrot 58 66 65
rubykon 53 60 56
30k_ifelse 68 171 127
30k_methods 57 176 76
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 25 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 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 160 75 160 20 160
mail 5 126 75 126 20 126
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 63 75 63 20 63
chunky_png 5 31 75 31 20 31
erubi 5 63 75 63 20 63
erubi_rails 5 1034 75 1034 20 1034
fannkuchredux 5 15 74 15 20 15
lee 5 21 75 21 20 21
nbody 5 262 75 262 20 262
optcarrot 5 15 75 15 20 15
rubykon 5 15 37 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 30 22 20 22
cfunc_itself 5 447 75 447 20 447
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 103 75 103 20 103
setivar 5 958 75 958 20 958
str_concat 5 460 75 460 20 460

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) 1037339 780686 131 1296 0 0% 0 0 0
hexapdf (click) 1151323 925665 682 8017 9 0% 0 0 0
liquid-render (click) 522459 406692 150 1707 2 0% 0 0 0
mail (click) 931547 670102 374 5613 17 0% 0 0 0
psych-load (click) 348059 263793 68 482 1 0% 0 0 0
railsbench (click) 2654043 1966736 1436 9991 16 0% 0 0 0
binarytrees (click) 171739 128078 13 58 0 0% 0 0 0
chunky_png (click) 386971 289614 88 1002 0 0% 0 0 0
erubi (click) 323547 246784 10 79 0 0% 0 0 0
erubi_rails (click) 1961371 1429531 300 2006 4 0% 0 0 0
fannkuchredux (click) 186011 138504 10 188 0 0% 0 0 0
lee (click) 384539 290327 58 632 0 0% 0 0 0
nbody (click) 182811 137569 12 171 0 0% 0 0 0
optcarrot (click) 514203 442736 207 3588 20 0% 0 0 0
rubykon (click) 322203 257420 144 1579 1 0% 0 0 0
30k_ifelse (click) 5561243 4348842 9265 57804 0 0% 0 0 0
30k_methods (click) 2176411 1657304 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170715 127147 10 49 0 0% 0 0 0
fib (click) 169307 126755 10 38 0 0% 0 0 0
getivar (click) 170907 128842 10 65 0 0% 0 0 0
keyword_args (click) 171547 127788 11 51 0 0% 0 0 0
respond_to (click) 172827 128601 10 64 0 0% 0 0 0
setivar (click) 170843 127662 10 38 0 0% 0 0 0
str_concat (click) 170843 128069 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.