docs(memory): 记录 target 清理与 sccache 空转根因
This commit is contained in:
1 parent
827c054780
commit
efb4cd6500
1 file changed
+27
@@ -235,3 +235,30 @@
|
||||
main CLI / modules spec 完整性)⇒ 本就该留壳侧。
|
||||
- ✅ **迁移全部完成**:M1–M7 七个批次走完 ⇒ `crates/` 现有 **17 个包**,
|
||||
`src/backend/src/` 只剩**装配**(bootstrap / routes / compat 别名表 / modules)+ **业务层**。
|
||||
|
||||
## 编译中间产物清理 —— target 58G → 1.2G,并修掉 sccache 空转的根因(tag `v0.1.8-target-cleanup`)
|
||||
|
||||
- **发现**:用户以为「编译中间产物应该很小」,实测 `target/` = **58G**
|
||||
(`debug/deps` 45G + `debug/incremental` 12G + `release` 820M),磁盘已用 **87%**(仅剩 60Gi)。
|
||||
而 `src/` 135M 里 74M 是 `node_modules`、60M 是 pglite 运行数据(**都不是编译中间产物**,按约定不删)。
|
||||
- 🔴 **根因(实测定位,非猜测)**:sccache **全程空转**。
|
||||
`~/.cargo/config.toml` 早就配了 `rustc-wrapper = sccache`、缓存实体有 8.4G,
|
||||
但 `sccache --show-stats` 的 `Cache hits` **恒为 0**、`Non-cacheable calls` 等于请求数。
|
||||
真实原因:**cargo 默认给 rustc 传 `-C incremental=<target/debug/incremental>`,
|
||||
而 sccache 遇到 `incremental` 直接拒缓存** —— server 端 debug 日志明确写着
|
||||
`CannotCache(incremental)` ⇒ **8.4G 缓存全是废的**,每轮构建都从零重编 ⇒ target 无限膨胀。
|
||||
(查法:`SCCACHE_LOG=debug` + `SCCACHE_ERROR_LOG` 看 server 端,不要只看 client 端统计。)
|
||||
- **修法**:根 `Cargo.toml` 加 `[profile.dev] incremental = false`。
|
||||
- 收益:清空 `target` 后重建 **走缓存命中** —— 实测 **14.14s**(vs 全量 63s);命中率 **86.71%**。
|
||||
- 代价:失去 cargo 自己的增量加速,由 sccache 命中替代(**且跨 `cargo clean` 仍有效**)。
|
||||
- 附带:`target/debug/incremental` 不再产生(实测只残留 0B 空目录)。
|
||||
- **清理动作**:`cargo clean`(**不要手 `rm -rf target/`**,让 cargo 自己收)⇒
|
||||
`Removed 631330 files, 92.4GiB total`,可用空间 **59 GiB → 118 GiB**;
|
||||
另删 `scripts/__pycache__`(124K)。
|
||||
- **数字**:`cargo test --workspace` **695 passed / 0 failed / 2 ignored**(79 个二进制,与 M1 基线一致);
|
||||
`check-arch` 20/20、`check-boundary` 12/12、`check-contract` 10/10、
|
||||
`check-module` 123/123、`check-citations` 4/4 全绿;磁盘占用 **87% → 75%**。
|
||||
- **文档**:`CLAUDE.md` §9 命令速查下新增「磁盘占用」小节(记根因 + 修法 + `target/` 现在随时可清)。
|
||||
- ⏭ **推论(已写进 CLAUDE.md)**:`target/` 现在是「随时可清」的东西(清了重建只要十几秒);
|
||||
真要清先 `pgrep -f "cargo (build|rustc|check)"` 确认没构建在跑;
|
||||
sccache 缓存实体在 `~/.cache/sccache`,**不在项目内** ⇒ 别跟着 target 一起删。
|
||||
Reference in new issue
Block a user