YJIT Benchmarks

2022-09-20 05:38:42

As of 2022-09-20 05:38:42:

Overall YJIT is 37.8% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 35.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.2 0.47% 178.2 4.27% 104.0 0.74% 0.84x 4.30% 1.43x 0.87% 85.99%
hexapdf 3200.5 1.05% 2325.4 1.02% 1.38x 1.47% 82.63%
liquid-render 200.8 1.81% 173.0 1.10% 116.9 1.87% 1.16x 2.12% 1.72x 2.61% 85.97%
mail 174.9 0.09% 175.1 2.33% 153.7 0.25% 1.00x 2.33% 1.14x 0.27% 99.37%
psych-load 2495.0 0.81% 2149.0 0.06% 1900.1 0.04% 1.16x 0.82% 1.31x 0.81% 88.89%
railsbench 2782.8 0.66% 2953.1 0.53% 2060.3 0.91% 0.94x 0.85% 1.35x 1.12% 86.57%
binarytrees 475.4 0.04% 328.2 0.28% 236.6 0.06% 1.45x 0.28% 2.01x 0.07% 100.00%
chunky_png 979.7 0.03% 797.6 0.17% 653.8 0.05% 1.23x 0.17% 1.50x 0.06% 99.95%
erubi 344.5 1.35% 311.4 0.50% 294.4 0.69% 1.11x 1.44% 1.17x 1.51% 100.00%
erubi_rails 26.6 2.85% 27.8 9.83% 18.9 3.50% 0.96x 10.23% 1.41x 4.51% 86.41%
fannkuchredux 5396.0 0.19% 5360.7 0.05% 2364.5 0.11% 1.01x 0.20% 2.28x 0.22% 77.42%
lee 1256.2 0.95% 1014.8 1.51% 948.8 1.21% 1.24x 1.78% 1.32x 1.54% 99.97%
nbody 122.1 0.09% 75.7 0.06% 90.9 0.12% 1.61x 0.11% 1.34x 0.15% 100.00%
optcarrot 6268.6 0.44% 2694.8 0.63% 3465.0 0.62% 2.33x 0.77% 1.81x 0.76% 96.16%
rubykon 12529.9 0.32% 9323.1 1.70% 7032.1 0.73% 1.34x 1.73% 1.78x 0.80% 99.69%
30k_ifelse 2346.9 0.01% 4455.3 2.91% 361.2 0.11% 0.53x 2.91% 6.50x 0.11% 100.00%
30k_methods 6445.9 0.02% 13101.5 3.79% 792.0 0.02% 0.49x 3.79% 8.14x 0.03% 100.00%
cfunc_itself 107.0 0.15% 97.3 0.19% 46.2 0.80% 1.10x 0.24% 2.32x 0.82% 100.00%
fib 240.9 0.03% 79.2 0.03% 63.7 0.05% 3.04x 0.04% 3.78x 0.06% 100.00%
getivar 112.6 0.25% 113.0 0.18% 42.8 0.05% 1.00x 0.31% 2.63x 0.25% 98.73%
keyword_args 288.9 0.08% 233.9 0.08% 54.6 0.18% 1.23x 0.11% 5.29x 0.19% 100.00%
respond_to 259.1 0.63% 247.7 0.34% 30.5 0.64% 1.05x 0.72% 8.50x 0.90% 100.00%
setivar 76.0 0.22% 76.2 0.22% 40.7 0.21% 1.00x 0.31% 1.87x 0.31% 97.98%
str_concat 83.6 0.82% 51.8 8.15% 40.7 1.75% 1.61x 8.19% 2.06x 1.93% 99.97%

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-20T03:54:08Z master 9de11fe796) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-20T03:54:08Z master 9de11fe796) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 72 76
hexapdf 315 415
liquid-render 30 33 36
mail 49 53 56
psych-load 35 45 41
railsbench 102 122 131
binarytrees 30 31 33
chunky_png 43 42 49
erubi 68 104 98
erubi_rails 103 105 122
fannkuchredux 24 25 27
lee 31 41 39
nbody 24 26 27
optcarrot 57 65 64
rubykon 50 65 55
30k_ifelse 67 145 128
30k_methods 58 168 79
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 26 27
str_concat 98 114 105

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 197 75 197 20 197
hexapdf 5 15 20 15
liquid-render 5 170 75 170 20 170
mail 5 129 75 129 20 129
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 85 75 85 20 85
chunky_png 5 30 75 30 20 30
erubi 5 67 75 67 20 67
erubi_rails 5 1051 75 1051 20 1051
fannkuchredux 5 15 56 15 20 15
lee 5 20 75 20 20 20
nbody 5 264 75 264 20 264
optcarrot 5 15 75 15 20 15
rubykon 5 15 33 15 20 15
30k_ifelse 5 55 68 55 20 55
30k_methods 5 25 23 25 20 25
cfunc_itself 5 430 75 430 20 430
fib 5 318 75 318 20 318
getivar 5 467 75 467 20 467
keyword_args 5 359 75 359 20 359
respond_to 5 666 75 666 20 666
setivar 5 396 75 396 20 396
str_concat 5 420 75 420 20 420

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) 1068407 778183 131 1284 0 0% 0 0 0
hexapdf (click) 1178615 919666 683 8049 9 0% 0 0 0
liquid-render (click) 526583 398738 150 1694 2 0% 0 0 0
mail (click) 943927 657611 374 5555 17 0% 0 0 0
psych-load (click) 356215 261195 68 480 1 0% 0 0 0
railsbench (click) 2729143 1961913 1436 10056 16 0% 0 0 0
binarytrees (click) 177079 127640 13 64 0 0% 0 0 0
chunky_png (click) 397367 287378 88 1003 0 0% 0 0 0
erubi (click) 341111 250594 10 79 0 0% 0 0 0
erubi_rails (click) 2023351 1428828 300 2038 4 0% 0 0 0
fannkuchredux (click) 189879 136594 10 196 0 0% 0 0 0
lee (click) 396471 288578 58 634 0 0% 0 0 0
nbody (click) 187255 136324 12 171 0 0% 0 0 0
optcarrot (click) 531831 441312 207 3592 20 0% 0 0 0
rubykon (click) 327799 254260 144 1564 2 0% 0 0 0
30k_ifelse (click) 5664503 4347597 9265 57804 0 0% 0 0 0
30k_methods (click) 2208375 1655471 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174391 125599 10 49 0 0% 0 0 0
fib (click) 172663 125157 10 38 0 0% 0 0 0
getivar (click) 174455 127244 10 65 0 0% 0 0 0
keyword_args (click) 175095 126240 11 51 0 0% 0 0 0
respond_to (click) 174903 127116 10 64 0 0% 0 0 0
setivar (click) 174775 126467 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.