YJIT Benchmarks

2022-05-11 19:13:14

As of 2022-05-11 19:13:14:

Overall YJIT is 30.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 26.0% 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.1 0.35% 174.0 3.70% 106.6 0.47% 0.87x 3.72% 1.43x 0.58% 85.01%
hexapdf 3237.9 1.10% 2373.1 1.61% 1.36x 1.95% 83.25%
liquid-render 210.7 2.65% 203.7 1.38% 146.6 1.48% 1.03x 2.99% 1.44x 3.04% 85.70%
mail 201.5 1.99% 204.8 3.31% 188.7 2.60% 0.98x 3.86% 1.07x 3.27% 99.40%
psych-load 2793.3 0.05% 2301.4 0.04% 2131.9 0.04% 1.21x 0.06% 1.31x 0.06% 88.45%
railsbench 3067.6 0.26% 3485.7 0.54% 2434.4 0.32% 0.88x 0.60% 1.26x 0.41% 85.92%
binarytrees 477.3 0.04% 308.2 0.30% 369.6 0.15% 1.55x 0.30% 1.29x 0.16% 84.27%
chunky_png 975.7 0.28% 788.6 0.88% 667.0 0.54% 1.24x 0.92% 1.46x 0.61% 99.95%
discourse 608.9 17.60% 622.5 14.67% 657.8 21.08% 0.98x 22.91% 0.93x 27.46% 73.13%
erubi 484.1 0.67% 460.7 0.88% 418.9 0.81% 1.05x 1.11% 1.16x 1.06% 100.00%
erubi_rails 32.2 39.61% 35.7 41.46% 24.5 52.66% 0.90x 57.34% 1.31x 65.89% 86.29%
fannkuchredux 7876.9 10.83% 5845.0 0.17% 8904.4 0.14% 1.35x 10.83% 0.88x 10.83% 0.02%
lee 1256.8 0.22% 1056.6 0.21% 951.5 0.23% 1.19x 0.30% 1.32x 0.32% 99.97%
nbody 130.4 0.18% 72.6 0.09% 89.3 0.48% 1.80x 0.20% 1.46x 0.51% 100.00%
optcarrot 6147.2 0.45% 2587.8 0.61% 3430.2 0.59% 2.38x 0.76% 1.79x 0.74% 96.13%
rubykon 13921.3 1.98% 11594.6 1.38% 8066.3 3.70% 1.20x 2.42% 1.73x 4.19% 99.72%
30k_ifelse 2266.5 0.05% 3444.3 3.34% 358.9 0.19% 0.66x 3.34% 6.32x 0.19% 100.00%
30k_methods 6349.1 0.01% 10085.1 16.74% 874.5 0.06% 0.63x 16.74% 7.26x 0.06% 100.00%
cfunc_itself 107.7 0.14% 70.7 0.87% 45.1 1.02% 1.52x 0.88% 2.39x 1.03% 100.00%
fib 246.9 0.27% 86.1 0.03% 62.5 0.59% 2.87x 0.28% 3.95x 0.65% 100.00%
getivar 109.6 0.50% 26.0 68.04% 42.6 0.73% 4.22x 68.04% 2.57x 0.88% 99.22%
keyword_args 292.6 0.09% 223.0 0.37% 52.5 0.69% 1.31x 0.38% 5.57x 0.70% 100.00%
respond_to 273.6 0.51% 231.6 0.22% 194.0 0.28% 1.18x 0.56% 1.41x 0.59% 100.00%
setivar 79.1 0.55% 10.7 101.33% 53.9 0.59% 7.36x 101.34% 1.47x 0.81% 99.55%
str_concat 135.2 0.85% 101.7 1.06% 110.5 1.49% 1.33x 1.36% 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-11T19:11:51Z master 019169346a) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-11T19:11:51Z master 019169346a) +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 331
hexapdf 272 686
liquid-render 30 35 292
mail 50 53 311
psych-load 39 51 300
railsbench 102 136 383
binarytrees 30 33 288
chunky_png 41 49 301
discourse 389 401 703
erubi 39 42 298
erubi_rails 102 106 378
fannkuchredux 25 28 283
lee 32 37 293
nbody 25 27 283
optcarrot 58 67 320
rubykon 50 80 310
30k_ifelse 67 162 375
30k_methods 57 184 332
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 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 189 75 189 20 189
hexapdf 5 15 20 15
liquid-render 5 138 75 138 20 138
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 37 75 37 20 37
erubi 5 45 75 45 20 45
erubi_rails 5 790 75 790 20 790
fannkuchredux 5 15 73 15 20 15
lee 5 22 75 22 20 22
nbody 5 275 75 275 20 275
optcarrot 5 15 75 15 20 15
rubykon 5 15 25 15 20 15
30k_ifelse 5 50 75 50 20 50
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 777 75 777 20 777
keyword_args 5 380 75 380 20 380
respond_to 5 103 75 103 20 103
setivar 5 1860 75 1860 20 1860
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) 1011163 751180 131 1227 0 0% 0 0 0
hexapdf (click) 1114779 874468 682 7703 9 0% 0 0 0
liquid-render (click) 508763 389508 150 1590 2 0% 0 0 0
mail (click) 887323 642568 374 5289 15 0% 0 0 0
psych-load (click) 339547 255149 68 457 1 0% 0 0 0
railsbench (click) 2621211 1913386 1435 9814 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 376923 281764 88 970 0 0% 0 0 0
discourse (click) 5909083 4379911 3195 25385 83 0% 2 0 0
erubi (click) 318811 242364 10 79 0 0% 0 0 0
erubi_rails (click) 1932827 1390533 300 2021 4 0% 0 0 0
fannkuchredux (click) 185883 139427 10 188 0 0% 0 0 0
lee (click) 378139 283924 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) 317339 250312 145 1540 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.