Spinel vs JRuby vs CRuby (YJIT): 28 Ruby benchmarks

Spinel, Matz’s ahead-of-time compiler for Ruby, ran 28 benchmark programs 20× faster than CRuby 4.0 with YJIT on the geometric mean, and faster on every one of them: from 4.4× (io_wordcount) to 334× (fib). It still cannot run a Rails app. This article has the numbers, the reason, and the pattern that lets a Rails app use Spinel anyway.

Spinel parses a whole program with Prism, infers a static type for every value in it, emits C and hands that to the system C compiler. The result is a standalone native executable with no interpreter, no parser and no JIT inside, which needs only libc and libm. The price: everything has to be known when the binary is built.

Related measurements: Ruby vs JRuby on eight everyday fragments (long-running JRuby, memory, threads) and Ruby vs Rust on the same fragments (a compiled-language baseline).

Benchmark setup

SetupDetails
Programsthe 28 programs in Spinel’s benchmark/ directory, unchanged, at upstream-equivalent commit 1c0cc5e35
Host20-core ARM64 (aarch64) Linux server: 10 Cortex-X925 cores at 3.9 GHz and 10 Cortex-A725 at 2.8 GHz, performance governor, otherwise idle
Pinningevery runtime on the fast X925 cores: Spinel, CRuby and CRuby + YJIT on one core; JRuby on four (--cpuset-cpus=16-19), so its JIT and GC threads have cores of their own · containers pinned with docker --cpuset-cpus, the Spinel binary with taskset
Repeats3 trials per cell; the table and charts show the median. Trials are interleaved: all 28 programs for trial 1, then trial 2, then trial 3, so a disturbance lands in one trial, not all three. Median trial-to-trial spread: 3.4 %
Spinelthe native binary · a trial is the mean of 5 wall-clock runs
CRuby4.0.9, --disable-gems, with and without --yjit (RUBY_DESCRIPTION shows +YJIT) · a trial is the mean of 5 runs, timed inside the container
JRuby10.1.2 on OpenJDK 21, invokedynamic + JIT · cold: mean of 5 process runs, JVM start-up included · warm: the file loaded 20 times in one JVM, mean of the last 5, so JRuby after 15 warm-up runs, not a peak-throughput figure
Correctnessevery program’s output on every runtime matches its .expected file in Spinel’s repo: 112 of 112
Empty programmedian of 3 trials of 5 starts: Spinel binary of nil 0.77 ms · ruby --disable-gems -e 0 5.3 ms · with --yjit 5.5 ms · jruby -e 0 620 ms
Did not runnone: all 28 ran on every runtime

Results: wall time per program

Spinel is the fastest runtime on every program except bigint_fib and pidigits, where warm JRuby is ahead. The three charts are the groups Spinel’s own README uses, each sorted by Spinel’s speedup over YJIT. The scale is logarithmic: one gridline is 10×.

Computation

