YJIT Benchmarks

2022-06-16 05:14:59

As of 2022-06-16 05:14:59:

Overall YJIT is 36.8% 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 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 154.1 0.39% 155.2 0.32% 104.6 0.56% 0.99x 0.50% 1.47x 0.68% 85.54%
hexapdf 3190.4 1.02% 2323.6 2.08% 1.37x 2.31% 83.48%
liquid-render 197.2 1.40% 172.1 2.03% 129.5 2.10% 1.15x 2.47% 1.52x 2.52% 85.70%
mail 183.1 0.15% 178.1 1.62% 161.9 0.15% 1.03x 1.62% 1.13x 0.21% 99.37%
psych-load 2586.9 0.06% 2169.7 0.12% 1852.2 0.02% 1.19x 0.14% 1.40x 0.07% 88.45%
railsbench 2862.0 1.08% 2860.4 0.83% 2126.3 1.41% 1.00x 1.36% 1.35x 1.78% 86.12%
binarytrees 465.4 0.04% 303.4 0.34% 355.8 0.05% 1.53x 0.34% 1.31x 0.07% 84.27%
chunky_png 982.5 0.05% 800.2 0.39% 664.1 0.04% 1.23x 0.39% 1.48x 0.07% 99.95%
discourse 541.6 1.61% 549.3 1.19% 495.3 11.98% 0.99x 2.01% 1.09x 12.09% 73.61%
erubi 469.5 0.55% 435.3 0.70% 392.8 0.68% 1.08x 0.89% 1.20x 0.88% 100.00%
erubi_rails 28.5 2.72% 28.5 2.47% 21.2 3.22% 1.00x 3.67% 1.34x 4.21% 86.30%
fannkuchredux 8684.1 0.15% 5796.2 0.23% 8819.1 0.15% 1.50x 0.27% 0.98x 0.21% 0.02%
lee 1251.2 0.05% 1048.1 0.96% 934.8 0.05% 1.19x 0.96% 1.34x 0.07% 99.97%
nbody 122.8 0.16% 72.9 0.27% 87.7 0.09% 1.68x 0.31% 1.40x 0.19% 100.00%
optcarrot 6320.9 0.44% 2598.2 0.61% 3470.1 0.60% 2.43x 0.76% 1.82x 0.75% 96.13%
rubykon 13260.4 2.25% 8946.1 3.57% 7535.6 3.83% 1.48x 4.22% 1.76x 4.44% 99.65%
30k_ifelse 2250.0 0.01% 3600.7 3.93% 359.1 0.08% 0.62x 3.93% 6.27x 0.08% 100.00%
30k_methods 6398.3 0.01% 10005.8 17.88% 874.8 0.02% 0.64x 17.88% 7.31x 0.02% 100.00%
cfunc_itself 106.4 0.20% 68.5 0.48% 46.4 0.76% 1.55x 0.52% 2.29x 0.79% 100.00%
fib 262.7 0.09% 86.2 0.20% 63.3 0.04% 3.05x 0.22% 4.15x 0.09% 100.00%
getivar 113.9 0.26% 26.3 70.82% 42.5 0.06% 4.33x 70.82% 2.68x 0.27% 99.22%
keyword_args 287.5 0.10% 235.6 1.24% 53.0 0.16% 1.22x 1.24% 5.42x 0.19% 100.00%
respond_to 290.4 0.26% 234.0 0.43% 200.5 0.15% 1.24x 0.50% 1.45x 0.30% 100.00%
setivar 74.6 0.18% 10.8 99.03% 54.4 0.08% 6.89x 99.03% 1.37x 0.20% 99.55%
str_concat 131.7 0.92% 103.5 0.84% 110.4 0.76% 1.27x 1.25% 1.19x 1.20% 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-16T05:10:54Z master 30ca4a8263) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-06-16T05:10:54Z master 30ca4a8263) +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 293 384
liquid-render 30 35 37
mail 49 54 56
psych-load 38 52 41
railsbench 103 105 131
binarytrees 31 33 33
chunky_png 40 46 45
discourse 402 416 463
erubi 65 94 81
erubi_rails 104 105 122
fannkuchredux 25 27 27
lee 33 40 38
nbody 25 26 27
optcarrot 59 66 65
rubykon 54 62 57
30k_ifelse 67 171 126
30k_methods 57 179 78
cfunc_itself 25 27 27
fib 25 27 27
getivar 24 27 27
keyword_args 24 27 27
respond_to 24 27 27
setivar 24 26 27
str_concat 100 95 93

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 153 75 153 20 153
mail 5 124 75 124 20 124
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 30 75 30 20 30
discourse 5 41 75 41 20 41
erubi 5 50 75 50 20 50
erubi_rails 5 939 75 939 20 939
fannkuchredux 5 15 75 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 31 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 437 75 437 20 437
fib 5 315 75 315 20 315
getivar 5 771 75 771 20 771
keyword_args 5 379 75 379 20 379
respond_to 5 102 75 102 20 102
setivar 5 1847 75 1847 20 1847
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) 1014043 754187 131 1247 0 0% 0 0 0
hexapdf (click) 1120347 879224 682 7753 9 0% 0 0 0
liquid-render (click) 516699 396245 150 1661 2 0% 0 0 0
mail (click) 910811 658065 374 5513 15 0% 0 0 0
psych-load (click) 339995 255533 68 462 1 0% 0 0 0
railsbench (click) 2619483 1916565 1436 9835 16 0% 0 0 0
binarytrees (click) 174235 130445 13 58 0 0% 0 0 0
chunky_png (click) 384923 287043 88 1040 0 0% 0 0 0
discourse (click) 5926363 4401854 3197 25520 85 0% 2 0 0
erubi (click) 319515 242786 10 79 0 0% 0 0 0
erubi_rails (click) 1927387 1389125 300 1959 4 0% 0 0 0
fannkuchredux (click) 188123 141008 10 188 0 0% 0 0 0
lee (click) 378331 283802 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) 319451 251719 144 1537 1 0% 0 0 0
30k_ifelse (click) 5563163 4350634 9265 57804 0 0% 0 0 0
30k_methods (click) 2178331 1659231 5784 19361 0 0% 0 0 0
cfunc_itself (click) 172763 129074 10 49 0 0% 0 0 0
fib (click) 171227 128682 10 38 0 0% 0 0 0
getivar (click) 172891 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) 172827 129717 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.