YJIT Benchmarks

2022-08-15 20:14:29

As of 2022-08-15 20:14:29:

Overall YJIT is 34.4% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.5% 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 152.1 0.41% 154.4 0.36% 102.3 0.55% 0.99x 0.54% 1.49x 0.69% 85.96%
hexapdf 3159.8 0.90% 2410.1 2.03% 1.31x 2.22% 82.65%
liquid-render 196.4 1.00% 169.9 1.67% 126.7 1.82% 1.16x 1.95% 1.55x 2.08% 85.90%
mail 176.1 0.15% 172.1 1.77% 155.3 0.18% 1.02x 1.77% 1.13x 0.23% 99.34%
psych-load 2439.3 0.06% 2117.1 0.03% 1895.8 0.02% 1.15x 0.07% 1.29x 0.06% 88.89%
railsbench 2828.3 0.50% 2909.7 0.58% 2118.9 1.16% 0.97x 0.77% 1.33x 1.27% 86.38%
binarytrees 463.0 0.09% 327.2 1.55% 373.1 0.06% 1.42x 1.56% 1.24x 0.10% 84.27%
chunky_png 964.8 0.04% 783.4 0.36% 653.8 0.06% 1.23x 0.36% 1.48x 0.07% 99.95%
erubi 377.6 1.91% 344.3 0.63% 326.1 0.70% 1.10x 2.01% 1.16x 2.03% 100.00%
erubi_rails 26.8 2.69% 27.2 2.99% 19.3 3.63% 0.99x 4.02% 1.39x 4.51% 86.41%
fannkuchredux 5280.1 0.16% 2489.9 0.24% 2350.6 0.24% 2.12x 0.28% 2.25x 0.28% 77.42%
lee 1291.1 1.32% 1082.4 2.17% 985.1 1.76% 1.19x 2.54% 1.31x 2.20% 99.97%
nbody 138.6 0.11% 75.9 0.24% 94.9 0.10% 1.83x 0.27% 1.46x 0.15% 100.00%
optcarrot 6389.2 0.42% 2775.3 0.61% 3590.1 0.57% 2.30x 0.74% 1.78x 0.71% 96.16%
rubykon 12601.6 0.40% 8616.1 0.89% 6984.4 0.52% 1.46x 0.98% 1.80x 0.65% 99.62%
30k_ifelse 2360.2 0.01% 3557.9 3.93% 355.4 0.08% 0.66x 3.93% 6.64x 0.08% 100.00%
30k_methods 6440.6 0.13% 9985.6 19.73% 869.2 0.02% 0.64x 19.73% 7.41x 0.13% 100.00%
cfunc_itself 105.0 0.25% 71.1 0.89% 46.5 0.59% 1.48x 0.92% 2.26x 0.64% 100.00%
fib 233.7 0.08% 86.2 0.20% 63.4 0.08% 2.71x 0.21% 3.69x 0.11% 100.00%
getivar 107.1 0.57% 32.3 54.32% 44.2 0.12% 3.32x 54.33% 2.42x 0.58% 99.03%
keyword_args 284.4 0.10% 226.4 0.44% 54.2 0.14% 1.26x 0.45% 5.24x 0.17% 100.00%
respond_to 272.8 0.35% 232.6 0.52% 184.2 0.75% 1.17x 0.63% 1.48x 0.83% 100.00%
setivar 83.5 0.27% 20.2 61.07% 49.7 0.09% 4.14x 61.07% 1.68x 0.28% 99.17%
str_concat 83.4 1.10% 53.1 1.24% 44.2 1.51% 1.57x 1.66% 1.89x 1.86% 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-08-15T17:48:04Z master 4e66b3f47b) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-15T17:48:04Z master 4e66b3f47b) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 66 76
hexapdf 262 413
liquid-render 30 35 37
mail 49 53 56
psych-load 35 45 39
railsbench 104 106 133
binarytrees 28 32 30
chunky_png 40 47 50
erubi 96 121 117
erubi_rails 103 105 122
fannkuchredux 24 27 26
lee 34 42 41
nbody 24 26 26
optcarrot 63 70 68
rubykon 53 60 57
30k_ifelse 66 164 122
30k_methods 58 184 79
cfunc_itself 24 27 26
fib 24 27 27
getivar 24 26 27
keyword_args 24 27 26
respond_to 24 27 26
setivar 24 26 27
str_concat 102 110 102

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 155 75 155 20 155
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 62 75 62 20 62
erubi_rails 5 1027 75 1027 20 1027
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 35 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 30 22 20 22
cfunc_itself 5 430 75 430 20 430
fib 5 315 75 315 20 315
getivar 5 619 75 619 20 619
keyword_args 5 366 75 366 20 366
respond_to 5 108 75 108 20 108
setivar 5 992 75 992 20 992
str_concat 5 446 75 446 20 446

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) 1034203 778077 131 1272 0 0% 0 0 0
hexapdf (click) 1153051 926153 682 8051 9 0% 0 0 0
liquid-render (click) 518747 403859 150 1681 2 0% 0 0 0
mail (click) 910619 657066 374 5422 17 0% 0 0 0
psych-load (click) 347227 263298 68 482 1 0% 0 0 0
railsbench (click) 2652059 1964429 1436 9985 16 0% 0 0 0
binarytrees (click) 171675 127963 13 58 0 0% 0 0 0
chunky_png (click) 384475 287599 88 991 0 0% 0 0 0
erubi (click) 322779 245939 10 79 0 0% 0 0 0
erubi_rails (click) 1960155 1427822 300 2026 4 0% 0 0 0
fannkuchredux (click) 185819 138016 10 196 0 0% 0 0 0
lee (click) 386075 291590 58 632 0 0% 0 0 0
nbody (click) 182043 137147 12 171 0 0% 0 0 0
optcarrot (click) 513883 442610 207 3588 20 0% 0 0 0
rubykon (click) 320859 256644 144 1575 1 0% 0 0 0
30k_ifelse (click) 5560475 4348420 9265 57804 0 0% 0 0 0
30k_methods (click) 2175643 1656882 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) 170075 127240 10 38 0 0% 0 0 0
str_concat (click) 170075 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.