Incremental indexing + the edge tables: one file changed, one file merged

Owner-requested round. WorkspaceIndex::update_file/remove_file replace
one file's contribution without reading or parsing anything else;
Server::reindex_one takes the fast path for a didSave of one held file
or a one-file watcher event (33 ms vs 1.5 s on the corpus, 45x), with
everything else — settings, scope, filelist, multi-file events —
keeping the full rebuild, pinned by a trigger-table test. FileIds stay
sorted positions by deliberate deviation: renumbering through the one
merge both finish and update_file end in makes build(W) byte-identical
to build(W minus F).update_file(F) — fingerprint equality, attacked by
QA across long interleaved sequences, disambiguation flips, define
shadowing and the ghost hunt (the affected-keys union reads old and
new records both). The per-file FileFacts the index retains are the
documented memory cost (~1.4 MB on the corpus).

The two oldest filed Handshakes land: instantiation and inheritance
edge tables, built by the byte-for-byte moved census walks, turn
codeLens counts (92 ms to 0.26 ms), incomingCalls and typeHierarchy
subtypes into lookups — census policies pinned unchanged at both the
consumers and now the source. Counts are as of the index, not of
unsaved keystrokes: the freshness delta is documented and pinned from
both sides. Saves no longer raise a progress bar; generation and lens
refresh still ride. Round 18's three inherited scope obligations are
pinned permanent.

36 tests added (dev 27 + QA 9). Left open, filed: wholesale republish,
Candidates re-derivation cost, incremental removal vs include
re-resolution.

docs/features/incremental-index/README.md

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-27 14:35:27 -07:00
1 parent 7266b13702
commit 5e4aa7bd6f
26 files changed
+3132 -383

No files matched your search

+31 -7
View File
@@ -68,22 +68,46 @@ computed by, so the lens and the hierarchy view can never disagree (TODO.md
invalidate. Not on a keystroke either — a `didChange` cannot change any
count, since the census is over instantiations in *other* files and a client
re-requests lenses for the buffer it just edited anyway.
- **The count is computed against `Workspace::sources()`**, which reads every
- ~~**The count is computed against `Workspace::sources()`**, which reads every
in-scope file from disk with open buffers overriding it. So an unsaved
instantiation typed into another open buffer *is* counted, and a file
changed on disk that no watcher reported is counted as of this request.
- **The cost is one workspace walk per request, not one per module.**
changed on disk that no watcher reported is counted as of this request.~~
**Superseded (incremental-index, 2026-08-27)** — see the assumption above.
- ~~**The cost is one workspace walk per request, not one per module.**
`hierarchy::callers_of_each` takes a batch precisely because `sources()`
re-reads the whole file set: measured over the 860-file corpus, a
three-module file costs 133 ms against 93 ms for a single name (debug build)
— amortized, not tripled. The absolute number is the honest cost of having
no instantiation-edge table in the index; see Status / TODO.
no instantiation-edge table in the index; see Status / TODO.~~
**Superseded (incremental-index, 2026-08-27): the cost is a lookup.** The
count comes from the index's instantiation-edge table, and the only I/O left
is reading the handful of files that really do instantiate one of the names,
to turn recorded byte spans into ranges — 0.26 ms for the same three-module
file over the same corpus. The batch stays the primitive for the same
reason at a smaller scale: one file instantiating three of the names is read
once.
- **The count is as of the index, which is as of its last build or update**
(incremental-index, 2026-08-27) — superseding the assumption below that the
count is computed against `Workspace::sources()` per request. A save, or any
other rescan trigger, folds every open buffer in and makes an edit count; a
keystroke alone no longer does. The trade and the alternatives considered are
in `docs/features/incremental-index/README.md`.
## Handshakes
### Request to `vlog_semantic` — an instantiation-edge table in the index
Filed by the lead (2026-08-26) on QA's recommendation, since **two** shipped
**Delivered (incremental-index, 2026-08-27).** `WorkspaceIndex::instantiations_of`
exists with the shape proposed below — plus the owning declaration's name and
full extent, which is what stopped `callers_of_each` re-parsing the file to
find them — and `hierarchy::callers_of_each` is a lookup with its walk-and-parse
body deleted. The census policies carried over by construction: the table is
built by the same `instantiations::sites` walk the handler used to run, which
was lifted into `vlog_semantic` for exactly that reason, and every one of this
feature's QA tests passes unchanged. Measured 92 ms → 0.26 ms for a
three-module file over the corpus. The original request, kept legible:
~~Filed by the lead (2026-08-26) on QA's recommendation, since **two** shipped
features now pay the same cost: every `textDocument/codeLens` request and
every `callHierarchy/incomingCalls` walks `Workspace::sources()` — a re-read
and tolerant re-parse of every in-scope file — because `WorkspaceIndex`
@@ -100,7 +124,7 @@ pub fn instantiations_of(&self, name: &str) -> &[InstantiationEdge]
so `hierarchy::callers_of_each` becomes a lookup and its whole
walk-and-parse body is deleted. The census policies (multi-instance
statements = one site, textual not elaborated, both `ifdef` arms) must carry
over unchanged — `lens.rs`'s QA tests pin the numbers that must not move.
over unchanged — `lens.rs`'s QA tests pin the numbers that must not move.~~
### `lucisv_server::hierarchy` — **changed, deliberately**
@@ -206,7 +230,7 @@ no-showDocument path — verified by running it.
is an instantiation-edge table in `WorkspaceIndex`, built once per
rescan, which would make both this and `incomingCalls` a lookup. That is
a `vlog_semantic` change and belongs in its own round; **request
recorded here, not made.**
recorded here, not made.** — **done, incremental-index, 2026-08-27.**
## Work log