YJIT Benchmarks

2022-06-19 20:14:21

As of 2022-06-19 20:14:21:

Overall YJIT is 34.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 31.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 151.9 0.34% 155.2 0.69% 103.6 0.59% 0.98x 0.77% 1.47x 0.68% 85.54%
hexapdf 3166.1 0.75% 2323.8 2.22% 1.36x 2.34% 83.42%
liquid-render 199.1 2.36% 172.8 1.92% 128.1 2.11% 1.15x 3.04% 1.55x 3.16% 85.70%
mail 180.8 0.14% 181.9 2.05% 161.1 0.20% 0.99x 2.06% 1.12x 0.25% 99.35%
psych-load 2588.4 0.41% 2138.2 0.04% 2047.4 0.12% 1.21x 0.41% 1.26x 0.43% 88.45%
railsbench 2786.2 0.79% 2832.6 0.75% 2117.7 1.36% 0.98x 1.09% 1.32x 1.58% 86.12%
binarytrees 472.2 0.05% 300.4 0.34% 361.3 0.06% 1.57x 0.35% 1.31x 0.07% 84.27%
chunky_png 975.9 0.05% 787.3 0.04% 663.3 0.07% 1.24x 0.07% 1.47x 0.09% 99.95%
discourse 538.6 1.67% 556.6 9.19% 485.9 9.47% 0.97x 9.34% 1.11x 9.62% 73.53%
erubi 465.6 0.54% 422.3 0.85% 392.4 0.60% 1.10x 1.00% 1.19x 0.81% 100.00%
erubi_rails 27.9 2.66% 28.2 2.10% 20.1 3.44% 0.99x 3.39% 1.39x 4.35% 86.30%
fannkuchredux 8676.9 0.14% 5713.0 0.25% 8885.0 0.17% 1.52x 0.29% 0.98x 0.22% 0.02%
lee 1260.9 0.08% 1037.8 0.14% 937.9 0.07% 1.21x 0.16% 1.34x 0.10% 99.97%
nbody 122.4 0.15% 72.9 0.28% 90.6 0.07% 1.68x 0.31% 1.35x 0.16% 100.00%
optcarrot 6342.6 0.42% 2591.3 0.60% 3434.9 0.61% 2.45x 0.73% 1.85x 0.74% 96.13%
rubykon 13151.5 2.90% 8973.4 2.81% 7641.1 3.16% 1.47x 4.04% 1.72x 4.29% 99.82%
30k_ifelse 2280.1 0.08% 3567.5 4.10% 354.5 0.08% 0.64x 4.10% 6.43x 0.12% 100.00%
30k_methods 6226.8 0.02% 10055.7 17.53% 889.8 0.02% 0.62x 17.53% 7.00x 0.03% 100.00%
cfunc_itself 105.1 0.21% 70.8 0.80% 44.8 0.62% 1.48x 0.83% 2.35x 0.65% 100.00%
fib 243.4 0.06% 86.2 0.21% 63.3 0.04% 2.82x 0.22% 3.84x 0.07% 100.00%
getivar 112.5 0.57% 26.2 69.04% 42.5 0.06% 4.30x 69.04% 2.64x 0.57% 99.21%
keyword_args 289.3 0.22% 231.3 1.25% 53.7 0.11% 1.25x 1.27% 5.39x 0.25% 100.00%
respond_to 278.9 0.71% 229.4 1.01% 188.7 0.16% 1.22x 1.23% 1.48x 0.73% 100.00%
setivar 83.8 0.73% 10.6 101.61% 54.0 0.24% 7.89x 101.61% 1.55x 0.77% 99.56%
str_concat 133.7 0.81% 101.6 0.87% 111.3 0.70% 1.32x 1.19% 1.20x 1.07% 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-06-19T17:34:57Z master 6622a41891) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-19T17:34:57Z master 6622a41891) +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 65 76
hexapdf 265 375
liquid-render 30 35 37
mail 49 54 56
psych-load 38 52 43
railsbench 103 105 131
binarytrees 30 33 33
chunky_png 41 43 45
discourse 398 419 461
erubi 67 108 80
erubi_rails 104 102 121
fannkuchredux 25 27 27
lee 33 40 38
nbody 24 26 27
optcarrot 59 66 65
rubykon 54 61 58
30k_ifelse 66 170 126
30k_methods 57 179 78
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 24 26 27
str_concat 113 93 98

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 155 75 155 20 155
mail 5 123 75 123 20 123
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 30 75 30 20 30
discourse 5 41 75 41 20 41
erubi 5 51 75 51 20 51
erubi_rails 5 1000 75 1000 20 1000
fannkuchredux 5 15 52 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 33 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 441 75 441 20 441
fib 5 315 75 315 20 315
getivar 5 760 75 760 20 760
keyword_args 5 377 75 377 20 377
respond_to 5 106 75 106 20 106
setivar 5 1875 75 1875 20 1875
str_concat 5 196 75 196 20 196

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) 1016475 755758 131 1259 0 0% 0 0 0
hexapdf (click) 1120667 879499 682 7753 10 0% 0 0 0
liquid-render (click) 512667 391903 150 1626 2 0% 0 0 0
mail (click) 918235 663342 375 5577 15 0% 0 0 0
psych-load (click) 339675 255124 68 457 1 0% 0 0 0
railsbench (click) 2624731 1918974 1436 9862 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 380315 284167 88 998 0 0% 0 0 0
discourse (click) 5943323 4412397 3222 25667 86 0% 2 0 0
erubi (click) 319515 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1931227 1391415 300 1992 4 0% 0 0 0
fannkuchredux (click) 188251 141143 10 188 0 0% 0 0 0
lee (click) 376347 282136 58 622 0 0% 0 0 0
nbody (click) 183707 137646 12 158 0 0% 0 0 0
optcarrot (click) 514907 442895 207 3571 20 0% 0 0 0
rubykon (click) 321051 253025 144 1552 1 0% 0 0 0
30k_ifelse (click) 5563291 4350769 9265 57804 0 0% 0 0 0
30k_methods (click) 2178459 1659231 5784 19361 0 0% 0 0 0
cfunc_itself (click) 172763 129074 10 49 0 0% 0 0 0
fib (click) 169819 127821 10 38 0 0% 0 0 0
getivar (click) 173019 131193 10 65 0 0% 0 0 0
keyword_args (click) 173595 129715 11 51 0 0% 0 0 0
respond_to (click) 174875 130528 10 64 0 0% 0 0 0
setivar (click) 172059 129152 10 38 0 0% 0 0 0
str_concat (click) 172955 130037 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.