YJIT Benchmarks

2022-05-12 07:13:12

As of 2022-05-12 07:13:12:

Overall YJIT is 30.8% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 27.7% 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.4 1.47% 180.8 4.85% 105.2 0.47% 0.84x 5.07% 1.45x 1.54% 85.01%
hexapdf 3265.4 0.96% 2396.9 1.81% 1.36x 2.05% 83.83%
liquid-render 213.4 1.04% 204.4 1.51% 145.5 1.65% 1.04x 1.84% 1.47x 1.95% 85.70%
mail 204.5 2.45% 207.6 3.24% 187.4 2.45% 0.98x 4.06% 1.09x 3.46% 99.41%
psych-load 2797.9 0.06% 2346.6 0.07% 2251.2 0.06% 1.19x 0.09% 1.24x 0.08% 88.45%
railsbench 3122.3 0.57% 3539.1 0.57% 2445.4 0.95% 0.88x 0.81% 1.28x 1.10% 85.93%
binarytrees 486.2 0.04% 309.2 0.29% 370.0 0.15% 1.57x 0.30% 1.31x 0.16% 84.27%
chunky_png 1006.8 0.11% 796.6 0.61% 667.1 0.49% 1.26x 0.62% 1.51x 0.50% 99.95%
discourse 587.2 13.96% 622.6 13.54% 600.3 24.56% 0.94x 19.45% 0.98x 28.25% 73.80%
erubi 485.3 0.68% 460.1 1.12% 419.1 0.86% 1.05x 1.31% 1.16x 1.10% 100.00%
erubi_rails 32.7 39.74% 36.0 41.92% 24.8 53.62% 0.91x 57.76% 1.32x 66.74% 86.29%
fannkuchredux 8665.6 0.13% 4609.6 19.44% 8591.0 9.64% 1.88x 19.44% 1.01x 9.64% 0.02%
lee 1275.4 0.21% 998.1 0.68% 895.4 1.65% 1.28x 0.71% 1.42x 1.66% 99.97%
nbody 126.0 0.08% 72.6 0.05% 88.3 0.51% 1.73x 0.09% 1.43x 0.52% 100.00%
optcarrot 6280.1 0.43% 2610.3 0.61% 3421.5 0.60% 2.41x 0.75% 1.84x 0.74% 96.13%
rubykon 13857.9 1.77% 11592.3 1.10% 8156.7 2.76% 1.20x 2.08% 1.70x 3.28% 99.68%
30k_ifelse 2335.6 0.01% 3689.2 3.73% 366.2 0.20% 0.63x 3.73% 6.38x 0.20% 100.00%
30k_methods 6177.1 0.01% 10131.0 16.73% 889.5 0.07% 0.61x 16.73% 6.94x 0.07% 100.00%
cfunc_itself 107.6 0.15% 68.7 0.18% 45.6 1.11% 1.57x 0.23% 2.36x 1.12% 100.00%
fib 249.1 0.19% 86.1 0.03% 62.5 0.60% 2.89x 0.19% 3.99x 0.63% 100.00%
getivar 109.8 1.20% 26.0 68.25% 42.6 0.73% 4.23x 68.26% 2.58x 1.40% 99.22%
keyword_args 291.6 0.08% 225.1 0.30% 53.3 0.68% 1.30x 0.31% 5.47x 0.68% 100.00%
respond_to 272.2 0.12% 230.5 1.31% 193.4 0.28% 1.18x 1.31% 1.41x 0.30% 100.00%
setivar 79.0 0.54% 10.7 101.24% 53.9 0.62% 7.36x 101.24% 1.47x 0.83% 99.55%
str_concat 134.4 0.81% 101.3 1.25% 110.4 1.52% 1.33x 1.49% 1.22x 1.72% 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-12T05:54:37Z master fbebfe1697) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-12T05:54:37Z master fbebfe1697) +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 64 72 330
hexapdf 198 614
liquid-render 30 35 292
mail 50 53 311
psych-load 39 49 299
railsbench 102 136 383
binarytrees 30 33 288
chunky_png 43 47 301
discourse 387 402 703
erubi 39 43 298
erubi_rails 103 106 378
fannkuchredux 25 28 283
lee 32 40 297
nbody 25 26 283
optcarrot 58 67 321
rubykon 50 80 310
30k_ifelse 67 174 375
30k_methods 57 184 331
cfunc_itself 24 27 282
fib 24 27 282
getivar 25 27 282
keyword_args 24 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 136 75 136 20 136
mail 5 106 75 106 20 106
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 32 75 32 20 32
erubi 5 47 75 47 20 47
erubi_rails 5 815 75 815 20 815
fannkuchredux 5 15 51 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 25 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 22 29 22 20 22
cfunc_itself 5 443 75 443 20 443
fib 5 320 75 320 20 320
getivar 5 770 75 770 20 770
keyword_args 5 380 75 380 20 380
respond_to 5 103 75 103 20 103
setivar 5 1861 75 1861 20 1861
str_concat 5 196 75 196 20 196

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) 1009819 750106 131 1238 0 0% 0 0 0
hexapdf (click) 1111451 871711 683 7702 10 0% 0 0 0
liquid-render (click) 507547 388973 150 1580 2 0% 0 0 0
mail (click) 885019 640837 374 5275 15 0% 0 0 0
psych-load (click) 340187 255601 68 462 1 0% 0 0 0
railsbench (click) 2622811 1914983 1436 9818 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 382619 285138 88 1026 0 0% 0 0 0
discourse (click) 5837275 4330267 3161 24851 81 0% 2 0 0
erubi (click) 319451 242761 10 79 0 0% 0 0 0
erubi_rails (click) 1933851 1391498 300 2015 4 0% 0 0 0
fannkuchredux (click) 185371 139131 10 188 0 0% 0 0 0
lee (click) 377755 283390 58 618 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) 317403 250332 144 1543 2 0% 0 0 0
30k_ifelse (click) 5560923 4349053 9265 57804 0 0% 0 0 0
30k_methods (click) 2176027 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) 170139 129181 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.