You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Explorer.findSymbol currently iterates every entry in self.outlines for every call (src/explore.zig around line 1256 on main). For a large project this is O(files × symbols-per-file) per query — the find command and any downstream HTTP/MCP endpoints that call it pay that cost even though an O(1) symbol_index map already exists on the explorer.
Two things need to change together for the index to be a safe replacement:
Use the index in findSymbol. Look up the name in self.symbol_index; if it's present, build SymbolResult entries from the locations and return. Keep the current outline scan as a fallback so the change is defensive — if indexing ever misses a kind the old behavior still covers it.
Stop excluding kinds from the index.rebuildSymbolIndexFor currently skips .import and .comment_block:
if (sym.kind==.importorsym.kind==.comment_block) continue;
That makes the index incomplete — imports are often exactly what a user searches for ("find Store" → the import line). Without this, the O(1) path misses those hits and callers silently diverge from the scan-based path. Removing the skip makes the index authoritative.
Summary
Explorer.findSymbolcurrently iterates every entry inself.outlinesfor every call (src/explore.zigaround line 1256 on main). For a large project this is O(files × symbols-per-file) per query — thefindcommand and any downstream HTTP/MCP endpoints that call it pay that cost even though an O(1)symbol_indexmap already exists on the explorer.Two things need to change together for the index to be a safe replacement:
Use the index in
findSymbol. Look up the name inself.symbol_index; if it's present, buildSymbolResultentries from the locations and return. Keep the current outline scan as a fallback so the change is defensive — if indexing ever misses a kind the old behavior still covers it.Stop excluding kinds from the index.
rebuildSymbolIndexForcurrently skips.importand.comment_block:That makes the index incomplete — imports are often exactly what a user searches for ("find
Store" → the import line). Without this, the O(1) path misses those hits and callers silently diverge from the scan-based path. Removing the skip makes the index authoritative.Why this matters
findis a hot path (it's hit from shell usage, MCP tools, and any restored HTTP server endpoint — see Restorecodedb serve --portHTTP endpoint on Zig 0.16 #307)Scope
src/explore.zig:findSymbol— add index lookup before the existing scanrebuildSymbolIndexFor— drop the kind filter so every symbol is indexedVerification
findoutput should be unchanged (same kinds, same order per file)findSymboldropping from linear in file count to constant