YJIT Benchmarks

2022-08-02 05:31:45

As of 2022-08-02 05:31:45:

Overall YJIT is 35.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 36.9% 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% 155.6 0.66% 103.2 0.74% 0.98x 0.75% 1.47x 0.82% 85.94%
hexapdf 3094.8 1.01% 2273.0 2.53% 1.36x 2.72% 83.22%
liquid-render 195.6 0.99% 168.2 1.66% 125.7 1.70% 1.16x 1.93% 1.56x 1.96% 85.90%
mail 178.6 0.14% 175.6 1.88% 157.1 0.17% 1.02x 1.89% 1.14x 0.23% 99.40%
psych-load 2481.4 0.04% 2131.9 0.09% 1934.7 0.01% 1.16x 0.10% 1.28x 0.04% 88.89%
railsbench 2853.9 0.61% 2832.5 0.59% 2084.3 1.18% 1.01x 0.85% 1.37x 1.32% 86.38%
binarytrees 469.0 0.04% 306.3 0.35% 363.0 0.06% 1.53x 0.35% 1.29x 0.07% 84.27%
chunky_png 956.3 0.46% 768.2 0.39% 632.2 0.08% 1.24x 0.60% 1.51x 0.47% 99.95%
erubi 376.1 0.49% 345.2 0.71% 318.1 0.60% 1.09x 0.86% 1.18x 0.78% 100.00%
erubi_rails 27.1 2.93% 26.9 2.57% 19.1 3.51% 1.01x 3.89% 1.42x 4.57% 86.40%
fannkuchredux 6996.9 0.71% 3969.0 0.09% 6894.3 0.06% 1.76x 0.72% 1.01x 0.72% 0.02%
lee 1263.5 0.88% 1060.8 1.96% 938.2 1.81% 1.19x 2.15% 1.35x 2.01% 99.97%
nbody 122.7 0.08% 76.5 0.24% 89.3 0.11% 1.60x 0.25% 1.37x 0.14% 100.00%
optcarrot 6164.9 0.41% 2770.3 0.63% 3562.7 0.61% 2.23x 0.75% 1.73x 0.74% 96.16%
rubykon 12699.4 0.55% 8045.6 0.53% 6786.8 1.09% 1.58x 0.76% 1.87x 1.22% 99.82%
30k_ifelse 2337.1 0.10% 3674.1 3.97% 364.5 0.08% 0.64x 3.97% 6.41x 0.13% 100.00%
30k_methods 6384.1 0.01% 9685.2 20.06% 866.0 0.02% 0.66x 20.06% 7.37x 0.02% 100.00%
cfunc_itself 104.2 0.21% 69.7 0.58% 45.2 0.82% 1.50x 0.62% 2.31x 0.85% 100.00%
fib 252.6 0.05% 86.2 0.22% 63.3 0.04% 2.93x 0.22% 3.99x 0.06% 100.00%
getivar 112.9 0.55% 32.7 57.13% 44.3 0.13% 3.46x 57.13% 2.55x 0.56% 99.02%
keyword_args 298.1 0.08% 223.8 0.21% 54.0 0.14% 1.33x 0.23% 5.52x 0.16% 100.00%
respond_to 282.5 0.51% 236.0 0.41% 198.4 0.08% 1.20x 0.66% 1.42x 0.52% 100.00%
setivar 76.2 0.25% 20.9 62.99% 40.5 0.31% 3.64x 62.99% 1.88x 0.40% 99.14%
str_concat 85.1 0.94% 51.8 1.31% 44.1 1.55% 1.64x 1.61% 1.93x 1.81% 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-01T19:14:48Z master 24204d54ab) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-01T19:14:48Z master 24204d54ab) +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 272 396
liquid-render 31 36 37
mail 49 53 57
psych-load 39 45 41
railsbench 104 107 133
binarytrees 31 33 33
chunky_png 44 50 48
erubi 75 89 84
erubi_rails 102 104 123
fannkuchredux 25 27 27
lee 33 40 39
nbody 24 26 27
optcarrot 58 66 65
rubykon 53 60 57
30k_ifelse 68 174 127
30k_methods 57 176 76
cfunc_itself 24 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 107

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 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 158 75 158 20 158
mail 5 126 75 126 20 126
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 65 75 65 20 65
chunky_png 5 31 75 31 20 31
erubi 5 61 75 61 20 61
erubi_rails 5 1041 75 1041 20 1041
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 37 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 30 22 20 22
cfunc_itself 5 443 75 443 20 443
fib 5 315 75 315 20 315
getivar 5 614 75 614 20 614
keyword_args 5 378 75 378 20 378
respond_to 5 101 75 101 20 101
setivar 5 958 75 958 20 958
str_concat 5 459 75 459 20 459

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) 1038171 781057 131 1276 0 0% 0 0 0
hexapdf (click) 1150939 925535 682 8016 9 0% 0 0 0
liquid-render (click) 519771 404039 150 1674 2 0% 0 0 0
mail (click) 901147 650718 374 5332 17 0% 0 0 0
psych-load (click) 348059 263818 68 482 1 0% 0 0 0
railsbench (click) 2660507 1970833 1436 10039 16 0% 0 0 0
binarytrees (click) 172187 128374 13 58 0 0% 0 0 0
chunky_png (click) 385563 288575 88 1003 0 0% 0 0 0
erubi (click) 322139 245757 10 79 0 0% 0 0 0
erubi_rails (click) 1961755 1429969 300 2026 4 0% 0 0 0
fannkuchredux (click) 186011 138504 10 188 0 0% 0 0 0
lee (click) 385819 291354 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) 320795 256457 144 1566 1 0% 0 0 0
30k_ifelse (click) 5560795 4348546 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) 169179 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.