Computation: wall time per benchmark in milliseconds, log scale, for Spinel, CRuby 4.0 with YJIT, the CRuby 4.0 interpreter and warm JRuby 10.1, sorted by Spinel's speedup over YJIT Spinel: hover to isolate this seriesSpinel CRuby 4.0 + YJIT: hover to isolate this seriesCRuby 4.0 + YJIT CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s vs YJIT fib: Spinel 1.1 ms; CRuby + YJIT 354 ms; CRuby interpreter 345 ms; JRuby warm 1.84 s. Spinel is 334× faster than YJIT. fib334× fib · Spinel: 1.1 ms (334× faster than YJIT)1.1 ms fib · CRuby + YJIT: 354 ms (the baseline)354 ms fib · CRuby interpreter: 345 ms (level with YJIT (within 5 %))345 ms fib · JRuby warm: 1.84 s (5.2× slower than YJIT)1.84 s matmul: Spinel 3.2 ms; CRuby + YJIT 239 ms; CRuby interpreter 239 ms; JRuby warm 899 ms. Spinel is 75× faster than YJIT. matmul75× matmul · Spinel: 3.2 ms (75× faster than YJIT)3.2 ms matmul · CRuby + YJIT: 239 ms (the baseline)239 ms matmul · CRuby interpreter: 239 ms (level with YJIT (within 5 %))239 ms matmul · JRuby warm: 899 ms (3.8× slower than YJIT)899 ms tak: Spinel 6.5 ms; CRuby + YJIT 446 ms; CRuby interpreter 304 ms; JRuby warm 62.7 ms. Spinel is 68× faster than YJIT. tak68× tak · Spinel: 6.5 ms (68× faster than YJIT)6.5 ms tak · CRuby + YJIT: 446 ms (the baseline)446 ms tak · CRuby interpreter: 304 ms (1.5× faster than YJIT)304 ms tak · JRuby warm: 62.7 ms (7.1× faster than YJIT)62.7 ms sieve: Spinel 7.2 ms; CRuby + YJIT 379 ms; CRuby interpreter 380 ms; JRuby warm 1.40 s. Spinel is 52× faster than YJIT. sieve52× sieve · Spinel: 7.2 ms (52× faster than YJIT)7.2 ms sieve · CRuby + YJIT: 379 ms (the baseline)379 ms sieve · CRuby interpreter: 380 ms (level with YJIT (within 5 %))380 ms sieve · JRuby warm: 1.40 s (3.7× slower than YJIT)1.40 s mandelbrot: Spinel 16.0 ms; CRuby + YJIT 774 ms; CRuby interpreter 774 ms; JRuby warm 2.93 s. Spinel is 48× faster than YJIT. mandelbrot48× mandelbrot · Spinel: 16.0 ms (48× faster than YJIT)16.0 ms mandelbrot · CRuby + YJIT: 774 ms (the baseline)774 ms mandelbrot · CRuby interpreter: 774 ms (level with YJIT (within 5 %))774 ms mandelbrot · JRuby warm: 2.93 s (3.8× slower than YJIT)2.93 s sudoku: Spinel 2.3 ms; CRuby + YJIT 109 ms; CRuby interpreter 71.1 ms; JRuby warm 577 ms. Spinel is 47× faster than YJIT. sudoku47× sudoku · Spinel: 2.3 ms (47× faster than YJIT)2.3 ms sudoku · CRuby + YJIT: 109 ms (the baseline)109 ms sudoku · CRuby interpreter: 71.1 ms (1.5× faster than YJIT)71.1 ms sudoku · JRuby warm: 577 ms (5.3× slower than YJIT)577 ms tarai: Spinel 5.4 ms; CRuby + YJIT 245 ms; CRuby interpreter 237 ms; JRuby warm 69.1 ms. Spinel is 45× faster than YJIT. tarai45× tarai · Spinel: 5.4 ms (45× faster than YJIT)5.4 ms tarai · CRuby + YJIT: 245 ms (the baseline)245 ms tarai · CRuby interpreter: 237 ms (level with YJIT (within 5 %))237 ms tarai · JRuby warm: 69.1 ms (3.5× faster than YJIT)69.1 ms ackermann: Spinel 4.2 ms; CRuby + YJIT 176 ms; CRuby interpreter 305 ms; JRuby warm 112 ms. Spinel is 42× faster than YJIT. ackermann42× ackermann · Spinel: 4.2 ms (42× faster than YJIT)4.2 ms ackermann · CRuby + YJIT: 176 ms (the baseline)176 ms ackermann · CRuby interpreter: 305 ms (1.7× slower than YJIT)305 ms ackermann · JRuby warm: 112 ms (1.6× faster than YJIT)112 ms partial_sums: Spinel 16.8 ms; CRuby + YJIT 695 ms; CRuby interpreter 693 ms; JRuby warm 2.39 s. Spinel is 41× faster than YJIT. partial_sums41× partial_sums · Spinel: 16.8 ms (41× faster than YJIT)16.8 ms partial_sums · CRuby + YJIT: 695 ms (the baseline)695 ms partial_sums · CRuby interpreter: 693 ms (level with YJIT (within 5 %))693 ms partial_sums · JRuby warm: 2.39 s (3.4× slower than YJIT)2.39 s life (Game of Life): Spinel 20.8 ms; CRuby + YJIT 830 ms; CRuby interpreter 480 ms; JRuby warm 430 ms. Spinel is 40× faster than YJIT. life (Game of Life)40× life (Game of Life) · Spinel: 20.8 ms (40× faster than YJIT)20.8 ms life (Game of Life) · CRuby + YJIT: 830 ms (the baseline)830 ms life (Game of Life) · CRuby interpreter: 480 ms (1.7× faster than YJIT)480 ms life (Game of Life) · JRuby warm: 430 ms (1.9× faster than YJIT)430 ms nqueens: Spinel 4.9 ms; CRuby + YJIT 146 ms; CRuby interpreter 145 ms; JRuby warm 464 ms. Spinel is 30× faster than YJIT. nqueens30× nqueens · Spinel: 4.9 ms (30× faster than YJIT)4.9 ms nqueens · CRuby + YJIT: 146 ms (the baseline)146 ms nqueens · CRuby interpreter: 145 ms (level with YJIT (within 5 %))145 ms nqueens · JRuby warm: 464 ms (3.2× slower than YJIT)464 ms fannkuch: Spinel 1.1 ms; CRuby + YJIT 8.9 ms; CRuby interpreter 8.6 ms; JRuby warm 13.4 ms. Spinel is 8.0× faster than YJIT. fannkuch8.0× fannkuch · Spinel: 1.1 ms (8.0× faster than YJIT)1.1 ms fannkuch · CRuby + YJIT: 8.9 ms (the baseline)8.9 ms fannkuch · CRuby interpreter: 8.6 ms (level with YJIT (within 5 %))8.6 ms fannkuch · JRuby warm: 13.4 ms (1.5× slower than YJIT)13.4 ms fasta: Spinel 1.4 ms; CRuby + YJIT 9.3 ms; CRuby interpreter 8.5 ms; JRuby warm 28.2 ms. Spinel is 6.7× faster than YJIT. fasta6.7× fasta · Spinel: 1.4 ms (6.7× faster than YJIT)1.4 ms fasta · CRuby + YJIT: 9.3 ms (the baseline)9.3 ms fasta · CRuby interpreter: 8.5 ms (1.1× faster than YJIT)8.5 ms fasta · JRuby warm: 28.2 ms (3.0× slower than YJIT)28.2 ms
Computation: wall time, median of 3 trials, log scale (each gridline is 10×), sorted by Spinel's speedup over YJIT. JRuby warm is JRuby after 15 warm-up runs in one JVM. Hover a row or a legend entry to isolate it.
Computation: wall time per benchmark in milliseconds, log scale, for Spinel, CRuby 4.0 with YJIT, the CRuby 4.0 interpreter and warm JRuby 10.1, sorted by Spinel's speedup over YJIT Spinel: hover to isolate this seriesSpinel CRuby 4.0 + YJIT: hover to isolate this seriesCRuby 4.0 + YJIT CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s fib: Spinel 1.1 ms; CRuby + YJIT 354 ms; CRuby interpreter 345 ms; JRuby warm 1.84 s. Spinel is 334× faster than YJIT. fib334× vs YJIT fib · Spinel: 1.1 ms (334× faster than YJIT)1.1 ms fib · CRuby + YJIT: 354 ms (the baseline)354 ms fib · CRuby interpreter: 345 ms (level with YJIT (within 5 %))345 ms fib · JRuby warm: 1.84 s (5.2× slower than YJIT)1.84 s matmul: Spinel 3.2 ms; CRuby + YJIT 239 ms; CRuby interpreter 239 ms; JRuby warm 899 ms. Spinel is 75× faster than YJIT. matmul75× vs YJIT matmul · Spinel: 3.2 ms (75× faster than YJIT)3.2 ms matmul · CRuby + YJIT: 239 ms (the baseline)239 ms matmul · CRuby interpreter: 239 ms (level with YJIT (within 5 %))239 ms matmul · JRuby warm: 899 ms (3.8× slower than YJIT)899 ms tak: Spinel 6.5 ms; CRuby + YJIT 446 ms; CRuby interpreter 304 ms; JRuby warm 62.7 ms. Spinel is 68× faster than YJIT. tak68× vs YJIT tak · Spinel: 6.5 ms (68× faster than YJIT)6.5 ms tak · CRuby + YJIT: 446 ms (the baseline)446 ms tak · CRuby interpreter: 304 ms (1.5× faster than YJIT)304 ms tak · JRuby warm: 62.7 ms (7.1× faster than YJIT)62.7 ms sieve: Spinel 7.2 ms; CRuby + YJIT 379 ms; CRuby interpreter 380 ms; JRuby warm 1.40 s. Spinel is 52× faster than YJIT. sieve52× vs YJIT sieve · Spinel: 7.2 ms (52× faster than YJIT)7.2 ms sieve · CRuby + YJIT: 379 ms (the baseline)379 ms sieve · CRuby interpreter: 380 ms (level with YJIT (within 5 %))380 ms sieve · JRuby warm: 1.40 s (3.7× slower than YJIT)1.40 s mandelbrot: Spinel 16.0 ms; CRuby + YJIT 774 ms; CRuby interpreter 774 ms; JRuby warm 2.93 s. Spinel is 48× faster than YJIT. mandelbrot48× vs YJIT mandelbrot · Spinel: 16.0 ms (48× faster than YJIT)16.0 ms mandelbrot · CRuby + YJIT: 774 ms (the baseline)774 ms mandelbrot · CRuby interpreter: 774 ms (level with YJIT (within 5 %))774 ms mandelbrot · JRuby warm: 2.93 s (3.8× slower than YJIT)2.93 s sudoku: Spinel 2.3 ms; CRuby + YJIT 109 ms; CRuby interpreter 71.1 ms; JRuby warm 577 ms. Spinel is 47× faster than YJIT. sudoku47× vs YJIT sudoku · Spinel: 2.3 ms (47× faster than YJIT)2.3 ms sudoku · CRuby + YJIT: 109 ms (the baseline)109 ms sudoku · CRuby interpreter: 71.1 ms (1.5× faster than YJIT)71.1 ms sudoku · JRuby warm: 577 ms (5.3× slower than YJIT)577 ms tarai: Spinel 5.4 ms; CRuby + YJIT 245 ms; CRuby interpreter 237 ms; JRuby warm 69.1 ms. Spinel is 45× faster than YJIT. tarai45× vs YJIT tarai · Spinel: 5.4 ms (45× faster than YJIT)5.4 ms tarai · CRuby + YJIT: 245 ms (the baseline)245 ms tarai · CRuby interpreter: 237 ms (level with YJIT (within 5 %))237 ms tarai · JRuby warm: 69.1 ms (3.5× faster than YJIT)69.1 ms ackermann: Spinel 4.2 ms; CRuby + YJIT 176 ms; CRuby interpreter 305 ms; JRuby warm 112 ms. Spinel is 42× faster than YJIT. ackermann42× vs YJIT ackermann · Spinel: 4.2 ms (42× faster than YJIT)4.2 ms ackermann · CRuby + YJIT: 176 ms (the baseline)176 ms ackermann · CRuby interpreter: 305 ms (1.7× slower than YJIT)305 ms ackermann · JRuby warm: 112 ms (1.6× faster than YJIT)112 ms partial_sums: Spinel 16.8 ms; CRuby + YJIT 695 ms; CRuby interpreter 693 ms; JRuby warm 2.39 s. Spinel is 41× faster than YJIT. partial_sums41× vs YJIT partial_sums · Spinel: 16.8 ms (41× faster than YJIT)16.8 ms partial_sums · CRuby + YJIT: 695 ms (the baseline)695 ms partial_sums · CRuby interpreter: 693 ms (level with YJIT (within 5 %))693 ms partial_sums · JRuby warm: 2.39 s (3.4× slower than YJIT)2.39 s life (Game of Life): Spinel 20.8 ms; CRuby + YJIT 830 ms; CRuby interpreter 480 ms; JRuby warm 430 ms. Spinel is 40× faster than YJIT. life (Game of Life)40× vs YJIT life (Game of Life) · Spinel: 20.8 ms (40× faster than YJIT)20.8 ms life (Game of Life) · CRuby + YJIT: 830 ms (the baseline)830 ms life (Game of Life) · CRuby interpreter: 480 ms (1.7× faster than YJIT)480 ms life (Game of Life) · JRuby warm: 430 ms (1.9× faster than YJIT)430 ms nqueens: Spinel 4.9 ms; CRuby + YJIT 146 ms; CRuby interpreter 145 ms; JRuby warm 464 ms. Spinel is 30× faster than YJIT. nqueens30× vs YJIT nqueens · Spinel: 4.9 ms (30× faster than YJIT)4.9 ms nqueens · CRuby + YJIT: 146 ms (the baseline)146 ms nqueens · CRuby interpreter: 145 ms (level with YJIT (within 5 %))145 ms nqueens · JRuby warm: 464 ms (3.2× slower than YJIT)464 ms fannkuch: Spinel 1.1 ms; CRuby + YJIT 8.9 ms; CRuby interpreter 8.6 ms; JRuby warm 13.4 ms. Spinel is 8.0× faster than YJIT. fannkuch8.0× vs YJIT fannkuch · Spinel: 1.1 ms (8.0× faster than YJIT)1.1 ms fannkuch · CRuby + YJIT: 8.9 ms (the baseline)8.9 ms fannkuch · CRuby interpreter: 8.6 ms (level with YJIT (within 5 %))8.6 ms fannkuch · JRuby warm: 13.4 ms (1.5× slower than YJIT)13.4 ms fasta: Spinel 1.4 ms; CRuby + YJIT 9.3 ms; CRuby interpreter 8.5 ms; JRuby warm 28.2 ms. Spinel is 6.7× faster than YJIT. fasta6.7× vs YJIT fasta · Spinel: 1.4 ms (6.7× faster than YJIT)1.4 ms fasta · CRuby + YJIT: 9.3 ms (the baseline)9.3 ms fasta · CRuby interpreter: 8.5 ms (1.1× faster than YJIT)8.5 ms fasta · JRuby warm: 28.2 ms (3.0× slower than YJIT)28.2 ms
Computation: wall time, median of 3 trials, log scale (each gridline is 10×), sorted by Spinel's speedup over YJIT. JRuby warm is JRuby after 15 warm-up runs in one JVM.

Data structures and GC

