YJIT Benchmarks

2022-08-09 05:17:10

As of 2022-08-09 05:17:10:

Overall YJIT is 36.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 36.0% 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 152.2 0.45% 154.9 0.46% 103.1 0.72% 0.98x 0.64% 1.48x 0.85% 85.93%
hexapdf 3219.4 1.01% 2392.0 2.39% 1.35x 2.59% 82.66%
liquid-render 195.9 1.00% 168.8 1.66% 125.9 1.65% 1.16x 1.94% 1.56x 1.93% 85.90%
mail 179.5 0.11% 173.2 2.28% 154.1 0.20% 1.04x 2.28% 1.16x 0.23% 99.37%
psych-load 2574.3 0.18% 2156.7 0.01% 1951.8 0.03% 1.19x 0.18% 1.32x 0.18% 88.89%
railsbench 2804.6 0.66% 2809.1 0.58% 2061.8 0.72% 1.00x 0.88% 1.36x 0.98% 86.54%
binarytrees 475.0 0.05% 305.3 0.32% 369.4 0.05% 1.56x 0.33% 1.29x 0.07% 84.27%
chunky_png 973.9 0.04% 783.6 0.39% 644.2 0.05% 1.24x 0.39% 1.51x 0.07% 99.95%
erubi 369.3 0.59% 341.3 0.69% 323.1 0.71% 1.08x 0.90% 1.14x 0.92% 100.00%
erubi_rails 27.3 2.59% 27.1 2.52% 19.2 3.69% 1.01x 3.62% 1.42x 4.51% 86.40%
fannkuchredux 6889.9 0.17% 3956.5 0.10% 6906.2 0.10% 1.74x 0.20% 1.00x 0.20% 0.02%
lee 1248.1 0.20% 1040.3 0.38% 933.2 0.27% 1.20x 0.43% 1.34x 0.34% 99.97%
nbody 127.6 0.51% 76.3 0.22% 91.1 0.08% 1.67x 0.56% 1.40x 0.52% 100.00%
optcarrot 6398.1 0.42% 2768.6 0.61% 3434.9 0.59% 2.31x 0.74% 1.86x 0.73% 96.16%
rubykon 12506.8 0.50% 8249.7 0.49% 6795.1 0.55% 1.52x 0.70% 1.84x 0.74% 99.69%
30k_ifelse 2377.4 0.03% 3533.3 4.01% 352.5 0.09% 0.67x 4.01% 6.74x 0.09% 100.00%
30k_methods 6312.5 0.05% 10150.3 17.19% 863.9 0.02% 0.62x 17.19% 7.31x 0.05% 100.00%
cfunc_itself 111.8 0.23% 69.3 1.14% 45.4 0.59% 1.61x 1.16% 2.46x 0.63% 100.00%
fib 260.0 0.16% 86.2 0.20% 63.3 0.04% 3.02x 0.26% 4.11x 0.17% 100.00%
getivar 105.8 0.47% 32.7 59.12% 44.2 0.09% 3.23x 59.12% 2.39x 0.48% 99.02%
keyword_args 294.7 0.08% 224.8 0.40% 53.2 0.09% 1.31x 0.41% 5.54x 0.12% 100.00%
respond_to 272.4 0.15% 227.8 0.51% 186.9 0.09% 1.20x 0.53% 1.46x 0.17% 100.00%
setivar 76.2 0.15% 20.9 63.15% 50.3 0.30% 3.65x 63.15% 1.52x 0.34% 99.14%
str_concat 83.1 1.01% 50.4 1.17% 42.8 1.76% 1.65x 1.55% 1.94x 2.03% 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-09T03:05:19Z master 44264b4fee) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-09T03:05:19Z master 44264b4fee) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 319 402
liquid-render 30 35 37
mail 49 53 56
psych-load 36 47 41
railsbench 104 106 133
binarytrees 31 33 33
chunky_png 44 50 49
erubi 70 76 93
erubi_rails 102 103 124
fannkuchredux 25 27 27
lee 32 42 39
nbody 25 26 27
optcarrot 59 66 65
rubykon 53 59 57
30k_ifelse 68 172 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 25 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 125 110 117

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 187 75 187 20 187
hexapdf 5 15 20 15
liquid-render 5 157 75 157 20 157
mail 5 129 75 129 20 129
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 31 75 31 20 31
erubi 5 61 75 61 20 61
erubi_rails 5 1031 75 1031 20 1031
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 262 75 262 20 262
optcarrot 5 15 75 15 20 15
rubykon 5 15 36 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 431 75 431 20 431
fib 5 315 75 315 20 315
getivar 5 611 75 611 20 611
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 466 75 466 20 466

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) 1036891 780219 131 1275 0 0% 0 0 0
hexapdf (click) 1150299 923986 682 8007 9 0% 0 0 0
liquid-render (click) 523291 406713 150 1706 2 0% 0 0 0
mail (click) 908443 655781 374 5406 17 0% 0 0 0
psych-load (click) 347355 263298 68 482 1 0% 0 0 0
railsbench (click) 2650971 1963521 1436 9982 16 0% 0 0 0
binarytrees (click) 171419 127952 13 58 0 0% 0 0 0
chunky_png (click) 389595 290917 88 1037 0 0% 0 0 0
erubi (click) 322843 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1962651 1429769 300 2031 4 0% 0 0 0
fannkuchredux (click) 185691 138378 10 188 0 0% 0 0 0
lee (click) 386075 291615 58 632 0 0% 0 0 0
nbody (click) 182491 137443 12 171 0 0% 0 0 0
optcarrot (click) 514395 442939 207 3588 20 0% 0 0 0
rubykon (click) 320411 256543 144 1571 1 0% 0 0 0
30k_ifelse (click) 5560475 4348420 9265 57804 0 0% 0 0 0
30k_methods (click) 2176603 1657507 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170395 127021 10 49 0 0% 0 0 0
fib (click) 169371 126958 10 38 0 0% 0 0 0
getivar (click) 170587 128716 10 65 0 0% 0 0 0
keyword_args (click) 170779 127366 11 51 0 0% 0 0 0
respond_to (click) 172059 128179 10 64 0 0% 0 0 0
setivar (click) 170523 127536 10 38 0 0% 0 0 0
str_concat (click) 170523 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.