YJIT Benchmarks

2022-08-08 20:14:01

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

Overall YJIT is 35.0% 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 152.3 0.84% 154.4 0.75% 106.5 0.52% 0.99x 1.12% 1.43x 0.99% 85.93%
hexapdf 3223.6 0.65% 2361.9 2.83% 1.36x 2.90% 82.63%
liquid-render 197.0 0.99% 168.9 1.64% 126.8 1.82% 1.17x 1.91% 1.55x 2.07% 85.90%
mail 179.3 0.15% 174.3 2.25% 154.6 0.16% 1.03x 2.26% 1.16x 0.22% 99.36%
psych-load 2483.2 0.03% 2122.4 0.02% 1956.6 0.05% 1.17x 0.04% 1.27x 0.06% 88.89%
railsbench 2824.8 0.52% 2799.4 0.45% 2078.5 0.77% 1.01x 0.68% 1.36x 0.92% 86.54%
binarytrees 478.9 0.05% 308.9 0.34% 367.3 0.05% 1.55x 0.34% 1.30x 0.07% 84.27%
chunky_png 984.2 0.18% 795.0 0.04% 643.5 0.05% 1.24x 0.18% 1.53x 0.18% 99.95%
erubi 373.5 0.60% 341.7 0.62% 323.7 0.64% 1.09x 0.86% 1.15x 0.88% 100.00%
erubi_rails 27.4 2.50% 27.3 2.67% 19.4 3.76% 1.00x 3.66% 1.41x 4.52% 86.40%
fannkuchredux 6922.9 0.18% 3958.3 0.07% 6920.4 0.22% 1.75x 0.20% 1.00x 0.28% 0.02%
lee 1254.0 0.36% 1039.2 0.36% 930.1 0.62% 1.21x 0.51% 1.35x 0.71% 99.97%
nbody 128.0 0.35% 76.3 0.23% 91.2 0.08% 1.68x 0.41% 1.40x 0.36% 100.00%
optcarrot 6348.6 0.43% 2797.7 0.63% 3473.4 0.60% 2.27x 0.76% 1.83x 0.73% 96.16%
rubykon 12480.4 0.51% 8230.6 0.72% 6822.6 0.63% 1.52x 0.88% 1.83x 0.82% 99.69%
30k_ifelse 2300.2 0.01% 3802.4 4.22% 357.1 0.09% 0.60x 4.22% 6.44x 0.09% 100.00%
30k_methods 6500.4 0.02% 10177.8 19.58% 873.3 0.02% 0.64x 19.58% 7.44x 0.03% 100.00%
cfunc_itself 111.1 0.16% 68.6 0.61% 46.4 0.73% 1.62x 0.63% 2.40x 0.74% 100.00%
fib 265.4 0.09% 86.2 0.22% 63.4 0.10% 3.08x 0.24% 4.19x 0.14% 100.00%
getivar 109.7 0.81% 32.7 57.20% 44.2 0.10% 3.35x 57.21% 2.48x 0.81% 99.02%
keyword_args 288.3 0.08% 228.9 1.08% 52.7 0.30% 1.26x 1.08% 5.47x 0.31% 100.00%
respond_to 273.1 0.13% 234.5 1.12% 187.4 0.11% 1.16x 1.13% 1.46x 0.17% 100.00%
setivar 76.7 0.23% 20.9 63.12% 49.7 0.12% 3.68x 63.12% 1.54x 0.26% 99.14%
str_concat 83.7 1.11% 49.5 1.48% 42.9 2.02% 1.69x 1.85% 1.95x 2.30% 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 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-08T19:35:33Z master 35b9cd1def) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-08T19:35:33Z master 35b9cd1def) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 266 390
liquid-render 30 35 37
mail 49 53 57
psych-load 37 46 41
railsbench 104 106 133
binarytrees 31 33 33
chunky_png 44 46 48
erubi 81 82 95
erubi_rails 103 105 124
fannkuchredux 25 27 27
lee 34 42 39
nbody 25 26 27
optcarrot 58 67 65
rubykon 52 60 56
30k_ifelse 68 177 127
30k_methods 57 176 75
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 123 111 111

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 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 158 75 158 20 158
mail 5 129 75 129 20 129
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 63 75 63 20 63
erubi_rails 5 1021 75 1021 20 1021
fannkuchredux 5 15 74 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 22 29 22 20 22
cfunc_itself 5 438 75 438 20 438
fib 5 315 75 315 20 315
getivar 5 614 75 614 20 614
keyword_args 5 373 75 373 20 373
respond_to 5 106 75 106 20 106
setivar 5 957 75 957 20 957
str_concat 5 466 75 466 20 466

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) 1037083 780094 131 1288 0 0% 0 0 0
hexapdf (click) 1149659 923689 682 8011 9 0% 0 0 0
liquid-render (click) 521883 405873 150 1705 2 0% 0 0 0
mail (click) 911515 657647 374 5431 17 0% 0 0 0
psych-load (click) 346011 262324 68 482 1 0% 0 0 0
railsbench (click) 2653979 1965392 1436 10017 16 0% 0 0 0
binarytrees (click) 171867 128248 13 58 0 0% 0 0 0
chunky_png (click) 385883 288711 88 1000 0 0% 0 0 0
erubi (click) 322843 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1965531 1431877 300 2051 4 0% 0 0 0
fannkuchredux (click) 185691 138378 10 188 0 0% 0 0 0
lee (click) 385115 290709 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) 320539 256496 144 1568 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) 172059 128179 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.