Skip to content

v0.3.11 — L6+L7 内存溢出修复

Choose a tag to compare

@Kirky-X Kirky-X released this 25 Jul 20:00
· 131 commits to main since this release

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> 中间集合;BufWriter 64KB 减少 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 warnings
  • cargo test --lib --features "full": 4461 passed, 0 failed
  • cargo test --lib --features "core": 2260 passed, 0 failed
  • cargo 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