YJIT Benchmarks

2022-05-12 19:13:34

As of 2022-05-12 19:13:34:

Overall YJIT is 29.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 28.4% 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.2 0.36% 171.1 4.04% 106.0 0.47% 0.89x 4.05% 1.44x 0.59% 85.01%
hexapdf 3267.5 0.94% 2371.8 1.74% 1.38x 1.98% 83.71%
liquid-render 216.7 1.05% 204.4 1.36% 146.2 1.76% 1.06x 1.71% 1.48x 2.05% 85.70%
mail 202.9 2.02% 208.1 3.28% 187.1 2.63% 0.98x 3.85% 1.08x 3.32% 99.34%
psych-load 2588.0 0.14% 2309.7 0.06% 2236.6 0.07% 1.12x 0.15% 1.16x 0.16% 88.45%
railsbench 3113.9 0.50% 3482.9 0.72% 2424.5 0.33% 0.89x 0.88% 1.28x 0.60% 86.09%
binarytrees 479.7 0.04% 310.4 0.26% 367.9 0.16% 1.55x 0.26% 1.30x 0.16% 84.27%
chunky_png 983.2 0.27% 800.9 0.52% 675.7 0.20% 1.23x 0.58% 1.46x 0.34% 99.95%
discourse 586.8 15.21% 604.5 15.76% 616.1 18.85% 0.97x 21.91% 0.95x 24.22% 73.07%
erubi 500.5 1.31% 470.7 0.96% 438.9 0.56% 1.06x 1.63% 1.14x 1.43% 100.00%
erubi_rails 33.0 37.04% 35.0 41.96% 25.3 54.96% 0.94x 55.97% 1.30x 66.28% 86.30%
fannkuchredux 7391.4 11.03% 4025.1 0.05% 6929.6 0.10% 1.84x 11.03% 1.07x 11.03% 0.02%
lee 1264.9 0.27% 1007.9 1.07% 916.3 1.23% 1.26x 1.10% 1.38x 1.26% 99.97%
nbody 124.6 0.11% 72.7 0.18% 89.6 0.46% 1.71x 0.21% 1.39x 0.47% 100.00%
optcarrot 6190.2 0.43% 2581.7 0.63% 3451.2 0.62% 2.40x 0.76% 1.79x 0.75% 96.13%
rubykon 13804.4 1.79% 11601.2 1.35% 8041.5 3.20% 1.19x 2.24% 1.72x 3.66% 99.68%
30k_ifelse 2304.7 0.02% 3483.0 3.72% 364.8 0.20% 0.66x 3.72% 6.32x 0.20% 100.00%
30k_methods 6441.8 0.04% 10098.7 17.31% 926.5 0.06% 0.64x 17.31% 6.95x 0.07% 100.00%
cfunc_itself 108.0 0.15% 70.6 1.58% 45.0 0.99% 1.53x 1.59% 2.40x 1.00% 100.00%
fib 245.2 0.40% 86.1 0.03% 62.5 0.61% 2.85x 0.40% 3.92x 0.73% 100.00%
getivar 111.2 1.47% 26.2 68.57% 42.6 0.70% 4.24x 68.58% 2.61x 1.63% 99.21%
keyword_args 286.8 0.07% 227.3 3.27% 53.5 0.69% 1.26x 3.27% 5.37x 0.69% 100.00%
respond_to 271.6 0.13% 229.3 0.52% 193.1 0.29% 1.18x 0.54% 1.41x 0.32% 100.00%
setivar 79.1 0.53% 10.7 101.29% 53.9 0.62% 7.37x 101.29% 1.47x 0.82% 99.55%
str_concat 132.4 0.87% 96.2 1.35% 108.0 1.43% 1.38x 1.61% 1.23x 1.67% 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-12T19:08:52Z master 30d0f08c83) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-05-12T19:08:52Z master 30d0f08c83) +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 65 72 331
hexapdf 194 616
liquid-render 30 35 292
mail 49 52 312
psych-load 40 51 299
railsbench 102 138 383
binarytrees 31 33 288
chunky_png 41 46 303
discourse 388 399 707
erubi 35 39 294
erubi_rails 102 105 376
fannkuchredux 25 28 283
lee 31 40 296
nbody 24 27 283
optcarrot 58 67 320
rubykon 51 80 310
30k_ifelse 66 167 375
30k_methods 57 184 332
cfunc_itself 25 27 282
fib 24 27 282
getivar 25 27 282
keyword_args 24 28 282
respond_to 24 27 282
setivar 25 27 282
str_concat 110 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 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 34 75 34 20 34
erubi 5 47 75 47 20 47
erubi_rails 5 807 75 807 20 807
fannkuchredux 5 15 65 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 54 75 54 20 54
30k_methods 5 22 29 22 20 22
cfunc_itself 5 438 75 438 20 438
fib 5 320 75 320 20 320
getivar 5 769 75 769 20 769
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 197 75 197 20 197

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) 1011099 751227 131 1232 0 0% 0 0 0
hexapdf (click) 1114011 873798 682 7699 10 0% 0 0 0
liquid-render (click) 504923 387375 150 1554 2 0% 0 0 0
mail (click) 913883 660046 374 5537 15 0% 0 0 0
psych-load (click) 338971 254677 68 457 1 0% 0 0 0
railsbench (click) 2623387 1915445 1436 9830 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 380251 283911 88 1001 0 0% 0 0 0
discourse (click) 5890907 4367338 3197 25266 83 0% 2 0 0
erubi (click) 319451 242761 10 79 0 0% 0 0 0
erubi_rails (click) 1931803 1390392 300 2006 4 0% 0 0 0
fannkuchredux (click) 185371 139131 10 188 0 0% 0 0 0
lee (click) 377755 283415 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) 317083 249961 144 1538 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) 168347 126670 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.