Skip to content

build(antd): size-optimized release profile (strip + thin LTO)#195

Open
Nic-dorman wants to merge 1 commit into
mainfrom
nic/antd-release-size-profile
Open

build(antd): size-optimized release profile (strip + thin LTO)#195
Nic-dorman wants to merge 1 commit into
mainfrom
nic/antd-release-size-profile

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

@

What

Adds a size-tuned [profile.release] to antd/Cargo.toml:

[profile.release]
strip = "symbols"
lto = "thin"
codegen-units = 1

Why

The release binary used cargos default release profile (unstripped, codegen-units = 16, no LTO). antd is a single static binary embedding a full P2P client (ant-core/saorsa + QUIC), the EVM payment stack (alloy/evmlib), and both a REST (axum) and gRPC (tonic) server — so there was real, untapped size headroom.

Measured impact (2026-06-09)

Built the same binary with the default profile vs. this profile:

Target Default This profile Δ
Linux (antd-linux-amd64) 36.5 MB 22.1 MB −37%
Windows (antd-windows-amd64.exe) 29.8 MB 24.6 MB −17%

strip is the dominant, zero-cost win on Linux (debug symbols the Windows .exe never carried — they live in a separate .pdb). Thin LTO + a single codegen unit add the rest and tend to improve runtime perf. Stripped+LTOd, both platforms converge to ~22–24 MB.

Cost: a slower release link (Linux ~1→4.5 min, Windows ~3→7 min). This is profile.release only — dev/cargo build inner-loop times are unaffected.

Verification

Both optimized binaries were smoke-tested on Linux and Windows: they launch, print --help, and serve a valid /health response ({"status":"ok",...}) while running. No behavior change beyond the binary layout.

🤖 Generated with Claude Code
@

Adds [profile.release] with strip = symbols, lto = thin, codegen-units = 1.

Measured 2026-06-09 against the default release profile: Linux 36.5 MB -> 22.1 MB (-37%), Windows .exe 29.8 MB -> 24.6 MB (-17%). strip is the dominant, zero-cost win on Linux; thin LTO + single codegen unit add the rest. Cost is a slower release link only (dev builds unaffected). Both optimized binaries smoke-tested on Linux + Windows: launch, --help, and serve a valid /health response.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Nic-dorman

Copy link
Copy Markdown
Collaborator Author

macOS arm64 measurement (2026-06-10)

Built locally on Apple Silicon (M-series) to fill in the gap left by the Linux/Windows numbers in the PR body:

Target Default This profile Δ
macOS arm64 (antd-darwin-arm64) 27.15 MiB 18.34 MiB −32.5%

For reference alongside the existing table:

Target Default This profile Δ
Linux (antd-linux-amd64) 36.5 MB 22.1 MB −37%
macOS arm64 (antd-darwin-arm64) 27.15 MiB 18.34 MiB −32.5%
Windows (antd-windows-amd64.exe) 29.8 MB 24.6 MB −17%

macOS lands between Linux and Windows — closer to Linux, as expected since Mach-O carries embedded debug symbols that strip = "symbols" removes (Windows .exe files don't, they live in separate .pdbs).

Build-time cost on mac: 1m 53s → 2m 30s (+37s, +33%). Much smaller than the Linux 1m → 4.5m jump noted in the PR — Apple Silicon handles the thin-LTO link cheaply.

Caveat: the comparison was origin/main vs origin/nic/antd-release-size-profile head-to-head, so the lockfiles differ slightly (ant-protocol 2.1.0 → 2.1.2, ant-core 0.2.4 → 0.2.7). The headline result is clearly dominated by strip, but the number isn't perfectly pure. Both binaries verified as Mach-O 64-bit executable arm64.

No CI change needed to capture this — [profile.release] is target-agnostic, so the aarch64-apple-darwin matrix entry in release.yml picks it up automatically on the next tag.

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