YJIT Benchmarks

2021-09-13 07:09:45

As of 2021-09-13 07:09:45:

Overall YJIT is 19.2% faster than interpreted CRuby, or 13.4% faster than MJIT (3.0)!
On Railsbench specifically, YJIT is 17.1% faster than CRuby, 15.4% faster than MJIT (3.0)!

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 No JIT MJIT3.0 YJIT activerecord jekyll liquid-render mail psych-load railsbench Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

MicroBenchmarks

0.0 2.0 4.0 6.0 8.0 No JIT MJIT3.0 YJIT 30k_ifelse 30k_methods cfunc_itself fib getivar respond_to setivar Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

Other Benchmarks

0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 No JIT MJIT3.0 YJIT binarytrees fannkuchredux lee nbody optcarrot 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.0 (ms) MJIT3.0 RSD YJIT (ms) YJIT RSD MJIT3.0 spd MJIT3.0 spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 149.5 1.46% 154.0 1.06% 110.2 1.95% 0.97x 1.80% 1.36x 2.44% 79.48%
jekyll 8350.3 1.96% 8312.2 1.68% 7655.9 2.69% 1.00x 2.59% 1.09x 3.33% 67.37%
liquid-render 188.4 2.05% 163.6 2.06% 150.3 1.65% 1.15x 2.91% 1.25x 2.63% 66.98%
mail 154.0 1.26% 149.9 1.27% 140.4 1.46% 1.03x 1.79% 1.10x 1.93% 24.46%
psych-load 2138.1 0.59% 1852.7 1.42% 1773.1 0.49% 1.15x 1.54% 1.21x 0.76% 66.23%
railsbench 3127.7 2.29% 3083.2 0.95% 2670.6 1.27% 1.01x 2.48% 1.17x 2.62% 75.95%
binarytrees 387.3 0.32% 254.9 0.50% 301.9 0.96% 1.52x 0.59% 1.28x 1.02% 82.95%
fannkuchredux 5602.6 0.10% 4057.6 0.03% 5665.3 0.15% 1.38x 0.11% 0.99x 0.19% 0.00%
lee 1122.7 1.00% 872.2 1.22% 799.1 1.44% 1.29x 1.58% 1.41x 1.76% 99.82%
nbody 114.4 0.04% 69.8 0.39% 113.4 0.50% 1.64x 0.39% 1.01x 0.50% 7.40%
optcarrot 5165.0 0.38% 2697.2 0.20% 3146.0 0.16% 1.91x 0.43% 1.64x 0.41% 96.19%
30k_ifelse 2412.0 4.63% 2202.4 0.79% 329.0 0.26% 1.10x 4.70% 7.33x 4.64% 99.98%
30k_methods 5859.5 0.06% 6424.2 0.98% 717.9 0.04% 0.91x 0.98% 8.16x 0.08% 100.00%
cfunc_itself 90.1 0.12% 57.6 0.20% 41.0 0.32% 1.57x 0.23% 2.20x 0.34% 100.00%
fib 199.1 0.03% 62.6 0.04% 58.4 0.07% 3.18x 0.05% 3.41x 0.08% 100.00%
getivar 93.0 0.18% 90.7 0.15% 36.3 0.06% 1.03x 0.24% 2.56x 0.19% 86.32%
respond_to 235.1 0.15% 202.4 0.38% 151.6 0.41% 1.16x 0.41% 1.55x 0.43% 100.00%
setivar 71.3 0.15% 73.4 0.24% 41.9 0.28% 0.97x 0.28% 1.70x 0.32% 88.46%

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.1.0dev (2021-09-10T21:08:26Z main 99e87e7f75) [x86_64-linux]
Tested Ruby version for Ruby 3.0 MJIT: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) +JIT [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.0 mem (MiB) YJIT mem (MiB)
activerecord 60 64 321
jekyll 853 850 1115
liquid-render 27 31 286
mail 48 50 307
psych-load 27 30 284
railsbench 180 184 450
binarytrees 28 31 283
fannkuchredux 22 22 279
lee 28 28 285
nbody 22 22 278
optcarrot 97 106 355
30k_ifelse 63 63 345
30k_methods 54 56 321
cfunc_itself 22 22 278
fib 22 22 278
getivar 22 21 279
respond_to 22 22 278
setivar 22 21 279

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 crashing.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT3.0 warmups MJIT3.0 iters YJIT warmups YJIT iters
activerecord 10 124 10 120 10 172
jekyll 10 10 10 10 10 10
liquid-render 10 97 10 112 10 123
mail 10 120 10 123 10 132
psych-load 10 10 10 10 10 10
railsbench 10 10 10 10 10 10
binarytrees 10 42 10 69 10 57
fannkuchredux 10 10 10 10 10 10
lee 10 10 10 13 10 16
nbody 10 165 10 273 10 167
optcarrot 10 10 10 10 10 10
30k_ifelse 10 10 10 10 10 51
30k_methods 10 10 10 10 10 18
cfunc_itself 10 212 10 337 10 478
fib 10 91 10 307 10 333
getivar 10 205 10 211 10 528
respond_to 10 76 10 89 10 122
setivar 10 271 10 263 10 462

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) 1055078 811078 185 ? 0 0
jekyll (click) 2287014 1678390 335 ? 0 0
liquid-render (click) 410400 331084 144 ? 0 0
mail (click) 756838 596952 337 ? 0 0
psych-load (click) 169138 133306 57 ? 0 0
railsbench (click) 5311290 3031362 1293 ? 0 0
binarytrees (click) 106117 82762 10 ? 0 0
fannkuchredux (click) 105925 82552 7 ? 0 0
lee (click) 216434 166338 86 ? 1 0
nbody (click) 105093 82426 8 ? 0 0
optcarrot (click) 634053 575328 287 ? 0 0
30k_ifelse (click) 5562053 4769962 9262 ? 0 0
30k_methods (click) 2191621 1872692 5781 ? 0 0
cfunc_itself (click) 105029 81590 7 ? 0 0
fib (click) 103301 80670 7 ? 0 0
getivar (click) 105221 83754 7 ? 0 0
respond_to (click) 107013 82786 7 ? 0 0
setivar (click) 105157 82010 7 ? 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.