YJIT Benchmarks

2022-08-10 05:15:38

As of 2022-08-10 05:15:38:

Overall YJIT is 37.0% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 32.2% 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.5 0.40% 155.3 0.28% 103.3 0.73% 0.99x 0.49% 1.50x 0.84% 85.93%
hexapdf 3233.2 1.13% 2360.7 2.71% 1.37x 2.94% 82.85%
liquid-render 197.8 0.97% 170.8 1.65% 126.4 1.82% 1.16x 1.92% 1.57x 2.07% 85.90%
mail 179.9 0.59% 173.0 2.31% 155.3 0.16% 1.04x 2.38% 1.16x 0.61% 99.31%
psych-load 2593.8 0.68% 2132.3 0.04% 1922.5 0.02% 1.22x 0.68% 1.35x 0.68% 88.89%
railsbench 2771.3 0.81% 2829.4 0.82% 2097.1 0.84% 0.98x 1.15% 1.32x 1.17% 86.38%
binarytrees 478.3 0.08% 323.2 0.33% 368.0 0.10% 1.48x 0.34% 1.30x 0.12% 84.27%
chunky_png 988.0 0.04% 774.9 0.04% 641.7 0.19% 1.27x 0.06% 1.54x 0.19% 99.95%
erubi 377.3 0.73% 343.3 0.52% 319.4 0.62% 1.10x 0.90% 1.18x 0.96% 100.00%
erubi_rails 27.5 2.72% 26.9 2.55% 19.3 3.59% 1.02x 3.73% 1.43x 4.50% 86.40%
fannkuchredux 6892.2 0.04% 3968.0 0.26% 6971.2 0.26% 1.74x 0.26% 0.99x 0.26% 0.02%
lee 1248.2 1.41% 1011.2 0.22% 918.2 1.39% 1.23x 1.43% 1.36x 1.99% 99.97%
nbody 129.7 0.41% 76.4 0.25% 91.1 0.07% 1.70x 0.48% 1.42x 0.42% 100.00%
optcarrot 6322.5 0.42% 2762.5 0.61% 3441.8 0.62% 2.29x 0.75% 1.84x 0.75% 96.16%
rubykon 12549.0 0.87% 8095.3 0.65% 6812.3 0.47% 1.55x 1.09% 1.84x 0.99% 99.62%
30k_ifelse 2476.3 0.02% 3779.1 4.09% 353.6 0.07% 0.66x 4.09% 7.00x 0.08% 100.00%
30k_methods 6212.2 0.00% 9920.7 18.31% 875.0 0.02% 0.63x 18.31% 7.10x 0.02% 100.00%
cfunc_itself 111.2 0.23% 68.8 0.56% 45.1 0.63% 1.62x 0.60% 2.47x 0.67% 100.00%
fib 258.7 0.14% 86.3 0.25% 63.3 0.04% 3.00x 0.29% 4.09x 0.15% 100.00%
getivar 105.7 0.44% 32.4 53.91% 44.2 0.11% 3.26x 53.92% 2.39x 0.45% 99.02%
keyword_args 291.0 0.10% 224.6 0.46% 52.7 0.28% 1.30x 0.47% 5.52x 0.30% 100.00%
respond_to 273.5 0.64% 226.3 1.08% 187.1 0.12% 1.21x 1.25% 1.46x 0.65% 100.00%
setivar 79.1 0.49% 20.9 63.29% 49.7 0.11% 3.79x 63.29% 1.59x 0.50% 99.14%
str_concat 83.4 1.09% 50.2 1.32% 43.0 1.51% 1.66x 1.72% 1.94x 1.87% 99.80%

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-10T05:13:45Z master 3569d13095) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-10T05:13:45Z master 3569d13095) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 65 76
hexapdf 299 429
liquid-render 30 35 37
mail 49 53 56
psych-load 36 45 40
railsbench 103 105 133
binarytrees 28 32 30
chunky_png 41 43 46
erubi 124 106 96
erubi_rails 103 104 122
fannkuchredux 24 27 27
lee 35 39 41
nbody 24 26 26
optcarrot 62 70 69
rubykon 52 59 57
30k_ifelse 66 172 122
30k_methods 58 180 79
cfunc_itself 24 27 27
fib 24 27 26
getivar 24 26 27
keyword_args 24 27 27
respond_to 24 27 26
setivar 24 26 27
str_concat 114 112 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 194 75 194 20 194
hexapdf 5 15 20 15
liquid-render 5 157 75 157 20 157
mail 5 128 75 128 20 128
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
erubi 5 61 75 61 20 61
erubi_rails 5 1037 75 1037 20 1037
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 261 75 261 20 261
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 22 30 22 20 22
cfunc_itself 5 425 75 425 20 425
fib 5 315 75 315 20 315
getivar 5 611 75 611 20 611
keyword_args 5 380 75 380 20 380
respond_to 5 105 75 105 20 105
setivar 5 954 75 954 20 954
str_concat 5 462 75 462 20 462

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) 1035163 779073 131 1271 0 0% 0 0 0
hexapdf (click) 1151131 924813 682 8014 9 0% 0 0 0
liquid-render (click) 519451 404239 150 1680 2 0% 0 0 0
mail (click) 928859 669405 374 5614 17 0% 0 0 0
psych-load (click) 347355 263273 68 482 1 0% 0 0 0
railsbench (click) 2657243 1967761 1436 10041 16 0% 0 0 0
binarytrees (click) 171419 127952 13 58 0 0% 0 0 0
chunky_png (click) 388635 290833 88 1014 0 0% 0 0 0
erubi (click) 322779 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1960539 1428389 300 1996 4 0% 0 0 0
fannkuchredux (click) 185691 138378 10 188 0 0% 0 0 0
lee (click) 385243 290709 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) 323035 258601 144 1592 1 0% 0 0 0
30k_ifelse (click) 5560475 4348420 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) 168411 126333 10 38 0 0% 0 0 0
getivar (click) 170587 128716 10 65 0 0% 0 0 0
keyword_args (click) 170779 127366 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.