YJIT Benchmarks

2022-08-12 05:14:26

As of 2022-08-12 05:14:26:

Overall YJIT is 36.2% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 37.4% 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 156.4 0.39% 155.9 0.38% 103.2 0.64% 1.00x 0.54% 1.52x 0.75% 85.96%
hexapdf 3194.7 1.23% 2368.6 1.95% 1.35x 2.31% 83.44%
liquid-render 196.5 0.98% 190.8 1.47% 125.8 1.83% 1.03x 1.76% 1.56x 2.08% 85.90%
mail 175.4 1.36% 172.3 1.69% 155.3 0.15% 1.02x 2.17% 1.13x 1.36% 99.35%
psych-load 2434.4 0.02% 2089.1 0.02% 1893.4 0.03% 1.17x 0.03% 1.29x 0.03% 88.89%
railsbench 2833.7 0.64% 2769.7 0.63% 2062.1 1.36% 1.02x 0.89% 1.37x 1.50% 86.54%
binarytrees 464.4 0.06% 331.1 0.35% 372.7 0.11% 1.40x 0.35% 1.25x 0.13% 84.27%
chunky_png 967.4 0.08% 783.8 0.39% 651.6 0.07% 1.23x 0.40% 1.48x 0.11% 99.95%
erubi 377.6 0.71% 343.8 0.61% 324.2 0.82% 1.10x 0.94% 1.16x 1.09% 100.00%
erubi_rails 27.2 2.80% 27.6 2.46% 19.5 3.65% 0.99x 3.73% 1.39x 4.60% 86.41%
fannkuchredux 5299.1 0.10% 2494.4 0.03% 2384.7 0.28% 2.12x 0.10% 2.22x 0.30% 77.42%
lee 1290.7 0.73% 1079.3 2.11% 979.4 2.17% 1.20x 2.23% 1.32x 2.29% 99.97%
nbody 139.3 0.26% 76.0 0.25% 94.9 0.11% 1.83x 0.36% 1.47x 0.29% 100.00%
optcarrot 6256.9 0.43% 2784.1 0.61% 3574.4 0.57% 2.25x 0.75% 1.75x 0.71% 96.16%
rubykon 12684.5 0.44% 8258.0 0.55% 6934.6 0.51% 1.54x 0.71% 1.83x 0.67% 99.84%
30k_ifelse 2401.2 0.08% 3603.6 3.62% 352.5 0.08% 0.67x 3.62% 6.81x 0.12% 100.00%
30k_methods 6569.1 0.01% 10002.9 19.74% 873.5 0.02% 0.66x 19.74% 7.52x 0.02% 100.00%
cfunc_itself 105.3 0.26% 71.4 1.10% 48.5 0.83% 1.47x 1.13% 2.17x 0.87% 100.00%
fib 243.6 0.07% 86.2 0.20% 63.4 0.08% 2.83x 0.21% 3.84x 0.11% 100.00%
getivar 107.5 0.23% 32.4 54.15% 44.2 0.12% 3.32x 54.15% 2.43x 0.26% 99.03%
keyword_args 289.4 0.10% 231.4 0.28% 55.3 0.18% 1.25x 0.30% 5.23x 0.21% 100.00%
respond_to 268.5 0.60% 221.4 0.82% 182.8 0.34% 1.21x 1.02% 1.47x 0.69% 100.00%
setivar 83.0 0.14% 20.2 61.71% 49.7 0.09% 4.11x 61.71% 1.67x 0.17% 99.17%
str_concat 83.5 1.13% 53.5 1.34% 45.2 1.29% 1.56x 1.76% 1.85x 1.72% 99.81%

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-12T05:04:41Z master d9f1b8baa3) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-12T05:04:41Z master d9f1b8baa3) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 66 76
hexapdf 288 393
liquid-render 31 36 37
mail 49 53 57
psych-load 34 47 39
railsbench 104 107 131
binarytrees 28 32 30
chunky_png 44 47 46
erubi 98 127 133
erubi_rails 104 104 122
fannkuchredux 24 27 27
lee 32 41 41
nbody 24 26 27
optcarrot 63 70 70
rubykon 53 60 57
30k_ifelse 66 166 122
30k_methods 58 180 79
cfunc_itself 24 27 26
fib 24 26 27
getivar 24 26 27
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 190 75 190 20 190
hexapdf 5 15 20 15
liquid-render 5 159 75 159 20 159
mail 5 127 75 127 20 127
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 61 75 61 20 61
chunky_png 5 30 75 30 20 30
erubi 5 60 75 60 20 60
erubi_rails 5 1025 75 1025 20 1025
fannkuchredux 5 15 75 15 20 15
lee 5 19 75 19 20 19
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 300 75 300 20 300
getivar 5 620 75 620 20 620
keyword_args 5 360 75 360 20 360
respond_to 5 110 75 110 20 110
setivar 5 989 75 989 20 989
str_concat 5 439 75 439 20 439

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) 1036443 779712 131 1287 0 0% 0 0 0
hexapdf (click) 1150235 924072 682 8012 9 0% 0 0 0
liquid-render (click) 516571 402306 150 1704 2 0% 0 0 0
mail (click) 943067 679095 374 5765 17 0% 0 0 0
psych-load (click) 347675 263701 68 482 1 0% 0 0 0
railsbench (click) 2660059 1969343 1436 10058 16 0% 0 0 0
binarytrees (click) 172187 128626 13 58 0 0% 0 0 0
chunky_png (click) 386203 289256 88 1000 0 0% 0 0 0
erubi (click) 321819 245290 10 79 0 0% 0 0 0
erubi_rails (click) 1962843 1429654 300 2032 4 0% 0 0 0
fannkuchredux (click) 185691 138098 10 196 0 0% 0 0 0
lee (click) 385435 291087 58 632 0 0% 0 0 0
nbody (click) 182811 137821 12 171 0 0% 0 0 0
optcarrot (click) 513755 442692 207 3588 20 0% 0 0 0
rubykon (click) 321947 257617 144 1577 1 0% 0 0 0
30k_ifelse (click) 5560795 4348798 9265 57804 0 0% 0 0 0
30k_methods (click) 2175963 1657260 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170267 127103 10 49 0 0% 0 0 0
fib (click) 168731 126711 10 38 0 0% 0 0 0
getivar (click) 170907 129094 10 65 0 0% 0 0 0
keyword_args (click) 171099 127744 11 51 0 0% 0 0 0
respond_to (click) 172379 128557 10 64 0 0% 0 0 0
setivar (click) 170395 127618 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.