YJIT Benchmarks

2022-06-18 20:14:23

As of 2022-06-18 20:14:23:

Overall YJIT is 35.6% 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 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 152.7 0.53% 156.4 0.31% 103.1 0.56% 0.98x 0.61% 1.48x 0.77% 85.54%
hexapdf 3211.4 0.83% 2342.4 2.18% 1.37x 2.33% 83.11%
liquid-render 199.4 1.23% 173.5 1.95% 129.8 2.07% 1.15x 2.30% 1.54x 2.41% 85.70%
mail 181.0 0.14% 177.5 1.75% 158.9 0.15% 1.02x 1.75% 1.14x 0.20% 99.37%
psych-load 2687.7 0.06% 2216.7 0.07% 2063.2 0.07% 1.21x 0.09% 1.30x 0.09% 88.45%
railsbench 2824.9 0.98% 2805.0 0.89% 2097.3 1.53% 1.01x 1.32% 1.35x 1.82% 86.29%
binarytrees 464.5 0.04% 298.4 0.33% 357.6 0.05% 1.56x 0.33% 1.30x 0.07% 84.27%
chunky_png 973.7 0.05% 796.4 0.41% 658.1 0.10% 1.22x 0.41% 1.48x 0.11% 99.95%
discourse 567.2 9.96% 630.2 14.96% 478.4 2.39% 0.90x 17.98% 1.19x 10.25% 73.57%
erubi 460.2 0.55% 423.4 0.77% 392.9 0.65% 1.09x 0.95% 1.17x 0.85% 100.00%
erubi_rails 27.9 2.91% 28.3 2.51% 19.9 3.71% 0.99x 3.84% 1.40x 4.71% 86.30%
fannkuchredux 8672.1 0.13% 5716.7 0.18% 9147.1 0.18% 1.52x 0.22% 0.95x 0.22% 0.02%
lee 1270.7 0.83% 1039.1 0.17% 942.8 0.04% 1.22x 0.84% 1.35x 0.83% 99.97%
nbody 123.8 0.05% 72.9 0.28% 90.9 0.08% 1.70x 0.28% 1.36x 0.10% 100.00%
optcarrot 6265.6 0.43% 2639.0 0.59% 3422.2 0.60% 2.37x 0.73% 1.83x 0.74% 96.13%
rubykon 13370.6 2.20% 8908.0 4.32% 7572.8 3.88% 1.50x 4.85% 1.77x 4.46% 99.74%
30k_ifelse 2336.2 0.01% 3663.1 3.83% 356.1 0.08% 0.64x 3.83% 6.56x 0.09% 100.00%
30k_methods 6427.2 0.01% 10143.4 17.60% 878.6 0.02% 0.63x 17.60% 7.32x 0.03% 100.00%
cfunc_itself 105.4 0.24% 70.2 0.54% 45.2 0.83% 1.50x 0.59% 2.33x 0.86% 100.00%
fib 243.8 0.07% 86.3 0.30% 64.1 0.04% 2.82x 0.31% 3.80x 0.08% 100.00%
getivar 112.5 0.45% 26.2 69.06% 42.5 0.06% 4.30x 69.07% 2.64x 0.46% 99.20%
keyword_args 294.0 0.08% 224.1 0.94% 52.9 0.33% 1.31x 0.94% 5.55x 0.34% 100.00%
respond_to 275.1 0.20% 230.4 1.41% 187.4 0.22% 1.19x 1.43% 1.47x 0.30% 100.00%
setivar 83.4 0.68% 10.7 103.48% 54.0 0.26% 7.78x 103.48% 1.55x 0.73% 99.55%
str_concat 133.1 0.92% 101.5 0.88% 109.4 0.80% 1.31x 1.28% 1.22x 1.22% 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-18T12:49:02Z master eca31d24d6) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-18T12:49:02Z master eca31d24d6) +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 253 382
liquid-render 30 35 37
mail 49 53 57
psych-load 38 46 43
railsbench 103 105 131
binarytrees 31 33 33
chunky_png 41 47 48
discourse 396 370 471
erubi 67 88 82
erubi_rails 104 105 124
fannkuchredux 25 27 27
lee 33 40 38
nbody 25 26 27
optcarrot 59 66 65
rubykon 53 62 60
30k_ifelse 66 171 126
30k_methods 57 179 79
cfunc_itself 25 27 27
fib 24 27 26
getivar 25 26 27
keyword_args 25 27 27
respond_to 24 27 26
setivar 25 26 27
str_concat 100 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 191 75 191 20 191
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 40 75 40 20 40
erubi 5 51 75 51 20 51
erubi_rails 5 988 75 988 20 988
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 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 445 75 445 20 445
fib 5 315 75 315 20 315
getivar 5 755 75 755 20 755
keyword_args 5 377 75 377 20 377
respond_to 5 104 75 104 20 104
setivar 5 1838 75 1838 20 1838
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) 1015835 755404 131 1248 0 0% 0 0 0
hexapdf (click) 1119707 878940 682 7748 9 0% 0 0 0
liquid-render (click) 511259 391511 150 1600 2 0% 0 0 0
mail (click) 923419 667806 374 5648 15 0% 0 0 0
psych-load (click) 339483 254981 68 457 1 0% 0 0 0
railsbench (click) 2621403 1917582 1436 9840 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 384603 286448 88 1040 0 0% 0 0 0
discourse (click) 5935707 4406201 3195 25534 85 0% 2 0 0
erubi (click) 319515 242761 10 79 0 0% 0 0 0
erubi_rails (click) 1932315 1392421 300 2005 4 0% 0 0 0
fannkuchredux (click) 188251 141143 10 188 0 0% 0 0 0
lee (click) 378331 283827 58 622 0 0% 0 0 0
nbody (click) 183643 137578 12 158 0 0% 0 0 0
optcarrot (click) 514907 442895 207 3571 20 0% 0 0 0
rubykon (click) 319131 251579 144 1536 1 0% 0 0 0
30k_ifelse (click) 5563163 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) 171099 128682 10 38 0 0% 0 0 0
getivar (click) 171611 130332 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.