YJIT Benchmarks

2022-08-11 05:14:55

As of 2022-08-11 05:14:55:

Overall YJIT is 35.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 35.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.2 0.31% 154.4 0.30% 103.7 0.56% 1.00x 0.44% 1.49x 0.64% 85.96%
hexapdf 3207.1 1.11% 2376.6 1.63% 1.35x 1.98% 83.60%
liquid-render 195.4 1.41% 170.7 1.68% 127.4 1.79% 1.14x 2.19% 1.53x 2.28% 85.90%
mail 175.7 0.15% 173.5 1.63% 156.0 0.15% 1.01x 1.64% 1.13x 0.22% 99.34%
psych-load 2444.8 0.03% 2110.0 0.01% 1899.7 0.03% 1.16x 0.03% 1.29x 0.04% 88.89%
railsbench 2802.7 0.65% 2820.1 0.45% 2067.7 1.00% 0.99x 0.79% 1.36x 1.19% 86.54%
binarytrees 462.9 0.07% 328.3 1.96% 373.1 0.09% 1.41x 1.96% 1.24x 0.11% 84.27%
chunky_png 965.7 0.04% 773.6 0.04% 649.7 0.04% 1.25x 0.06% 1.49x 0.06% 99.95%
erubi 374.4 0.56% 338.3 0.73% 316.4 0.92% 1.11x 0.92% 1.18x 1.08% 100.00%
erubi_rails 26.7 2.43% 27.4 2.35% 19.2 3.53% 0.98x 3.38% 1.39x 4.29% 86.41%
fannkuchredux 5264.0 0.69% 2485.7 0.04% 2352.1 0.28% 2.12x 0.69% 2.24x 0.74% 77.42%
lee 1295.7 1.56% 1077.8 2.04% 974.9 2.00% 1.20x 2.57% 1.33x 2.53% 99.97%
nbody 138.9 0.27% 75.9 0.22% 94.8 0.09% 1.83x 0.35% 1.46x 0.29% 100.00%
optcarrot 6326.8 0.43% 2779.0 0.65% 3538.3 0.54% 2.28x 0.78% 1.79x 0.69% 96.16%
rubykon 12632.8 0.66% 8259.0 0.31% 6952.2 0.84% 1.53x 0.72% 1.82x 1.07% 99.69%
30k_ifelse 2363.2 0.01% 3621.1 3.89% 353.2 0.08% 0.65x 3.89% 6.69x 0.08% 100.00%
30k_methods 6458.9 0.01% 9968.3 18.38% 873.8 0.02% 0.65x 18.38% 7.39x 0.02% 100.00%
cfunc_itself 106.0 0.24% 72.8 0.73% 48.2 0.78% 1.46x 0.76% 2.20x 0.82% 100.00%
fib 234.7 0.04% 86.2 0.20% 63.4 0.08% 2.72x 0.21% 3.70x 0.09% 100.00%
getivar 107.2 0.33% 32.4 54.24% 46.4 0.04% 3.31x 54.24% 2.31x 0.34% 99.02%
keyword_args 282.4 0.10% 222.2 0.51% 55.2 0.19% 1.27x 0.52% 5.11x 0.21% 100.00%
respond_to 266.4 0.96% 228.7 0.79% 182.7 0.51% 1.16x 1.24% 1.46x 1.09% 100.00%
setivar 83.5 0.29% 20.2 61.31% 49.7 0.09% 4.14x 61.31% 1.68x 0.30% 99.17%
str_concat 83.5 1.11% 53.9 1.30% 45.5 1.41% 1.55x 1.71% 1.84x 1.79% 99.86%

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-11T02:34:52Z master 74d95744bd) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-11T02:34:52Z master 74d95744bd) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 289 377
liquid-render 30 35 37
mail 49 53 57
psych-load 36 45 38
railsbench 104 106 133
binarytrees 28 32 30
chunky_png 43 43 48
erubi 73 89 88
erubi_rails 102 103 122
fannkuchredux 24 27 26
lee 33 40 41
nbody 24 26 27
optcarrot 63 70 69
rubykon 51 60 57
30k_ifelse 66 166 122
30k_methods 58 180 79
cfunc_itself 24 27 26
fib 24 27 26
getivar 24 26 26
keyword_args 24 27 26
respond_to 24 27 26
setivar 24 26 27
str_concat 75 110 107

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 192 75 192 20 192
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 64 75 64 20 64
chunky_png 5 30 75 30 20 30
erubi 5 62 75 62 20 62
erubi_rails 5 1030 75 1030 20 1030
fannkuchredux 5 15 75 15 20 15
lee 5 20 75 20 20 20
nbody 5 263 75 263 20 263
optcarrot 5 15 75 15 20 15
rubykon 5 15 35 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 22 30 22 20 22
cfunc_itself 5 429 75 429 20 429
fib 5 315 75 315 20 315
getivar 5 615 75 615 20 615
keyword_args 5 364 75 364 20 364
respond_to 5 110 75 110 20 110
setivar 5 988 75 988 20 988
str_concat 5 437 75 437 20 437

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) 1034971 778922 131 1267 0 0% 0 0 0
hexapdf (click) 1150427 924458 683 8016 9 0% 0 0 0
liquid-render (click) 519195 403705 150 1673 2 0% 0 0 0
mail (click) 931099 669846 374 5619 17 0% 0 0 0
psych-load (click) 347355 263483 68 480 1 0% 0 0 0
railsbench (click) 2655963 1967118 1436 10018 16 0% 0 0 0
binarytrees (click) 171995 128341 13 58 0 0% 0 0 0
chunky_png (click) 386011 289101 88 999 0 0% 0 0 0
erubi (click) 323099 246292 10 79 0 0% 0 0 0
erubi_rails (click) 1962459 1429596 300 2031 4 0% 0 0 0
fannkuchredux (click) 186139 138394 10 196 0 0% 0 0 0
lee (click) 384091 290035 58 632 0 0% 0 0 0
nbody (click) 182811 137821 12 171 0 0% 0 0 0
optcarrot (click) 514203 442988 207 3588 20 0% 0 0 0
rubykon (click) 321819 257847 144 1578 1 0% 0 0 0
30k_ifelse (click) 5561243 4349094 9265 57804 0 0% 0 0 0
30k_methods (click) 2176411 1657556 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170715 127399 10 49 0 0% 0 0 0
fib (click) 169179 127007 10 38 0 0% 0 0 0
getivar (click) 170907 129094 10 65 0 0% 0 0 0
keyword_args (click) 171547 128040 11 51 0 0% 0 0 0
respond_to (click) 172827 128853 10 64 0 0% 0 0 0
setivar (click) 170843 127914 10 38 0 0% 0 0 0
str_concat (click) 170843 128246 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.