Data structures & GC: wall time per benchmark in milliseconds, log scale, for Spinel, CRuby 4.0 with YJIT, the CRuby 4.0 interpreter and warm JRuby 10.1, sorted by Spinel's speedup over YJIT Spinel: hover to isolate this seriesSpinel CRuby 4.0 + YJIT: hover to isolate this seriesCRuby 4.0 + YJIT CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s vs YJIT so_lists: Spinel 15.0 ms; CRuby + YJIT 389 ms; CRuby interpreter 228 ms; JRuby warm 248 ms. Spinel is 26× faster than YJIT. so_lists26× so_lists · Spinel: 15.0 ms (26× faster than YJIT)15.0 ms so_lists · CRuby + YJIT: 389 ms (the baseline)389 ms so_lists · CRuby interpreter: 228 ms (1.7× faster than YJIT)228 ms so_lists · JRuby warm: 248 ms (1.6× faster than YJIT)248 ms rbtree: Spinel 18.0 ms; CRuby + YJIT 446 ms; CRuby interpreter 267 ms; JRuby warm 413 ms. Spinel is 25× faster than YJIT. rbtree25× rbtree · Spinel: 18.0 ms (25× faster than YJIT)18.0 ms rbtree · CRuby + YJIT: 446 ms (the baseline)446 ms rbtree · CRuby interpreter: 267 ms (1.7× faster than YJIT)267 ms rbtree · JRuby warm: 413 ms (1.1× faster than YJIT)413 ms splay tree: Spinel 9.2 ms; CRuby + YJIT 170 ms; CRuby interpreter 94.4 ms; JRuby warm 315 ms. Spinel is 19× faster than YJIT. splay tree19× splay tree · Spinel: 9.2 ms (19× faster than YJIT)9.2 ms splay tree · CRuby + YJIT: 170 ms (the baseline)170 ms splay tree · CRuby interpreter: 94.4 ms (1.8× faster than YJIT)94.4 ms splay tree · JRuby warm: 315 ms (1.9× slower than YJIT)315 ms gcbench: Spinel 182 ms; CRuby + YJIT 2.61 s; CRuby interpreter 1.78 s; JRuby warm 462 ms. Spinel is 14× faster than YJIT. gcbench14× gcbench · Spinel: 182 ms (14× faster than YJIT)182 ms gcbench · CRuby + YJIT: 2.61 s (the baseline)2.61 s gcbench · CRuby interpreter: 1.78 s (1.5× faster than YJIT)1.78 s gcbench · JRuby warm: 462 ms (5.7× faster than YJIT)462 ms linked_list: Spinel 31.3 ms; CRuby + YJIT 336 ms; CRuby interpreter 177 ms; JRuby warm 331 ms. Spinel is 11× faster than YJIT. linked_list11× linked_list · Spinel: 31.3 ms (11× faster than YJIT)31.3 ms linked_list · CRuby + YJIT: 336 ms (the baseline)336 ms linked_list · CRuby interpreter: 177 ms (1.9× faster than YJIT)177 ms linked_list · JRuby warm: 331 ms (level with YJIT (within 5 %))331 ms binary_trees: Spinel 3.2 ms; CRuby + YJIT 32.2 ms; CRuby interpreter 21.2 ms; JRuby warm 50.8 ms. Spinel is 9.9× faster than YJIT. binary_trees9.9× binary_trees · Spinel: 3.2 ms (9.9× faster than YJIT)3.2 ms binary_trees · CRuby + YJIT: 32.2 ms (the baseline)32.2 ms binary_trees · CRuby interpreter: 21.2 ms (1.5× faster than YJIT)21.2 ms binary_trees · JRuby warm: 50.8 ms (1.6× slower than YJIT)50.8 ms huffman: Spinel 4.4 ms; CRuby + YJIT 40.0 ms; CRuby interpreter 38.1 ms; JRuby warm 118 ms. Spinel is 9.1× faster than YJIT. huffman9.1× huffman · Spinel: 4.4 ms (9.1× faster than YJIT)4.4 ms huffman · CRuby + YJIT: 40.0 ms (the baseline)40.0 ms huffman · CRuby interpreter: 38.1 ms (level with YJIT (within 5 %))38.1 ms huffman · JRuby warm: 118 ms (2.9× slower than YJIT)118 ms
Data structures & GC: wall time, median of 3 trials, log scale (each gridline is 10×), sorted by Spinel's speedup over YJIT. JRuby warm is JRuby after 15 warm-up runs in one JVM. Hover a row or a legend entry to isolate it.
Data structures & GC: wall time per benchmark in milliseconds, log scale, for Spinel, CRuby 4.0 with YJIT, the CRuby 4.0 interpreter and warm JRuby 10.1, sorted by Spinel's speedup over YJIT Spinel: hover to isolate this seriesSpinel CRuby 4.0 + YJIT: hover to isolate this seriesCRuby 4.0 + YJIT CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s so_lists: Spinel 15.0 ms; CRuby + YJIT 389 ms; CRuby interpreter 228 ms; JRuby warm 248 ms. Spinel is 26× faster than YJIT. so_lists26× vs YJIT so_lists · Spinel: 15.0 ms (26× faster than YJIT)15.0 ms so_lists · CRuby + YJIT: 389 ms (the baseline)389 ms so_lists · CRuby interpreter: 228 ms (1.7× faster than YJIT)228 ms so_lists · JRuby warm: 248 ms (1.6× faster than YJIT)248 ms rbtree: Spinel 18.0 ms; CRuby + YJIT 446 ms; CRuby interpreter 267 ms; JRuby warm 413 ms. Spinel is 25× faster than YJIT. rbtree25× vs YJIT rbtree · Spinel: 18.0 ms (25× faster than YJIT)18.0 ms rbtree · CRuby + YJIT: 446 ms (the baseline)446 ms rbtree · CRuby interpreter: 267 ms (1.7× faster than YJIT)267 ms rbtree · JRuby warm: 413 ms (1.1× faster than YJIT)413 ms splay tree: Spinel 9.2 ms; CRuby + YJIT 170 ms; CRuby interpreter 94.4 ms; JRuby warm 315 ms. Spinel is 19× faster than YJIT. splay tree19× vs YJIT splay tree · Spinel: 9.2 ms (19× faster than YJIT)9.2 ms splay tree · CRuby + YJIT: 170 ms (the baseline)170 ms splay tree · CRuby interpreter: 94.4 ms (1.8× faster than YJIT)94.4 ms splay tree · JRuby warm: 315 ms (1.9× slower than YJIT)315 ms gcbench: Spinel 182 ms; CRuby + YJIT 2.61 s; CRuby interpreter 1.78 s; JRuby warm 462 ms. Spinel is 14× faster than YJIT. gcbench14× vs YJIT gcbench · Spinel: 182 ms (14× faster than YJIT)182 ms gcbench · CRuby + YJIT: 2.61 s (the baseline)2.61 s gcbench · CRuby interpreter: 1.78 s (1.5× faster than YJIT)1.78 s gcbench · JRuby warm: 462 ms (5.7× faster than YJIT)462 ms linked_list: Spinel 31.3 ms; CRuby + YJIT 336 ms; CRuby interpreter 177 ms; JRuby warm 331 ms. Spinel is 11× faster than YJIT. linked_list11× vs YJIT linked_list · Spinel: 31.3 ms (11× faster than YJIT)31.3 ms linked_list · CRuby + YJIT: 336 ms (the baseline)336 ms linked_list · CRuby interpreter: 177 ms (1.9× faster than YJIT)177 ms linked_list · JRuby warm: 331 ms (level with YJIT (within 5 %))331 ms binary_trees: Spinel 3.2 ms; CRuby + YJIT 32.2 ms; CRuby interpreter 21.2 ms; JRuby warm 50.8 ms. Spinel is 9.9× faster than YJIT. binary_trees9.9× vs YJIT binary_trees · Spinel: 3.2 ms (9.9× faster than YJIT)3.2 ms binary_trees · CRuby + YJIT: 32.2 ms (the baseline)32.2 ms binary_trees · CRuby interpreter: 21.2 ms (1.5× faster than YJIT)21.2 ms binary_trees · JRuby warm: 50.8 ms (1.6× slower than YJIT)50.8 ms huffman: Spinel 4.4 ms; CRuby + YJIT 40.0 ms; CRuby interpreter 38.1 ms; JRuby warm 118 ms. Spinel is 9.1× faster than YJIT. huffman9.1× vs YJIT huffman · Spinel: 4.4 ms (9.1× faster than YJIT)4.4 ms huffman · CRuby + YJIT: 40.0 ms (the baseline)40.0 ms huffman · CRuby interpreter: 38.1 ms (level with YJIT (within 5 %))38.1 ms huffman · JRuby warm: 118 ms (2.9× slower than YJIT)118 ms
Data structures & GC: wall time, median of 3 trials, log scale (each gridline is 10×), sorted by Spinel's speedup over YJIT. JRuby warm is JRuby after 15 warm-up runs in one JVM.

Real-world programs

