YJIT Benchmarks

2022-05-11 07:15:14

As of 2022-05-11 07:15:14:

Overall YJIT is 30.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 27.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 No JIT MJIT3.1 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 MJIT3.1 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 MJIT3.1 YJIT binarytrees chunky_png discourse 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 MJIT3.1 (ms) MJIT3.1 RSD YJIT (ms) YJIT RSD MJIT3.1 spd MJIT3.1 spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 152.5 0.35% 171.5 3.47% 105.7 0.63% 0.89x 3.49% 1.44x 0.72% 85.01%
hexapdf 3204.5 0.91% 2359.4 0.40% 1.36x 0.99% 82.62%
liquid-render 209.6 0.98% 202.1 1.35% 144.8 1.88% 1.04x 1.67% 1.45x 2.12% 85.70%
mail 201.9 1.85% 205.8 3.35% 188.1 2.85% 0.98x 3.83% 1.07x 3.40% 99.39%
psych-load 2790.4 0.07% 2286.4 0.07% 2243.7 0.06% 1.22x 0.10% 1.24x 0.09% 88.45%
railsbench 3109.4 0.33% 3511.6 0.77% 2436.9 0.34% 0.89x 0.84% 1.28x 0.47% 86.09%
binarytrees 477.6 0.04% 308.0 0.31% 370.2 0.16% 1.55x 0.32% 1.29x 0.17% 84.27%
chunky_png 983.7 0.28% 796.1 0.36% 673.2 0.20% 1.24x 0.46% 1.46x 0.35% 99.95%
discourse 590.5 15.44% 613.9 13.57% 533.1 18.20% 0.96x 20.56% 1.11x 23.87% 73.13%
erubi 482.3 0.83% 459.9 1.00% 441.1 0.76% 1.05x 1.30% 1.09x 1.13% 100.00%
erubi_rails 32.9 39.20% 36.0 43.13% 25.3 57.21% 0.91x 58.28% 1.30x 69.35% 86.29%
fannkuchredux 8681.6 1.97% 4056.2 0.07% 8892.3 0.10% 2.14x 1.97% 0.98x 1.97% 0.02%
lee 1287.0 0.16% 1065.0 0.07% 899.6 1.60% 1.21x 0.17% 1.43x 1.61% 99.96%
nbody 126.1 0.09% 72.7 0.37% 89.5 0.49% 1.73x 0.38% 1.41x 0.49% 100.00%
optcarrot 6158.3 0.44% 2599.8 0.61% 3434.3 0.62% 2.37x 0.75% 1.79x 0.76% 96.13%
rubykon 13962.2 1.73% 11910.9 1.16% 7924.7 3.31% 1.17x 2.08% 1.76x 3.74% 99.75%
30k_ifelse 2262.2 0.02% 3525.0 3.79% 393.5 0.14% 0.64x 3.79% 5.75x 0.15% 100.00%
30k_methods 6455.8 0.01% 10102.1 15.43% 880.3 0.06% 0.64x 15.43% 7.33x 0.06% 100.00%
cfunc_itself 107.6 0.14% 70.2 0.90% 45.8 0.94% 1.53x 0.91% 2.35x 0.95% 100.00%
fib 246.5 0.15% 86.1 0.03% 62.5 0.60% 2.86x 0.15% 3.94x 0.62% 100.00%
getivar 121.1 0.07% 25.7 69.96% 42.6 0.73% 4.71x 69.96% 2.84x 0.74% 99.21%
keyword_args 290.6 0.08% 229.4 1.44% 52.5 0.70% 1.27x 1.44% 5.53x 0.71% 100.00%
respond_to 274.9 0.26% 237.5 0.96% 193.7 0.34% 1.16x 1.00% 1.42x 0.43% 100.00%
setivar 79.0 0.55% 10.8 102.04% 53.8 0.62% 7.35x 102.04% 1.47x 0.83% 99.55%
str_concat 134.5 0.79% 103.3 1.21% 110.3 1.43% 1.30x 1.44% 1.22x 1.63% 99.68%

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 it 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.
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-05-10T04:07:16Z master a85cdb5a6e) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-10T04:07:16Z master a85cdb5a6e) +MJIT [x86_64-linux]
(We got much better MJIT results with released than prerelease, so we used those.)

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT3.1 mem (MiB) YJIT mem (MiB)
activerecord 65 72 330
hexapdf 211 591
liquid-render 30 35 292
mail 49 52 311
psych-load 39 50 299
railsbench 102 137 383
binarytrees 30 33 288
chunky_png 41 49 303
discourse 388 401 706
erubi 39 43 298
erubi_rails 101 105 374
fannkuchredux 25 28 283
lee 32 38 298
nbody 24 27 282
optcarrot 58 67 320
rubykon 51 80 310
30k_ifelse 66 170 375
30k_methods 57 184 331
cfunc_itself 24 27 282
fib 24 27 282
getivar 25 27 282
keyword_args 25 27 282
respond_to 24 27 282
setivar 25 27 282
str_concat 113 93 349

