YJIT Benchmarks

2022-08-07 05:13:37

As of 2022-08-07 05:13:37:

Overall YJIT is 36.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 36.5% 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 151.7 1.03% 154.4 0.43% 102.1 0.61% 0.98x 1.11% 1.49x 1.19% 85.93%
hexapdf 3219.0 1.01% 2415.8 1.09% 1.33x 1.49% 83.11%
liquid-render 198.5 1.14% 170.7 1.57% 126.7 1.81% 1.16x 1.94% 1.57x 2.14% 85.90%
mail 179.8 0.15% 174.0 2.30% 154.3 0.19% 1.03x 2.30% 1.17x 0.24% 99.34%
psych-load 2547.1 0.05% 2228.4 0.02% 1928.4 0.02% 1.14x 0.05% 1.32x 0.05% 88.89%
railsbench 2790.8 0.73% 2788.7 0.50% 2044.2 0.86% 1.00x 0.89% 1.37x 1.13% 86.54%
binarytrees 475.5 0.05% 305.1 0.31% 367.4 0.05% 1.56x 0.31% 1.29x 0.07% 84.27%
chunky_png 976.5 0.16% 785.4 0.36% 648.3 0.05% 1.24x 0.39% 1.51x 0.16% 99.95%
erubi 373.2 0.52% 340.1 0.68% 320.8 0.69% 1.10x 0.86% 1.16x 0.86% 100.00%
erubi_rails 28.3 2.62% 27.6 2.54% 19.2 3.84% 1.02x 3.65% 1.47x 4.64% 86.40%
fannkuchredux 7053.0 0.11% 3975.3 0.32% 6988.8 0.60% 1.77x 0.34% 1.01x 0.61% 0.02%
lee 1263.1 0.78% 1032.3 0.29% 931.7 0.71% 1.22x 0.83% 1.36x 1.05% 99.97%
nbody 128.4 0.59% 76.4 0.22% 90.9 0.07% 1.68x 0.63% 1.41x 0.59% 100.00%
optcarrot 6422.6 0.42% 2780.1 0.61% 3456.7 0.60% 2.31x 0.74% 1.86x 0.74% 96.16%
rubykon 12791.4 0.48% 8020.8 0.57% 6865.7 0.47% 1.59x 0.74% 1.86x 0.67% 99.61%
30k_ifelse 2214.4 0.05% 3546.0 3.88% 354.1 0.10% 0.62x 3.88% 6.25x 0.11% 100.00%
30k_methods 6322.2 0.02% 9779.7 20.29% 876.7 0.02% 0.65x 20.29% 7.21x 0.03% 100.00%
cfunc_itself 111.1 0.14% 69.5 0.92% 45.8 0.74% 1.60x 0.93% 2.42x 0.76% 100.00%
fib 261.0 0.10% 86.2 0.21% 63.5 0.05% 3.03x 0.23% 4.11x 0.11% 100.00%
getivar 106.9 0.91% 32.7 56.23% 44.2 0.12% 3.27x 56.23% 2.42x 0.92% 99.02%
keyword_args 287.9 0.09% 223.1 0.70% 52.4 0.15% 1.29x 0.70% 5.49x 0.17% 100.00%
respond_to 272.6 0.39% 226.8 0.35% 187.4 0.14% 1.20x 0.52% 1.45x 0.41% 100.00%
setivar 76.7 0.24% 20.9 63.09% 50.0 0.63% 3.67x 63.09% 1.54x 0.67% 99.14%
str_concat 82.8 0.93% 50.3 1.23% 42.8 1.74% 1.65x 1.55% 1.94x 1.98% 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-07T04:09:46Z master 591ee9d068) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-07T04:09:46Z master 591ee9d068) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 275 393
liquid-render 30 35 37
mail 49 54 56
psych-load 36 46 41
railsbench 104 105 133
binarytrees 31 33 32
chunky_png 43 50 49
erubi 64 80 105
erubi_rails 103 104 122
fannkuchredux 25 27 27
lee 33 40 39
nbody 24 26 27
optcarrot 58 66 65
rubykon 52 60 56
30k_ifelse 68 168 127
30k_methods 57 176 75
cfunc_itself 25 27 26
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 26
respond_to 24 27 27
setivar 25 26 27
str_concat 122 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 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 159 75 159 20 159
mail 5 128 75 128 20 128
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 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 35 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 22 30 22 20 22
cfunc_itself 5 436 75 436 20 436
fib 5 314 75 314 20 314
getivar 5 611 75 611 20 611
keyword_args 5 366 75 366 20 366
respond_to 5 105 75 105 20 105
setivar 5 956 75 956 20 956
str_concat 5 463 75 463 20 463

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) 1038171 780969 131 1294 0 0% 0 0 0
hexapdf (click) 1149723 923852 682 8013 10 0% 0 0 0
liquid-render (click) 518683 402805 150 1671 2 0% 0 0 0
mail (click) 905499 652740 374 5366 17 0% 0 0 0
psych-load (click) 347419 263298 68 482 1 0% 0 0 0
railsbench (click) 2657243 1967947 1436 10030 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 386331 288891 88 998 0 0% 0 0 0
erubi (click) 322907 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1958811 1427387 300 2000 4 0% 0 0 0
fannkuchredux (click) 185755 138378 10 188 0 0% 0 0 0
lee (click) 386139 291615 58 632 0 0% 0 0 0
nbody (click) 182555 137443 12 171 0 0% 0 0 0
optcarrot (click) 513947 442610 207 3588 20 0% 0 0 0
rubykon (click) 320475 256184 144 1564 2 0% 0 0 0
30k_ifelse (click) 5560987 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2176155 1657178 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170459 127021 10 49 0 0% 0 0 0
fib (click) 168923 126629 10 38 0 0% 0 0 0
getivar (click) 170651 128716 10 65 0 0% 0 0 0
keyword_args (click) 171291 127662 11 51 0 0% 0 0 0
respond_to (click) 172123 128179 10 64 0 0% 0 0 0
setivar (click) 170587 127536 10 38 0 0% 0 0 0
str_concat (click) 170587 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.