YJIT Benchmarks

2022-09-17 05:25:41

As of 2022-09-17 05:25:41:

Overall YJIT is 36.4% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 31.1% 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 2.0 4.0 6.0 8.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 149.8 0.47% 183.2 4.96% 102.2 0.61% 0.82x 4.98% 1.47x 0.77% 85.28%
hexapdf 3184.8 0.74% 2327.7 2.57% 1.37x 2.67% 82.85%
liquid-render 191.2 1.00% 165.5 1.19% 111.4 1.81% 1.16x 1.55% 1.72x 2.07% 85.97%
mail 176.0 0.15% 175.0 2.19% 156.2 0.24% 1.01x 2.20% 1.13x 0.28% 99.32%
psych-load 2420.2 0.03% 2114.5 0.02% 1911.1 0.01% 1.14x 0.03% 1.27x 0.03% 88.89%
railsbench 2745.7 0.60% 2990.5 0.72% 2095.1 1.05% 0.92x 0.94% 1.31x 1.21% 86.28%
binarytrees 473.4 0.05% 313.8 0.88% 240.0 0.07% 1.51x 0.88% 1.97x 0.08% 100.00%
chunky_png 960.2 0.13% 786.8 0.04% 654.4 0.17% 1.22x 0.13% 1.47x 0.22% 99.95%
erubi 337.4 0.67% 314.9 0.54% 299.6 0.77% 1.07x 0.86% 1.13x 1.02% 100.00%
erubi_rails 26.1 2.64% 27.9 10.22% 19.2 3.63% 0.94x 10.55% 1.36x 4.49% 86.35%
fannkuchredux 5372.4 0.06% 2473.8 0.03% 2373.0 0.06% 2.17x 0.07% 2.26x 0.08% 77.42%
lee 1229.9 0.87% 1031.6 1.53% 943.4 0.94% 1.19x 1.76% 1.30x 1.28% 99.97%
nbody 120.6 0.12% 75.1 0.04% 90.9 0.10% 1.61x 0.13% 1.33x 0.16% 100.00%
optcarrot 6029.2 0.43% 2707.0 0.65% 3542.9 0.61% 2.23x 0.78% 1.70x 0.75% 96.16%
rubykon 12419.3 0.44% 9306.5 0.46% 6819.5 0.95% 1.33x 0.63% 1.82x 1.05% 99.81%
30k_ifelse 2328.1 0.01% 4112.6 3.09% 361.2 0.11% 0.57x 3.09% 6.45x 0.11% 100.00%
30k_methods 6788.0 0.09% 12968.2 4.48% 789.1 0.02% 0.52x 4.48% 8.60x 0.09% 100.00%
cfunc_itself 106.1 0.17% 98.2 0.08% 46.7 0.67% 1.08x 0.19% 2.27x 0.69% 100.00%
fib 257.4 0.04% 79.2 0.03% 62.9 0.04% 3.25x 0.05% 4.09x 0.06% 100.00%
getivar 105.2 0.36% 105.7 0.18% 42.7 0.05% 1.00x 0.40% 2.46x 0.36% 98.73%
keyword_args 285.2 0.10% 226.4 0.03% 54.2 0.27% 1.26x 0.10% 5.26x 0.29% 100.00%
respond_to 276.2 0.06% 260.8 0.15% 30.0 0.35% 1.06x 0.16% 9.22x 0.35% 100.00%
setivar 75.6 0.19% 78.2 0.23% 49.7 0.83% 0.97x 0.30% 1.52x 0.85% 98.16%
str_concat 83.8 0.91% 54.5 8.65% 46.7 1.21% 1.54x 8.70% 1.79x 1.51% 99.76%

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-09-17T03:09:34Z master 6898984f1c) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-17T03:09:34Z master 6898984f1c) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 72 77
hexapdf 301 404
liquid-render 31 34 38
mail 49 54 57
psych-load 39 42 43
railsbench 102 122 131
binarytrees 30 32 33
chunky_png 38 46 43
erubi 60 107 106
erubi_rails 101 105 122
fannkuchredux 24 26 27
lee 34 41 40
nbody 25 26 27
optcarrot 63 70 70
rubykon 51 65 55
30k_ifelse 66 143 124
30k_methods 57 168 76
cfunc_itself 24 26 27
fib 24 26 27
getivar 25 26 27
keyword_args 24 26 27
respond_to 24 26 27
setivar 25 25 27
str_concat 98 119 104

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 194 75 194 20 194
hexapdf 5 15 20 15
liquid-render 5 178 75 178 20 178
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 83 75 83 20 83
chunky_png 5 30 75 30 20 30
erubi 5 67 75 67 20 67
erubi_rails 5 1047 75 1047 20 1047
fannkuchredux 5 15 56 15 20 15
lee 5 21 75 21 20 21
nbody 5 266 75 266 20 266
optcarrot 5 15 75 15 20 15
rubykon 5 15 31 15 20 15
30k_ifelse 5 54 68 54 20 54
30k_methods 5 25 23 25 20 25
cfunc_itself 5 434 75 434 20 434
fib 5 317 75 317 20 317
getivar 5 467 75 467 20 467
keyword_args 5 370 75 370 20 370
respond_to 5 665 75 665 20 665
setivar 5 436 75 436 20 436
str_concat 5 427 75 427 20 427

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) 1064759 775622 131 1264 0 0% 0 0 0
hexapdf (click) 1176695 918233 683 8043 9 0% 0 0 0
liquid-render (click) 529655 401474 150 1732 2 0% 0 0 0
mail (click) 931639 650635 374 5424 17 0% 0 0 0
psych-load (click) 355447 260672 68 474 1 0% 0 0 0
railsbench (click) 2726391 1960541 1436 10044 16 0% 0 0 0
binarytrees (click) 175543 126657 13 64 0 0% 0 0 0
chunky_png (click) 398391 288180 88 1010 0 0% 0 0 0
erubi (click) 341175 250544 10 79 0 0% 0 0 0
erubi_rails (click) 2013431 1422103 300 2026 4 0% 0 0 0
fannkuchredux (click) 189815 136544 10 196 0 0% 0 0 0
lee (click) 396471 288578 58 634 0 0% 0 0 0
nbody (click) 186999 136021 12 171 0 0% 0 0 0
optcarrot (click) 531831 441312 207 3592 20 0% 0 0 0
rubykon (click) 329015 255181 144 1575 2 0% 0 0 0
30k_ifelse (click) 5663863 4347034 9265 57804 0 0% 0 0 0
30k_methods (click) 2208439 1655706 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174007 125339 10 49 0 0% 0 0 0
fib (click) 172727 125207 10 38 0 0% 0 0 0
getivar (click) 174455 127244 10 65 0 0% 0 0 0
keyword_args (click) 173815 125537 11 51 0 0% 0 0 0
respond_to (click) 173367 126110 10 64 0 0% 0 0 0
setivar (click) 174263 125969 10 38 0 0% 0 0 0
str_concat (click) 174391 126446 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.