Repository navigation
perf(cli): cut Windows short-command startup by 40-58% - #416
Merged
Merged
Conversation
Re-ran the benchmarks (last process run 2026-10-16, last criterion run 2026-09-11). `--version` had drifted to 17 ms on Windows while an empty Rust exe starts in ~10 ms on the same host. Three fixes: - Delay-load user32, shell32, combase, oleaut32, ws2_32, bcrypt, userenv and advapi32 (MSVC only, build.rs). Loading them eagerly cost ~6 ms per process whether or not they were used. - `hide_possible_values` on the dynamic clap value parsers. clap asked them for their values while building the command, which read config.toml and opened the session database on every invocation (~8 ms). Completion scripts are byte-identical; `--help` no longer lists every model id and local session ids. - Skip the pre-0.7 legacy-instance migration before resolving Windows known folders when ~/.whycodes already holds instance files (~9 ms once the DLLs above are deferred). Behavior is unchanged: the copy step already returned early in that case. Interleaved medians, before -> after: --version 17.5 -> 10.5 ms, --help 26.1 -> 10.8 ms, config show 42.2 -> 23.2 ms, session list 44.1 -> 25.8 ms. Peak RSS of config show 14.2 -> 7.6 MB. TUI harness spawn-to-exit 20.0 -> 12.5 ms. Criterion hot paths are flat or faster except short `assess` calls (~1 us fixed cost from the #294 parser, documented and left alone). Co-Authored-By: Claude Opus 5.5 <[email protected]>
mrnasil
force-pushed
the
perf/windows-startup
branch
from
November 7, 2026 00:09
4ff1128 to
ea0a47d
Compare
This was referenced Nov 7, 2026
Merged
mrnasil
added a commit
that referenced
this pull request
Nov 9, 2026
…ms) (#441) With the system DLLs delay-loaded (#416), the dynamic CRT was the last thing loading before main: VCRUNTIME140 plus nine api-ms-win-crt-* DLLs. +crt-static for MSVC targets removes them. Released v0.6.36 vs this tree, interleaved, 2x300 runs: 6.88 -> 6.43 ms median, p95 7.75 -> 7.07 ms. The binary no longer needs the VC++ redistributable. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Re-ran the benchmarks: the last process run was 2026-10-16 and the last criterion run was 2026-09-11. On Windows,
--versionhad drifted to 17 ms, while an empty Rustmainstarts in ~10 ms on the same host. Three fixes:crates/cli/build.rs, MSVC only).user32,shell32,combase,oleaut32,ws2_32,bcrypt,userenvandadvapi32cost ~6 ms per process whether or not they were used. An emptymainlinked against the same DLLs starts in 15.9 ms instead of 9.6 ms. With/DELAYLOAD, they load on first call.hide_possible_valueson the dynamic clap value parsers. While building the command, clap asks every argument for its possible values to decide whether long help exists. The provider, model, session-id and auth-provider parsers readconfig.tomland opened the session DB to answer, on every invocation (~8 ms). Completion scripts are byte-identical before and after (bash, zsh, fish, PowerShell).--helpno longer prints the full model list or this machine's session ids.~/.whycodesfirst.Config::loadresolved the pre-0.7ProjectDirsknown folders (shell32 + COM) before it checked whether there was anything to migrate. Once (1) deferred those DLLs, this cost ~9 ms. Behavior is unchanged, because the copy step already returned early in that case. Includes a new test for the settled-home path.The binary size jump (18.5 → 28.9 MB) is the Windows
embedded-shelldefault. A build without it starts no faster, so the extra size does not cost startup time.Numbers (Windows, Ryzen 7 3800X, interleaved, 40 runs, median)
--version--helpconfig showsession liststatsconfig showCriterion hot paths are flat or faster: ANSI render of a 200-line fence went from 40.9 to 14.2 ms, and the index is slightly faster. The exception is
assesson short commands. The #294 parser adds ~1 µs of fixed cost there, which is documented and left alone (40× under budget).docs/benchmarks.md,docs/bench-results.jsonand the README Windows column are updated.Checks
cargo test -p whycodes-config --lib: 164 passedcargo test -p whycodes-cli: all green except 4 unit tests and 2cli_argsplain-REPL tests that fail identically on cleanmainon this Windows machine (lockfile PIDs, upgrade zip,run_shell, a debug-only stack overflow in--plain)cli,config), panic / swallowed-error / dependency / secrets ratchets, bench ceilings: okwhycodes-configcoverage locally: every new line covered. The only gaps are 3 non-UTF-8-filename branches that Windows cannot exercise, which is pre-existing.🤖 Generated with Claude Code