Real-world programs: wall time per benchmark in milliseconds, log scale, for Spinel, CRuby 4.0 with YJIT, the CRuby 4.0 interpreter and warm JRuby 10.1, sorted by Spinel's speedup over YJIT Spinel: hover to isolate this seriesSpinel CRuby 4.0 + YJIT: hover to isolate this seriesCRuby 4.0 + YJIT CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s vs YJIT ao_render (ray tracer): Spinel 65.4 ms; CRuby + YJIT 2.03 s; CRuby interpreter 1.40 s; JRuby warm 2.13 s. Spinel is 31× faster than YJIT. ao_render (ray tracer)31× ao_render (ray tracer) · Spinel: 65.4 ms (31× faster than YJIT)65.4 ms ao_render (ray tracer) · CRuby + YJIT: 2.03 s (the baseline)2.03 s ao_render (ray tracer) · CRuby interpreter: 1.40 s (1.4× faster than YJIT)1.40 s ao_render (ray tracer) · JRuby warm: 2.13 s (1.1× slower than YJIT)2.13 s json_parse: Spinel 22.8 ms; CRuby + YJIT 275 ms; CRuby interpreter 169 ms; JRuby warm 203 ms. Spinel is 12× faster than YJIT. json_parse12× json_parse · Spinel: 22.8 ms (12× faster than YJIT)22.8 ms json_parse · CRuby + YJIT: 275 ms (the baseline)275 ms json_parse · CRuby interpreter: 169 ms (1.6× faster than YJIT)169 ms json_parse · JRuby warm: 203 ms (1.4× faster than YJIT)203 ms template engine: Spinel 60.3 ms; CRuby + YJIT 630 ms; CRuby interpreter 433 ms; JRuby warm 336 ms. Spinel is 10× faster than YJIT. template engine10× template engine · Spinel: 60.3 ms (10× faster than YJIT)60.3 ms template engine · CRuby + YJIT: 630 ms (the baseline)630 ms template engine · CRuby interpreter: 433 ms (1.5× faster than YJIT)433 ms template engine · JRuby warm: 336 ms (1.9× faster than YJIT)336 ms bigint_fib: Spinel 1.1 ms; CRuby + YJIT 5.9 ms; CRuby interpreter 5.2 ms; JRuby warm 0.70 ms. Spinel is 5.4× faster than YJIT. bigint_fib5.4× bigint_fib · Spinel: 1.1 ms (5.4× faster than YJIT)1.1 ms bigint_fib · CRuby + YJIT: 5.9 ms (the baseline)5.9 ms bigint_fib · CRuby interpreter: 5.2 ms (1.1× faster than YJIT)5.2 ms bigint_fib · JRuby warm: 0.70 ms (8.4× faster than YJIT)0.70 ms pidigits: Spinel 1.1 ms; CRuby + YJIT 5.9 ms; CRuby interpreter 5.8 ms; JRuby warm 0.60 ms. Spinel is 5.3× faster than YJIT. pidigits5.3× pidigits · Spinel: 1.1 ms (5.3× faster than YJIT)1.1 ms pidigits · CRuby + YJIT: 5.9 ms (the baseline)5.9 ms pidigits · CRuby interpreter: 5.8 ms (level with YJIT (within 5 %))5.8 ms pidigits · JRuby warm: 0.60 ms (9.8× faster than YJIT)0.60 ms csv_process: Spinel 98.3 ms; CRuby + YJIT 511 ms; CRuby interpreter 404 ms; JRuby warm 1.19 s. Spinel is 5.2× faster than YJIT. csv_process5.2× csv_process · Spinel: 98.3 ms (5.2× faster than YJIT)98.3 ms csv_process · CRuby + YJIT: 511 ms (the baseline)511 ms csv_process · CRuby interpreter: 404 ms (1.3× faster than YJIT)404 ms csv_process · JRuby warm: 1.19 s (2.3× slower than YJIT)1.19 s str_concat: Spinel 1.1 ms; CRuby + YJIT 5.6 ms; CRuby interpreter 5.7 ms; JRuby warm 1.5 ms. Spinel is 5.0× faster than YJIT. str_concat5.0× str_concat · Spinel: 1.1 ms (5.0× faster than YJIT)1.1 ms str_concat · CRuby + YJIT: 5.6 ms (the baseline)5.6 ms str_concat · CRuby interpreter: 5.7 ms (level with YJIT (within 5 %))5.7 ms str_concat · JRuby warm: 1.5 ms (3.7× faster than YJIT)1.5 ms io_wordcount: Spinel 12.1 ms; CRuby + YJIT 53.4 ms; CRuby interpreter 41.8 ms; JRuby warm 76.2 ms. Spinel is 4.4× faster than YJIT. io_wordcount4.4× io_wordcount · Spinel: 12.1 ms (4.4× faster than YJIT)12.1 ms io_wordcount · CRuby + YJIT: 53.4 ms (the baseline)53.4 ms io_wordcount · CRuby interpreter: 41.8 ms (1.3× faster than YJIT)41.8 ms io_wordcount · JRuby warm: 76.2 ms (1.4× slower than YJIT)76.2 ms
Real-world programs: wall time, median of 3 trials, log scale (each gridline is 10×), sorted by Spinel's speedup over YJIT. JRuby warm is JRuby after 15 warm-up runs in one JVM. Hover a row or a legend entry to isolate it.
Real-world programs: wall time per benchmark in milliseconds, log scale, for Spinel, CRuby 4.0 with YJIT, the CRuby 4.0 interpreter and warm JRuby 10.1, sorted by Spinel's speedup over YJIT Spinel: hover to isolate this seriesSpinel CRuby 4.0 + YJIT: hover to isolate this seriesCRuby 4.0 + YJIT CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s ao_render (ray tracer): Spinel 65.4 ms; CRuby + YJIT 2.03 s; CRuby interpreter 1.40 s; JRuby warm 2.13 s. Spinel is 31× faster than YJIT. ao_render (ray tracer)31× vs YJIT ao_render (ray tracer) · Spinel: 65.4 ms (31× faster than YJIT)65.4 ms ao_render (ray tracer) · CRuby + YJIT: 2.03 s (the baseline)2.03 s ao_render (ray tracer) · CRuby interpreter: 1.40 s (1.4× faster than YJIT)1.40 s ao_render (ray tracer) · JRuby warm: 2.13 s (1.1× slower than YJIT)2.13 s json_parse: Spinel 22.8 ms; CRuby + YJIT 275 ms; CRuby interpreter 169 ms; JRuby warm 203 ms. Spinel is 12× faster than YJIT. json_parse12× vs YJIT json_parse · Spinel: 22.8 ms (12× faster than YJIT)22.8 ms json_parse · CRuby + YJIT: 275 ms (the baseline)275 ms json_parse · CRuby interpreter: 169 ms (1.6× faster than YJIT)169 ms json_parse · JRuby warm: 203 ms (1.4× faster than YJIT)203 ms template engine: Spinel 60.3 ms; CRuby + YJIT 630 ms; CRuby interpreter 433 ms; JRuby warm 336 ms. Spinel is 10× faster than YJIT. template engine10× vs YJIT template engine · Spinel: 60.3 ms (10× faster than YJIT)60.3 ms template engine · CRuby + YJIT: 630 ms (the baseline)630 ms template engine · CRuby interpreter: 433 ms (1.5× faster than YJIT)433 ms template engine · JRuby warm: 336 ms (1.9× faster than YJIT)336 ms bigint_fib: Spinel 1.1 ms; CRuby + YJIT 5.9 ms; CRuby interpreter 5.2 ms; JRuby warm 0.70 ms. Spinel is 5.4× faster than YJIT. bigint_fib5.4× vs YJIT bigint_fib · Spinel: 1.1 ms (5.4× faster than YJIT)1.1 ms bigint_fib · CRuby + YJIT: 5.9 ms (the baseline)5.9 ms bigint_fib · CRuby interpreter: 5.2 ms (1.1× faster than YJIT)5.2 ms bigint_fib · JRuby warm: 0.70 ms (8.4× faster than YJIT)0.70 ms pidigits: Spinel 1.1 ms; CRuby + YJIT 5.9 ms; CRuby interpreter 5.8 ms; JRuby warm 0.60 ms. Spinel is 5.3× faster than YJIT. pidigits5.3× vs YJIT pidigits · Spinel: 1.1 ms (5.3× faster than YJIT)1.1 ms pidigits · CRuby + YJIT: 5.9 ms (the baseline)5.9 ms pidigits · CRuby interpreter: 5.8 ms (level with YJIT (within 5 %))5.8 ms pidigits · JRuby warm: 0.60 ms (9.8× faster than YJIT)0.60 ms csv_process: Spinel 98.3 ms; CRuby + YJIT 511 ms; CRuby interpreter 404 ms; JRuby warm 1.19 s. Spinel is 5.2× faster than YJIT. csv_process5.2× vs YJIT csv_process · Spinel: 98.3 ms (5.2× faster than YJIT)98.3 ms csv_process · CRuby + YJIT: 511 ms (the baseline)511 ms csv_process · CRuby interpreter: 404 ms (1.3× faster than YJIT)404 ms csv_process · JRuby warm: 1.19 s (2.3× slower than YJIT)1.19 s str_concat: Spinel 1.1 ms; CRuby + YJIT 5.6 ms; CRuby interpreter 5.7 ms; JRuby warm 1.5 ms. Spinel is 5.0× faster than YJIT. str_concat5.0× vs YJIT str_concat · Spinel: 1.1 ms (5.0× faster than YJIT)1.1 ms str_concat · CRuby + YJIT: 5.6 ms (the baseline)5.6 ms str_concat · CRuby interpreter: 5.7 ms (level with YJIT (within 5 %))5.7 ms str_concat · JRuby warm: 1.5 ms (3.7× faster than YJIT)1.5 ms io_wordcount: Spinel 12.1 ms; CRuby + YJIT 53.4 ms; CRuby interpreter 41.8 ms; JRuby warm 76.2 ms. Spinel is 4.4× faster than YJIT. io_wordcount4.4× vs YJIT io_wordcount · Spinel: 12.1 ms (4.4× faster than YJIT)12.1 ms io_wordcount · CRuby + YJIT: 53.4 ms (the baseline)53.4 ms io_wordcount · CRuby interpreter: 41.8 ms (1.3× faster than YJIT)41.8 ms io_wordcount · JRuby warm: 76.2 ms (1.4× slower than YJIT)76.2 ms
Real-world programs: wall time, median of 3 trials, log scale (each gridline is 10×), sorted by Spinel's speedup over YJIT. JRuby warm is JRuby after 15 warm-up runs in one JVM.

How to read the Spinel numbers

Geometric mean: Spinel, CRuby and JRuby against YJIT

