YJIT Benchmarks

2022-09-16 20:11:43

As of 2022-09-16 20:11:43:

Overall YJIT is 36.4% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 30.6% 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 149.2 0.68% 181.5 4.66% 102.7 0.62% 0.82x 4.71% 1.45x 0.92% 85.28%
hexapdf 3194.8 1.07% 2323.1 1.54% 1.38x 1.88% 83.01%
liquid-render 192.8 0.97% 166.4 1.23% 112.1 1.86% 1.16x 1.57% 1.72x 2.09% 85.97%
mail 175.3 0.08% 175.2 2.55% 155.8 0.18% 1.00x 2.55% 1.13x 0.20% 99.32%
psych-load 2431.6 0.02% 2114.9 0.04% 1907.7 0.04% 1.15x 0.05% 1.27x 0.05% 88.89%
railsbench 2739.6 0.79% 3023.8 0.84% 2097.3 0.69% 0.91x 1.15% 1.31x 1.05% 86.28%
binarytrees 472.3 0.06% 312.4 0.86% 239.6 0.06% 1.51x 0.86% 1.97x 0.09% 100.00%
chunky_png 965.4 0.11% 790.2 0.05% 653.9 0.16% 1.22x 0.12% 1.48x 0.19% 99.95%
erubi 343.0 0.59% 317.2 0.53% 298.1 0.74% 1.08x 0.79% 1.15x 0.94% 100.00%
erubi_rails 26.3 2.54% 28.0 9.56% 19.1 3.33% 0.94x 9.89% 1.38x 4.19% 86.35%
fannkuchredux 5328.1 0.57% 5342.4 0.73% 2373.4 0.03% 1.00x 0.92% 2.24x 0.57% 77.42%
lee 1256.5 0.76% 1058.5 0.10% 944.6 0.95% 1.19x 0.77% 1.33x 1.22% 99.97%
nbody 120.9 0.11% 75.1 0.04% 90.9 0.12% 1.61x 0.12% 1.33x 0.16% 100.00%
optcarrot 6115.4 0.44% 2678.2 0.63% 3544.5 0.68% 2.28x 0.77% 1.73x 0.81% 96.16%
rubykon 12493.2 0.74% 9421.7 0.48% 6792.0 0.57% 1.33x 0.88% 1.84x 0.93% 99.70%
30k_ifelse 2375.5 0.01% 4379.0 3.07% 366.5 0.11% 0.54x 3.07% 6.48x 0.11% 100.00%
30k_methods 6473.7 0.01% 12748.3 3.37% 786.4 0.02% 0.51x 3.37% 8.23x 0.02% 100.00%
cfunc_itself 106.2 0.16% 98.3 0.10% 46.1 0.60% 1.08x 0.19% 2.30x 0.63% 100.00%
fib 242.9 0.04% 79.5 0.04% 62.9 0.06% 3.06x 0.06% 3.86x 0.07% 100.00%
getivar 105.4 0.31% 104.5 0.35% 42.8 0.05% 1.01x 0.47% 2.47x 0.32% 98.73%
keyword_args 292.9 0.06% 224.2 0.04% 54.0 0.18% 1.31x 0.07% 5.42x 0.19% 100.00%
respond_to 278.4 0.06% 257.6 0.20% 30.1 0.80% 1.08x 0.21% 9.26x 0.80% 100.00%
setivar 75.6 0.19% 75.7 0.17% 45.9 0.49% 1.00x 0.25% 1.65x 0.52% 98.15%
str_concat 83.8 1.04% 54.9 8.00% 46.8 1.64% 1.53x 8.07% 1.79x 1.94% 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-09-16T17:25:39Z master e3a32abe2e) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-16T17:25:39Z master e3a32abe2e) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 72 76
hexapdf 299 363
liquid-render 31 34 38
mail 49 53 56
psych-load 36 44 42
railsbench 103 122 131
binarytrees 30 32 33
chunky_png 39 46 45
erubi 78 114 105
erubi_rails 102 105 122
fannkuchredux 24 25 27
lee 35 39 40
nbody 24 26 27
optcarrot 63 70 70
rubykon 51 66 55
30k_ifelse 66 147 124
30k_methods 57 157 76
cfunc_itself 25 26 27
fib 24 25 27
getivar 25 26 27
keyword_args 24 26 27
respond_to 24 26 27
setivar 24 26 27
str_concat 114 119 123

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 189 75 189 20 189
hexapdf 5 15 20 15
liquid-render 5 178 75 178 20 178
mail 5 127 75 127 20 127
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 29 75 29 20 29
erubi 5 67 75 67 20 67
erubi_rails 5 1041 75 1041 20 1041
fannkuchredux 5 15 56 15 20 15
lee 5 21 75 21 20 21
nbody 5 266 75 266 20 266
optcarrot 5 15 75 15 20 15
rubykon 5 15 32 15 20 15
30k_ifelse 5 55 67 55 20 55
30k_methods 5 25 23 25 20 25
cfunc_itself 5 430 75 430 20 430
fib 5 317 75 317 20 317
getivar 5 467 75 467 20 467
keyword_args 5 371 75 371 20 371
respond_to 5 611 75 611 20 611
setivar 5 435 75 435 20 435
str_concat 5 425 75 425 20 425

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) 1065719 776208 131 1283 0 0% 0 0 0
hexapdf (click) 1177015 918424 683 8048 9 0% 0 0 0
liquid-render (click) 524087 397040 150 1667 2 0% 0 0 0
mail (click) 956855 666802 375 5655 17 0% 0 0 0
psych-load (click) 356471 261499 68 474 1 0% 0 0 0
railsbench (click) 2726455 1959743 1436 10068 16 0% 0 0 0
binarytrees (click) 177079 127640 13 64 0 0% 0 0 0
chunky_png (click) 399095 288833 88 1006 0 0% 0 0 0
erubi (click) 340727 250309 10 79 0 0% 0 0 0
erubi_rails (click) 2015543 1424002 300 2036 4 0% 0 0 0
fannkuchredux (click) 189815 136544 10 196 0 0% 0 0 0
lee (click) 397751 289715 58 634 0 0% 0 0 0
nbody (click) 186935 135971 12 171 0 0% 0 0 0
optcarrot (click) 531831 441312 207 3592 20 0% 0 0 0
rubykon (click) 329143 254810 144 1572 1 0% 0 0 0
30k_ifelse (click) 5663863 4347034 9265 57804 0 0% 0 0 0
30k_methods (click) 2208503 1655756 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174327 125549 10 49 0 0% 0 0 0
fib (click) 172727 125207 10 38 0 0% 0 0 0
getivar (click) 174391 127244 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) 174071 125854 10 38 0 0% 0 0 0
str_concat (click) 174327 126396 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.