YJIT Benchmarks

2022-08-12 20:14:50

As of 2022-08-12 20:14:50:

Overall YJIT is 35.1% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.2% 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 154.4 0.31% 157.6 0.29% 102.4 0.56% 0.98x 0.42% 1.51x 0.64% 85.96%
hexapdf 3207.5 1.12% 2391.7 2.07% 1.34x 2.35% 83.21%
liquid-render 195.3 2.42% 176.3 1.59% 126.6 1.85% 1.11x 2.89% 1.54x 3.04% 85.90%
mail 176.0 0.13% 172.3 1.60% 155.7 0.14% 1.02x 1.61% 1.13x 0.19% 99.27%
psych-load 2455.8 0.01% 2173.4 0.02% 1897.9 0.03% 1.13x 0.03% 1.29x 0.03% 88.89%
railsbench 2781.8 0.86% 2816.2 0.74% 2088.4 0.83% 0.99x 1.14% 1.33x 1.20% 86.54%
binarytrees 462.8 0.09% 311.5 0.33% 374.1 0.10% 1.49x 0.34% 1.24x 0.13% 84.27%
chunky_png 976.5 0.04% 786.0 0.41% 651.3 0.05% 1.24x 0.41% 1.50x 0.06% 99.95%
erubi 374.8 0.73% 341.2 0.60% 324.8 0.82% 1.10x 0.95% 1.15x 1.10% 100.00%
erubi_rails 26.7 2.66% 27.1 2.35% 19.4 3.51% 0.99x 3.55% 1.38x 4.40% 86.40%
fannkuchredux 5311.0 0.16% 2479.1 0.03% 2354.5 1.16% 2.14x 0.16% 2.26x 1.17% 77.42%
lee 1285.6 1.17% 1061.4 0.09% 972.2 0.08% 1.21x 1.17% 1.32x 1.17% 99.97%
nbody 138.1 0.11% 76.1 0.30% 94.9 0.11% 1.82x 0.31% 1.46x 0.16% 100.00%
optcarrot 6267.7 0.43% 2790.6 0.63% 3547.8 0.62% 2.25x 0.76% 1.77x 0.75% 96.16%
rubykon 12645.3 0.47% 8219.3 0.53% 6979.3 0.60% 1.54x 0.71% 1.81x 0.76% 99.74%
30k_ifelse 2395.4 0.02% 3542.4 3.76% 358.3 0.08% 0.68x 3.76% 6.69x 0.08% 100.00%
30k_methods 6542.7 0.03% 10181.7 14.44% 868.7 0.02% 0.64x 14.44% 7.53x 0.03% 100.00%
cfunc_itself 105.7 0.17% 70.1 0.39% 48.0 0.73% 1.51x 0.43% 2.20x 0.75% 100.00%
fib 235.0 0.04% 86.2 0.20% 63.4 0.07% 2.73x 0.21% 3.71x 0.08% 100.00%
getivar 106.9 0.57% 32.3 53.83% 44.2 0.11% 3.31x 53.83% 2.42x 0.58% 99.03%
keyword_args 293.8 0.10% 226.2 0.65% 55.6 0.14% 1.30x 0.66% 5.29x 0.17% 100.00%
respond_to 270.6 0.43% 230.4 0.75% 184.1 0.29% 1.17x 0.87% 1.47x 0.52% 100.00%
setivar 87.6 0.19% 20.2 61.36% 50.1 0.24% 4.34x 61.36% 1.75x 0.30% 99.17%
str_concat 84.7 1.08% 52.8 1.53% 44.8 1.32% 1.60x 1.87% 1.89x 1.71% 99.81%

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-08-12T14:52:48Z master 3a6405db1b) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-12T14:52:48Z master 3a6405db1b) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 65 76
hexapdf 275 421
liquid-render 31 35 37
mail 49 53 56
psych-load 36 42 38
railsbench 104 106 133
binarytrees 28 33 30
chunky_png 41 47 46
erubi 96 114 121
erubi_rails 102 103 122
fannkuchredux 24 27 27
lee 32 39 41
nbody 24 26 26
optcarrot 63 70 68
rubykon 53 60 56
30k_ifelse 66 163 122
30k_methods 58 180 79
cfunc_itself 24 27 26
fib 24 27 26
getivar 24 26 27
keyword_args 24 27 26
respond_to 24 27 27
setivar 24 26 27
str_concat 102 110 107

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 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 159 75 159 20 159
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 60 75 60 20 60
chunky_png 5 30 75 30 20 30
erubi 5 61 75 61 20 61
erubi_rails 5 1023 75 1023 20 1023
fannkuchredux 5 15 75 15 20 15
lee 5 20 75 20 20 20
nbody 5 263 75 263 20 263
optcarrot 5 15 75 15 20 15
rubykon 5 15 36 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 412 75 412 20 412
fib 5 315 75 315 20 315
getivar 5 617 75 617 20 617
keyword_args 5 361 75 361 20 361
respond_to 5 109 75 109 20 109
setivar 5 990 75 990 20 990
str_concat 5 442 75 442 20 442

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) 1034459 778497 131 1278 0 0% 0 0 0
hexapdf (click) 1150555 924143 683 8018 9 0% 0 0 0
liquid-render (click) 521435 405808 150 1700 2 0% 0 0 0
mail (click) 892955 645328 374 5272 17 0% 0 0 0
psych-load (click) 347355 263273 68 482 1 0% 0 0 0
railsbench (click) 2660827 1970139 1436 10052 16 0% 0 0 0
binarytrees (click) 171867 128248 13 58 0 0% 0 0 0
chunky_png (click) 384219 287705 88 987 0 0% 0 0 0
erubi (click) 322523 245796 10 79 0 0% 0 0 0
erubi_rails (click) 1963099 1429817 300 2031 4 0% 0 0 0
fannkuchredux (click) 185371 137720 10 196 0 0% 0 0 0
lee (click) 386139 291590 58 632 0 0% 0 0 0
nbody (click) 182043 137147 12 171 0 0% 0 0 0
optcarrot (click) 513435 442314 207 3588 20 0% 0 0 0
rubykon (click) 322075 257642 144 1581 1 0% 0 0 0
30k_ifelse (click) 5560923 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2175643 1656882 5784 19361 0 0% 0 0 0
cfunc_itself (click) 169947 126725 10 49 0 0% 0 0 0
fib (click) 168411 126333 10 38 0 0% 0 0 0
getivar (click) 170139 128420 10 65 0 0% 0 0 0
keyword_args (click) 170779 127366 11 51 0 0% 0 0 0
respond_to (click) 172059 128179 10 64 0 0% 0 0 0
setivar (click) 170075 127240 10 38 0 0% 0 0 0
str_concat (click) 170523 127868 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.