fix(index): cap parent index walk at git repo boundary + store perf improvements#58
Merged
fix(index): cap parent index walk at git repo boundary + store perf improvements#58
Conversation
Prevents lumen from adopting ancestor indexes outside the current git repository (e.g. a GOPATH-level index) when EnsureFresh is called from a subdirectory. Without this cap, the upward walk in findEffectiveRoot could reach indexes containing the entire workspace, causing excessive scanning and high GPU/fan usage. Adds git.RepoRoot() utility that resolves the repository root via git rev-parse --show-toplevel with symlink resolution. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds an integration test that creates a real git repository and a fake ancestor index DB above the repo root, then asserts findEffectiveRoot does not walk above the git boundary to adopt it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add idx_chunks_symbol index to speed up symbol-based lookups (used in search queries that filter by function/type name). Also run ANALYZE after each batch commit so the SQLite query planner has up-to-date statistics from the start. No schema version bump needed — CREATE INDEX IF NOT EXISTS applies the new index to existing databases automatically on first open. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
idx_chunks_symbol was not useful: TopSymbols uses GROUP BY symbol ORDER BY count(*) DESC, which SQLite cannot accelerate with a column index because the sort key is an aggregate computed after grouping. The index added write overhead on every chunk INSERT with no measurable read benefit. ANALYZE is now called once per full index pass (in indexWithTree, after the final flushBatch) via a new Store.Analyze() method, rather than after every 32-row batch. Running ANALYZE dozens of times per re-index was wasteful I/O; once at the end gives the query planner accurate statistics at the right time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
findEffectiveRootnow stops walking parent directories at the git repository boundary, preventing excessive scanning when opening an index from a subdirectory of a large monorepoTestIndexerCache_FindEffectiveRoot_GitBoundaryvalidates the boundary protection using a real git repo created in a temp directoryidx_chunks_symbolindex onchunks(symbol)to speed up symbol-based lookups; runANALYZEafter each batch insert so the SQLite query planner has accurate statistics immediatelySchema note
No
IndexVersionbump needed —CREATE INDEX IF NOT EXISTSautomatically adds the new index to existing databases on first open without incompatibility.Test plan
go test ./...— all packages passidx_chunks_file_pathandidx_chunks_symbol🤖 Generated with Claude Code