YJIT Benchmarks

2022-05-10 07:17:59

As of 2022-05-10 07:17:59:

Overall YJIT is 28.6% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 26.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 154.1 0.35% 176.3 4.20% 113.7 0.46% 0.87x 4.22% 1.36x 0.58% 85.01%
hexapdf 3259.5 1.48% 2362.9 2.28% 1.38x 2.71% 83.29%
liquid-render 212.0 1.03% 205.0 1.38% 146.0 1.76% 1.03x 1.72% 1.45x 2.04% 85.70%
mail 204.8 2.01% 206.2 3.24% 186.8 2.58% 0.99x 3.81% 1.10x 3.26% 99.35%
psych-load 2792.3 0.02% 2283.1 0.06% 2320.1 0.06% 1.22x 0.07% 1.20x 0.06% 88.45%
railsbench 3106.3 0.26% 3504.2 0.35% 2453.6 0.32% 0.89x 0.43% 1.27x 0.41% 86.09%
binarytrees 475.0 0.04% 319.4 0.31% 369.7 0.15% 1.49x 0.32% 1.28x 0.15% 84.27%
chunky_png 986.3 0.27% 800.1 0.60% 670.0 0.51% 1.23x 0.66% 1.47x 0.57% 99.95%
discourse 596.6 15.95% 625.8 14.77% 617.8 19.33% 0.95x 21.74% 0.97x 25.06% 73.08%
erubi 508.3 0.43% 485.3 1.00% 437.9 0.77% 1.05x 1.09% 1.16x 0.88% 100.00%
erubi_rails 32.4 39.66% 34.9 41.08% 24.3 52.94% 0.93x 57.10% 1.33x 66.15% 86.29%
fannkuchredux 8757.0 0.14% 4070.4 0.04% 8944.9 1.66% 2.15x 0.15% 0.98x 1.67% 0.02%
lee 1275.0 0.17% 1002.2 1.17% 935.5 0.21% 1.27x 1.18% 1.36x 0.27% 99.97%
nbody 125.2 0.06% 80.6 0.13% 89.0 0.48% 1.55x 0.14% 1.41x 0.48% 100.00%
optcarrot 6160.4 0.45% 2573.8 0.60% 3622.2 0.59% 2.39x 0.75% 1.70x 0.74% 96.13%
rubykon 13781.1 2.00% 11591.6 1.07% 7976.1 3.51% 1.19x 2.27% 1.73x 4.04% 99.59%
30k_ifelse 2344.4 0.02% 3802.6 3.72% 356.5 0.18% 0.62x 3.72% 6.58x 0.18% 100.00%
30k_methods 6596.3 0.00% 10137.9 13.25% 919.9 0.05% 0.65x 13.25% 7.17x 0.05% 100.00%
cfunc_itself 108.0 0.12% 68.5 0.15% 45.2 1.00% 1.58x 0.20% 2.39x 1.01% 100.00%
fib 245.4 0.15% 86.1 0.03% 62.5 0.59% 2.85x 0.15% 3.93x 0.61% 100.00%
getivar 110.8 1.44% 26.1 68.54% 42.6 0.71% 4.24x 68.56% 2.60x 1.61% 99.21%
keyword_args 286.2 0.09% 225.9 0.40% 52.5 0.67% 1.27x 0.41% 5.45x 0.67% 100.00%
respond_to 271.9 0.07% 233.1 0.55% 193.5 0.27% 1.17x 0.55% 1.41x 0.28% 100.00%
setivar 79.1 0.58% 10.7 101.52% 53.9 0.61% 7.36x 101.52% 1.47x 0.84% 99.55%
str_concat 134.5 0.81% 103.0 1.11% 110.3 1.41% 1.30x 1.38% 1.22x 1.62% 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 64 72 331
hexapdf 206 614
liquid-render 30 35 292
mail 49 53 312
psych-load 40 50 299
railsbench 102 136 383
binarytrees 30 33 288
chunky_png 41 47 302
discourse 386 403 706
erubi 34 39 298
erubi_rails 102 108 378
fannkuchredux 25 28 282
lee 31 40 293
nbody 24 27 282
optcarrot 58 67 320
rubykon 50 80 310
30k_ifelse 66 174 375
30k_methods 57 184 332
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 348

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 190 75 190 20 190
hexapdf 5 15 20 15
liquid-render 5 137 75 137 20 137
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 810 75 810 20 810
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 26 15 20 15
30k_ifelse 5 52 75 52 20 52
30k_methods 5 22 29 22 20 22
cfunc_itself 5 441 75 441 20 441
fib 5 320 75 320 20 320
getivar 5 762 75 762 20 762
keyword_args 5 381 75 381 20 381
respond_to 5 102 75 102 20 102
setivar 5 1859 75 1859 20 1859
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) 1011291 751212 131 1232 0 0% 0 0 0
hexapdf (click) 1115035 874034 683 7704 10 0% 0 0 0
liquid-render (click) 507483 388604 150 1586 2 0% 0 0 0
mail (click) 914907 660895 374 5545 15 0% 0 0 0
psych-load (click) 341403 256177 68 474 1 0% 0 0 0
railsbench (click) 2619419 1912275 1435 9797 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 379611 283640 88 988 0 0% 0 0 0
discourse (click) 5913051 4379120 3196 25407 83 0% 2 0 0
erubi (click) 322395 242528 10 79 0 0% 0 0 0
erubi_rails (click) 1931867 1389486 300 1995 4 0% 0 0 0
fannkuchredux (click) 185883 139427 10 188 0 0% 0 0 0
lee (click) 377435 283058 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) 320731 253367 144 1588 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) 170267 127223 10 49 0 0% 0 0 0
fib (click) 168795 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.