YJIT Benchmarks

2021-10-13 07:09:47

As of 2021-10-13 07:09:47:

Overall YJIT is 25.2% faster than interpreted CRuby, or 20.6% faster than MJIT (3.0)!
On Railsbench specifically, YJIT is 19.6% faster than CRuby, 20.2% 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 hexapdf 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 keyword_args 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 145.3 1.77% 153.5 0.63% 106.1 0.70% 0.95x 1.88% 1.37x 1.90% 80.96%
hexapdf 2830.7 1.08% 2746.7 2.76% 2177.2 1.44% 1.03x 2.96% 1.30x 1.80% 72.00%
jekyll 8391.0 1.57% 8303.3 1.82% 7472.8 1.63% 1.01x 2.40% 1.12x 2.27% 78.42%
liquid-render 174.8 1.22% 163.2 2.08% 125.6 1.91% 1.07x 2.41% 1.39x 2.27% 71.70%
mail 154.4 0.13% 149.0 1.60% 140.5 0.45% 1.04x 1.61% 1.10x 0.47% 98.30%
psych-load 2252.3 1.44% 1879.9 2.09% 1707.0 2.09% 1.20x 2.53% 1.32x 2.53% 82.02%
railsbench 2990.7 1.92% 3006.1 1.59% 2500.4 3.64% 0.99x 2.49% 1.20x 4.11% 79.87%
binarytrees 372.4 0.19% 254.4 0.50% 289.1 2.67% 1.46x 0.53% 1.29x 2.68% 84.27%
fannkuchredux 5516.7 0.04% 3982.4 1.21% 5514.2 0.10% 1.39x 1.21% 1.00x 0.11% 0.01%
lee 1099.0 0.79% 870.1 1.26% 786.2 1.67% 1.26x 1.49% 1.40x 1.85% 99.92%
nbody 109.0 0.03% 57.7 1.23% 75.5 0.03% 1.89x 1.23% 1.44x 0.04% 100.00%
optcarrot 4906.7 0.56% 4281.3 0.99% 3115.5 0.46% 1.15x 1.14% 1.57x 0.73% 96.13%
30k_ifelse 2175.2 0.02% 2175.8 0.71% 317.3 0.14% 1.00x 0.71% 6.86x 0.14% 99.99%
30k_methods 6044.2 0.43% 6340.0 0.58% 748.0 0.02% 0.95x 0.72% 8.08x 0.43% 100.00%
cfunc_itself 88.8 0.15% 57.2 0.15% 39.3 0.32% 1.55x 0.21% 2.26x 0.35% 100.00%
fib 192.5 0.03% 62.5 0.02% 52.0 0.06% 3.08x 0.03% 3.70x 0.07% 100.00%
getivar 87.2 0.19% 90.7 0.13% 36.2 0.10% 0.96x 0.23% 2.41x 0.21% 86.63%
keyword_args 236.4 0.02% 185.7 0.03% 46.0 0.37% 1.27x 0.04% 5.14x 0.37% 100.00%
respond_to 231.5 0.13% 199.8 0.58% 165.0 0.27% 1.16x 0.59% 1.40x 0.30% 100.00%
setivar 70.9 0.04% 73.0 0.11% 42.3 0.04% 0.97x 0.12% 1.68x 0.05% 88.07%

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-10-12T14:26:16Z main 270ba9a02a) +YJIT [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 61 64 322
hexapdf 340 337 672
jekyll 856 846 1118
liquid-render 30 32 289
mail 48 49 308
psych-load 31 36 284
railsbench 106 184 377
binarytrees 28 31 287
fannkuchredux 23 22 279
lee 28 28 286
nbody 22 22 279
optcarrot 77 78 335
30k_ifelse 64 63 349
30k_methods 53 56 317
cfunc_itself 22 22 279
fib 22 22 279
getivar 22 21 279
keyword_args 22 22 279
respond_to 22 22 279
setivar 22 22 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 128 10 121 10 179
hexapdf 10 10 10 10 10 10
jekyll 10 10 10 10 10 10
liquid-render 10 105 10 113 10 150
mail 10 119 10 123 10 132
psych-load 10 10 10 10 10 10
railsbench 10 10 10 10 10 10
binarytrees 10 44 10 69 10 60
fannkuchredux 10 10 10 10 10 10
lee 10 10 10 13 10 16
nbody 10 174 10 331 10 255
optcarrot 10 10 10 10 10 10
30k_ifelse 10 10 10 10 10 53
30k_methods 10 10 10 10 10 17
cfunc_itself 10 216 10 339 10 500
fib 10 94 10 308 10 375
getivar 10 220 10 211 10 530
keyword_args 10 75 10 98 10 426
respond_to 10 77 10 90 10 112
setivar 10 273 10 264 10 458

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) 1114010 867819 185 1165 0 0% 0 0 0
hexapdf (click) 975553 816566 602 7876 677 8% 0 0 320
jekyll (click) 1963354 1632021 336 3739 173 4% 0 0 0
liquid-render (click) 456276 373431 143 1263 94 7% 0 0 1
mail (click) 992410 766826 337 5214 129 2% 0 0 39
psych-load (click) 185002 149179 56 409 1 0% 0 0 0
railsbench (click) 2566513 1999576 1293 9587 262 2% 0 0 26
binarytrees (click) 112957 89432 9 49 0 0% 0 0 0
fannkuchredux (click) 129597 103451 6 203 0 0% 0 0 0
lee (click) 234922 181419 85 1091 114 10% 1 0 13
nbody (click) 122941 97556 8 149 0 0% 0 0 0
optcarrot (click) 459453 429726 196 3567 20 0% 0 0 0
30k_ifelse (click) 5561085 4890755 9261 57795 0 0% 0 0 0
30k_methods (click) 2118013 1816950 5780 19352 0 0% 0 0 0
cfunc_itself (click) 112381 88643 6 40 0 0% 0 0 0
fib (click) 110461 87838 6 29 0 0% 0 0 0
getivar (click) 112573 91057 6 56 0 0% 0 0 0
keyword_args (click) 112829 89021 7 42 0 0% 0 0 0
respond_to (click) 114173 89941 6 55 0 0% 0 0 0
setivar (click) 112253 88988 6 29 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.