YJIT Benchmarks

2022-09-22 05:37:04

As of 2022-09-22 05:37:04:

Overall YJIT is 37.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.4% 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 153.1 0.44% 179.8 4.18% 109.5 0.58% 0.85x 4.20% 1.40x 0.73% 85.99%
hexapdf 3211.7 0.94% 2300.0 2.29% 1.40x 2.48% 82.70%
liquid-render 198.5 0.95% 172.1 1.09% 117.1 1.93% 1.15x 1.45% 1.70x 2.15% 85.97%
mail 181.8 0.11% 173.7 2.43% 153.1 0.21% 1.05x 2.44% 1.19x 0.24% 99.36%
psych-load 2481.4 1.10% 2140.0 0.06% 1920.5 0.35% 1.16x 1.10% 1.29x 1.16% 88.89%
railsbench 2769.5 0.69% 3222.7 0.55% 2076.7 0.73% 0.86x 0.89% 1.33x 1.01% 86.57%
binarytrees 477.5 0.04% 311.7 0.25% 232.9 0.06% 1.53x 0.25% 2.05x 0.07% 100.00%
chunky_png 980.1 0.02% 786.4 0.03% 653.9 0.05% 1.25x 0.04% 1.50x 0.05% 99.95%
erubi 340.2 0.63% 318.5 0.53% 300.7 0.76% 1.07x 0.82% 1.13x 0.98% 100.00%
erubi_rails 26.6 2.62% 28.7 9.81% 19.0 3.42% 0.93x 10.16% 1.40x 4.31% 86.41%
fannkuchredux 5388.2 0.04% 5373.4 0.07% 2293.8 0.10% 1.00x 0.08% 2.35x 0.11% 77.42%
lee 1251.7 0.85% 1034.4 1.77% 950.5 0.23% 1.21x 1.96% 1.32x 0.88% 99.97%
nbody 120.4 0.09% 75.6 0.06% 90.9 0.12% 1.59x 0.11% 1.32x 0.15% 100.00%
optcarrot 6271.6 0.43% 2704.2 0.63% 3470.1 0.62% 2.32x 0.76% 1.81x 0.76% 96.16%
rubykon 12645.4 0.64% 9480.6 0.37% 6819.6 0.44% 1.33x 0.74% 1.85x 0.78% 99.69%
30k_ifelse 2339.9 0.01% 4602.2 2.87% 357.0 0.10% 0.51x 2.87% 6.55x 0.10% 100.00%
30k_methods 6648.9 0.01% 13590.5 3.81% 828.6 0.02% 0.49x 3.81% 8.02x 0.02% 100.00%
cfunc_itself 107.2 0.16% 98.1 0.08% 48.9 0.60% 1.09x 0.18% 2.19x 0.63% 100.00%
fib 238.7 0.03% 79.2 0.03% 62.7 0.05% 3.01x 0.05% 3.81x 0.06% 100.00%
getivar 115.4 0.07% 115.3 0.06% 42.8 0.05% 1.00x 0.09% 2.70x 0.08% 98.73%
keyword_args 291.7 0.08% 228.9 0.09% 54.4 0.15% 1.27x 0.12% 5.36x 0.17% 100.00%
respond_to 276.5 0.28% 259.0 0.19% 30.0 0.59% 1.07x 0.34% 9.21x 0.65% 100.00%
setivar 76.6 0.23% 76.6 0.24% 40.7 0.38% 1.00x 0.33% 1.88x 0.44% 98.36%
str_concat 83.4 0.87% 51.6 9.17% 40.1 1.87% 1.62x 9.21% 2.08x 2.06% 99.95%

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-22T05:20:35Z master ec93d09c94) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-22T05:20:35Z master ec93d09c94) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 72 77
hexapdf 284 387
liquid-render 30 33 37
mail 49 53 57
psych-load 35 45 41
railsbench 102 124 131
binarytrees 30 32 33
chunky_png 44 41 49
erubi 73 90 96
erubi_rails 101 105 122
fannkuchredux 24 26 27
lee 33 41 39
nbody 24 26 27
optcarrot 57 65 65
rubykon 50 60 55
30k_ifelse 68 148 128
30k_methods 58 167 80
cfunc_itself 24 26 27
fib 24 26 27
getivar 24 26 27
keyword_args 24 26 27
respond_to 25 26 27
setivar 24 26 27
str_concat 108 110 110

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 196 75 196 20 196
hexapdf 5 15 20 15
liquid-render 5 170 75 170 20 170
mail 5 130 75 130 20 130
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 86 75 86 20 86
chunky_png 5 30 75 30 20 30
erubi 5 67 75 67 20 67
erubi_rails 5 1061 75 1061 20 1061
fannkuchredux 5 15 55 15 20 15
lee 5 21 75 21 20 21
nbody 5 264 75 264 20 264
optcarrot 5 15 75 15 20 15
rubykon 5 15 32 15 20 15
30k_ifelse 5 55 69 55 20 55
30k_methods 5 25 22 25 20 25
cfunc_itself 5 429 75 429 20 429
fib 5 318 75 318 20 318
getivar 5 467 75 467 20 467
keyword_args 5 365 75 365 20 365
respond_to 5 659 75 659 20 659
setivar 5 492 75 492 20 492
str_concat 5 497 75 497 20 497

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) 1067063 777560 131 1278 0 0% 0 0 0
hexapdf (click) 1177655 918941 682 8047 10 0% 0 0 0
liquid-render (click) 529271 401139 150 1730 2 0% 0 0 0
mail (click) 929783 649033 374 5412 17 0% 0 0 0
psych-load (click) 356599 261363 68 482 1 0% 0 0 0
railsbench (click) 2722679 1956321 1436 9964 16 0% 0 0 0
binarytrees (click) 177143 127690 13 64 0 0% 0 0 0
chunky_png (click) 404791 292067 88 1072 0 0% 0 0 0
erubi (click) 341111 250544 10 79 0 0% 0 0 0
erubi_rails (click) 2020983 1427180 300 2024 4 0% 0 0 0
fannkuchredux (click) 189879 136594 10 196 0 0% 0 0 0
lee (click) 396407 288628 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) 328183 254697 144 1569 1 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) 174647 126813 10 64 0 0% 0 0 0
setivar (click) 174455 126114 10 38 0 0% 0 0 0
str_concat (click) 174391 126446 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.