Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
827c054780 |
No files matched your search
@@ -321,6 +321,25 @@ cargo test -p sspf-pack-asset # 业务包独立可编(业务包剥离
|
||||
> 本机 curl 走系统代理,测 localhost 必须加 `--noproxy '*'`。
|
||||
> 🔴 本机沙箱**禁止 `ps` / `top`**(Operation not permitted)⇒ 内存只能用 `vmmap`(`mem-budget.sh` 已处理)。
|
||||
> 🔴 本机 rustup 下载受代理限速(~6 MB 卡死)⇒ 不要随手 `rustup update`,工具链以 `rust-toolchain.toml` 为准。
|
||||
>
|
||||
> 🔴🔴 **磁盘占用:`target/` 已从 58G 降到 1.2G,别再让它涨回去**
|
||||
>
|
||||
> 2026-11-03 实测:`target/` 曾达 **58G**(`debug/deps` 45G + `debug/incremental` 12G),
|
||||
> 而磁盘已用 87%。根因是**增量编译让 sccache 全程空转**:
|
||||
> cargo 默认给 rustc 传 `-C incremental=<target/debug/incremental>`,
|
||||
> 而 **sccache 遇到 `incremental` 直接拒缓存**(server 日志 `CannotCache(incremental)`)
|
||||
> ⇒ `Cache hits` 恒为 0、`Non-cacheable calls` 等于请求数 ⇒ 8.4G 缓存全是废的。
|
||||
>
|
||||
> 修法(已在根 `Cargo.toml` 的 `[profile.dev]` 落地 `incremental = false`):
|
||||
> - 收益:清空 `target` 后重建 **走缓存命中** —— 实测 14s(vs 全量 63s),
|
||||
> 日常改一处重编也走命中;
|
||||
> - 代价:失去 cargo 自己的增量加速(由 sccache 命中替代,且跨 `cargo clean` 仍有效)。
|
||||
>
|
||||
> ⇒ **推论**:`target/` 现在是「随时可清」的东西,清了重建只要十几秒。
|
||||
> 真要清就 `cargo clean`(**别手 `rm -rf target/`**,让 cargo 自己收)。
|
||||
> 清理前先 `pgrep -f "cargo (build|rustc|check)"` 确认没有构建在跑。
|
||||
> sccache 缓存实体在 `~/.cache/sccache`(`~/.cargo/config.toml` 已配 `rustc-wrapper`),
|
||||
> 它**不是**项目内的东西 ⇒ 不要跟着 `target/` 一起删。
|
||||
|
||||
---
|
||||
|
||||
|
||||
+19
@@ -53,6 +53,25 @@ async-trait = "0.1"
|
||||
# 只用于「MCP 模式下把 fd 1 让给 stderr」这一个系统调用(见 main.rs 的注释)。
|
||||
libc = "0.2"
|
||||
|
||||
[profile.dev]
|
||||
# 🔴🔴 **必须关掉增量编译**(2026-11-03 定)—— 否则 sccache 全程空转。
|
||||
#
|
||||
# 成因(已实测确认):cargo 默认给 rustc 传 `-C incremental=<target/debug/incremental>`,
|
||||
# 而 **sccache 遇到 `incremental` 直接拒缓存**(server 端日志:`CannotCache(incremental)`)。
|
||||
# ⇒ 表现为 `sccache --show-stats` 里 `Non-cacheable calls` 等于请求数、
|
||||
# `Cache hits` 恒为 0 ⇒ **8.4G 缓存全是废的**,每轮构建都从零重编。
|
||||
#
|
||||
# 代价与收益(实测):
|
||||
# - 关掉后 `target/debug/incremental` 不再产生 ⇒ target 少涨 12G;
|
||||
# - 清空 target 后重建 **走缓存命中**(探针实测 1.09s → 0.22s,快 5 倍)。
|
||||
# - 日常「改一处重编」的增量加速会消失(sccache 命中代替它,
|
||||
# 且跨机器/跨 clean 都有效,增量缓存则一 clear 就没)。
|
||||
#
|
||||
# 与既定约定的对齐:`~/.cargo/config.toml` 已配 `rustc-wrapper = sccache`
|
||||
# 且缓存实体在 `~/.cache/sccache`(包缓存统一放 ~/.cache,工具默认路径留软链)。
|
||||
# 本行是让那个配置**真正生效**的前提。
|
||||
incremental = false
|
||||
|
||||
[profile.release]
|
||||
opt-level = 2
|
||||
lto = "thin"
|
||||
|
||||
Reference in new issue
Block a user