Skip to content

perf(windows): link the C runtime statically (--version 6.88 -> 6.43 ms) - #441

Merged
mrnasil merged 2 commits into
mainfrom
perf/windows-static-crt
Nov 9, 2026
Merged

mrnasil merged 2 commits into
mainfrom
perf/windows-static-crt

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 9, 2026

Copy link
Copy Markdown
Member

Summary

  • .cargo/config.toml: +crt-static for cfg(all(windows, target_env = "msvc")). The release workflow builds from the checkout, so shipped Windows binaries pick it up.
  • After perf(cli): cut Windows short-command startup by 40-58% #416 delay-loaded the system DLLs, the dynamic CRT (VCRUNTIME140 + nine api-ms-win-crt-*) was the last thing loading before main.
  • Side effect: the binary no longer needs the VC++ redistributable.

Measurements (Windows 11, x86_64, release, --version, interleaved, 2×300 runs)

Build Median p95
v0.6.36 (dynamic CRT) 6.88 ms 7.75 ms
static CRT 6.43 ms 7.07 ms

Empty Rust main on the same boot: 6.7 ms dynamic, 6.3 ms static — the rest is Windows process creation.

Test plan

  • Release build with --features bundled-sqlite (same as release.yml); dumpbin /dependents: no CRT DLLs, the eight system DLLs still delay-loaded
  • Isolated WHYCODES_HOME smoke: config show, session list (creates whycodes.db), --help, __shell -c "echo hi && ls | wc -l"
  • Debug build picks up the config (0 CRT imports); cli_args test_cli_help, whycodes-storage --lib pass

🤖 Generated with Claude Code

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]>
@mrnasil
mrnasil enabled auto-merge (squash) November 9, 2026 12:06
@mrnasil
mrnasil merged commit 62c6d09 into main Nov 9, 2026
7 checks passed
@mrnasil
mrnasil deleted the perf/windows-static-crt branch November 9, 2026 12:14
mrnasil added a commit that referenced this pull request Nov 9, 2026
_norm used lstrip("./"), which strips every leading '.' and '/', so
".cargo/config.toml" became "cargo/config.toml" and never matched the
.cargo/ workspace root: Test (linux) selected nothing for it (#441).
Only a leading "./" is dropped now.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@mrnasil mrnasil mentioned this pull request Nov 9, 2026
mrnasil added a commit that referenced this pull request Nov 9, 2026
The released binary links the CRT statically (#441). Interleaved with
v0.6.36 on the same boot: 6.96 vs 7.46 ms.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant