YJIT Benchmarks

2022-08-01 20:14:50

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

Overall YJIT is 35.6% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.3% 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 MJIT3.1 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 MJIT3.1 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 MJIT3.1 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 MJIT3.1 (ms) MJIT3.1 RSD YJIT (ms) YJIT RSD MJIT3.1 spd MJIT3.1 spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 150.7 0.35% 154.1 0.31% 102.5 0.54% 0.98x 0.47% 1.47x 0.65% 85.94%
hexapdf 3128.7 0.91% 2293.4 1.86% 1.36x 2.07% 83.70%
liquid-render 197.0 1.77% 168.9 1.72% 126.0 1.79% 1.17x 2.47% 1.56x 2.52% 85.90%
mail 179.2 0.12% 175.5 1.81% 157.6 0.17% 1.02x 1.81% 1.14x 0.21% 99.34%
psych-load 2486.3 0.09% 2186.8 0.03% 1914.4 0.03% 1.14x 0.10% 1.30x 0.10% 88.89%
railsbench 2799.3 0.57% 2801.8 0.82% 2084.4 1.25% 1.00x 1.00% 1.34x 1.38% 86.54%
binarytrees 468.1 0.25% 307.2 0.33% 361.2 0.05% 1.52x 0.41% 1.30x 0.26% 84.27%
chunky_png 966.4 0.08% 769.9 0.39% 636.1 0.05% 1.26x 0.40% 1.52x 0.10% 99.95%
erubi 370.9 0.59% 344.7 0.59% 323.7 0.63% 1.08x 0.84% 1.15x 0.86% 100.00%
erubi_rails 26.7 2.67% 27.2 2.54% 19.2 3.55% 0.98x 3.68% 1.39x 4.44% 86.40%
fannkuchredux 6911.0 0.17% 3960.4 0.07% 6925.2 0.38% 1.75x 0.19% 1.00x 0.42% 0.02%
lee 1271.1 0.34% 1049.0 0.39% 946.5 1.11% 1.21x 0.52% 1.34x 1.16% 99.97%
nbody 124.0 0.08% 76.4 0.23% 89.4 0.08% 1.62x 0.24% 1.39x 0.11% 100.00%
optcarrot 6142.8 0.45% 2764.8 0.62% 3415.3 0.62% 2.22x 0.77% 1.80x 0.77% 96.16%
rubykon 12600.7 0.48% 8030.6 0.80% 6805.6 0.52% 1.57x 0.93% 1.85x 0.71% 99.74%
30k_ifelse 2337.5 0.01% 3657.3 3.63% 357.0 0.07% 0.64x 3.63% 6.55x 0.07% 100.00%
30k_methods 6516.9 0.02% 9741.2 19.01% 873.2 0.02% 0.67x 19.01% 7.46x 0.03% 100.00%
cfunc_itself 105.2 0.47% 68.0 0.47% 45.0 0.81% 1.55x 0.67% 2.34x 0.93% 100.00%
fib 255.8 0.08% 86.2 0.21% 63.3 0.04% 2.97x 0.22% 4.04x 0.09% 100.00%
getivar 113.1 0.57% 32.6 56.45% 44.2 0.10% 3.47x 56.46% 2.56x 0.58% 99.02%
keyword_args 284.9 0.07% 224.5 0.59% 52.8 0.39% 1.27x 0.59% 5.40x 0.39% 100.00%
respond_to 279.1 0.11% 236.9 0.41% 197.2 0.08% 1.18x 0.42% 1.42x 0.14% 100.00%
setivar 76.2 0.22% 20.9 62.92% 40.4 0.36% 3.65x 62.92% 1.88x 0.43% 99.14%
str_concat 85.2 0.94% 51.0 1.50% 43.6 1.56% 1.67x 1.77% 1.96x 1.82% 99.69%

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 it 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.
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-01T19:14:48Z master 24204d54ab) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-01T19:14:48Z master 24204d54ab) +MJIT [x86_64-linux]
(We got much better MJIT results with released than prerelease, so we used those.)

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT3.1 mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 297 392
liquid-render 31 35 37
mail 49 53 56
psych-load 36 45 41
railsbench 104 107 133
binarytrees 31 33 33
chunky_png 44 50 49
erubi 73 100 94
erubi_rails 103 103 123
fannkuchredux 25 27 27
lee 32 40 39
nbody 24 26 27
optcarrot 59 66 65
rubykon 52 59 57
30k_ifelse 68 173 127
30k_methods 57 176 76
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 25 27 27
setivar 25 26 27
str_concat 122 124 101

Memory is shown in mebibytes (1024 * 1024 bytes.)

By default, YJIT allocates an additional 256MiB for generated code. The additional size allocated can be tuned with a command-line parameter, but allocating too little memory will result in YJIT no longer JITting new functions, so performance reverts toward interpreter speeds.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT3.1 warmups MJIT3.1 iters YJIT warmups YJIT iters
activerecord 5 191 75 191 20 191
hexapdf 5 15 20 15
liquid-render 5 159 75 159 20 159
mail 5 126 75 126 20 126
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 31 75 31 20 31
erubi 5 62 75 62 20 62
erubi_rails 5 1017 75 1017 20 1017
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 37 15 20 15
30k_ifelse 5 56 75 56 20 56
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 611 75 611 20 611
keyword_args 5 377 75 377 20 377
respond_to 5 101 75 101 20 101
setivar 5 960 75 960 20 960
str_concat 5 449 75 449 20 449

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) 1037467 780804 131 1284 0 0% 0 0 0
hexapdf (click) 1151899 925996 682 8021 9 0% 0 0 0
liquid-render (click) 519451 404872 150 1680 2 0% 0 0 0
mail (click) 944859 680445 374 5775 17 0% 0 0 0
psych-load (click) 347739 263625 68 480 1 0% 0 0 0
railsbench (click) 2656667 1968397 1436 10022 16 0% 0 0 0
binarytrees (click) 172187 128374 13 58 0 0% 0 0 0
chunky_png (click) 391131 291740 88 1037 0 0% 0 0 0
erubi (click) 323611 246759 10 79 0 0% 0 0 0
erubi_rails (click) 1964059 1431442 300 2037 4 0% 0 0 0
fannkuchredux (click) 186011 138504 10 188 0 0% 0 0 0
lee (click) 386779 292260 58 632 0 0% 0 0 0
nbody (click) 182811 137569 12 171 0 0% 0 0 0
optcarrot (click) 514203 442736 207 3588 20 0% 0 0 0
rubykon (click) 321499 257101 144 1575 2 0% 0 0 0
30k_ifelse (click) 5560795 4348546 9265 57804 0 0% 0 0 0
30k_methods (click) 2176411 1657304 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170715 127147 10 49 0 0% 0 0 0
fib (click) 169179 126755 10 38 0 0% 0 0 0
getivar (click) 170907 128842 10 65 0 0% 0 0 0
keyword_args (click) 171547 127788 11 51 0 0% 0 0 0
respond_to (click) 172827 128601 10 64 0 0% 0 0 0
setivar (click) 170843 127662 10 38 0 0% 0 0 0
str_concat (click) 170843 128069 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.