YJIT Benchmarks

2022-08-06 05:13:41

As of 2022-08-06 05:13:41:

Overall YJIT is 34.2% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 36.0% 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.2 0.53% 154.0 1.01% 111.2 0.47% 0.98x 1.14% 1.36x 0.71% 85.93%
hexapdf 3212.0 1.08% 2417.5 3.02% 1.33x 3.21% 83.64%
liquid-render 198.1 1.39% 171.2 1.54% 126.0 1.80% 1.16x 2.07% 1.57x 2.27% 85.90%
mail 178.8 0.21% 174.2 2.36% 155.2 0.14% 1.03x 2.37% 1.15x 0.25% 99.34%
psych-load 2521.5 0.02% 2133.5 0.02% 1917.1 0.01% 1.18x 0.03% 1.32x 0.03% 88.89%
railsbench 2822.0 0.53% 2841.6 0.59% 2074.4 1.18% 0.99x 0.79% 1.36x 1.29% 86.38%
binarytrees 475.1 0.06% 305.7 0.34% 366.5 0.05% 1.55x 0.35% 1.30x 0.08% 84.27%
chunky_png 998.8 0.04% 775.2 0.06% 644.9 0.05% 1.29x 0.07% 1.55x 0.06% 99.95%
erubi 373.4 0.57% 340.8 0.68% 325.3 0.60% 1.10x 0.89% 1.15x 0.82% 100.00%
erubi_rails 27.0 2.70% 27.2 2.65% 19.6 3.49% 1.00x 3.78% 1.38x 4.41% 86.39%
fannkuchredux 7081.7 0.15% 4083.3 0.18% 7020.4 0.43% 1.73x 0.23% 1.01x 0.45% 0.02%
lee 1261.6 0.22% 1042.4 1.20% 932.1 1.17% 1.21x 1.22% 1.35x 1.19% 99.97%
nbody 129.0 0.69% 76.4 0.23% 90.8 0.09% 1.69x 0.72% 1.42x 0.69% 100.00%
optcarrot 6411.0 0.42% 2795.0 0.60% 3445.1 0.60% 2.29x 0.73% 1.86x 0.73% 96.16%
rubykon 12625.6 0.45% 7990.5 1.06% 6856.0 0.48% 1.58x 1.15% 1.84x 0.66% 99.75%
30k_ifelse 2335.8 0.01% 3468.1 3.88% 355.3 0.09% 0.67x 3.88% 6.57x 0.09% 100.00%
30k_methods 6542.7 0.00% 9841.4 20.02% 874.1 0.02% 0.66x 20.02% 7.49x 0.02% 100.00%
cfunc_itself 117.1 0.15% 70.6 1.17% 45.7 0.68% 1.66x 1.18% 2.56x 0.69% 100.00%
fib 259.4 0.14% 86.2 0.21% 63.3 0.05% 3.01x 0.25% 4.10x 0.15% 100.00%
getivar 105.9 0.49% 32.9 56.94% 44.2 0.08% 3.22x 56.95% 2.39x 0.50% 99.02%
keyword_args 291.9 0.11% 222.8 1.16% 52.6 0.33% 1.31x 1.17% 5.54x 0.35% 100.00%
respond_to 272.7 0.14% 227.8 0.40% 194.0 0.29% 1.20x 0.42% 1.41x 0.32% 100.00%
setivar 76.5 0.36% 20.9 63.06% 50.1 0.30% 3.66x 63.06% 1.53x 0.46% 99.14%
str_concat 84.6 0.79% 49.7 1.64% 43.4 1.54% 1.70x 1.82% 1.95x 1.73% 99.97%

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-06T01:52:00Z master 27173e3735) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-06T01:52:00Z master 27173e3735) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 308 387
liquid-render 31 35 37
mail 49 53 56
psych-load 36 45 42
railsbench 104 105 133
binarytrees 30 33 33
chunky_png 43 46 48
erubi 70 106 103
erubi_rails 102 103 122
fannkuchredux 25 27 27
lee 32 40 39
nbody 24 26 27
optcarrot 58 66 65
rubykon 52 60 57
30k_ifelse 68 165 127
30k_methods 57 176 75
cfunc_itself 24 27 27
fib 25 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 99 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 158 75 158 20 158
mail 5 130 75 130 20 130
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 65 75 65 20 65
chunky_png 5 30 75 30 20 30
erubi 5 62 75 62 20 62
erubi_rails 5 1028 75 1028 20 1028
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 261 75 261 20 261
optcarrot 5 15 75 15 20 15
rubykon 5 15 36 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 23 30 23 20 23
cfunc_itself 5 442 75 442 20 442
fib 5 315 75 315 20 315
getivar 5 613 75 613 20 613
keyword_args 5 381 75 381 20 381
respond_to 5 107 75 107 20 107
setivar 5 956 75 956 20 956
str_concat 5 462 75 462 20 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) 1034843 778538 131 1279 0 0% 0 0 0
hexapdf (click) 1149339 923452 682 8015 10 0% 0 0 0
liquid-render (click) 519963 403882 150 1676 2 0% 0 0 0
mail (click) 929051 669148 374 5616 17 0% 0 0 0
psych-load (click) 346459 262673 68 480 1 0% 0 0 0
railsbench (click) 2662235 1971294 1436 10078 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 384923 287966 88 989 0 0% 0 0 0
erubi (click) 322907 245939 10 79 0 0% 0 0 0
erubi_rails (click) 1961371 1428846 300 2025 4 0% 0 0 0
fannkuchredux (click) 185307 138082 10 188 0 0% 0 0 0
lee (click) 385179 290709 58 632 0 0% 0 0 0
nbody (click) 182555 137443 12 171 0 0% 0 0 0
optcarrot (click) 513499 442314 207 3588 20 0% 0 0 0
rubykon (click) 321691 257398 144 1577 1 0% 0 0 0
30k_ifelse (click) 5560987 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2175707 1656882 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170459 127021 10 49 0 0% 0 0 0
fib (click) 168923 126629 10 38 0 0% 0 0 0
getivar (click) 170651 128716 10 65 0 0% 0 0 0
keyword_args (click) 171291 127662 11 51 0 0% 0 0 0
respond_to (click) 172571 128475 10 64 0 0% 0 0 0
setivar (click) 170139 127240 10 38 0 0% 0 0 0
str_concat (click) 170139 127572 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.