Repository navigation
I ran an autoresearch loop to optimize the executable size of zoxide. ~ 40.2% reduction #1269
Closed
haydonryan
started this conversation in
General
Replies: 1 comment 1 reply
|
Hey, thanks. A lot of these changes trade stability for a very small binary size reduction:
|
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Thank you for an amazing tool - I use it every day on every computer and VM use.
I know AI is a polarizing topic for developers so I wanted to start a discussion before sending in PRs etc.
I'm playing around a lot with AI, and I decided to do an karparthy style auto-research experiment and decided to use one of my favorite rust apps as the test subject.
Initial prompt was done on chatgpt (instant) and I fed that into deepseek v4 flash (nvidia/DeepSeek-V4-Flash-NVFP4) running locally on my server.
A few things I noted in this experiment:
Anyways let me know what you think? Want a PR? Want this to just go away? :)
Everything below here was written by AI.
Binary size optimization results for zoxide
Cargo.toml, stable toolchain)panic = "abort"in release profileouroboroswith plain struct; makeDirownedcolor,help,usage,error-context)anyhowwithdefault-features = falsetimecrate with manual YYYY-MM-DD HH:MM:SS parsing-Z build-std=std,panic_abort+panic = "immediate-abort"(nightly)What each change does
1.
panic = "abort"— Eliminates landing pads and unwind tables for every function, since this binary never unwinds. Saves ~92K.2. Remove
ouroboros— TheDatabasestruct usedouroborosfor a self-referential pattern (Vec<u8>with borrowedVec<Dir>). Replaced with a plain struct using ownedStringpaths. Removes the proc-macro crate entirely.3. Prune clap features — Disabled
suggestions(did-you-mean),env(env-var parsing),debug,unicode. Keptcolor,help,usage,error-contextso appearance is identical.4.
anyohdefault-features=false — Disables backtrace capture in error chain objects. No functional change to error messages.5. Replace
timecrate — Only consumer wasatuin.rs, parsing one timestamp format (YYYY-MM-DD HH:MM:SS). Replaced with ~30 lines of manual parsing. Removestime,time-core,time-macros,deranged,num-conv,powerfmt,nom,minimal-lexicalfrom the dependency tree.6.
build-std+immediate-abort— Rebuilds the standard library with all panic formatting, backtrace capture, DWARF debug-info readers (gimli, addr2line, object), and unwind tables stripped. Requires nightly +-Z build-std.Why the
timecrate removal saved 233K with build-std vs only 34K on stableWithout
build-std, the standard library is a precompiled blob — removingtimeonly drops its own code (~34K). The standard library's date/time formatting and parsing code paths remain linked in regardless, because libstd ships as a single monolithic archive.With
build-std, libstd is compiled from source with full LTO. Removingtimemeans the compiler can now prove that std's own date/time formatting/parsing machinery is unreachable and eliminate all of it — not just thetimecrate itself, but every libstd function that was only reachable throughtime. The multiplier comes from LTO being able to see through the entire call graph, including the standard library.Appearance/behavior preserved
96 tests pass on stable (all 16 unit tests, plus the nix-dev-gated shell compatibility tests that require external shell binaries).
All reactions