YJIT Benchmarks

2022-05-13 19:12:53

As of 2022-05-13 19:12:53:

Overall YJIT is 30.8% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 28.8% 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.9 0.38% 177.4 4.49% 106.2 0.50% 0.86x 4.51% 1.44x 0.63% 85.55%
hexapdf 3243.6 0.75% 2357.1 0.96% 1.38x 1.22% 83.93%
liquid-render 216.5 2.52% 204.7 1.33% 147.9 1.77% 1.06x 2.85% 1.46x 3.08% 85.70%
mail 203.9 2.09% 206.9 3.32% 186.2 2.61% 0.99x 3.92% 1.10x 3.35% 99.34%
psych-load 2784.2 1.48% 2293.4 0.19% 2274.2 0.06% 1.21x 1.49% 1.22x 1.48% 88.45%
railsbench 3165.5 0.55% 3530.2 0.49% 2456.8 0.35% 0.90x 0.73% 1.29x 0.65% 86.03%
binarytrees 479.6 0.15% 308.9 0.27% 370.4 0.18% 1.55x 0.31% 1.29x 0.23% 84.27%
chunky_png 981.6 0.29% 800.7 0.58% 673.7 0.51% 1.23x 0.65% 1.46x 0.59% 99.95%
discourse 608.2 16.02% 613.2 13.90% 527.3 17.52% 0.99x 21.21% 1.15x 23.74% 73.57%
erubi 484.3 1.07% 477.1 0.94% 417.7 0.89% 1.01x 1.42% 1.16x 1.39% 100.00%
erubi_rails 32.4 39.72% 35.0 43.59% 25.8 55.07% 0.92x 58.97% 1.25x 67.90% 86.30%
fannkuchredux 8756.4 0.11% 4114.4 0.05% 7651.4 11.35% 2.13x 0.12% 1.14x 11.35% 0.02%
lee 1292.0 0.07% 1038.9 0.28% 909.9 2.88% 1.24x 0.29% 1.42x 2.88% 99.97%
nbody 125.6 0.42% 72.8 0.22% 90.4 0.49% 1.73x 0.47% 1.39x 0.64% 100.00%
optcarrot 6311.5 0.42% 2528.4 0.62% 3413.6 0.62% 2.50x 0.75% 1.85x 0.75% 96.13%
rubykon 13715.0 1.82% 11606.3 1.29% 8083.5 3.63% 1.18x 2.23% 1.70x 4.06% 99.60%
30k_ifelse 2334.5 0.01% 3461.4 3.62% 362.8 0.19% 0.67x 3.62% 6.43x 0.19% 100.00%
30k_methods 6495.4 0.01% 10128.7 17.11% 878.9 0.06% 0.64x 17.11% 7.39x 0.06% 100.00%
cfunc_itself 108.2 0.17% 69.8 0.19% 45.8 1.03% 1.55x 0.26% 2.36x 1.04% 100.00%
fib 250.5 0.28% 86.1 0.03% 62.5 0.61% 2.91x 0.29% 4.01x 0.67% 100.00%
getivar 109.6 1.00% 26.2 68.56% 42.6 0.73% 4.18x 68.57% 2.57x 1.24% 99.21%
keyword_args 287.2 0.08% 223.2 0.24% 55.8 0.66% 1.29x 0.26% 5.15x 0.67% 100.00%
respond_to 272.1 0.09% 230.1 1.08% 193.6 0.30% 1.18x 1.08% 1.41x 0.32% 100.00%
setivar 79.0 0.56% 10.8 101.60% 53.9 0.60% 7.35x 101.60% 1.47x 0.82% 99.55%
str_concat 135.0 0.85% 102.5 0.93% 110.9 1.57% 1.32x 1.26% 1.22x 1.78% 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-13T14:47:50Z master 09c72f41ce) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-13T14:47:50Z master 09c72f41ce) +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 331
hexapdf 217 588
liquid-render 30 35 292
mail 49 53 311
psych-load 37 52 298
railsbench 102 137 383
binarytrees 31 33 288
chunky_png 41 47 302
discourse 388 403 701
erubi 39 39 299
erubi_rails 102 108 376
fannkuchredux 25 28 283
lee 32 37 296
nbody 24 26 282
optcarrot 58 67 321
rubykon 50 80 310
30k_ifelse 66 166 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 26 282
str_concat 112 93 354

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 191 75 191 20 191
hexapdf 5 15 20 15
liquid-render 5 134 75 134 20 134
mail 5 105 75 105 20 105
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 64 75 64 20 64
chunky_png 5 29 75 29 20 29
discourse 5 38 75 38 20 38
erubi 5 47 75 47 20 47
erubi_rails 5 807 75 807 20 807
fannkuchredux 5 15 73 15 20 15
lee 5 21 75 21 20 21
nbody 5 274 75 274 20 274
optcarrot 5 15 75 15 20 15
rubykon 5 15 25 15 20 15
30k_ifelse 5 54 75 54 20 54
30k_methods 5 22 29 22 20 22
cfunc_itself 5 439 75 439 20 439
fib 5 320 75 320 20 320
getivar 5 764 75 764 20 764
keyword_args 5 380 75 380 20 380
respond_to 5 98 75 98 20 98
setivar 5 1843 75 1843 20 1843
str_concat 5 195 75 195 20 195

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) 1018203 757642 131 1239 0 0% 0 0 0
hexapdf (click) 1119451 878694 682 7742 9 0% 0 0 0
liquid-render (click) 501787 384824 150 1550 2 0% 0 0 0
mail (click) 936987 676463 374 5759 15 0% 0 0 0
psych-load (click) 339355 255006 68 457 1 0% 0 0 0
railsbench (click) 2627675 1919692 1436 9749 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 379995 284032 88 997 0 0% 0 0 0
discourse (click) 5934939 4405782 3197 25369 84 0% 2 0 0
erubi (click) 319451 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1952347 1404072 300 2013 4 0% 0 0 0
fannkuchredux (click) 185883 139427 10 188 0 0% 0 0 0
lee (click) 377691 283380 58 622 0 0% 0 0 0
nbody (click) 181339 135930 12 158 0 0% 0 0 0
optcarrot (click) 512539 441179 207 3571 20 0% 0 0 0
rubykon (click) 316891 249825 144 1535 1 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.