YJIT Benchmarks

2022-05-13 07:14:29

As of 2022-05-13 07:14:29:

Overall YJIT is 30.8% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 27.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 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 153.9 0.93% 180.7 4.67% 104.5 0.52% 0.85x 4.77% 1.47x 1.07% 85.55%
hexapdf 3226.1 1.19% 2384.1 1.79% 1.35x 2.15% 81.99%
liquid-render 213.1 1.09% 205.1 1.30% 148.7 1.81% 1.04x 1.70% 1.43x 2.11% 85.70%
mail 204.2 2.01% 205.3 3.38% 188.7 2.57% 0.99x 3.93% 1.08x 3.26% 99.36%
psych-load 2814.6 0.04% 2291.7 0.12% 2211.9 0.04% 1.23x 0.13% 1.27x 0.06% 88.45%
railsbench 3096.9 0.57% 3518.6 0.38% 2428.9 0.89% 0.88x 0.68% 1.28x 1.06% 86.19%
binarytrees 480.6 0.04% 310.2 0.33% 365.7 0.15% 1.55x 0.33% 1.31x 0.16% 84.27%
chunky_png 981.1 0.28% 793.1 0.52% 675.0 0.51% 1.24x 0.59% 1.45x 0.58% 99.95%
discourse 591.6 15.05% 614.3 14.37% 524.2 18.27% 0.96x 20.81% 1.13x 23.67% 73.57%
erubi 487.0 0.66% 459.6 1.14% 421.8 0.84% 1.06x 1.32% 1.15x 1.07% 100.00%
erubi_rails 32.8 40.35% 35.0 43.76% 24.8 52.72% 0.94x 59.52% 1.32x 66.39% 86.30%
fannkuchredux 8705.6 0.13% 4080.6 0.07% 7020.2 0.08% 2.13x 0.15% 1.24x 0.16% 0.02%
lee 1252.7 0.04% 1032.0 0.12% 914.8 1.83% 1.21x 0.13% 1.37x 1.83% 99.97%
nbody 125.7 0.14% 72.8 0.16% 89.1 0.49% 1.73x 0.21% 1.41x 0.51% 100.00%
optcarrot 6212.1 0.42% 2623.0 0.60% 3405.6 0.62% 2.37x 0.74% 1.82x 0.75% 96.13%
rubykon 13821.7 1.73% 11708.4 1.48% 8069.3 3.81% 1.18x 2.28% 1.71x 4.19% 99.64%
30k_ifelse 2301.7 0.02% 3712.3 3.66% 365.1 0.19% 0.62x 3.66% 6.31x 0.20% 100.00%
30k_methods 6243.3 0.02% 10277.7 15.52% 876.1 0.06% 0.61x 15.52% 7.13x 0.06% 100.00%
cfunc_itself 107.5 0.14% 69.9 0.31% 45.5 1.08% 1.54x 0.34% 2.36x 1.09% 100.00%
fib 247.7 0.14% 86.4 1.15% 62.5 0.61% 2.87x 1.16% 3.96x 0.62% 100.00%
getivar 111.8 1.36% 26.2 68.52% 42.6 0.68% 4.27x 68.53% 2.62x 1.52% 99.21%
keyword_args 285.8 0.08% 226.9 0.40% 52.5 0.69% 1.26x 0.41% 5.44x 0.69% 100.00%
respond_to 285.4 0.07% 239.8 1.05% 202.2 0.57% 1.19x 1.05% 1.41x 0.58% 100.00%
setivar 79.1 0.57% 10.8 100.66% 53.9 0.61% 7.29x 100.66% 1.47x 0.83% 99.55%
str_concat 133.5 0.80% 102.1 1.37% 112.1 1.44% 1.31x 1.59% 1.19x 1.65% 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-13T06:23:56Z master 4c9ddaac0d) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-13T06:23:56Z master 4c9ddaac0d) +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 73 330
hexapdf 258 578
liquid-render 30 35 292
mail 49 53 311
psych-load 39 50 296
railsbench 103 136 383
binarytrees 30 33 288
chunky_png 41 51 301
discourse 388 403 706
erubi 39 44 298
erubi_rails 102 106 378
fannkuchredux 25 28 283
lee 31 37 298
nbody 25 27 283
optcarrot 59 67 320
rubykon 50 80 310
30k_ifelse 66 173 375
30k_methods 58 184 332
cfunc_itself 25 27 282
fib 24 27 282
getivar 25 27 282
keyword_args 25 28 282
respond_to 25 27 282
setivar 25 26 282
str_concat 111 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 188 75 188 20 188
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 34 75 34 20 34
erubi 5 45 75 45 20 45
erubi_rails 5 789 75 789 20 789
fannkuchredux 5 15 74 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 54 75 54 20 54
30k_methods 5 21 29 21 20 21
cfunc_itself 5 444 75 444 20 444
fib 5 320 75 320 20 320
getivar 5 763 75 763 20 763
keyword_args 5 374 75 374 20 374
respond_to 5 103 75 103 20 103
setivar 5 1862 75 1862 20 1862
str_concat 5 207 75 207 20 207

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) 1014043 754480 131 1233 0 0% 0 0 0
hexapdf (click) 1119899 878800 682 7747 10 0% 0 0 0
liquid-render (click) 512027 392429 150 1625 2 0% 0 0 0
mail (click) 916379 662514 374 5565 15 0% 0 0 0
psych-load (click) 339547 255124 68 457 1 0% 0 0 0
railsbench (click) 2636635 1926172 1436 9817 16 0% 0 0 0
binarytrees (click) 171739 128594 13 58 0 0% 0 0 0
chunky_png (click) 383707 286073 88 1026 0 0% 0 0 0
discourse (click) 5954715 4418480 3196 25505 84 0% 2 0 0
erubi (click) 319451 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1952027 1404353 300 2011 4 0% 0 0 0
fannkuchredux (click) 185883 139427 10 188 0 0% 0 0 0
lee (click) 378267 283852 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) 316443 249393 144 1528 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.