Repository navigation
v0.3.11 — L6+L7 内存溢出修复
v0.3.11 — L6+L7 内存溢出修复
70 GB 主机峰值内存从 60 GB 降至 ~4 GB。
L6 — 管线流式化 + LSP kill 超时 + iterator API
- L6-1 pipeline streaming + ctx.take():
ResolvePhase改用ctx.remove::<ScopeOutput>("scope")取得 Graph 所有权(替代scope.graph.clone(),消除大型仓库多 GB 的 deep-clone);Phase::run签名从&PipelineCtx改为&mut PipelineCtx支持ctx.remove独占借用。 - L6-3 iterator API:
save_nodes/save_edges/write_nodes_csv_stream/write_edges_csv_stream签名从&[Node]/&[Edge]改为impl IntoIterator<Item = &Node/&Edge>,消除Vec<Node>/Vec<Edge>中间集合;BufWriter64KB 减少 syscall。 - L6-3 LSP kill timeout:
force_kill_and_wait用wait_with_timeout替代child.wait()(防止 D-state/zombie 永久阻塞);新增KILL_TIMEOUT_MS=3000/SHUTDOWN_TIMEOUT_MS=5000常量。
L7 — 6 个剩余瓶颈定位与修复
- L7-1 LZ4 buffer lifetime:
ParsePhase移除RamFirstSources字段,LZ4 压缩缓冲存入PipelineCtx,parse 阶段读取后立即释放。10k 文件仓库省 ~3 GB。 - L7-2 parse edge cleanup:
ScopeResolutionPhase把 edges clone 进 graph 后clear()+shrink_to_fit()result.edges和seen_qns。大型仓库省 ~1 GB。 - L7-3 PipelineCtx drain:
LoadPhase用ctx.remove取得ScanOutput/ResolveOutput所有权,返回时立即 drop。省 ~1–2 GB。 - L7-4 RAM-first amplification factor:
evaluate_ram_first_budget用total × 8估算峰值 RSS 对比max_rss_bytes / 2,修正预算失真。70 GB 主机允许 ~2.2 GB 仓库走 RAM-first;4 GB 笔记本仅允许 ~125 MB。 - L7-5 LadybugDB buffer_pool cap: 生产环境
SystemConfig显式buffer_pool_size=4GB/max_db_size=16GB/max_num_threads=8。DuckDB 默认 80% 物理内存(70 GB 主机 ~56 GB),是 L6 后剩余的主要瓶颈。省 ~52 GB。 - L7-6 LSP on-demand startup:
enhance_with_lsp先查询 Function/Method 行,收集实际出现的扩展名集合,只start()需要的 LSP provider。纯 Rust 仓库现在只启动 rust-analyzer,省 ~3–5 GB。
三维度审查(rule 22+24)
| 维度 | CRITICAL | HIGH | MEDIUM | LOW | 结论 |
|---|---|---|---|---|---|
| tiangang SAST | 0 | 0 | 1 | 4 | ✅ 允许发版 |
| diting architecture | 0 | 1 (已修复) | 1 | 1 | ✅ 允许发版 |
| diting performance | 0 | 0 | 2 | 3 | ✅ 允许发版 |
所有 MEDIUM/LOW 不阻断,已记入 v0.3.12 议程。
验证
cargo clippy --lib --features "core"/"full" -- -D warnings: 0 warningscargo test --lib --features "full": 4461 passed, 0 failedcargo test --lib --features "core": 2260 passed, 0 failedcargo test --tests --features "full": 163 integration tests passed- pre-push hook: fmt/check/clippy/test/coverage 95%/audit/deny 全绿
Full Changelog: v0.3.10...v0.3.11
Full Changelog: v0.3.10...v0.3.11