YJIT Benchmarks

2022-06-22 20:14:27

As of 2022-06-22 20:14:27:

Overall YJIT is 34.9% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 31.1% 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 154.4 0.41% 155.0 0.33% 105.3 0.56% 1.00x 0.52% 1.47x 0.70% 85.54%
hexapdf 3209.6 0.86% 2310.0 2.95% 1.39x 3.07% 82.65%
liquid-render 199.0 1.48% 174.2 1.94% 127.3 2.09% 1.14x 2.44% 1.56x 2.56% 85.70%
mail 183.0 0.13% 178.0 1.54% 160.3 0.19% 1.03x 1.55% 1.14x 0.23% 99.37%
psych-load 2459.3 0.06% 2111.7 0.04% 1948.5 0.04% 1.16x 0.07% 1.26x 0.07% 88.45%
railsbench 2797.7 0.82% 2818.8 0.77% 2134.0 1.00% 0.99x 1.12% 1.31x 1.29% 86.29%
binarytrees 464.5 0.05% 304.7 0.33% 371.9 0.09% 1.52x 0.33% 1.25x 0.10% 84.27%
chunky_png 969.8 0.44% 792.9 0.03% 651.8 0.05% 1.22x 0.44% 1.49x 0.44% 99.95%
erubi 460.5 0.67% 418.3 0.71% 400.9 0.84% 1.10x 0.98% 1.15x 1.07% 100.00%
erubi_rails 27.8 2.21% 27.8 2.13% 20.0 3.15% 1.00x 3.07% 1.39x 3.85% 86.30%
fannkuchredux 8608.8 0.18% 5758.5 0.30% 8761.0 0.31% 1.49x 0.36% 0.98x 0.36% 0.02%
lee 1238.2 0.26% 1015.8 0.60% 905.9 0.44% 1.22x 0.65% 1.37x 0.51% 99.97%
nbody 126.3 0.08% 73.4 0.30% 90.8 0.06% 1.72x 0.31% 1.39x 0.10% 100.00%
optcarrot 6269.4 0.42% 2573.8 0.63% 3489.6 0.60% 2.44x 0.76% 1.80x 0.74% 96.13%
rubykon 13198.1 2.27% 8960.3 3.82% 7670.8 4.48% 1.47x 4.44% 1.72x 5.03% 99.80%
30k_ifelse 2228.8 0.03% 3570.4 4.02% 357.8 0.09% 0.62x 4.02% 6.23x 0.09% 100.00%
30k_methods 6441.6 0.01% 10150.6 15.23% 879.5 0.02% 0.63x 15.23% 7.32x 0.02% 100.00%
cfunc_itself 105.2 0.15% 68.2 0.34% 48.3 0.68% 1.54x 0.37% 2.18x 0.69% 100.00%
fib 240.7 0.04% 86.2 0.21% 63.4 0.19% 2.79x 0.21% 3.80x 0.19% 100.00%
getivar 105.0 0.26% 26.5 67.89% 42.5 0.06% 3.96x 67.89% 2.47x 0.27% 99.21%
keyword_args 283.8 0.10% 220.3 0.38% 52.7 0.25% 1.29x 0.40% 5.39x 0.27% 100.00%
respond_to 286.8 0.08% 236.4 0.29% 197.6 0.04% 1.21x 0.30% 1.45x 0.09% 100.00%
setivar 76.7 0.26% 10.8 100.82% 53.8 0.15% 7.12x 100.82% 1.43x 0.30% 99.56%
str_concat 131.4 0.81% 100.4 0.76% 109.2 0.70% 1.31x 1.11% 1.20x 1.07% 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-22T12:30:39Z master 744d17ff6c) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-22T12:30:39Z master 744d17ff6c) +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 75
hexapdf 242 382
liquid-render 30 35 37
mail 49 53 57
psych-load 40 46 44
railsbench 102 107 131
binarytrees 30 33 33
chunky_png 42 44 47
erubi 85 93 117
erubi_rails 101 103 121
fannkuchredux 25 27 27
lee 35 42 39
nbody 24 26 27
optcarrot 59 67 65
rubykon 56 61 58
30k_ifelse 67 169 126
30k_methods 58 179 78
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 26 27
keyword_args 24 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 113 98 98

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 196 75 196 20 196
hexapdf 5 15 20 15
liquid-render 5 156 75 156 20 156
mail 5 117 75 117 20 117
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 67 75 67 20 67
chunky_png 5 30 75 30 20 30
erubi 5 51 75 51 20 51
erubi_rails 5 1003 75 1003 20 1003
fannkuchredux 5 15 52 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 33 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 428 75 428 20 428
fib 5 315 75 315 20 315
getivar 5 765 75 765 20 765
keyword_args 5 378 75 378 20 378
respond_to 5 105 75 105 20 105
setivar 5 1883 75 1883 20 1883
str_concat 5 205 75 205 20 205

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) 1013083 753803 131 1254 0 0% 0 0 0
hexapdf (click) 1119387 878752 682 7749 9 0% 0 0 0
liquid-render (click) 515419 395398 150 1663 2 0% 0 0 0
mail (click) 892059 645004 374 5330 15 0% 0 0 0
psych-load (click) 339035 254740 68 457 1 0% 0 0 0
railsbench (click) 2623579 1918742 1436 9873 16 0% 0 0 0
binarytrees (click) 173211 129800 13 58 0 0% 0 0 0
chunky_png (click) 379099 283360 88 995 0 0% 0 0 0
erubi (click) 318875 242377 10 79 0 0% 0 0 0
erubi_rails (click) 1927899 1389710 300 1962 4 0% 0 0 0
fannkuchredux (click) 187227 140498 10 188 0 0% 0 0 0
lee (click) 377755 283393 58 622 0 0% 0 0 0
nbody (click) 182555 136866 12 158 0 0% 0 0 0
optcarrot (click) 513371 441954 207 3571 20 0% 0 0 0
rubykon (click) 317851 250826 144 1538 1 0% 0 0 0
30k_ifelse (click) 5562267 4350124 9265 57804 0 0% 0 0 0
30k_methods (click) 2177435 1658586 5784 19361 0 0% 0 0 0
cfunc_itself (click) 171227 128133 10 49 0 0% 0 0 0
fib (click) 169691 127741 10 38 0 0% 0 0 0
getivar (click) 171995 130548 10 65 0 0% 0 0 0
keyword_args (click) 172571 129070 11 51 0 0% 0 0 0
respond_to (click) 173851 129883 10 64 0 0% 0 0 0
setivar (click) 171931 129072 10 38 0 0% 0 0 0
str_concat (click) 171931 129392 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.