Geometric-mean speed relative to CRuby 4.0 with YJIT, log scale, per benchmark group and over all programs: Spinel, the CRuby interpreter, warm JRuby and cold JRuby Spinel: hover to isolate this seriesSpinel CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm JRuby 10.1 cold: hover to isolate this seriesJRuby 10.1 cold 0.01× 0.1× 1× 10× 100× ◂ slowerfaster than YJIT ▸ Computation (13 programs), geometric mean against YJIT = 1×: Spinel 41×; CRuby interpreter 1.1×; JRuby warm 0.59×; JRuby cold 0.16×. Computation13 programs Computation · Spinel: 41× as fast as YJIT (geometric mean of 13 programs)41× Computation · CRuby interpreter: 1.1× as fast as YJIT (geometric mean of 13 programs)1.1× Computation · JRuby warm: 0.59× of YJIT's speed (geometric mean of 13 programs)0.59× Computation · JRuby cold: 0.16× of YJIT's speed (geometric mean of 13 programs)0.16× Data structures & GC (7 programs), geometric mean against YJIT = 1×: Spinel 15×; CRuby interpreter 1.6×; JRuby warm 1.0×; JRuby cold 0.23×. Data structures & GC7 programs Data structures & GC · Spinel: 15× as fast as YJIT (geometric mean of 7 programs)15× Data structures & GC · CRuby interpreter: 1.6× as fast as YJIT (geometric mean of 7 programs)1.6× Data structures & GC · JRuby warm: level with YJIT (within 5 %) (geometric mean of 7 programs)1.0× Data structures & GC · JRuby cold: 0.23× of YJIT's speed (geometric mean of 7 programs)0.23× Real-world programs (8 programs), geometric mean against YJIT = 1×: Spinel 7.7×; CRuby interpreter 1.3×; JRuby warm 2.0×; JRuby cold 0.08×. Real-world programs8 programs Real-world programs · Spinel: 7.7× as fast as YJIT (geometric mean of 8 programs)7.7× Real-world programs · CRuby interpreter: 1.3× as fast as YJIT (geometric mean of 8 programs)1.3× Real-world programs · JRuby warm: 2.0× as fast as YJIT (geometric mean of 8 programs)2.0× Real-world programs · JRuby cold: 0.08× of YJIT's speed (geometric mean of 8 programs)0.08× All programs (28 programs), geometric mean against YJIT = 1×: Spinel 20×; CRuby interpreter 1.2×; JRuby warm 0.95×; JRuby cold 0.14×. All programs28 programs All programs · Spinel: 20× as fast as YJIT (geometric mean of 28 programs)20× All programs · CRuby interpreter: 1.2× as fast as YJIT (geometric mean of 28 programs)1.2× All programs · JRuby warm: level with YJIT (within 5 %) (geometric mean of 28 programs)0.95× All programs · JRuby cold: 0.14× of YJIT's speed (geometric mean of 28 programs)0.14×
Geometric mean of the per-program speedup against CRuby 4.0 + YJIT, log scale. Right of the 1× line is faster than YJIT, left is slower. Hover a row or a legend entry to isolate it.
Geometric-mean speed relative to CRuby 4.0 with YJIT, log scale, per benchmark group and over all programs: Spinel, the CRuby interpreter, warm JRuby and cold JRuby Spinel: hover to isolate this seriesSpinel CRuby 4.0 interpreter: hover to isolate this seriesCRuby 4.0 interpreter JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm JRuby 10.1 cold: hover to isolate this seriesJRuby 10.1 cold 0.01× 0.1× 1× 10× 100× ◂ slowerfaster than YJIT ▸ Computation (13 programs), geometric mean against YJIT = 1×: Spinel 41×; CRuby interpreter 1.1×; JRuby warm 0.59×; JRuby cold 0.16×. Computation · 13 programs Computation · Spinel: 41× as fast as YJIT (geometric mean of 13 programs)41× Computation · CRuby interpreter: 1.1× as fast as YJIT (geometric mean of 13 programs)1.1× Computation · JRuby warm: 0.59× of YJIT's speed (geometric mean of 13 programs)0.59× Computation · JRuby cold: 0.16× of YJIT's speed (geometric mean of 13 programs)0.16× Data structures & GC (7 programs), geometric mean against YJIT = 1×: Spinel 15×; CRuby interpreter 1.6×; JRuby warm 1.0×; JRuby cold 0.23×. Data structures & GC · 7 programs Data structures & GC · Spinel: 15× as fast as YJIT (geometric mean of 7 programs)15× Data structures & GC · CRuby interpreter: 1.6× as fast as YJIT (geometric mean of 7 programs)1.6× Data structures & GC · JRuby warm: level with YJIT (within 5 %) (geometric mean of 7 programs)1.0× Data structures & GC · JRuby cold: 0.23× of YJIT's speed (geometric mean of 7 programs)0.23× Real-world programs (8 programs), geometric mean against YJIT = 1×: Spinel 7.7×; CRuby interpreter 1.3×; JRuby warm 2.0×; JRuby cold 0.08×. Real-world programs · 8 programs Real-world programs · Spinel: 7.7× as fast as YJIT (geometric mean of 8 programs)7.7× Real-world programs · CRuby interpreter: 1.3× as fast as YJIT (geometric mean of 8 programs)1.3× Real-world programs · JRuby warm: 2.0× as fast as YJIT (geometric mean of 8 programs)2.0× Real-world programs · JRuby cold: 0.08× of YJIT's speed (geometric mean of 8 programs)0.08× All programs (28 programs), geometric mean against YJIT = 1×: Spinel 20×; CRuby interpreter 1.2×; JRuby warm 0.95×; JRuby cold 0.14×. All programs · 28 programs All programs · Spinel: 20× as fast as YJIT (geometric mean of 28 programs)20× All programs · CRuby interpreter: 1.2× as fast as YJIT (geometric mean of 28 programs)1.2× All programs · JRuby warm: level with YJIT (within 5 %) (geometric mean of 28 programs)0.95× All programs · JRuby cold: 0.14× of YJIT's speed (geometric mean of 28 programs)0.14×
Geometric mean of the per-program speedup against CRuby 4.0 + YJIT, log scale. Right of the 1× line is faster than YJIT, left is slower.

With YJIT as 1×, Spinel is at 20× over all 28 programs. On this host the plain interpreter is 1.2× as fast as YJIT on the geometric mean.

JRuby: start-up vs steady state

A cold JRuby run never finishes under 622 ms, because an empty program on a new JVM already takes 620 ms. That start-up is at least half of the cold time on 19 of the 28 programs; cold runs span 622 ms–3.04 s. A Spinel binary starts in 0.77 ms, 805× faster, and ruby -e 0 in 5.3 ms.

