YJIT Benchmarks

2022-08-11 20:13:55

As of 2022-08-11 20:13:55:

Overall YJIT is 34.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.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 151.8 0.41% 154.5 0.77% 105.1 0.59% 0.98x 0.88% 1.44x 0.72% 85.96%
hexapdf 3185.3 0.84% 2395.8 2.16% 1.33x 2.32% 83.96%
liquid-render 196.1 1.01% 172.4 1.62% 125.0 1.88% 1.14x 1.91% 1.57x 2.13% 85.90%
mail 183.4 0.10% 173.3 1.97% 156.3 0.16% 1.06x 1.97% 1.17x 0.19% 99.35%
psych-load 2456.3 0.03% 2096.2 0.05% 1965.6 0.04% 1.17x 0.06% 1.25x 0.05% 88.89%
railsbench 2776.3 0.47% 2771.9 0.55% 2068.7 1.25% 1.00x 0.73% 1.34x 1.34% 86.38%
binarytrees 460.6 0.06% 326.7 2.31% 372.2 0.09% 1.41x 2.31% 1.24x 0.11% 84.27%
chunky_png 996.5 0.05% 782.5 0.05% 652.3 0.07% 1.27x 0.07% 1.53x 0.08% 99.95%
erubi 380.6 2.66% 344.2 0.81% 331.1 0.77% 1.11x 2.78% 1.15x 2.77% 100.00%
erubi_rails 27.1 2.48% 27.4 2.35% 19.5 3.48% 0.99x 3.41% 1.39x 4.27% 86.41%
fannkuchredux 5499.5 0.06% 2490.9 0.18% 2356.1 0.31% 2.21x 0.19% 2.33x 0.31% 77.42%
lee 1279.4 0.96% 1055.8 0.29% 1011.2 2.08% 1.21x 1.01% 1.27x 2.29% 99.97%
nbody 140.5 0.13% 76.0 0.22% 94.8 0.11% 1.85x 0.26% 1.48x 0.17% 100.00%
optcarrot 5992.3 0.45% 2823.4 0.57% 3555.4 0.54% 2.12x 0.73% 1.69x 0.70% 96.16%
rubykon 12676.3 0.74% 8333.4 0.99% 6944.0 0.35% 1.52x 1.24% 1.83x 0.82% 99.84%
30k_ifelse 2395.5 0.06% 3627.6 3.87% 361.4 0.08% 0.66x 3.87% 6.63x 0.10% 100.00%
30k_methods 6422.9 0.02% 9934.5 20.71% 874.8 0.02% 0.65x 20.71% 7.34x 0.02% 100.00%
cfunc_itself 111.7 0.30% 70.8 0.27% 46.5 0.66% 1.58x 0.40% 2.40x 0.72% 100.00%
fib 236.2 0.06% 86.2 0.20% 66.6 0.06% 2.74x 0.21% 3.55x 0.08% 100.00%
getivar 107.6 0.72% 32.2 53.77% 44.2 0.12% 3.34x 53.78% 2.43x 0.73% 99.03%
keyword_args 283.1 0.11% 224.8 0.65% 55.5 0.18% 1.26x 0.66% 5.10x 0.21% 100.00%
respond_to 268.0 0.50% 223.7 0.79% 180.7 0.29% 1.20x 0.94% 1.48x 0.58% 100.00%
setivar 83.4 0.25% 20.2 61.45% 49.7 0.09% 4.13x 61.45% 1.68x 0.27% 99.17%
str_concat 83.5 1.13% 53.7 1.33% 45.5 1.29% 1.55x 1.74% 1.83x 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-11T20:09:02Z master 5e3e4bc984) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-11T20:09:02Z master 5e3e4bc984) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 66 77
hexapdf 330 416
liquid-render 30 35 37
mail 49 53 56
psych-load 35 48 41
railsbench 104 106 133
binarytrees 28 32 30
chunky_png 42 44 48
erubi 103 120 115
erubi_rails 102 103 122
fannkuchredux 24 27 27
lee 32 38 41
nbody 24 26 26
optcarrot 63 70 70
rubykon 52 59 56
30k_ifelse 66 167 122
30k_methods 58 180 79
cfunc_itself 24 27 26
fib 24 27 26
getivar 24 26 27
keyword_args 24 27 27
respond_to 24 27 26
setivar 24 26 26
str_concat 75 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 192 75 192 20 192
hexapdf 5 15 20 15
liquid-render 5 156 75 156 20 156
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 63 75 63 20 63
erubi_rails 5 1039 75 1039 20 1039
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 30 22 20 22
cfunc_itself 5 414 75 414 20 414
fib 5 315 75 315 20 315
getivar 5 617 75 617 20 617
keyword_args 5 362 75 362 20 362
respond_to 5 109 75 109 20 109
setivar 5 991 75 991 20 991
str_concat 5 440 75 440 20 440

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) 1037019 780208 131 1281 0 0% 0 0 0
hexapdf (click) 1148507 922700 682 8017 9 0% 0 0 0
liquid-render (click) 519579 404458 150 1676 2 0% 0 0 0
mail (click) 911643 657942 374 5430 17 0% 0 0 0
psych-load (click) 347355 263483 68 480 1 0% 0 0 0
railsbench (click) 2657627 1968365 1436 10036 16 0% 0 0 0
binarytrees (click) 172187 128626 13 58 0 0% 0 0 0
chunky_png (click) 384923 287781 88 1004 0 0% 0 0 0
erubi (click) 323099 246292 10 79 0 0% 0 0 0
erubi_rails (click) 1961371 1429114 300 2026 4 0% 0 0 0
fannkuchredux (click) 186139 138394 10 196 0 0% 0 0 0
lee (click) 384091 290010 58 632 0 0% 0 0 0
nbody (click) 182811 137821 12 171 0 0% 0 0 0
optcarrot (click) 514203 442988 207 3588 20 0% 0 0 0
rubykon (click) 321755 257639 144 1576 1 0% 0 0 0
30k_ifelse (click) 5561243 4349094 9265 57804 0 0% 0 0 0
30k_methods (click) 2176411 1657556 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170715 127399 10 49 0 0% 0 0 0
fib (click) 169179 127007 10 38 0 0% 0 0 0
getivar (click) 170907 129094 10 65 0 0% 0 0 0
keyword_args (click) 171099 127744 11 51 0 0% 0 0 0
respond_to (click) 172827 128853 10 64 0 0% 0 0 0
setivar (click) 170843 127914 10 38 0 0% 0 0 0
str_concat (click) 170843 128246 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.