YJIT Benchmarks

2022-05-10 19:17:43

As of 2022-05-10 19:17:43:

Overall YJIT is 28.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 26.9% 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.37% 174.8 3.51% 106.9 0.48% 0.88x 3.53% 1.44x 0.60% 85.01%
hexapdf 3249.9 0.73% 2383.4 2.03% 1.36x 2.16% 83.15%
liquid-render 212.0 1.03% 203.6 1.39% 145.2 1.86% 1.04x 1.73% 1.46x 2.13% 85.70%
mail 204.7 2.35% 204.9 3.25% 189.1 2.47% 1.00x 4.01% 1.08x 3.41% 99.36%
psych-load 2739.1 0.02% 2383.1 0.15% 2398.2 0.07% 1.15x 0.15% 1.14x 0.07% 88.45%
railsbench 3125.0 0.24% 3489.9 0.68% 2461.7 0.94% 0.90x 0.72% 1.27x 0.97% 86.09%
binarytrees 478.3 0.03% 307.7 0.32% 367.7 0.16% 1.55x 0.32% 1.30x 0.17% 84.27%
chunky_png 980.6 0.12% 800.2 0.56% 682.4 0.18% 1.23x 0.57% 1.44x 0.22% 99.95%
discourse 590.6 15.50% 619.2 14.92% 624.1 18.74% 0.95x 21.52% 0.95x 24.32% 73.78%
erubi 511.1 0.49% 470.6 1.07% 446.5 0.77% 1.09x 1.18% 1.14x 0.91% 100.00%
erubi_rails 32.2 39.47% 35.0 42.19% 25.5 55.46% 0.92x 57.77% 1.26x 68.07% 86.29%
fannkuchredux 7617.3 11.60% 5905.7 0.34% 8946.8 0.14% 1.29x 11.60% 0.85x 11.60% 0.02%
lee 1262.2 2.35% 1043.6 0.45% 930.3 0.14% 1.21x 2.40% 1.36x 2.36% 99.97%
nbody 124.2 0.15% 72.6 0.03% 89.1 0.50% 1.71x 0.16% 1.39x 0.52% 100.00%
optcarrot 6206.9 0.41% 2596.3 0.60% 3431.7 0.60% 2.39x 0.73% 1.81x 0.73% 96.13%
rubykon 13632.9 1.67% 11491.9 1.51% 7863.4 2.41% 1.19x 2.25% 1.73x 2.93% 99.59%
30k_ifelse 2277.0 0.02% 3406.1 3.88% 353.7 0.19% 0.67x 3.88% 6.44x 0.19% 100.00%
30k_methods 6479.2 0.01% 10239.3 15.47% 874.4 0.06% 0.63x 15.47% 7.41x 0.06% 100.00%
cfunc_itself 116.9 0.53% 69.2 0.33% 45.8 1.01% 1.69x 0.63% 2.55x 1.14% 100.00%
fib 248.0 0.84% 86.1 0.02% 62.5 0.57% 2.88x 0.84% 3.97x 1.02% 100.00%
getivar 110.2 0.81% 26.1 69.43% 42.6 0.73% 4.22x 69.43% 2.59x 1.10% 99.21%
keyword_args 288.5 0.09% 225.6 0.86% 52.5 0.68% 1.28x 0.87% 5.50x 0.68% 100.00%
respond_to 272.1 0.54% 233.6 0.56% 193.5 0.26% 1.16x 0.78% 1.41x 0.60% 100.00%
setivar 79.0 0.66% 10.7 101.48% 53.9 0.62% 7.35x 101.48% 1.47x 0.90% 99.55%
str_concat 134.8 0.82% 103.3 1.13% 110.4 1.49% 1.31x 1.40% 1.22x 1.70% 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 144 620
liquid-render 30 35 292
mail 49 53 311
psych-load 36 49 299
railsbench 102 135 382
binarytrees 30 33 288
chunky_png 43 47 303
discourse 388 401 708
erubi 34 43 298
erubi_rails 102 106 375
fannkuchredux 25 28 282
lee 34 38 293
nbody 24 26 283
optcarrot 59 67 320
rubykon 50 80 310
30k_ifelse 66 166 375
30k_methods 57 184 331
cfunc_itself 24 27 282
fib 24 27 282
getivar 24 27 282
keyword_args 24 27 282
respond_to 24 27 282
setivar 25 27 283
str_concat 111 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 175 75 175 20 175
hexapdf 5 15 20 15
liquid-render 5 136 75 136 20 136
mail 5 107 75 107 20 107
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 62 75 62 20 62
chunky_png 5 29 75 29 20 29
discourse 5 33 75 33 20 33
erubi 5 45 75 45 20 45
erubi_rails 5 822 75 822 20 822
fannkuchredux 5 15 73 15 20 15
lee 5 21 75 21 20 21
nbody 5 248 75 248 20 248
optcarrot 5 15 75 15 20 15
rubykon 5 15 25 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 21 29 21 20 21
cfunc_itself 5 442 75 442 20 442
fib 5 320 75 320 20 320
getivar 5 766 75 766 20 766
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 194 75 194 20 194

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) 1013915 752753 131 1260 0 0% 0 0 0
hexapdf (click) 1113755 873301 682 7697 10 0% 0 0 0
liquid-render (click) 505691 387538 150 1553 2 0% 0 0 0
mail (click) 915611 661734 374 5563 15 0% 0 0 0
psych-load (click) 339547 255149 68 457 1 0% 0 0 0
railsbench (click) 2616155 1910452 1435 9766 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 381659 284857 88 1021 0 0% 0 0 0
discourse (click) 5845595 4333118 3161 24869 81 0% 2 0 0
erubi (click) 322395 242503 10 79 0 0% 0 0 0
erubi_rails (click) 1931227 1389289 300 1987 4 0% 0 0 0
fannkuchredux (click) 185883 139427 10 188 0 0% 0 0 0
lee (click) 377947 283455 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) 316699 249762 144 1534 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.