Memory is shown in mebibytes (1024 * 1024 bytes.)

By default, YJIT allocates an additional 256MiB for generated code. The additional size allocated can be tuned with a command-line parameter, but allocating too little memory will result in YJIT no longer JITting new functions, so performance reverts toward interpreter speeds.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT3.1 warmups MJIT3.1 iters YJIT warmups YJIT iters
activerecord 5 187 75 187 20 187
hexapdf 5 15 20 15
liquid-render 5 137 75 137 20 137
mail 5 105 75 105 20 105
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 29 75 29 20 29
discourse 5 33 75 33 20 33
erubi 5 44 75 44 20 44
erubi_rails 5 785 75 785 20 785
fannkuchredux 5 15 50 15 20 15
lee 5 21 75 21 20 21
nbody 5 275 75 275 20 275
optcarrot 5 15 75 15 20 15
rubykon 5 15 26 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 436 75 436 20 436
fib 5 320 75 320 20 320
getivar 5 765 75 765 20 765
keyword_args 5 381 75 381 20 381
respond_to 5 103 75 103 20 103
setivar 5 1861 75 1861 20 1861
str_concat 5 193 75 193 20 193

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) 1010395 751160 131 1219 0 0% 0 0 0
hexapdf (click) 1114395 873833 683 7701 9 0% 0 0 0
liquid-render (click) 505819 387893 150 1565 2 0% 0 0 0
mail (click) 888539 643012 374 5297 15 0% 0 0 0
psych-load (click) 339547 255124 68 457 1 0% 0 0 0
railsbench (click) 2619803 1912996 1435 9811 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 381403 284352 88 1009 0 0% 0 0 0
discourse (click) 5906523 4377646 3195 25361 83 0% 2 0 0
erubi (click) 322459 242503 10 79 0 0% 0 0 0
erubi_rails (click) 1933915 1391318 300 2010 4 0% 0 0 0
fannkuchredux (click) 185883 139427 10 188 0 0% 0 0 0
lee (click) 377691 283337 58 618 0 0% 0 0 0
nbody (click) 181339 135930 12 158 0 0% 0 0 0
optcarrot (click) 512475 441179 207 3571 20 0% 0 0 0
rubykon (click) 316571 249963 144 1541 2 0% 0 0 0
30k_ifelse (click) 5560923 4349053 9265 57804 0 0% 0 0 0
30k_methods (click) 2176091 1657515 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170395 127358 10 49 0 0% 0 0 0
fib (click) 168859 126966 10 38 0 0% 0 0 0
getivar (click) 170651 129477 10 65 0 0% 0 0 0
keyword_args (click) 171227 127999 11 51 0 0% 0 0 0
respond_to (click) 172507 128812 10 64 0 0% 0 0 0
setivar (click) 170587 128001 10 38 0 0% 0 0 0
str_concat (click) 170587 128321 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.