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

Open
#197 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
22/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
go

Research direction

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.

Written by the indexing model from the issue text.

Description

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

Dominant language
Go
Stars
0
Forks
0
Avg merge
5h 16m
Merged PRs (30d)
107

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from seanb4t/codegraph-go

All issues in seanb4t/codegraph-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.