YJIT Benchmarks

2022-09-15 05:36:19

As of 2022-09-15 05:36:19:

Overall YJIT is 36.1% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.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 1.6 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 2.0 4.0 6.0 8.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 151.3 0.53% 177.7 4.37% 103.3 0.61% 0.85x 4.40% 1.47x 0.81% 85.28%
hexapdf 3158.3 1.39% 2297.7 2.42% 1.37x 2.79% 83.92%
liquid-render 191.1 0.96% 169.4 1.20% 112.3 1.88% 1.13x 1.54% 1.70x 2.11% 85.97%
mail 176.0 0.14% 175.3 2.38% 156.1 0.31% 1.00x 2.38% 1.13x 0.34% 99.33%
psych-load 2414.7 0.03% 2111.5 0.01% 1954.4 0.03% 1.14x 0.03% 1.24x 0.04% 88.89%
railsbench 2747.4 0.60% 3025.1 0.14% 2064.0 0.67% 0.91x 0.61% 1.33x 0.89% 86.28%
binarytrees 477.5 0.03% 311.0 0.04% 364.2 0.04% 1.54x 0.05% 1.31x 0.05% 84.57%
chunky_png 968.9 0.04% 780.6 0.04% 655.0 0.20% 1.24x 0.06% 1.48x 0.21% 99.95%
erubi 341.1 0.66% 321.9 3.00% 298.4 0.77% 1.06x 3.08% 1.14x 1.01% 100.00%
erubi_rails 26.1 2.61% 28.1 9.53% 19.2 3.68% 0.93x 9.88% 1.36x 4.51% 86.35%
fannkuchredux 5356.2 0.65% 5378.0 0.05% 2376.3 0.06% 1.00x 0.65% 2.25x 0.65% 77.42%
lee 1231.6 0.76% 1069.3 0.14% 952.1 0.96% 1.15x 0.77% 1.29x 1.22% 99.97%
nbody 119.5 0.30% 75.1 0.04% 91.1 0.12% 1.59x 0.30% 1.31x 0.33% 100.00%
optcarrot 6092.2 0.43% 2681.3 0.65% 3523.3 0.62% 2.27x 0.78% 1.73x 0.76% 96.16%
rubykon 12377.8 0.48% 9023.1 1.22% 6782.7 0.55% 1.37x 1.31% 1.82x 0.73% 99.81%
30k_ifelse 2369.3 0.01% 4221.1 2.99% 360.9 0.10% 0.56x 2.99% 6.56x 0.10% 100.00%
30k_methods 6632.0 0.01% 12985.8 4.02% 786.8 0.02% 0.51x 4.02% 8.43x 0.02% 100.00%
cfunc_itself 109.2 0.18% 98.8 0.21% 46.8 0.75% 1.11x 0.28% 2.33x 0.77% 100.00%
fib 253.0 0.06% 79.2 0.05% 62.9 0.04% 3.19x 0.08% 4.02x 0.07% 100.00%
getivar 105.6 1.98% 105.3 0.12% 42.7 0.05% 1.00x 1.99% 2.47x 1.98% 98.73%
keyword_args 285.5 0.07% 229.4 0.03% 53.8 0.17% 1.24x 0.08% 5.30x 0.18% 100.00%
respond_to 278.5 0.05% 258.2 0.81% 30.0 0.28% 1.08x 0.81% 9.29x 0.28% 100.00%
setivar 79.5 0.27% 75.7 0.16% 45.9 0.59% 1.05x 0.31% 1.73x 0.64% 98.12%
str_concat 85.8 1.04% 54.5 8.01% 47.0 1.22% 1.58x 8.07% 1.83x 1.60% 99.86%

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-09-15T03:50:48Z master 6b2b9e0019) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-15T03:50:48Z master 6b2b9e0019) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 72 76
hexapdf 239 393
liquid-render 31 34 38
mail 49 54 57
psych-load 36 44 41
railsbench 102 122 131
binarytrees 30 32 33
chunky_png 38 46 43
erubi 66 116 106
erubi_rails 101 105 124
fannkuchredux 24 26 27
lee 35 39 40
nbody 24 26 27
optcarrot 63 70 70
rubykon 51 63 55
30k_ifelse 67 146 124
30k_methods 57 171 75
cfunc_itself 24 26 27
fib 24 26 27
getivar 25 25 27
keyword_args 24 26 27
respond_to 24 25 27
setivar 24 26 27
str_concat 113 111 100

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 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 161 75 161 20 161
mail 5 124 75 124 20 124
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 64 75 64 20 64
chunky_png 5 30 75 30 20 30
erubi 5 67 75 67 20 67
erubi_rails 5 1043 75 1043 20 1043
fannkuchredux 5 15 56 15 20 15
lee 5 21 75 21 20 21
nbody 5 266 75 266 20 266
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 55 70 55 20 55
30k_methods 5 25 23 25 20 25
cfunc_itself 5 442 75 442 20 442
fib 5 318 75 318 20 318
getivar 5 467 75 467 20 467
keyword_args 5 372 75 372 20 372
respond_to 5 107 75 107 20 107
setivar 5 427 75 427 20 427
str_concat 5 430 75 430 20 430

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) 1065591 775920 131 1280 0 0% 0 0 0
hexapdf (click) 1175991 917360 682 8046 9 0% 0 0 0
liquid-render (click) 526903 399532 150 1699 2 0% 0 0 0
mail (click) 952119 663593 374 5643 17 0% 0 0 0
psych-load (click) 353847 259566 68 472 1 0% 0 0 0
railsbench (click) 2722231 1956456 1436 10056 16 0% 0 0 0
binarytrees (click) 175799 126856 13 60 0 0% 0 0 0
chunky_png (click) 396471 286843 88 991 0 0% 0 0 0
erubi (click) 342583 251676 10 79 0 0% 0 0 0
erubi_rails (click) 2014199 1421770 300 2040 4 0% 0 0 0
fannkuchredux (click) 189879 136594 10 196 0 0% 0 0 0
lee (click) 396535 288648 58 634 0 0% 0 0 0
nbody (click) 186999 136021 12 171 0 0% 0 0 0
optcarrot (click) 531767 441262 207 3592 20 0% 0 0 0
rubykon (click) 329527 255374 144 1576 1 0% 0 0 0
30k_ifelse (click) 5664183 4347244 9265 57804 0 0% 0 0 0
30k_methods (click) 2208439 1655706 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174327 125549 10 49 0 0% 0 0 0
fib (click) 172663 125157 10 38 0 0% 0 0 0
getivar (click) 174071 126984 10 65 0 0% 0 0 0
keyword_args (click) 175031 126190 11 51 0 0% 0 0 0
respond_to (click) 174647 126813 10 64 0 0% 0 0 0
setivar (click) 174455 126114 10 38 0 0% 0 0 0
str_concat (click) 174327 126396 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.