YJIT Benchmarks

2022-06-23 05:15:40

As of 2022-06-23 05:15:40:

Overall YJIT is 33.6% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 22.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 MJIT 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 MJIT 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 MJIT 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 MJIT (ms) MJIT RSD YJIT (ms) YJIT RSD MJIT spd MJIT spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 155.1 0.40% 156.2 0.36% 104.4 0.59% 0.99x 0.54% 1.48x 0.71% 85.54%
hexapdf 3186.9 1.29% 2316.5 1.81% 1.38x 2.22% 83.65%
liquid-render 195.5 1.23% 175.3 1.91% 128.8 2.04% 1.12x 2.27% 1.52x 2.38% 85.70%
mail 181.5 0.14% 176.9 1.61% 158.8 0.20% 1.03x 1.61% 1.14x 0.25% 99.37%
psych-load 2475.2 0.07% 2096.6 0.03% 1897.0 0.02% 1.18x 0.07% 1.30x 0.07% 88.45%
railsbench 2795.0 0.94% 2859.1 0.79% 2278.4 1.34% 0.98x 1.22% 1.23x 1.63% 86.29%
binarytrees 479.3 0.06% 302.7 0.33% 362.9 0.05% 1.58x 0.34% 1.32x 0.07% 84.27%
chunky_png 967.9 0.04% 798.9 0.40% 655.3 0.05% 1.21x 0.40% 1.48x 0.06% 99.95%
erubi 466.7 0.61% 417.1 0.68% 393.5 0.84% 1.12x 0.92% 1.19x 1.04% 100.00%
erubi_rails 27.5 2.42% 27.9 2.08% 20.1 3.42% 0.99x 3.20% 1.37x 4.19% 86.30%
fannkuchredux 8597.7 0.17% 3935.8 0.04% 8941.3 0.14% 2.18x 0.17% 0.96x 0.22% 0.02%
lee 1245.6 0.32% 1020.2 0.46% 904.6 0.41% 1.22x 0.56% 1.38x 0.52% 99.97%
nbody 126.1 0.09% 73.1 0.30% 92.1 0.07% 1.73x 0.32% 1.37x 0.12% 100.00%
optcarrot 6289.1 0.44% 2624.9 0.56% 3459.1 0.61% 2.40x 0.71% 1.82x 0.75% 96.13%
rubykon 13171.3 2.42% 8860.4 5.05% 7583.5 4.35% 1.49x 5.60% 1.74x 4.98% 99.60%
30k_ifelse 2261.3 0.01% 3659.0 3.89% 352.3 0.09% 0.62x 3.89% 6.42x 0.09% 100.00%
30k_methods 6160.7 0.01% 10023.8 17.09% 879.2 0.02% 0.61x 17.09% 7.01x 0.02% 100.00%
cfunc_itself 105.2 0.15% 68.2 0.50% 44.8 0.69% 1.54x 0.52% 2.35x 0.71% 100.00%
fib 240.1 0.05% 86.3 0.20% 63.4 0.18% 2.78x 0.20% 3.79x 0.19% 100.00%
getivar 105.5 0.11% 26.2 69.70% 42.5 0.06% 4.02x 69.70% 2.48x 0.13% 99.20%
keyword_args 288.1 0.10% 221.8 1.98% 52.9 0.33% 1.30x 1.98% 5.44x 0.34% 100.00%
respond_to 286.4 0.09% 237.7 0.51% 198.3 0.07% 1.21x 0.52% 1.44x 0.11% 100.00%
setivar 76.5 0.30% 10.8 101.41% 53.8 0.16% 7.08x 101.41% 1.42x 0.34% 99.55%
str_concat 131.9 0.87% 101.1 0.51% 108.4 0.66% 1.30x 1.01% 1.22x 1.10% 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 MJIT 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 and the yjit-extra-benchmarks 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 latest MJIT: ruby 3.2.0dev (2022-06-22T12:30:39Z master 744d17ff6c) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 64 76
hexapdf 248 358
liquid-render 30 35 37
mail 49 53 57
psych-load 40 52 44
railsbench 103 104 131
binarytrees 31 33 33
chunky_png 42 48 49
erubi 88 87 118
erubi_rails 101 104 121
fannkuchredux 25 27 27
lee 34 42 39
nbody 25 26 27
optcarrot 59 67 65
rubykon 56 63 59
30k_ifelse 67 171 126
30k_methods 57 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 114 93 93

Memory is shown in mebibytes (1024 * 1024 bytes.)

Older YJIT allocated an additional 256MiB for generated code. Current YJIT allocates executable memory on demand, so this overhead should no longer be present.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT warmups MJIT iters YJIT warmups YJIT iters
activerecord 5 189 75 189 20 189
hexapdf 5 15 20 15
liquid-render 5 157 75 157 20 157
mail 5 124 75 124 20 124
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 30 75 30 20 30
erubi 5 49 75 49 20 49
erubi_rails 5 1001 75 1001 20 1001
fannkuchredux 5 15 52 15 20 15
lee 5 22 75 22 20 22
nbody 5 272 75 272 20 272
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 22 29 22 20 22
cfunc_itself 5 413 75 413 20 413
fib 5 315 75 315 20 315
getivar 5 754 75 754 20 754
keyword_args 5 379 75 379 20 379
respond_to 5 101 75 101 20 101
setivar 5 1855 75 1855 20 1855
str_concat 5 199 75 199 20 199

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) 1016411 755836 131 1267 0 0% 0 0 0
hexapdf (click) 1120155 879540 682 7750 10 0% 0 0 0
liquid-render (click) 507867 389188 150 1582 2 0% 0 0 0
mail (click) 909467 657271 374 5510 15 0% 0 0 0
psych-load (click) 339035 254740 68 457 1 0% 0 0 0
railsbench (click) 2625563 1919261 1436 9886 16 0% 0 0 0
binarytrees (click) 173211 129800 13 58 0 0% 0 0 0
chunky_png (click) 379419 283725 88 996 0 0% 0 0 0
erubi (click) 319579 243165 10 79 0 0% 0 0 0
erubi_rails (click) 1926619 1388475 300 1951 4 0% 0 0 0
fannkuchredux (click) 187227 140498 10 188 0 0% 0 0 0
lee (click) 378459 284131 58 622 0 0% 0 0 0
nbody (click) 182683 137001 12 158 0 0% 0 0 0
optcarrot (click) 513883 442250 207 3571 20 0% 0 0 0
rubykon (click) 319387 252008 144 1547 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) 171739 128429 10 49 0 0% 0 0 0
fib (click) 170203 128037 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.