Repository navigation
perf(release): 关 overflow-checks + 默认 features,体积 -2.43% - #33
Merged
Merged
Conversation
release profile 已在教科书最小边界(codegen-units=1 + lto + opt-level="z" + panic="abort" + strip),Cargo.toml 依赖也已裁过(wasmtime 关默认 features、 reqwest/chrono/tar/flate2 全部禁默认)。还能再挤的部分是 release profile 里的 `overflow-checks`:与 `panic="abort"` 组合后,overflow 行为不变(进程 退出),只是少插一条分支检查。hub 内部所有计数(流量字节、月份累加、 id 序列)都用显式 `wrapping_*` 走显式语义,不依赖隐式 wrapping。debug profile 保留检查,免得本地复现时被静默溢出误导。 同棵 dep tree 下,host release 二进制:8,233,136 → 8,099,904 字节 (-133,232 / -1.62%)。cargo test 全 229 项通过。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
axum 0.8 默认 features 含 `tracing`/`tower-log`/`matched-path`/`form` 等我们没在用的中间件/extractor:没有 TraceLayer / LogLayer / Form / 匹配 路径展开,留着只是把 tracing-core / tower 链条拉进二进制。`http1`/ `json`/`query`/`tokio` 是显式列出来的必要项;显式列表加 default-features=false 后 229 项 cargo test 全过。 tower-http 默认 features 含 `trace`/`util`/`catch-panic`/`follow-redirect` 等我们没在用的中间件,同理关掉。 同棵 dep tree 下,host release 二进制:8,099,904 → 8,033,296 字节 (-66,608 / -0.82%);两次提交累计 -199,840 / -2.43%。musl 静态链接版本 CI 重新跑就能看到比例一致的缩减。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
release profile 已在教科书最小边界(codegen-units=1 + lto + opt-level="z" + panic="abort" + strip),Cargo.toml 显式依赖裁痕也都过了(wasmtime 关默认 features、reqwest/chrono/tar/flate2 全部
default-features=false)。剩下的两个形性维度:release 关
overflow-checks——panic="abort"已经把 panic 转成进程退出,overflow 走同一条路径(只是少插一条分支检查),overflow-checks=false在 release 里与panic="abort"组合后行为不变;hub 内部所有计数(流量字节、月份累加、id 序列)用显式wrapping_*,不依赖隐式 wrapping。debug profile 保留检查。axum / tower-http 关默认 features —— axum 0.8 默认含
tracing/tower-log/matched-path/form等没在用的中间件/extractor(没有 TraceLayer/LogLayer/Form/匹配路径展开),explicit 列表 +default-features=false砍掉。tower-http 同理(没在用 trace / util / catch-panic / follow-redirect)。cargo test全 229 项通过。同棵 dep tree 下,host release 二进制(arm64 macOS):
musl 静态链接 release(11.3 MB)按比例减约 275 KB,具体数字由 CI 出。
Post-Deploy Monitoring & Validation
无新 hub 日志或 metrics,这是构建层的 profile + dep features 改动。验证在 build 阶段:本次 PR 合入后,下一次打 tag 触发的 release workflow 会在 CI 里跨两个 musl target 产出两份新二进制。直连观察 artifact 大小应为同比例缩减(host 测的是 arm64 macOS glibc,musl 静态链接会偏大,但比例接近)。若某条 target 上 binary size 没变小反而变大,说明 cross 工具链对
overflow-checks=false的处理与 host rustc 不一致,需要重新评估。回滚:revert PR(两行 profile + features 改动)。