perf(indexer): an incremental sync reads the whole store

未关闭
#197 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
22/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
go

调研方向

Start in internal/indexer/storeview.go, where loadStoreView reads every node and edge, and follow buildReverseAdjacency and the implements/override synthesis from there. First add the sync benchmark under tools/bench: a large generated corpus with one changed file, reporting time and peak RSS. Done means the benchmark runs and the reads and synthesis in the sync path are cut down, while requireSyncEqualsRun and the 30-commit replay still pass.

由索引模型根据 Issue 内容生成。

描述

area:indexer enhancement priority:low

Every codegraph sync that reparses or deletes a file reads the whole store. Its cost therefore grows with the size of the repository, not with the size of the change. The file watcher and the daemon run it after each save, and serve runs it before every MCP handshake.

What a sync reads today (after #192, #195 and #196)

  • Every File record: the stat pre-filter (GetFile per discovered file), the deletion check (IterateFiles) and, when the sync adds a symbol, the waiting-file check (filesWaitingOn).
  • Every node and every edge, in loadStoreView (internal/indexer/storeview.go). It builds the store-seeded symbol index and the lookups that resolution and edge synthesis read.
  • Every calls edge again when the sync removes a node (buildReverseAdjacency).
  • Implements and override synthesis over the whole graph, held in memory.

A sync with no changes returns before any of this.

Why it reads everything. Resolving a batch the way a fresh index does needs any symbol a batch file can reference, and any type or interface its edges can match. #196 chose correctness over cost. Nothing measures sync cost today: the perf regression gate (tools/bench) measures a full index, query latency, peak RSS and cold start.

What to do

  • Add a sync benchmark to tools/bench: a large generated corpus, one file changed, time and peak RSS of the sync.
  • Read on demand, not up front. Look up a node's kind or edges (GetNode, IterateEdges(source)) as resolution needs them, and cache them for the sync. Looking up a referenced name's symbols the same way needs a store index keyed by module and name, which would be new.
  • Limit implements and override synthesis to the types and interfaces whose method sets the batch changes, with the stored synthesized edges of those types as the set to compare against.
  • Keep the equality tests (requireSyncEqualsRun, the 30-commit replay in #196) as the check that a cheaper sync still matches a fresh index.

🤖 Generated with Claude Code

主要语言
Go
星标
0
派生
0
平均合并
7 小时 42 分钟
30 天内合并 PR
111

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

seanb4t/codegraph-go 的其他 Issue

查看 seanb4t/codegraph-go 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。