YJIT Benchmarks

2022-08-08 05:15:18

As of 2022-08-08 05:15:18:

Overall YJIT is 36.2% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.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 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 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 154.0 1.97% 157.6 0.31% 102.1 0.62% 0.98x 1.99% 1.51x 2.06% 85.93%
hexapdf 3218.4 1.09% 2370.0 1.86% 1.36x 2.16% 83.81%
liquid-render 196.2 0.96% 173.1 1.55% 126.2 1.80% 1.13x 1.82% 1.55x 2.04% 85.90%
mail 178.2 0.15% 174.4 2.36% 154.3 0.21% 1.02x 2.36% 1.15x 0.26% 99.34%
psych-load 2476.7 0.02% 2112.1 0.05% 1923.2 0.01% 1.17x 0.06% 1.29x 0.03% 88.89%
railsbench 2796.2 0.73% 2801.5 0.90% 2077.8 1.11% 1.00x 1.16% 1.35x 1.33% 86.54%
binarytrees 476.1 0.05% 306.2 0.33% 367.0 0.05% 1.55x 0.33% 1.30x 0.07% 84.27%
chunky_png 987.3 0.04% 784.5 0.37% 645.8 0.04% 1.26x 0.37% 1.53x 0.05% 99.95%
erubi 368.2 0.71% 336.5 0.65% 315.5 0.74% 1.09x 0.97% 1.17x 1.02% 100.00%
erubi_rails 27.5 2.57% 27.0 2.54% 19.6 3.53% 1.02x 3.61% 1.40x 4.37% 86.40%
fannkuchredux 6923.2 0.34% 4025.6 0.12% 6905.2 0.23% 1.72x 0.36% 1.00x 0.41% 0.02%
lee 1250.3 0.20% 1030.9 0.31% 934.8 0.29% 1.21x 0.37% 1.34x 0.35% 99.97%
nbody 130.3 0.32% 76.4 0.26% 91.1 0.08% 1.71x 0.41% 1.43x 0.33% 100.00%
optcarrot 6351.1 0.43% 2784.2 0.60% 3447.0 0.61% 2.28x 0.74% 1.84x 0.74% 96.16%
rubykon 12375.5 0.48% 8038.2 0.88% 6799.7 1.10% 1.54x 1.00% 1.82x 1.21% 99.75%
30k_ifelse 2334.9 0.02% 3643.9 3.90% 355.1 0.10% 0.64x 3.90% 6.58x 0.10% 100.00%
30k_methods 6195.4 0.05% 10155.7 16.69% 875.9 0.02% 0.61x 16.69% 7.07x 0.06% 100.00%
cfunc_itself 111.1 0.18% 91.6 1.27% 45.6 0.60% 1.21x 1.28% 2.44x 0.63% 100.00%
fib 259.5 0.14% 86.2 0.28% 63.3 0.04% 3.01x 0.31% 4.10x 0.15% 100.00%
getivar 105.7 0.49% 32.6 56.35% 44.2 0.12% 3.25x 56.36% 2.39x 0.51% 99.02%
keyword_args 288.3 0.08% 235.8 3.68% 53.5 0.11% 1.22x 3.68% 5.39x 0.14% 100.00%
respond_to 272.8 0.23% 229.6 0.72% 188.0 0.49% 1.19x 0.75% 1.45x 0.54% 100.00%
setivar 76.7 0.24% 20.9 63.29% 49.7 0.10% 3.67x 63.29% 1.54x 0.26% 99.14%
str_concat 83.6 1.02% 50.4 1.22% 42.9 1.71% 1.66x 1.59% 1.95x 2.00% 99.69%

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-08-08T00:42:31Z master 1607c6d281) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-08T00:42:31Z master 1607c6d281) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 295 397
liquid-render 31 36 37
mail 49 53 56
psych-load 36 46 40
railsbench 104 105 131
binarytrees 31 33 33
chunky_png 44 49 48
erubi 65 97 95
erubi_rails 102 104 122
fannkuchredux 25 27 27
lee 32 40 39
nbody 25 26 27
optcarrot 59 66 65
rubykon 53 60 57
30k_ifelse 68 171 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 125 110 110

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 196 75 196 20 196
hexapdf 5 15 20 15
liquid-render 5 158 75 158 20 158
mail 5 129 75 129 20 129
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 65 75 65 20 65
chunky_png 5 31 75 31 20 31
erubi 5 62 75 62 20 62
erubi_rails 5 1032 75 1032 20 1032
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 261 75 261 20 261
optcarrot 5 15 75 15 20 15
rubykon 5 15 37 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 22 29 22 20 22
cfunc_itself 5 446 75 446 20 446
fib 5 315 75 315 20 315
getivar 5 613 75 613 20 613
keyword_args 5 379 75 379 20 379
respond_to 5 106 75 106 20 106
setivar 5 959 75 959 20 959
str_concat 5 465 75 465 20 465

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) 1037659 781094 131 1287 0 0% 0 0 0
hexapdf (click) 1150939 924675 682 8013 9 0% 0 0 0
liquid-render (click) 514267 400163 150 1621 2 0% 0 0 0
mail (click) 930907 670742 374 5621 17 0% 0 0 0
psych-load (click) 348315 264154 68 482 1 0% 0 0 0
railsbench (click) 2656923 1968057 1436 10038 16 0% 0 0 0
binarytrees (click) 172443 128577 13 58 0 0% 0 0 0
chunky_png (click) 385435 288233 88 998 0 0% 0 0 0
erubi (click) 323867 246845 10 79 0 0% 0 0 0
erubi_rails (click) 1960859 1428135 300 2020 4 0% 0 0 0
fannkuchredux (click) 185307 138082 10 188 0 0% 0 0 0
lee (click) 386203 291615 58 632 0 0% 0 0 0
nbody (click) 182107 137147 12 171 0 0% 0 0 0
optcarrot (click) 513499 442314 207 3588 20 0% 0 0 0
rubykon (click) 321499 257148 144 1578 1 0% 0 0 0
30k_ifelse (click) 5560731 4348431 9265 57804 0 0% 0 0 0
30k_methods (click) 2176219 1657211 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170459 127021 10 49 0 0% 0 0 0
fib (click) 169435 126958 10 38 0 0% 0 0 0
getivar (click) 170715 128749 10 65 0 0% 0 0 0
keyword_args (click) 170843 127366 11 51 0 0% 0 0 0
respond_to (click) 172123 128179 10 64 0 0% 0 0 0
setivar (click) 170139 127240 10 38 0 0% 0 0 0
str_concat (click) 170587 127868 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.