YJIT Benchmarks

2022-08-14 05:13:56

As of 2022-08-14 05:13:56:

Overall YJIT is 31.6% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 35.9% 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.7 0.40% 157.3 0.32% 105.6 0.66% 0.98x 0.52% 1.46x 0.77% 85.96%
hexapdf 3211.1 0.86% 2383.5 4.10% 1.35x 4.19% 82.95%
liquid-render 196.8 2.17% 170.5 1.64% 136.5 1.69% 1.15x 2.72% 1.44x 2.74% 85.90%
mail 174.9 0.28% 173.1 1.67% 158.1 0.13% 1.01x 1.69% 1.11x 0.31% 99.36%
psych-load 2424.9 0.02% 2129.0 0.19% 1991.5 0.01% 1.14x 0.19% 1.22x 0.02% 88.89%
railsbench 2822.0 1.16% 2833.1 0.51% 2077.1 1.45% 1.00x 1.27% 1.36x 1.86% 86.54%
binarytrees 462.1 0.10% 328.9 0.34% 374.9 0.07% 1.40x 0.35% 1.23x 0.12% 84.27%
chunky_png 975.1 0.05% 775.9 0.03% 652.8 0.05% 1.26x 0.06% 1.49x 0.07% 99.95%
erubi 369.6 0.51% 341.8 0.79% 320.8 0.63% 1.08x 0.93% 1.15x 0.81% 100.00%
erubi_rails 27.6 2.61% 27.5 2.32% 19.5 3.45% 1.00x 3.50% 1.41x 4.33% 86.41%
fannkuchredux 5274.8 0.37% 2492.8 0.04% 2349.7 0.29% 2.12x 0.37% 2.24x 0.47% 77.42%
lee 1278.4 0.93% 1073.3 1.79% 971.6 0.06% 1.19x 2.02% 1.32x 0.93% 99.97%
nbody 137.2 0.08% 75.9 0.23% 95.3 0.07% 1.81x 0.24% 1.44x 0.11% 100.00%
optcarrot 6347.0 0.43% 2775.6 0.62% 3535.5 0.60% 2.29x 0.75% 1.80x 0.74% 96.16%
rubykon 12705.7 0.52% 8481.1 0.71% 6999.0 0.57% 1.50x 0.88% 1.82x 0.77% 99.84%
30k_ifelse 2434.0 0.06% 3815.0 3.88% 360.1 0.09% 0.64x 3.88% 6.76x 0.10% 100.00%
30k_methods 6419.5 0.13% 10061.5 19.67% 873.7 0.02% 0.64x 19.67% 7.35x 0.14% 100.00%
cfunc_itself 105.0 0.24% 70.3 0.33% 46.6 0.65% 1.49x 0.41% 2.25x 0.69% 100.00%
fib 234.3 0.06% 86.2 0.23% 63.4 0.07% 2.72x 0.23% 3.70x 0.09% 100.00%
getivar 107.6 0.50% 32.3 53.89% 44.2 0.11% 3.33x 53.90% 2.43x 0.51% 99.03%
keyword_args 285.0 0.09% 236.2 0.77% 54.2 0.13% 1.21x 0.77% 5.26x 0.16% 100.00%
respond_to 278.4 0.44% 226.8 0.50% 186.0 0.16% 1.23x 0.67% 1.50x 0.46% 100.00%
setivar 83.4 0.24% 20.1 60.96% 49.7 0.11% 4.14x 60.96% 1.68x 0.26% 99.17%
str_concat 89.0 1.01% 52.9 1.34% 44.8 1.57% 1.68x 1.68% 1.99x 1.87% 99.87%

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-13T02:23:47Z master 0617cba197) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-13T02:23:47Z master 0617cba197) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 77
hexapdf 280 387
liquid-render 30 35 37
mail 49 54 57
psych-load 36 46 39
railsbench 104 106 131
binarytrees 28 32 30
chunky_png 41 43 46
erubi 73 78 95
erubi_rails 102 103 122
fannkuchredux 24 27 26
lee 32 41 40
nbody 24 26 27
optcarrot 63 70 69
rubykon 53 60 57
30k_ifelse 66 173 122
30k_methods 58 180 79
cfunc_itself 24 27 26
fib 24 26 26
getivar 24 26 27
keyword_args 24 27 27
respond_to 24 27 26
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 189 75 189 20 189
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 61 75 61 20 61
chunky_png 5 30 75 30 20 30
erubi 5 60 75 60 20 60
erubi_rails 5 1035 75 1035 20 1035
fannkuchredux 5 15 75 15 20 15
lee 5 20 75 20 20 20
nbody 5 259 75 259 20 259
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 22 29 22 20 22
cfunc_itself 5 429 75 429 20 429
fib 5 315 75 315 20 315
getivar 5 620 75 620 20 620
keyword_args 5 369 75 369 20 369
respond_to 5 109 75 109 20 109
setivar 5 988 75 988 20 988
str_concat 5 445 75 445 20 445

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) 1036059 779334 131 1274 0 0% 0 0 0
hexapdf (click) 1149147 923042 682 8005 9 0% 0 0 0
liquid-render (click) 515547 401345 150 1682 2 0% 0 0 0
mail (click) 906779 654261 375 5413 17 0% 0 0 0
psych-load (click) 347035 263105 68 480 1 0% 0 0 0
railsbench (click) 2659355 1968716 1436 10053 16 0% 0 0 0
binarytrees (click) 171867 128248 13 58 0 0% 0 0 0
chunky_png (click) 387355 289626 88 1011 0 0% 0 0 0
erubi (click) 322779 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1962971 1429912 300 2044 4 0% 0 0 0
fannkuchredux (click) 185819 138016 10 196 0 0% 0 0 0
lee (click) 384987 290734 58 632 0 0% 0 0 0
nbody (click) 182491 137443 12 171 0 0% 0 0 0
optcarrot (click) 513883 442610 207 3588 20 0% 0 0 0
rubykon (click) 321051 256898 144 1574 1 0% 0 0 0
30k_ifelse (click) 5560923 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2176091 1657178 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170395 127021 10 49 0 0% 0 0 0
fib (click) 168859 126629 10 38 0 0% 0 0 0
getivar (click) 170587 128716 10 65 0 0% 0 0 0
keyword_args (click) 171227 127662 11 51 0 0% 0 0 0
respond_to (click) 172507 128475 10 64 0 0% 0 0 0
setivar (click) 170523 127536 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.