YJIT Benchmarks

2022-09-18 05:27:58

As of 2022-09-18 05:27:58:

Overall YJIT is 36.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.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 1.6 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 2.0 4.0 6.0 8.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.5 0.86% 182.7 4.25% 104.2 0.68% 0.83x 4.34% 1.45x 1.09% 85.28%
hexapdf 3181.7 0.92% 2370.4 2.25% 1.34x 2.43% 82.83%
liquid-render 195.4 1.54% 170.8 1.12% 117.0 1.88% 1.14x 1.90% 1.67x 2.43% 85.97%
mail 175.3 0.13% 176.0 2.31% 155.5 0.32% 1.00x 2.31% 1.13x 0.34% 99.29%
psych-load 2493.6 0.24% 2132.4 0.03% 1929.5 0.02% 1.17x 0.25% 1.29x 0.25% 88.89%
railsbench 2789.7 0.58% 3016.4 0.63% 2092.1 0.91% 0.92x 0.86% 1.33x 1.08% 86.28%
binarytrees 474.9 0.62% 316.6 1.03% 237.8 0.06% 1.50x 1.20% 2.00x 0.62% 100.00%
chunky_png 966.0 0.10% 786.2 0.06% 665.4 0.08% 1.23x 0.12% 1.45x 0.13% 99.95%
erubi 344.6 0.60% 311.8 0.52% 295.5 0.69% 1.11x 0.79% 1.17x 0.91% 100.00%
erubi_rails 26.7 2.67% 28.6 10.22% 19.0 3.67% 0.93x 10.56% 1.40x 4.54% 86.35%
fannkuchredux 5304.6 0.24% 5297.7 0.06% 2323.4 0.07% 1.00x 0.25% 2.28x 0.25% 77.42%
lee 1264.2 1.04% 1038.2 1.46% 961.1 1.20% 1.22x 1.80% 1.32x 1.59% 99.97%
nbody 121.8 0.08% 75.7 0.06% 91.7 0.10% 1.61x 0.11% 1.33x 0.13% 100.00%
optcarrot 6131.0 0.44% 2702.0 0.63% 3526.1 0.61% 2.27x 0.77% 1.74x 0.75% 96.16%
rubykon 12595.0 0.46% 9221.0 0.46% 6846.6 0.69% 1.37x 0.65% 1.84x 0.83% 99.70%
30k_ifelse 2338.4 0.06% 4303.1 2.86% 364.2 0.10% 0.54x 2.86% 6.42x 0.12% 100.00%
30k_methods 6364.4 0.00% 13042.6 4.05% 792.0 0.02% 0.49x 4.05% 8.04x 0.03% 100.00%
cfunc_itself 107.7 0.21% 98.7 0.10% 47.2 0.79% 1.09x 0.23% 2.28x 0.81% 100.00%
fib 243.4 0.08% 79.7 0.05% 62.7 0.06% 3.06x 0.10% 3.88x 0.10% 100.00%
getivar 102.9 0.11% 103.1 0.09% 42.8 0.05% 1.00x 0.14% 2.41x 0.12% 99.16%
keyword_args 291.5 0.09% 229.6 0.06% 54.8 0.17% 1.27x 0.11% 5.32x 0.19% 100.00%
respond_to 278.4 0.07% 259.8 0.20% 30.1 0.36% 1.07x 0.21% 9.26x 0.37% 100.00%
setivar 77.9 0.17% 77.8 0.17% 49.7 0.31% 1.00x 0.24% 1.57x 0.35% 98.14%
str_concat 83.5 0.85% 54.6 7.57% 47.8 1.44% 1.53x 7.62% 1.75x 1.68% 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-09-18T05:21:40Z master 12023c833f) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-18T05:21:40Z master 12023c833f) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 72 77
hexapdf 298 367
liquid-render 30 33 37
mail 49 54 57
psych-load 36 44 40
railsbench 102 123 131
binarytrees 30 32 33
chunky_png 44 41 49
erubi 60 102 96
erubi_rails 103 108 122
fannkuchredux 24 26 27
lee 31 42 39
nbody 24 26 27
optcarrot 57 65 64
rubykon 51 59 55
30k_ifelse 68 142 128
30k_methods 58 165 79
cfunc_itself 25 25 27
fib 24 26 27
getivar 25 26 27
keyword_args 24 26 27
respond_to 25 26 27
setivar 24 26 27
str_concat 98 114 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 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 173 75 173 20 173
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 83 75 83 20 83
chunky_png 5 30 75 30 20 30
erubi 5 65 75 65 20 65
erubi_rails 5 1034 75 1034 20 1034
fannkuchredux 5 15 56 15 20 15
lee 5 21 75 21 20 21
nbody 5 265 75 265 20 265
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 55 68 55 20 55
30k_methods 5 25 22 25 20 25
cfunc_itself 5 425 75 425 20 425
fib 5 318 75 318 20 318
getivar 5 719 75 719 20 719
keyword_args 5 371 75 371 20 371
respond_to 5 656 75 656 20 656
setivar 5 432 75 432 20 432
str_concat 5 430 75 430 20 430

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) 1064055 775231 131 1275 0 0% 0 0 0
hexapdf (click) 1177015 918551 683 8046 10 0% 0 0 0
liquid-render (click) 527799 400388 150 1702 2 0% 0 0 0
mail (click) 946935 660513 374 5580 17 0% 0 0 0
psych-load (click) 355063 260454 68 472 1 0% 0 0 0
railsbench (click) 2724343 1958085 1436 10059 16 0% 0 0 0
binarytrees (click) 177143 127690 13 64 0 0% 0 0 0
chunky_png (click) 396663 287194 88 997 0 0% 0 0 0
erubi (click) 340151 249768 10 79 0 0% 0 0 0
erubi_rails (click) 2012919 1422423 300 2021 4 0% 0 0 0
fannkuchredux (click) 189879 136594 10 196 0 0% 0 0 0
lee (click) 398135 290068 58 634 0 0% 0 0 0
nbody (click) 186999 136021 12 171 0 0% 0 0 0
optcarrot (click) 531831 441312 207 3592 20 0% 0 0 0
rubykon (click) 329783 255282 144 1580 2 0% 0 0 0
30k_ifelse (click) 5664247 4347294 9265 57804 0 0% 0 0 0
30k_methods (click) 2208503 1655756 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174391 125599 10 49 0 0% 0 0 0
fib (click) 172727 125207 10 38 0 0% 0 0 0
getivar (click) 174519 127294 10 65 0 0% 0 0 0
keyword_args (click) 175095 126240 11 51 0 0% 0 0 0
respond_to (click) 174967 127166 10 64 0 0% 0 0 0
setivar (click) 174455 126114 10 38 0 0% 0 0 0
str_concat (click) 174711 126799 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.