Per benchmark, log scale, sorted by warm JRuby time: Spinel, JRuby warm (same JVM, mean of the last 5 of 20 runs) and JRuby cold (a new JVM per run). The bar between warm and cold is JVM start-up plus warm-up. Spinel: hover to isolate this seriesSpinel JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm JRuby 10.1 cold: hover to isolate this seriesJRuby 10.1 cold between warm and cold: start-up + warm-up an empty program on a new JVM: 620 ms 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s pidigits: Spinel 1.1 ms; JRuby warm 0.60 ms; JRuby cold 644 ms. A cold JRuby run takes 580× the Spinel time. pidigits pidigits · JRuby cold: 644 ms pidigits · JRuby warm: 0.60 ms pidigits · Spinel: 1.1 ms Spinel 1.1 ms · JRuby warm 0.60 ms · JRuby cold 644 ms · cold = 580× Spinel bigint_fib: Spinel 1.1 ms; JRuby warm 0.70 ms; JRuby cold 622 ms. A cold JRuby run takes 565× the Spinel time. bigint_fib bigint_fib · JRuby cold: 622 ms bigint_fib · JRuby warm: 0.70 ms bigint_fib · Spinel: 1.1 ms Spinel 1.1 ms · JRuby warm 0.70 ms · JRuby cold 622 ms · cold = 565× Spinel str_concat: Spinel 1.1 ms; JRuby warm 1.5 ms; JRuby cold 636 ms. A cold JRuby run takes 563× the Spinel time. str_concat str_concat · JRuby cold: 636 ms str_concat · JRuby warm: 1.5 ms str_concat · Spinel: 1.1 ms Spinel 1.1 ms · JRuby warm 1.5 ms · JRuby cold 636 ms · cold = 563× Spinel fannkuch: Spinel 1.1 ms; JRuby warm 13.4 ms; JRuby cold 706 ms. A cold JRuby run takes 636× the Spinel time. fannkuch fannkuch · JRuby cold: 706 ms fannkuch · JRuby warm: 13.4 ms fannkuch · Spinel: 1.1 ms Spinel 1.1 ms · JRuby warm 13.4 ms · JRuby cold 706 ms · cold = 636× Spinel fasta: Spinel 1.4 ms; JRuby warm 28.2 ms; JRuby cold 742 ms. A cold JRuby run takes 537× the Spinel time. fasta fasta · JRuby cold: 742 ms fasta · JRuby warm: 28.2 ms fasta · Spinel: 1.4 ms Spinel 1.4 ms · JRuby warm 28.2 ms · JRuby cold 742 ms · cold = 537× Spinel binary_trees: Spinel 3.2 ms; JRuby warm 50.8 ms; JRuby cold 714 ms. A cold JRuby run takes 220× the Spinel time. binary_trees binary_trees · JRuby cold: 714 ms binary_trees · JRuby warm: 50.8 ms binary_trees · Spinel: 3.2 ms Spinel 3.2 ms · JRuby warm 50.8 ms · JRuby cold 714 ms · cold = 220× Spinel tak: Spinel 6.5 ms; JRuby warm 62.7 ms; JRuby cold 702 ms. A cold JRuby run takes 107× the Spinel time. tak tak · JRuby cold: 702 ms tak · JRuby warm: 62.7 ms tak · Spinel: 6.5 ms Spinel 6.5 ms · JRuby warm 62.7 ms · JRuby cold 702 ms · cold = 107× Spinel tarai: Spinel 5.4 ms; JRuby warm 69.1 ms; JRuby cold 689 ms. A cold JRuby run takes 127× the Spinel time. tarai tarai · JRuby cold: 689 ms tarai · JRuby warm: 69.1 ms tarai · Spinel: 5.4 ms Spinel 5.4 ms · JRuby warm 69.1 ms · JRuby cold 689 ms · cold = 127× Spinel io_wordcount: Spinel 12.1 ms; JRuby warm 76.2 ms; JRuby cold 786 ms. A cold JRuby run takes 65× the Spinel time. io_wordcount io_wordcount · JRuby cold: 786 ms io_wordcount · JRuby warm: 76.2 ms io_wordcount · Spinel: 12.1 ms Spinel 12.1 ms · JRuby warm 76.2 ms · JRuby cold 786 ms · cold = 65× Spinel ackermann: Spinel 4.2 ms; JRuby warm 112 ms; JRuby cold 783 ms. A cold JRuby run takes 186× the Spinel time. ackermann ackermann · JRuby cold: 783 ms ackermann · JRuby warm: 112 ms ackermann · Spinel: 4.2 ms Spinel 4.2 ms · JRuby warm 112 ms · JRuby cold 783 ms · cold = 186× Spinel huffman: Spinel 4.4 ms; JRuby warm 118 ms; JRuby cold 1.08 s. A cold JRuby run takes 245× the Spinel time. huffman huffman · JRuby cold: 1.08 s huffman · JRuby warm: 118 ms huffman · Spinel: 4.4 ms Spinel 4.4 ms · JRuby warm 118 ms · JRuby cold 1.08 s · cold = 245× Spinel json_parse: Spinel 22.8 ms; JRuby warm 203 ms; JRuby cold 888 ms. A cold JRuby run takes 39× the Spinel time. json_parse json_parse · JRuby cold: 888 ms json_parse · JRuby warm: 203 ms json_parse · Spinel: 22.8 ms Spinel 22.8 ms · JRuby warm 203 ms · JRuby cold 888 ms · cold = 39× Spinel so_lists: Spinel 15.0 ms; JRuby warm 248 ms; JRuby cold 858 ms. A cold JRuby run takes 57× the Spinel time. so_lists so_lists · JRuby cold: 858 ms so_lists · JRuby warm: 248 ms so_lists · Spinel: 15.0 ms Spinel 15.0 ms · JRuby warm 248 ms · JRuby cold 858 ms · cold = 57× Spinel splay tree: Spinel 9.2 ms; JRuby warm 315 ms; JRuby cold 1.12 s. A cold JRuby run takes 123× the Spinel time. splay tree splay tree · JRuby cold: 1.12 s splay tree · JRuby warm: 315 ms splay tree · Spinel: 9.2 ms Spinel 9.2 ms · JRuby warm 315 ms · JRuby cold 1.12 s · cold = 123× Spinel linked_list: Spinel 31.3 ms; JRuby warm 331 ms; JRuby cold 992 ms. A cold JRuby run takes 32× the Spinel time. linked_list linked_list · JRuby cold: 992 ms linked_list · JRuby warm: 331 ms linked_list · Spinel: 31.3 ms Spinel 31.3 ms · JRuby warm 331 ms · JRuby cold 992 ms · cold = 32× Spinel template engine: Spinel 60.3 ms; JRuby warm 336 ms; JRuby cold 1.07 s. A cold JRuby run takes 18× the Spinel time. template engine template engine · JRuby cold: 1.07 s template engine · JRuby warm: 336 ms template engine · Spinel: 60.3 ms Spinel 60.3 ms · JRuby warm 336 ms · JRuby cold 1.07 s · cold = 18× Spinel rbtree: Spinel 18.0 ms; JRuby warm 413 ms; JRuby cold 1.03 s. A cold JRuby run takes 57× the Spinel time. rbtree rbtree · JRuby cold: 1.03 s rbtree · JRuby warm: 413 ms rbtree · Spinel: 18.0 ms Spinel 18.0 ms · JRuby warm 413 ms · JRuby cold 1.03 s · cold = 57× Spinel life (Game of Life): Spinel 20.8 ms; JRuby warm 430 ms; JRuby cold 1.27 s. A cold JRuby run takes 61× the Spinel time. life (Game of Life) life (Game of Life) · JRuby cold: 1.27 s life (Game of Life) · JRuby warm: 430 ms life (Game of Life) · Spinel: 20.8 ms Spinel 20.8 ms · JRuby warm 430 ms · JRuby cold 1.27 s · cold = 61× Spinel gcbench: Spinel 182 ms; JRuby warm 462 ms; JRuby cold 1.44 s. A cold JRuby run takes 7.9× the Spinel time. gcbench gcbench · JRuby cold: 1.44 s gcbench · JRuby warm: 462 ms gcbench · Spinel: 182 ms Spinel 182 ms · JRuby warm 462 ms · JRuby cold 1.44 s · cold = 7.9× Spinel nqueens: Spinel 4.9 ms; JRuby warm 464 ms; JRuby cold 1.41 s. A cold JRuby run takes 288× the Spinel time. nqueens nqueens · JRuby cold: 1.41 s nqueens · JRuby warm: 464 ms nqueens · Spinel: 4.9 ms Spinel 4.9 ms · JRuby warm 464 ms · JRuby cold 1.41 s · cold = 288× Spinel sudoku: Spinel 2.3 ms; JRuby warm 577 ms; JRuby cold 1.06 s. A cold JRuby run takes 458× the Spinel time. sudoku sudoku · JRuby cold: 1.06 s sudoku · JRuby warm: 577 ms sudoku · Spinel: 2.3 ms Spinel 2.3 ms · JRuby warm 577 ms · JRuby cold 1.06 s · cold = 458× Spinel matmul: Spinel 3.2 ms; JRuby warm 899 ms; JRuby cold 1.24 s. A cold JRuby run takes 389× the Spinel time. matmul matmul · JRuby cold: 1.24 s matmul · JRuby warm: 899 ms matmul · Spinel: 3.2 ms Spinel 3.2 ms · JRuby warm 899 ms · JRuby cold 1.24 s · cold = 389× Spinel csv_process: Spinel 98.3 ms; JRuby warm 1.19 s; JRuby cold 2.20 s. A cold JRuby run takes 22× the Spinel time. csv_process csv_process · JRuby cold: 2.20 s csv_process · JRuby warm: 1.19 s csv_process · Spinel: 98.3 ms Spinel 98.3 ms · JRuby warm 1.19 s · JRuby cold 2.20 s · cold = 22× Spinel sieve: Spinel 7.2 ms; JRuby warm 1.40 s; JRuby cold 1.27 s. A cold JRuby run takes 176× the Spinel time. sieve sieve · JRuby cold: 1.27 s sieve · JRuby warm: 1.40 s sieve · Spinel: 7.2 ms Spinel 7.2 ms · JRuby warm 1.40 s · JRuby cold 1.27 s · cold = 176× Spinel fib: Spinel 1.1 ms; JRuby warm 1.84 s; JRuby cold 2.27 s. A cold JRuby run takes 2144× the Spinel time. fib fib · JRuby cold: 2.27 s fib · JRuby warm: 1.84 s fib · Spinel: 1.1 ms Spinel 1.1 ms · JRuby warm 1.84 s · JRuby cold 2.27 s · cold = 2144× Spinel ao_render (ray tracer): Spinel 65.4 ms; JRuby warm 2.13 s; JRuby cold 3.04 s. A cold JRuby run takes 47× the Spinel time. ao_render (ray tracer) ao_render (ray tracer) · JRuby cold: 3.04 s ao_render (ray tracer) · JRuby warm: 2.13 s ao_render (ray tracer) · Spinel: 65.4 ms Spinel 65.4 ms · JRuby warm 2.13 s · JRuby cold 3.04 s · cold = 47× Spinel partial_sums: Spinel 16.8 ms; JRuby warm 2.39 s; JRuby cold 2.35 s. A cold JRuby run takes 140× the Spinel time. partial_sums partial_sums · JRuby cold: 2.35 s partial_sums · JRuby warm: 2.39 s partial_sums · Spinel: 16.8 ms Spinel 16.8 ms · JRuby warm 2.39 s · JRuby cold 2.35 s · cold = 140× Spinel mandelbrot: Spinel 16.0 ms; JRuby warm 2.93 s; JRuby cold 1.74 s. A cold JRuby run takes 109× the Spinel time. mandelbrot mandelbrot · JRuby cold: 1.74 s mandelbrot · JRuby warm: 2.93 s mandelbrot · Spinel: 16.0 ms Spinel 16.0 ms · JRuby warm 2.93 s · JRuby cold 1.74 s · cold = 109× Spinel
Log scale, sorted by warm JRuby time. The shaded bar spans JRuby warm (after 15 warm-up runs in one JVM) to cold (a new JVM per run); the dashed line is an empty program on a new JVM. Hover a row for its three values.
Per benchmark, log scale, sorted by warm JRuby time: Spinel, JRuby warm (same JVM, mean of the last 5 of 20 runs) and JRuby cold (a new JVM per run). The bar between warm and cold is JVM start-up plus warm-up. Spinel: hover to isolate this seriesSpinel JRuby 10.1 warm: hover to isolate this seriesJRuby 10.1 warm JRuby 10.1 cold: hover to isolate this seriesJRuby 10.1 cold between warm and cold: start-up + warm-up an empty program on a new JVM: 620 ms 0.1 ms0.1 ms 1 ms1 ms 10 ms10 ms 100 ms100 ms 1 s1 s 10 s10 s pidigits: Spinel 1.1 ms; JRuby warm 0.60 ms; JRuby cold 644 ms. A cold JRuby run takes 580× the Spinel time. pidigits1.1 ms · 0.60 ms · 644 ms pidigits · JRuby cold: 644 ms pidigits · JRuby warm: 0.60 ms pidigits · Spinel: 1.1 ms bigint_fib: Spinel 1.1 ms; JRuby warm 0.70 ms; JRuby cold 622 ms. A cold JRuby run takes 565× the Spinel time. bigint_fib1.1 ms · 0.70 ms · 622 ms bigint_fib · JRuby cold: 622 ms bigint_fib · JRuby warm: 0.70 ms bigint_fib · Spinel: 1.1 ms str_concat: Spinel 1.1 ms; JRuby warm 1.5 ms; JRuby cold 636 ms. A cold JRuby run takes 563× the Spinel time. str_concat1.1 ms · 1.5 ms · 636 ms str_concat · JRuby cold: 636 ms str_concat · JRuby warm: 1.5 ms str_concat · Spinel: 1.1 ms fannkuch: Spinel 1.1 ms; JRuby warm 13.4 ms; JRuby cold 706 ms. A cold JRuby run takes 636× the Spinel time. fannkuch1.1 ms · 13.4 ms · 706 ms fannkuch · JRuby cold: 706 ms fannkuch · JRuby warm: 13.4 ms fannkuch · Spinel: 1.1 ms fasta: Spinel 1.4 ms; JRuby warm 28.2 ms; JRuby cold 742 ms. A cold JRuby run takes 537× the Spinel time. fasta1.4 ms · 28.2 ms · 742 ms fasta · JRuby cold: 742 ms fasta · JRuby warm: 28.2 ms fasta · Spinel: 1.4 ms binary_trees: Spinel 3.2 ms; JRuby warm 50.8 ms; JRuby cold 714 ms. A cold JRuby run takes 220× the Spinel time. binary_trees3.2 ms · 50.8 ms · 714 ms binary_trees · JRuby cold: 714 ms binary_trees · JRuby warm: 50.8 ms binary_trees · Spinel: 3.2 ms tak: Spinel 6.5 ms; JRuby warm 62.7 ms; JRuby cold 702 ms. A cold JRuby run takes 107× the Spinel time. tak6.5 ms · 62.7 ms · 702 ms tak · JRuby cold: 702 ms tak · JRuby warm: 62.7 ms tak · Spinel: 6.5 ms tarai: Spinel 5.4 ms; JRuby warm 69.1 ms; JRuby cold 689 ms. A cold JRuby run takes 127× the Spinel time. tarai5.4 ms · 69.1 ms · 689 ms tarai · JRuby cold: 689 ms tarai · JRuby warm: 69.1 ms tarai · Spinel: 5.4 ms io_wordcount: Spinel 12.1 ms; JRuby warm 76.2 ms; JRuby cold 786 ms. A cold JRuby run takes 65× the Spinel time. io_wordcount12.1 ms · 76.2 ms · 786 ms io_wordcount · JRuby cold: 786 ms io_wordcount · JRuby warm: 76.2 ms io_wordcount · Spinel: 12.1 ms ackermann: Spinel 4.2 ms; JRuby warm 112 ms; JRuby cold 783 ms. A cold JRuby run takes 186× the Spinel time. ackermann4.2 ms · 112 ms · 783 ms ackermann · JRuby cold: 783 ms ackermann · JRuby warm: 112 ms ackermann · Spinel: 4.2 ms huffman: Spinel 4.4 ms; JRuby warm 118 ms; JRuby cold 1.08 s. A cold JRuby run takes 245× the Spinel time. huffman4.4 ms · 118 ms · 1.08 s huffman · JRuby cold: 1.08 s huffman · JRuby warm: 118 ms huffman · Spinel: 4.4 ms json_parse: Spinel 22.8 ms; JRuby warm 203 ms; JRuby cold 888 ms. A cold JRuby run takes 39× the Spinel time. json_parse22.8 ms · 203 ms · 888 ms json_parse · JRuby cold: 888 ms json_parse · JRuby warm: 203 ms json_parse · Spinel: 22.8 ms so_lists: Spinel 15.0 ms; JRuby warm 248 ms; JRuby cold 858 ms. A cold JRuby run takes 57× the Spinel time. so_lists15.0 ms · 248 ms · 858 ms so_lists · JRuby cold: 858 ms so_lists · JRuby warm: 248 ms so_lists · Spinel: 15.0 ms splay tree: Spinel 9.2 ms; JRuby warm 315 ms; JRuby cold 1.12 s. A cold JRuby run takes 123× the Spinel time. splay tree9.2 ms · 315 ms · 1.12 s splay tree · JRuby cold: 1.12 s splay tree · JRuby warm: 315 ms splay tree · Spinel: 9.2 ms linked_list: Spinel 31.3 ms; JRuby warm 331 ms; JRuby cold 992 ms. A cold JRuby run takes 32× the Spinel time. linked_list31.3 ms · 331 ms · 992 ms linked_list · JRuby cold: 992 ms linked_list · JRuby warm: 331 ms linked_list · Spinel: 31.3 ms template engine: Spinel 60.3 ms; JRuby warm 336 ms; JRuby cold 1.07 s. A cold JRuby run takes 18× the Spinel time. template engine60.3 ms · 336 ms · 1.07 s template engine · JRuby cold: 1.07 s template engine · JRuby warm: 336 ms template engine · Spinel: 60.3 ms rbtree: Spinel 18.0 ms; JRuby warm 413 ms; JRuby cold 1.03 s. A cold JRuby run takes 57× the Spinel time. rbtree18.0 ms · 413 ms · 1.03 s rbtree · JRuby cold: 1.03 s rbtree · JRuby warm: 413 ms rbtree · Spinel: 18.0 ms life (Game of Life): Spinel 20.8 ms; JRuby warm 430 ms; JRuby cold 1.27 s. A cold JRuby run takes 61× the Spinel time. life (Game of Life)20.8 ms · 430 ms · 1.27 s life (Game of Life) · JRuby cold: 1.27 s life (Game of Life) · JRuby warm: 430 ms life (Game of Life) · Spinel: 20.8 ms gcbench: Spinel 182 ms; JRuby warm 462 ms; JRuby cold 1.44 s. A cold JRuby run takes 7.9× the Spinel time. gcbench182 ms · 462 ms · 1.44 s gcbench · JRuby cold: 1.44 s gcbench · JRuby warm: 462 ms gcbench · Spinel: 182 ms nqueens: Spinel 4.9 ms; JRuby warm 464 ms; JRuby cold 1.41 s. A cold JRuby run takes 288× the Spinel time. nqueens4.9 ms · 464 ms · 1.41 s nqueens · JRuby cold: 1.41 s nqueens · JRuby warm: 464 ms nqueens · Spinel: 4.9 ms sudoku: Spinel 2.3 ms; JRuby warm 577 ms; JRuby cold 1.06 s. A cold JRuby run takes 458× the Spinel time. sudoku2.3 ms · 577 ms · 1.06 s sudoku · JRuby cold: 1.06 s sudoku · JRuby warm: 577 ms sudoku · Spinel: 2.3 ms matmul: Spinel 3.2 ms; JRuby warm 899 ms; JRuby cold 1.24 s. A cold JRuby run takes 389× the Spinel time. matmul3.2 ms · 899 ms · 1.24 s matmul · JRuby cold: 1.24 s matmul · JRuby warm: 899 ms matmul · Spinel: 3.2 ms csv_process: Spinel 98.3 ms; JRuby warm 1.19 s; JRuby cold 2.20 s. A cold JRuby run takes 22× the Spinel time. csv_process98.3 ms · 1.19 s · 2.20 s csv_process · JRuby cold: 2.20 s csv_process · JRuby warm: 1.19 s csv_process · Spinel: 98.3 ms sieve: Spinel 7.2 ms; JRuby warm 1.40 s; JRuby cold 1.27 s. A cold JRuby run takes 176× the Spinel time. sieve7.2 ms · 1.40 s · 1.27 s sieve · JRuby cold: 1.27 s sieve · JRuby warm: 1.40 s sieve · Spinel: 7.2 ms fib: Spinel 1.1 ms; JRuby warm 1.84 s; JRuby cold 2.27 s. A cold JRuby run takes 2144× the Spinel time. fib1.1 ms · 1.84 s · 2.27 s fib · JRuby cold: 2.27 s fib · JRuby warm: 1.84 s fib · Spinel: 1.1 ms ao_render (ray tracer): Spinel 65.4 ms; JRuby warm 2.13 s; JRuby cold 3.04 s. A cold JRuby run takes 47× the Spinel time. ao_render (ray tracer)65.4 ms · 2.13 s · 3.04 s ao_render (ray tracer) · JRuby cold: 3.04 s ao_render (ray tracer) · JRuby warm: 2.13 s ao_render (ray tracer) · Spinel: 65.4 ms partial_sums: Spinel 16.8 ms; JRuby warm 2.39 s; JRuby cold 2.35 s. A cold JRuby run takes 140× the Spinel time. partial_sums16.8 ms · 2.39 s · 2.35 s partial_sums · JRuby cold: 2.35 s partial_sums · JRuby warm: 2.39 s partial_sums · Spinel: 16.8 ms mandelbrot: Spinel 16.0 ms; JRuby warm 2.93 s; JRuby cold 1.74 s. A cold JRuby run takes 109× the Spinel time. mandelbrot16.0 ms · 2.93 s · 1.74 s mandelbrot · JRuby cold: 1.74 s mandelbrot · JRuby warm: 2.93 s mandelbrot · Spinel: 16.0 ms
Log scale, sorted by warm JRuby time. The shaded bar spans JRuby warm (after 15 warm-up runs in one JVM) to cold (a new JVM per run); the dashed line is an empty program on a new JVM.

