YJIT Benchmarks

2022-08-13 05:13:31

As of 2022-08-13 05:13:31:

Overall YJIT is 34.3% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 37.3% 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 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.5 0.38% 161.5 0.32% 103.6 0.65% 0.96x 0.50% 1.49x 0.76% 85.96%
hexapdf 3195.3 1.09% 2451.5 1.17% 1.30x 1.60% 82.65%
liquid-render 194.6 0.99% 189.1 1.49% 126.1 1.82% 1.03x 1.79% 1.54x 2.07% 85.90%
mail 176.7 2.13% 174.3 1.69% 155.0 0.18% 1.01x 2.71% 1.14x 2.14% 99.38%
psych-load 2498.0 0.03% 2157.5 0.03% 1992.4 0.03% 1.16x 0.04% 1.25x 0.04% 88.89%
railsbench 2861.6 0.55% 2789.7 0.69% 2084.9 1.30% 1.03x 0.88% 1.37x 1.41% 86.54%
binarytrees 462.1 0.08% 329.4 0.34% 366.7 0.08% 1.40x 0.35% 1.26x 0.11% 84.27%
chunky_png 981.8 0.03% 776.8 0.03% 652.2 0.06% 1.26x 0.05% 1.51x 0.07% 99.95%
erubi 378.6 3.27% 339.8 0.69% 318.6 0.69% 1.11x 3.34% 1.19x 3.34% 100.00%
erubi_rails 27.1 2.74% 28.1 2.53% 19.5 3.83% 0.96x 3.72% 1.39x 4.70% 86.41%
fannkuchredux 5349.7 0.18% 2487.2 0.29% 2348.5 0.27% 2.15x 0.34% 2.28x 0.33% 77.42%
lee 1277.6 0.70% 1058.0 0.07% 969.4 0.06% 1.21x 0.71% 1.32x 0.71% 99.97%
nbody 138.1 0.09% 76.0 0.25% 94.9 0.12% 1.82x 0.26% 1.46x 0.15% 100.00%
optcarrot 6256.0 0.41% 2781.0 0.62% 3513.9 0.60% 2.25x 0.75% 1.78x 0.73% 96.16%
rubykon 12586.4 0.48% 8241.0 0.94% 6919.2 1.02% 1.53x 1.05% 1.82x 1.13% 99.90%
30k_ifelse 2479.5 0.02% 3561.8 3.85% 394.0 0.07% 0.70x 3.85% 6.29x 0.07% 100.00%
30k_methods 6266.8 0.01% 10003.5 20.02% 910.6 0.02% 0.63x 20.02% 6.88x 0.02% 100.00%
cfunc_itself 106.4 0.23% 72.0 1.06% 47.4 0.64% 1.48x 1.09% 2.25x 0.68% 100.00%
fib 234.8 0.06% 86.2 0.21% 63.3 0.04% 2.72x 0.22% 3.71x 0.07% 100.00%
getivar 107.2 0.56% 32.3 54.22% 44.3 0.12% 3.31x 54.23% 2.42x 0.57% 99.03%
keyword_args 279.6 0.11% 231.1 0.24% 54.4 0.14% 1.21x 0.26% 5.14x 0.17% 100.00%
respond_to 271.6 0.41% 227.6 0.71% 185.6 0.19% 1.19x 0.82% 1.46x 0.45% 100.00%
setivar 83.4 0.27% 20.2 60.99% 50.0 0.24% 4.13x 60.99% 1.67x 0.36% 99.17%
str_concat 85.3 1.10% 52.8 1.45% 44.9 1.31% 1.62x 1.82% 1.90x 1.71% 99.87%

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-13T02:23:47Z master 0617cba197) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-13T02:23:47Z master 0617cba197) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 297 399
liquid-render 30 36 37
mail 49 53 56
psych-load 35 46 38
railsbench 104 105 131
binarytrees 28 32 30
chunky_png 44 43 45
erubi 104 110 95
erubi_rails 102 103 122
fannkuchredux 24 27 27
lee 32 39 41
nbody 24 26 26
optcarrot 63 70 69
rubykon 52 59 55
30k_ifelse 66 164 123
30k_methods 58 180 79
cfunc_itself 24 27 26
fib 24 26 26
getivar 24 26 27
keyword_args 24 27 26
respond_to 24 27 27
setivar 24 26 27
str_concat 117 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 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 158 75 158 20 158
mail 5 128 75 128 20 128
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 61 75 61 20 61
erubi_rails 5 1033 75 1033 20 1033
fannkuchredux 5 15 75 15 20 15
lee 5 20 75 20 20 20
nbody 5 262 75 262 20 262
optcarrot 5 15 75 15 20 15
rubykon 5 15 36 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 23 29 23 20 23
cfunc_itself 5 416 75 416 20 416
fib 5 315 75 315 20 315
getivar 5 619 75 619 20 619
keyword_args 5 359 75 359 20 359
respond_to 5 108 75 108 20 108
setivar 5 991 75 991 20 991
str_concat 5 446 75 446 20 446

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) 1035355 778442 131 1271 0 0% 0 0 0
hexapdf (click) 1149403 923534 682 8010 9 0% 0 0 0
liquid-render (click) 519259 404114 150 1679 2 0% 0 0 0
mail (click) 923035 664437 374 5560 17 0% 0 0 0
psych-load (click) 347355 263248 68 482 1 0% 0 0 0
railsbench (click) 2668507 1976894 1436 10099 16 0% 0 0 0
binarytrees (click) 171611 127963 13 58 0 0% 0 0 0
chunky_png (click) 386651 289604 88 999 0 0% 0 0 0
erubi (click) 323675 246820 10 79 0 0% 0 0 0
erubi_rails (click) 1963995 1430671 300 2049 4 0% 0 0 0
fannkuchredux (click) 185819 138016 10 196 0 0% 0 0 0
lee (click) 386075 291590 58 632 0 0% 0 0 0
nbody (click) 182491 137443 12 171 0 0% 0 0 0
optcarrot (click) 513883 442610 207 3588 20 0% 0 0 0
rubykon (click) 321947 257357 144 1579 1 0% 0 0 0
30k_ifelse (click) 5560923 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2175643 1656882 5784 19361 0 0% 0 0 0
cfunc_itself (click) 169947 126725 10 49 0 0% 0 0 0
fib (click) 168859 126629 10 38 0 0% 0 0 0
getivar (click) 170587 128716 10 65 0 0% 0 0 0
keyword_args (click) 171227 127662 11 51 0 0% 0 0 0
respond_to (click) 172507 128475 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.