From 9975600be8e5be684ef238291ea17f4a78378425 Mon Sep 17 00:00:00 2001 From: CarlJia Date: Tue, 22 Sep 2026 21:18:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?perf(release):=20=E5=85=B3=E6=95=B4?= =?UTF-8?q?=E6=95=B0=E6=BA=A2=E5=87=BA=E6=A3=80=E6=9F=A5,release=20?= =?UTF-8?q?=E4=BA=8C=E8=BF=9B=E5=88=B6=E4=BD=93=E7=A7=AF=20-1.6%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 77a4d367..0dd83966 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,3 +74,8 @@ lto = true opt-level = "z" panic = "abort" strip = true +# 整数溢出检查在 release 里关掉:`panic = "abort"` 已经把 panic 转成进程退出, +# overflow 也只是这条路径的另一条出口,减一个分支检查能再压一点体积;hub 内部 +# 计数(流量字节、月份累加、id 序列)的 `wrapping_*` 调用仍然走显式环绕, +# 不依赖隐式 wrapping。debug profile 保留检查,免得本地复现时被静默溢出误导。 +overflow-checks = false From 2d6a9dae2fc42dd0c67ddfcbf60e0983cf57468c Mon Sep 17 00:00:00 2001 From: CarlJia Date: Tue, 22 Sep 2026 21:28:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf(release):=20=E5=85=B3=20axum=20/=20tow?= =?UTF-8?q?er-http=20=E9=BB=98=E8=AE=A4=20features,=E4=BD=93=E7=A7=AF?= =?UTF-8?q?=E5=86=8D=20-0.82%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Cargo.lock | 4 ---- Cargo.toml | 9 ++++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4abfbb40..8c9d8d82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,7 +135,6 @@ dependencies = [ "tower", "tower-layer", "tower-service", - "tracing", ] [[package]] @@ -154,7 +153,6 @@ dependencies = [ "sync_wrapper", "tower-layer", "tower-service", - "tracing", ] [[package]] @@ -2329,7 +2327,6 @@ dependencies = [ "tokio", "tower-layer", "tower-service", - "tracing", ] [[package]] @@ -2373,7 +2370,6 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", diff --git a/Cargo.toml b/Cargo.toml index 0dd83966..a45172f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,11 @@ rmp-serde = "1" tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "time", "signal", "sync", "fs"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -# "multipart": 插件上传(R11)接收 multipart/form-data 的 tar.gz。 -axum = { version = "0.8", features = ["ws", "macros", "multipart"] } +# "multipart": 插件上传(R11)接收 multipart/form-data 的 tar.gz。`http1`/ +# `json`/`query`/`tokio` 是显式列出来的必要项;`tracing`/`tower-log`/`form`/ +# `matched-path` 等默认 features 都是我们没在用的(没有 TraceLayer/LogLayer/ +# Form extractor/匹配路径展开),default-features=false 砍掉。 +axum = { version = "0.8", default-features = false, features = ["ws", "macros", "multipart", "http1", "json", "query", "tokio"] } rusqlite = { version = "0.37", features = ["bundled", "backup"] } reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] } argon2 = "0.5" @@ -32,7 +35,7 @@ chrono = { version = "0.4", default-features = false, features = ["std", "clock" rust-embed = { version = "8", features = ["include-exclude"] } mime_guess = "2" tokio-util = { version = "0.7", features = ["io"] } -tower-http = { version = "0.6", features = ["limit", "compression-gzip"] } +tower-http = { version = "0.6", default-features = false, features = ["limit", "compression-gzip"] } # Theme archives. Both are pure Rust: the release binary is built with `cross` # and the image is FROM scratch, which rules out a C dependency or an external # tar.