The JVM pays up front: it starts, loads classes, interprets, then compiles the hot methods. A warm run reuses all of that; a cold run pays it again.

After 15 warm-up runs, JRuby beats YJIT on 13 of 28 programs and Spinel on 2 (bigint_fib and pidigits, at most 0.70 ms warm): a warmed JIT re-running a tiny bignum workload, which is the best case for a long-lived process and says nothing about a cold job. On mandelbrot, sieve and partial_sums the warm mean is even slower than the cold one, so read the warm column as “JRuby after a warm-up”, not as JRuby’s peak. For JRuby on longer-running code, see the eight-fragment comparison.

Spinel has no such split: the binary starts like any C program and runs at full speed from the first instruction. For a short job (a CLI, a batch step, a helper spawned per request) start-up decides the result.

All 28 results

BenchmarkSpinelCRuby 4.0+ YJITJRuby coldJRuby warmSpinel vs YJIT
Computation
fib1.1 ms345 ms354 ms2.27 s1.84 s334×
matmul3.2 ms239 ms239 ms1.24 s899 ms75×
tak6.5 ms304 ms446 ms702 ms62.7 ms68×
sieve7.2 ms380 ms379 ms1.27 s1.40 s52×
mandelbrot16.0 ms774 ms774 ms1.74 s2.93 s48×
sudoku2.3 ms71.1 ms109 ms1.06 s577 ms47×
tarai5.4 ms237 ms245 ms689 ms69.1 ms45×
ackermann4.2 ms305 ms176 ms783 ms112 ms42×
partial_sums16.8 ms693 ms695 ms2.35 s2.39 s41×
life (Game of Life)20.8 ms480 ms830 ms1.27 s430 ms40×
nqueens4.9 ms145 ms146 ms1.41 s464 ms30×
fannkuch1.1 ms8.6 ms8.9 ms706 ms13.4 ms8.0×
fasta1.4 ms8.5 ms9.3 ms742 ms28.2 ms6.7×
Data structures & GC
so_lists15.0 ms228 ms389 ms858 ms248 ms26×
rbtree18.0 ms267 ms446 ms1.03 s413 ms25×
splay tree9.2 ms94.4 ms170 ms1.12 s315 ms19×
gcbench182 ms1.78 s2.61 s1.44 s462 ms14×
linked_list31.3 ms177 ms336 ms992 ms331 ms11×
binary_trees3.2 ms21.2 ms32.2 ms714 ms50.8 ms9.9×
huffman4.4 ms38.1 ms40.0 ms1.08 s118 ms9.1×
Real-world programs
ao_render (ray tracer)65.4 ms1.40 s2.03 s3.04 s2.13 s31×
json_parse22.8 ms169 ms275 ms888 ms203 ms12×
template engine60.3 ms433 ms630 ms1.07 s336 ms10×
bigint_fib1.1 ms5.2 ms5.9 ms622 ms0.70 ms5.4×
pidigits1.1 ms5.8 ms5.9 ms644 ms0.60 ms5.3×
csv_process98.3 ms404 ms511 ms2.20 s1.19 s5.2×
str_concat1.1 ms5.7 ms5.6 ms636 ms1.5 ms5.0×
io_wordcount12.1 ms41.8 ms53.4 ms786 ms76.2 ms4.4×

Why Spinel can’t run a Rails app, and JRuby can

Spinel has to know every class, method and type before it emits C. Rails creates many of them after the process starts, from the database schema, the file tree and each request. Everything right of the line below is invisible to Spinel.

