YJIT Benchmarks

2022-05-14 07:15:15

As of 2022-05-14 07:15:15:

Overall YJIT is 32.9% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 28.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 1.6 No JIT MJIT 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 MJIT 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 MJIT 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 MJIT (ms) MJIT RSD YJIT (ms) YJIT RSD MJIT spd MJIT spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 169.7 2.24% 202.5 5.25% 105.7 0.48% 0.84x 5.71% 1.60x 2.29% 85.54%
hexapdf 3223.2 0.94% 2387.7 1.68% 1.35x 1.93% 82.67%
liquid-render 209.3 1.00% 205.2 1.35% 145.7 1.79% 1.02x 1.68% 1.44x 2.05% 85.70%
mail 205.9 2.27% 218.1 3.16% 187.8 2.60% 0.94x 3.89% 1.10x 3.45% 99.36%
psych-load 2808.4 0.26% 2344.9 0.14% 2234.3 0.05% 1.20x 0.29% 1.26x 0.26% 88.45%
railsbench 3121.3 0.58% 3480.4 0.51% 2427.0 0.30% 0.90x 0.77% 1.29x 0.65% 86.19%
binarytrees 486.1 0.11% 308.2 0.30% 369.2 0.16% 1.58x 0.32% 1.32x 0.19% 84.27%
chunky_png 1007.3 0.26% 799.3 0.58% 666.4 0.21% 1.26x 0.64% 1.51x 0.33% 99.95%
discourse 599.2 16.33% 620.1 14.28% 682.5 22.66% 0.97x 21.69% 0.88x 27.93% 73.53%
erubi 502.4 0.58% 473.4 0.84% 442.3 0.69% 1.06x 1.02% 1.14x 0.90% 100.00%
erubi_rails 32.2 39.41% 34.7 42.74% 25.2 55.11% 0.93x 58.14% 1.27x 67.75% 86.29%
fannkuchredux 9010.4 0.12% 4088.9 0.05% 7066.6 0.30% 2.20x 0.13% 1.28x 0.32% 0.02%
lee 1261.1 0.15% 1050.4 0.10% 925.8 0.17% 1.20x 0.19% 1.36x 0.23% 99.97%
nbody 124.9 0.15% 72.7 0.10% 89.5 0.47% 1.72x 0.18% 1.40x 0.49% 100.00%
optcarrot 6105.3 0.45% 2537.2 0.62% 3407.0 0.63% 2.41x 0.77% 1.79x 0.77% 96.13%
rubykon 13773.8 1.78% 11593.5 1.24% 8082.4 3.86% 1.19x 2.17% 1.70x 4.25% 99.83%
30k_ifelse 2283.3 0.03% 3493.8 3.79% 355.2 0.18% 0.65x 3.79% 6.43x 0.18% 100.00%
30k_methods 6429.1 0.05% 10139.1 16.71% 877.2 0.07% 0.63x 16.71% 7.33x 0.08% 100.00%
cfunc_itself 108.1 0.17% 68.6 0.17% 44.9 0.98% 1.57x 0.24% 2.41x 1.00% 100.00%
fib 246.7 1.06% 86.1 0.08% 62.5 0.59% 2.86x 1.06% 3.95x 1.21% 100.00%
getivar 110.9 1.69% 26.1 69.59% 42.6 0.70% 4.25x 69.61% 2.60x 1.83% 99.21%
keyword_args 288.6 0.07% 222.5 0.35% 52.6 0.65% 1.30x 0.36% 5.48x 0.65% 100.00%
respond_to 271.8 0.47% 230.4 0.46% 194.3 0.25% 1.18x 0.66% 1.40x 0.53% 100.00%
setivar 79.1 0.54% 10.7 101.63% 53.9 0.59% 7.37x 101.63% 1.47x 0.80% 99.55%
str_concat 134.6 0.81% 103.8 1.15% 110.9 1.45% 1.30x 1.41% 1.21x 1.66% 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 MJIT 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 and the yjit-extra-benchmarks 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-13T20:26:41Z master 708e839dee) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-05-13T20:26:41Z master 708e839dee) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 73 331
hexapdf 253 598
liquid-render 30 35 292
mail 49 53 311
psych-load 39 47 299
railsbench 102 136 383
binarytrees 30 33 288
chunky_png 45 47 304
discourse 389 401 694
erubi 34 39 294
erubi_rails 101 106 374
fannkuchredux 25 28 282
lee 31 38 293
nbody 24 27 283
optcarrot 58 67 320
rubykon 50 80 310
30k_ifelse 67 168 375
30k_methods 57 184 331
cfunc_itself 24 27 282
fib 24 27 282
getivar 24 27 282
keyword_args 25 27 282
respond_to 24 27 283
setivar 24 27 282
str_concat 113 93 354

Memory is shown in mebibytes (1024 * 1024 bytes.)

Older YJIT allocated an additional 256MiB for generated code. Current YJIT allocates executable memory on demand, so this overhead should no longer be present.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT warmups MJIT iters YJIT warmups YJIT iters
activerecord 5 188 75 188 20 188
hexapdf 5 15 20 15
liquid-render 5 135 75 135 20 135
mail 5 107 75 107 20 107
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 47 75 47 20 47
erubi_rails 5 775 75 775 20 775
fannkuchredux 5 15 72 15 20 15
lee 5 21 75 21 20 21
nbody 5 274 75 274 20 274
optcarrot 5 15 75 15 20 15
rubykon 5 15 25 15 20 15
30k_ifelse 5 55 75 55 20 55
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 762 75 762 20 762
keyword_args 5 358 75 358 20 358
respond_to 5 103 75 103 20 103
setivar 5 1859 75 1859 20 1859
str_concat 5 195 75 195 20 195

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) 1016795 756065 131 1272 0 0% 0 0 0
hexapdf (click) 1119835 878882 682 7752 10 0% 0 0 0
liquid-render (click) 502683 385528 150 1524 2 0% 0 0 0
mail (click) 937947 677335 374 5784 15 0% 0 0 0
psych-load (click) 339803 255297 68 462 1 0% 0 0 0
railsbench (click) 2636187 1925708 1436 9826 16 0% 0 0 0
binarytrees (click) 171867 128729 13 58 0 0% 0 0 0
chunky_png (click) 376475 281686 88 968 0 0% 0 0 0
discourse (click) 5955739 4417510 3195 25515 84 0% 2 0 0
erubi (click) 319387 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1949467 1402233 300 1987 4 0% 0 0 0
fannkuchredux (click) 185883 139427 10 188 0 0% 0 0 0
lee (click) 378267 283852 58 622 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) 319579 252064 144 1561 1 0% 0 0 0
30k_ifelse (click) 5560411 4348757 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) 171163 127864 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.