YJIT Benchmarks

2022-05-08 19:12:50

As of 2022-05-08 19:12:50:

Overall YJIT is 35.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 33.3% 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.8 0.45% 177.4 3.92% 104.6 0.66% 0.87x 3.94% 1.48x 0.80% 85.01%
hexapdf 3226.4 1.14% 2394.0 2.10% 1.35x 2.39% 82.60%
liquid-render 194.4 1.92% 185.0 1.59% 125.5 1.86% 1.05x 2.50% 1.55x 2.68% 85.70%
mail 181.4 0.53% 175.1 1.20% 160.7 0.38% 1.04x 1.31% 1.13x 0.65% 99.29%
psych-load 2495.6 0.04% 2291.0 0.07% 1920.5 0.03% 1.09x 0.08% 1.30x 0.05% 88.45%
railsbench 2828.7 0.85% 3156.5 0.94% 2121.3 1.40% 0.90x 1.27% 1.33x 1.64% 86.09%
binarytrees 469.6 1.11% 314.5 2.50% 362.4 1.48% 1.49x 2.73% 1.30x 1.85% 84.27%
chunky_png 980.4 0.13% 785.2 0.28% 660.9 0.12% 1.25x 0.31% 1.48x 0.17% 99.95%
discourse 548.1 6.73% 547.6 1.25% 513.2 16.82% 1.00x 6.84% 1.07x 18.11% 73.75%
erubi 466.6 0.71% 426.2 0.82% 422.0 0.76% 1.09x 1.09% 1.11x 1.04% 100.00%
erubi_rails 27.3 2.49% 28.7 3.92% 19.8 3.72% 0.95x 4.65% 1.38x 4.48% 86.30%
fannkuchredux 6965.7 0.09% 4084.3 0.07% 7058.7 0.25% 1.71x 0.11% 0.99x 0.27% 0.01%
lee 1235.5 0.43% 1018.0 0.78% 915.6 0.31% 1.21x 0.89% 1.35x 0.53% 99.97%
nbody 123.1 0.07% 76.2 2.03% 87.8 0.51% 1.62x 2.03% 1.40x 0.52% 100.00%
optcarrot 6190.3 0.43% 2581.4 0.63% 3447.1 0.60% 2.40x 0.76% 1.80x 0.74% 96.13%
rubykon 13665.7 0.61% 10720.3 1.76% 7959.4 0.66% 1.27x 1.86% 1.72x 0.89% 99.53%
30k_ifelse 2402.1 0.02% 3445.2 3.81% 354.1 0.18% 0.70x 3.81% 6.78x 0.18% 100.00%
30k_methods 6747.8 0.01% 10151.1 18.42% 881.3 0.06% 0.66x 18.42% 7.66x 0.06% 100.00%
cfunc_itself 108.6 0.12% 69.0 0.65% 44.8 0.96% 1.57x 0.66% 2.42x 0.97% 100.00%
fib 248.4 0.09% 86.1 0.11% 62.6 0.66% 2.88x 0.14% 3.97x 0.67% 100.00%
getivar 108.1 0.53% 26.1 67.65% 42.6 0.73% 4.13x 67.65% 2.54x 0.90% 99.21%
keyword_args 287.5 0.07% 231.5 1.57% 52.9 0.94% 1.24x 1.57% 5.43x 0.95% 100.00%
respond_to 269.5 0.15% 224.1 0.98% 187.3 0.39% 1.20x 1.00% 1.44x 0.42% 100.00%
setivar 75.9 0.27% 10.9 101.35% 54.3 0.57% 6.97x 101.35% 1.40x 0.63% 99.55%
str_concat 137.1 0.77% 105.3 1.29% 112.3 1.57% 1.30x 1.51% 1.22x 1.75% 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-08T14:05:55Z master 98e3fdb444) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-08T14:05:55Z master 98e3fdb444) +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 279 613
liquid-render 31 36 293
mail 48 52 310
psych-load 36 47 295
railsbench 101 133 383
binarytrees 29 31 287
chunky_png 37 48 303
discourse 387 430 702
erubi 89 94 357
erubi_rails 103 107 376
fannkuchredux 24 27 282
lee 33 40 294
nbody 24 26 282
optcarrot 58 66 320
rubykon 48 80 308
30k_ifelse 66 167 376
30k_methods 55 182 327
cfunc_itself 24 27 282
fib 24 26 282
getivar 24 26 282
keyword_args 24 27 282
respond_to 24 27 282
setivar 24 26 282
str_concat 102 92 351

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 158 75 158 20 158
mail 5 124 75 124 20 124
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 66 75 66 20 66
chunky_png 5 29 75 29 20 29
discourse 5 37 75 37 20 37
erubi 5 47 75 47 20 47
erubi_rails 5 946 75 946 20 946
fannkuchredux 5 15 73 15 20 15
lee 5 21 75 21 20 21
nbody 5 267 75 267 20 267
optcarrot 5 15 75 15 20 15
rubykon 5 15 27 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 445 75 445 20 445
fib 5 319 75 319 20 319
getivar 5 769 75 769 20 769
keyword_args 5 372 75 372 20 372
respond_to 5 104 75 104 20 104
setivar 5 1839 75 1839 20 1839
str_concat 5 189 75 189 20 189

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) 1010011 750440 131 1229 0 0% 0 0 0
hexapdf (click) 1112987 872329 683 7683 10 0% 0 0 0
liquid-render (click) 514203 393956 150 1653 2 0% 0 0 0
mail (click) 891739 645712 375 5333 15 0% 0 0 0
psych-load (click) 339675 255527 68 457 1 0% 0 0 0
railsbench (click) 2618011 1910568 1435 9770 16 0% 0 0 0
binarytrees (click) 173211 129880 13 58 0 0% 0 0 0
chunky_png (click) 375835 281139 88 962 0 0% 0 0 0
discourse (click) 5875675 4353405 3186 25162 82 0% 2 0 0
erubi (click) 322267 242503 10 79 0 0% 0 0 0
erubi_rails (click) 1928411 1387439 300 1963 4 0% 0 0 0
fannkuchredux (click) 187227 140578 10 188 0 0% 0 0 0
lee (click) 377883 283455 58 618 0 0% 0 0 0
nbody (click) 182683 137081 12 158 0 0% 0 0 0
optcarrot (click) 514139 442708 207 3571 20 0% 0 0 0
rubykon (click) 317787 250519 144 1528 1 0% 0 0 0
30k_ifelse (click) 5562267 4350204 9265 57804 0 0% 0 0 0
30k_methods (click) 2178075 1658902 5784 19365 0 0% 0 0 0
cfunc_itself (click) 171739 128509 10 49 0 0% 0 0 0
fib (click) 170203 128117 10 38 0 0% 0 0 0
getivar (click) 171995 130628 10 65 0 0% 0 0 0
keyword_args (click) 172571 129150 11 51 0 0% 0 0 0
respond_to (click) 173851 129963 10 64 0 0% 0 0 0
setivar (click) 171931 129152 10 38 0 0% 0 0 0
str_concat (click) 171419 129176 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.