try, compiled: Ruby CLI to a 705KB native binary - #130
Merged
Merged
Conversation
This was referenced Aug 13, 2026
Owner
Author
Benchmark (hyperfine, MRI vs native)Moved here from the TUI PR so this stack stays Spinel-only. Measured 2026-08-13 16:04 EDT. hyperfine 1.19.0,
TUI demos (MRI + native) are still on branch |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ruby
trycompiled all the way to a 705 KB native binary with Spinel (Matz's AOT Ruby→C compiler). Same TUI, same 399 specs as MRI, startup in under a millisecond instead of ~70 ms.--helpis 73× faster. A first TUI frame is ~50–58×. The 1.0 MiB unstripped build shrinks to 705 KB with-Os+ strip.No patches to Spinel or CRuby.
ruby try.rband the gem keep working.make nativeemitsdist/try.cand linksdist/try.Watch it
Same session on MRI and on the native binary: type
spin, cursor into the word, insertx→sxpin, Ctrl-A/E, Backspace, Ctrl-U, filtertui, rename, Esc.MRI (
ruby try.rb)Native (
dist/try)Playable: MRI asciinema · native asciinema
Numbers
hyperfine 1.19.0,
--shell=none -w 3 -r 20, 2026-08-13 16:04 EDT. Ruby 3.3.8 vs Spinel79b1aba8bdef(PR 3906 soIO#tty?/#winsizework). Native won every case.--help--versioninit--and-keys=betaexec betaclonescriptworktreescriptinitis the outlier because native still forkspsto detect fish vs bash (~20 ms). Filtering 1000 dirs is whole-process (scan + four keystrokes + re-renders), not a microbench of the matcher. MRI never wins: interpreter boot is the MRI cost.399/399 specs on both
ruby try.rbanddist/try. Stack: this PR, then #131 (strip /-Os), then #133 (lint + MRI vs native compare).Why the Ruby had to change
Spinel compiles a closed world. try is a small stdlib CLI, but it used a few things AOT does not have yet (
FileUtils,IO#raw,method_missing,Integer#times, …). Those became MRI-compatible shims inTryCompatso the same source still runs on Ruby.Full gap list is in the first version of this description and in the diff. Remaining: no live SIGWINCH on native, raw mode is
stty, non-ttywinsizeis[0,0].