Build time on the left, run time on the right. JRuby carries a parser and JIT into run time; a Spinel binary has neither, so what Rails decides at boot or per request cannot reach Spinel's analysis. BUILD TIME binary built ▸ RUN TIME · boot → requests JRuby: a full Ruby runtime app + gems as Ruby source nothing compiled ahead; C gems swapped for Java ports parser → interpreter → JIT types checked while it runs code built at boot: parsed and run ✓ Spinel: a whole-program compiler app + libs all source read at once analysis fixes every class, method and type → C → cc native binary classes, methods and types frozen no parser, no interpreter inside string eval: refused at build ✗ What Rails decides at run time ← each is an answer the analysis needs at build time Spinel compiles only what is left of the line. ActiveRecord builds attribute methods from the schema at boot. Spinel refuses a define_method with a computed name and a module_eval of a computed string at compile time. ActiveRecord attributes schema → methods per column, at boot Zeitwerk registers an autoload per file from the directory tree at boot. Spinel compiles an autoload only when its path is readable at compile time, and loads the file at program start. Zeitwerk autoload file tree → constants, loaded on first use ActionView compiles each template to Ruby source at run time and evaluates it. Spinel refuses a string eval, and its ERB renders no template with Ruby code in a tag. ActionView templates ERB → a Ruby string → module_eval Spinel compiles every call site to a direct C call: method_missing is never dispatched, and send with a computed name reaches only methods that exist at compile time. method_missing · computed names the method is picked from run-time data Spinel cannot load a CRuby extension binary. An extension has to be rebuilt from source against Spinel's restricted C API, or bound through its FFI. C extensions pg · nio4r (puma) · nokogiri · bcrypt
Spinel compiles what it can see at build time. Rails computes classes, methods and code paths after boot, from the schema, the file tree and each request. Hover a row for what Spinel does with it.
Build time above the line, run time below. JRuby carries a parser and JIT into run time; a Spinel binary has neither, so what Rails decides at boot or per request cannot reach Spinel's analysis. BUILD TIME JRuby Spinel app + gems as source nothing compiled ahead; C gems → Java ports app + libraries all source read at once analysis fixes every class, method and type → C → cc → binary binary built ▾ RUN TIME · boot → requests parser → interpreter → JIT types checked while running code built at boot: parsed and run ✓ native binary no parser, no interpreter string eval: refused at build ✗ What Rails decides at run time ActiveRecord attributes schema → methods per column, at boot Zeitwerk autoload file tree → constants, loaded on first use ActionView templates ERB / HAML → a Ruby string → module_eval method_missing · computed names the method is picked from run-time data C extensions pg · nio4r (puma) · nokogiri · bcrypt ↑ each is an answer the analysis needs at build time Fix: move each decision above the line — templates to Ruby at build, attribute methods from a dumped schema, eager-loaded constants, ported C gems — or ship an interpreter in the binary, which is CRuby again.
Spinel compiles what it can see at build time. Rails computes classes, methods and code paths after boot, from the schema, the file tree and each request.

Each of those is ordinary Rails, not an edge case:

Making Rails compile would mean moving each decision to build time (templates rendered to Ruby, attribute methods generated from a schema dump, every constant eager-loaded, every C gem ported) or putting an interpreter in the binary, which is CRuby again.

JRuby has none of these problems because it is a complete Ruby runtime: the parser, an interpreter and a JIT are in the running process, so code that appears at boot is parsed and run like any other. The C gems are replaced with Java ports (activerecord-jdbc-adapter, nokogiri’s Java build). That is why JRuby runs Rails today and Spinel does not.

How to use Spinel from a Rails app

Spinel doesn’t need the whole app. Compile the pure, CPU-bound pieces into native binaries (“kernels”) and call them from Rails, which stays on CRuby. A kernel takes plain data in and returns plain data out: no database, no I/O beyond stdin and stdout, no metaprogramming. That is stdlib-only Ruby, which Spinel compiles today.

Rails on CRuby calls stdlib-only Ruby kernels compiled to native binaries through one KernelClient, passing plain data on stdin and stdout; CI builds the binaries for amd64 and arm64 and checks their output against CRuby's. CRuby + Rails: unchanged web controllers · views · ActiveRecord · auth · the database, as today The only code that knows kernels exist. It serialises plain data to JSON, spawns the binary for this CPU architecture, and raises on a missing binary or a non-zero exit. It never runs the kernel's Ruby source instead. KernelClient: the one boundary JSON → spawn binary → stdout plain data only, no ActiveRecord objects missing binary or exit ≠ 0 → raise background jobs · rake tasks batch work that calls the same kernels through the same client stdin: JSON stdout: SVG / JSON Kernels: stdlib-only Ruby, compiled by Spinel to native binaries Good fit: projection maths and turning polygons into SVG path strings is pure CPU work on plain arrays. map rendering projection maths, polygons → SVG Good fit when the rows are already loaded: Rails does the query, the kernel only aggregates. rollups aggregation only; reads stay in Rails Good fit: numeric transforms such as value-to-colour scales and sun-angle maths have no dependencies. colour scales value → colour, sun-angle maths Good fit: parsers for text formats and batch workers that build strings from files. parsers · batch text formats, string building Build + CI kernels/*.rb plain Ruby source spinel Ruby → C → native bin/kernels/ amd64 + arm64 builds app image binaries inside deployed with the app The kernel source is still Ruby, so CI runs every fixture through CRuby and through each compiled binary and compares the two outputs byte for byte. A difference fails the build. CI gate every fixture runs through CRuby and through each binary; the two outputs must match byte for byte, or the build is red
Rails keeps the database, the views and the request cycle. Kernels get plain data and return plain data; CI proves each binary prints exactly what CRuby prints for the same input.
Rails on CRuby calls stdlib-only Ruby kernels compiled to native binaries through one KernelClient, passing plain data on stdin and stdout; CI builds the binaries for amd64 and arm64 and checks their output against CRuby's. CRuby + Rails — unchanged web controllers · views · ActiveRecord · auth background jobs · rake tasks batch work through the same client KernelClient — the one boundary payload → JSON → spawn → stdout no ActiveRecord objects, no DB handles missing binary or exit ≠ 0 → raise stdin: data stdout: SVG/JSON Kernels — stdlib Ruby → Spinel → native one binary per arch: amd64 + arm64 map rendering projection maths, polygons → SVG paths rollups aggregation only; reads stay in Rails colour scales value → colour, sun-angle maths parsers · batch text formats, string building Build + CI kernels/*.rb plain Ruby source spinel Ruby → C → native bin/kernels/ <name>-amd64 · -arm64 app image binaries inside, deployed gate same fixture in, and the source also run on CRuby: CRuby output == binary output byte for byte — CRuby runs it in tests only, else the build is red
Rails keeps the database, the views and the request cycle. Kernels get plain data and return plain data; CI proves each binary prints exactly what CRuby prints for the same input.

The rules that make it work:

  1. Stdlib only inside a kernel. No Rails, no gems with C extensions, no database, no eval, no method_missing. That is the subset Spinel compiles today, and it also makes the code easy to test.
  2. Plain data across the boundary. Rails loads the records, turns them into arrays and hashes and writes JSON to the kernel’s stdin. The kernel writes SVG or JSON to stdout. ActiveRecord objects and connections never cross.
  3. One client, and it fails loudly. A missing binary, a binary for the wrong architecture or a non-zero exit raises. Rails never quietly runs the kernel’s Ruby source instead: that would hide a broken build behind a slow path that looks like it works.
  4. CI proves the two agree. The kernel’s source is still Ruby, so CI runs each fixture through CRuby and through the compiled binary and compares the output byte for byte. A difference fails the build.
  5. Measure first. Pick candidates by profile, not by code shape. A kernel pays only when the work is CPU time inside Ruby, and every call costs a process start (0.77 ms for an empty binary on this host) plus the JSON round trip, so batch the work per call.

The client is small:

require "open3"

class KernelClient
  Error = Class.new(StandardError)
  ARCH  = { "x86_64" => "amd64", "aarch64" => "arm64" }.fetch(RbConfig::CONFIG["host_cpu"])
  DIR   = Rails.root.join("bin/kernels")

  def self.call(name, payload)
    bin = DIR.join("#{name}-#{ARCH}")
    raise Error, "kernel #{name} is not built: #{bin}" unless bin.executable?

    out, err, status = Open3.capture3(bin.to_s, stdin_data: JSON.generate(payload))
    raise Error, "kernel #{name} exited #{status.exitstatus}: #{err}" unless status.success?

    out
  end
end

svg = KernelClient.call("map_svg", regions: regions.map { |r| [r.id, r.polygon] }, width: 1200)

ARCH uses fetch, so a host the build has no binary for stops at boot instead of picking the wrong one.

Good fits: map projections and SVG generation, rollups over data already loaded, colour scales and other numeric transforms, parsers for text formats, batch workers that chew through files. Bad fits: anything bound by the database, the network or the disk (a faster loop does nothing for a request that spends its time waiting on Postgres), and anything that leans on Rails itself.

Spinel vs JRuby vs CRuby + YJIT: which to pick

Keep the app on CRuby with YJIT, use JRuby when a long-lived process needs real threads or a JVM library, and move the hot, pure pieces into Spinel kernels.

CRuby + YJITJRubySpinel
Runs a Rails appyes, the referenceyes, with JDBC adapters and Java ports of C gemsno: everything must be known at build time
Empty-program start5.3 ms (ruby -e 0), 5.5 ms with YJIT620 ms (jruby -e 0)0.77 ms
Speed vs YJIT (geomean, these 28, ARM64)1× (interpreter: 1.2×)0.95× after warm-up · 0.14× cold20×
ThreadsGVL; Ractors and fork for parallelismreal threads, no GVLThread with true parallelism and no GVL (an M:N scheduler over OS workers)
String eval, method_missing, computed define_methodyesyesno: refused at compile time, and method_missing is not dispatched; see its limitations
C extensionsyesno, Java ports insteadno CRuby binaries: source rebuilt against a restricted C API, or FFI
Pick it forthe app itselflong-lived processes that need real threads or the JVM ecosystempure, CPU-bound kernels called from the app

FAQ

Is Spinel faster than YJIT?

On these 28 programs, yes: 20× on the geometric mean and faster on every program, from 4.4× to 334×. They are short, CPU-bound programs measured on one ARM64 host, not Rails requests.

Can Spinel run Ruby on Rails?

No. Rails builds classes and methods at run time from the schema, the file tree and its templates, and Spinel compiles only what it can see at build time. Spinel fits the pure, CPU-bound code a Rails app calls.

Is JRuby faster than CRuby?

It depends on how long the process lives. After 15 warm-up runs JRuby beats YJIT on 13 of these 28 programs (0.95× of YJIT’s speed on the geometric mean); started cold it is at 0.14×, because the JVM alone takes 620 ms to start.

Does a Spinel binary need Ruby installed?

No. The compiled executable has no interpreter or parser inside and needs only libc and libm at run time.

If you have a Rails app with a slow, CPU-bound corner, or one that needs to scale in any other way, let’s talk.

Questions? Let's Chat :)

ruby