Files
lucisv/docs/perf/README.md
T
Guoliang ChenandClaude Mythos 5.2 58d3db3e3c
ci / checks (push) Successful in 59s
ci / corpus (push) Successful in 16s
release / build-and-publish (push) Failing after 4m55s
Release 0.65.6: saving a file no longer re-indexes the workspace
TODO §71.1. On OpenTitan hw (4 058 files) every save cost ~160 ms of
whole-index work, twice (the save and VS Code's watcher echo), and watcher
events for files the index could not hold started whole rescans.

- vlog_semantic: resolution records every table lookup per reading file,
  misses included (workspace/dependents.rs, references.rs, replace.rs); an
  update re-resolves the edited file and the readers of keys whose values
  changed in what resolution reads. An unchanged record merges nothing. When
  the readers hold more than an eighth of all references, old results are
  removed in one pass over the postings.
- lucisv_server: watcher events are classified per file (state/watched.rs);
  the include graph keeps every include line as written and re-resolves the
  lines a named path could satisfy, in one pass per event; an event naming
  more paths than half the index takes the single rescan; an open buffer the
  index does not hold joins on its first save; completion tables are rebuilt
  only for the names a file declares. Every save still republishes every open
  buffer. The line-length lint follows the formatting style's width.
- Fixed on the way: removing an included header left other files' include
  edges pointing at it.

Typical saves: comment or watcher echo <0.3 ms, local signal 4 ms, package
member 12 ms; warm startup +40..120 ms for the readers table.

QA failed the first cut on four stale answers found with an independent
fresh-server oracle; all four are fixed and are differential tests. Dev
(three rounds), QA (two rounds) and lead review:
docs/features/localized-reindex/README.md. TODO.md files lane 71.7 from
what the QA rounds and an investigation found in earlier releases too.

Version bump (Cargo.toml, Cargo.lock, editors/vscode/package.json and both
package-lock.json spots); notes in CHANGELOG.md (## 0.65.6) and
editors/vscode/CHANGELOG.md.

Gates: tools/gates.sh PASS on this tree; vlog_semantic 435/0,
lucisv_server 2011/0, lucisv_mcp 384/0.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-19 08:52:01 -08:00

1471 lines
85 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# perf — measured numbers for the paths a keystroke and a hover run through
## Goal
Give the server's hot paths — `analyze`, opening a buffer, answering a hover,
reindexing one saved file, and (since round 2) one flush stage by stage and
one keystroke's round trip over the wire — a number that is *measured* rather
than guessed, taken the same way every time, so a later round can say whether
it made something faster or only different. This is the record; the
measurements themselves are `#[ignore]`d tests in
`crates/lucisv_server/src/perf.rs` and in
`crates/lucisv_server/tests/e2e.rs`, run on demand and asserting nothing about
duration. Nothing here is a performance *budget*: a test that fails when a
machine is busy is a test that gets deleted.
## Assumptions
- **No benchmark dependency.** `criterion` and friends are out: `CLAUDE.md`
requires a written justification for any new dependency, and the workspace
has six direct ones (`rayon`, `lsp-server`, `lsp-types`, `serde`,
`serde_json`, plus their pins). `std::time::Instant` + `eprintln!` is the
shape this repo already uses for perf notes (`hover.rs`'s QA measurement,
`includes.rs`, `inlay.rs`, `file_ops.rs`) and it is what is used here.
- **`--test-threads=1` or the numbers are noise.** The harness otherwise runs
these concurrently with each other and with 1 200 other tests. The first run
of these measurements was taken without it and reported a cross-file hover
as *cheaper* than the single file read it performs; that is how obvious the
contamination is.
- **Means, not single runs.** Each measurement is the mean of 10–1 000 runs
(`perf::mean`), with `std::hint::black_box` around the inputs and results so
a release build cannot optimize the work away.
- **Generated input, not the corpus.** `perf::generated_module` builds an
ANSI-headed module of repeated four-line blocks (a wire, an assign, a
register, an update) at 1 000 and 10 000 lines. It is uniform, which real
RTL is not — the numbers are a scale, not a prediction for any given file.
The corpus-scale numbers this repo already has live where they were taken
(`docs/features/incremental-index`, `index-persistence`, `references-nav`).
## Reproducing
```text
cargo test --release -p lucisv_server perf:: -- --ignored --nocapture --test-threads=1
```
Each test's own doc comment names the narrower filter for running it alone.
The over-the-wire measurement lives with the other end-to-end tests, because
it spawns the shipped binary, so it has its own command:
```text
cargo test --release -p lucisv_server --test e2e a_keystroke -- --ignored --nocapture --test-threads=1
```
The one older measurement quoted below has a third:
```text
cargo test --release -p lucisv_server large_closed -- --ignored --nocapture --test-threads=1
```
## The machine
| | |
|---|---|
| CPU | Apple M1 Max (`uname -m` = `arm64`) |
| OS | macOS 27.0 (build 26A5421a) |
| build | `--release`, workspace at 0.12.1 + rounds 1 and 2 uncommitted |
| date | 2026-08-28 (every figure below re-measured this day, round 2) |
## Numbers
All figures are the mean of the runs named above. "1k" and "10k" are the
generated module's line counts (29 KB / 501 symbols and 309 KB / 5 001
symbols respectively).
| what | 1k lines | 10k lines |
|---|---|---|
| `vlog_semantic::analyze` (tree already parsed) | 252 µs | 3.76 ms |
| `Document::new` — lex + parse + analyze + `resolve_external` | 2.54 ms | 31.1 ms |
| `hover`, target declared in the same open buffer | 2.68 µs | 1.10 µs |
| `hover`, target in a **closed** file (disk path) | 38.1 µs | 159 µs |
| — of which one read + one `LineIndex` of that file | 27.4 µs | 140 µs |
| `WorkspaceIndex::update_file`, 20 files of this size | 2.76 ms | 32.1 ms |
| — of which the clone the measurement needs to repeat itself | 60 µs | 567 µs |
| one name looked up among the file's symbols: **linear scan** | 767 ns | 8.14 µs |
| one name looked up among the file's symbols: **name-sorted lookup** | 93 ns | 131 ns |
| one token found at the cursor: **sweep** | 6.58 µs | 77.5 µs |
| one token found at the cursor: **binary search** | 15 ns | 20 ns |
| the balanced-paren window `completion.rs` needs: **sweep** | 8.63 µs | 130 µs |
| the balanced-paren window `completion.rs` needs: **binary search** | 27 ns | 36 ns |
Every figure above comes from one run of the command in *Reproducing*, on the
machine above. A local hover is a handful of pointer chases and comes out
under 3 µs at both sizes; the 1k figure being the larger of the two is that
measurement's noise floor, not a result.
Three things stand out:
- **A hover into a closed file is a file read.** 27 µs of the 1k hover's
38 µs, and 140 µs of the 10k hover's 159 µs, is reading that file and
building a `LineIndex` over it. Everything else — resolution, guards,
rendering — is single-digit microseconds.
- **`Document::new` is where a keystroke's cost lives**, and it is dominated
by lexing and parsing, not by `analyze` (31 ms against 3.8 ms at 10k
lines). The stage-by-stage table below says exactly how much.
- **A sweep of the token vector costs about what the parse of one line
costs**, and there are several per keystroke. That is round 2's Phase 2.
### One flush, stage by stage
`Document::new` runs the first seven of these in order; the eighth is not
inside it at all — `diagnostics::all` is what a *publish* runs, on every
flush, and round 1's table did not account for it.
`parse_tolerant` consumes its token vector, so each run of the parse needs a
fresh clone. The clone has its own row and the parse row still contains it;
subtracting one from the other is the honest reading, and it is what
`Document::new` really pays.
| stage of one flush | 1k lines (9 461 tokens) | 10k lines (94 961 tokens) |
|---|---|---|
| `tokenize` | 1.14 ms | 12.5 ms |
| `tokens.clone()` (the copy `Document` keeps) | 230 µs | 2.40 ms |
| `parse_tolerant`, clone included | 1.16 ms | 14.3 ms |
| — the parse alone, by subtraction | 0.93 ms | 11.9 ms |
| `collect_defines` | 7.09 µs | 121 µs |
| `analyze` | 278 µs | 5.55 ms |
| `resolve_external` | 943 ns | 49.3 µs |
| `LineIndex::new` | 10.5 µs | 115 µs |
| `diagnostics::all` (parse errors + closers + lint) | 104 µs | 1.40 ms |
Read this table as *shares of a flush*, not as the last word on any one
stage: it runs eight measurements back to back on one heap, and its `analyze`
row came out 5.55 ms in the same run where the dedicated `analyze` test —
which measures nothing else — came out 3.76 ms. The dedicated figure is the
cleaner one. What the table is for is the proportion, and the proportion is
unambiguous:
- **Lexing and parsing are 79 % of a flush** at 10 000 lines (12.5 + 11.9 of
30.9 ms, taking the dedicated `analyze` figure for the rest). Everything
else together is a fifth.
- **`tokens.clone()` is 7.7 %**, and it is load-bearing rather than waste:
`parse_tolerant` takes ownership of its tokens and *steals the comments out
of them*, so the copy `Document` keeps is the only one that still has its
trivia. It is also already the cheap option — before the one-lex change
this was a second `tokenize`, which is 12.5 ms.
- **`resolve_external` is 49 µs, one part in six hundred.** Making the
workspace overlay skippable was on this round's list of candidates; the
measurement says there is nothing there to save.
- **The lint pass is 1.40 ms on top of the flush**, about 4 %. It walks the
tree once per rule.
### Over the wire — what a keystroke actually costs a user
Round 1 listed this as its own open TODO, because it cannot be taken from
inside the crate: the number includes two pipes, a JSON encoder and decoder,
the change debounce's quiet-period timer and a whole flush. It is measured by
spawning the shipped binary and speaking framed JSON-RPC at it
(`tests/e2e.rs::a_keystroke_round_trip_over_the_wire`, command above).
| `didChange` → `publishDiagnostics` | 1k lines | 10k lines |
|---|---|---|
| one keystroke, nothing following it | 164 ms | 202 ms |
| a burst of ten keystrokes, no pause | 165 ms | 207 ms |
| — publishes that burst produced | **1** | **1** |
| one keystroke **a request follows** (mean of 10) | 4.35 ms | 37.6 ms |
The three rows say three different things.
- **The debounce is the felt latency when a client asks for nothing.**
150 ms of the 164 ms is `CHANGE_DEBOUNCE`'s quiet period; the work is the
rest. At 10 000 lines the same 150 ms sits on top of a 31 ms flush. This
is the one row where round 1 made something *slower*: before the debounce
a lone keystroke published in about one flush, and it now waits out the
timer first. It is the bargain debouncing is, and the last row is why it
is worth taking.
- **A real editor never waits for that timer.** VS Code asks for semantic
tokens, inlay hints and highlights the moment a buffer changes, and a
request flushes the dirty buffer before it is answered. That is the last
row, and it is the number a user actually feels: **4.35 ms at 1 000 lines,
37.6 ms at 10 000**.
- The first two rows are single round trips, not means, and each is bounded
below by a 150 ms timer; treat their differences as noise. The last row is
the mean of ten and is the one worth comparing across rounds.
## Before / after — round 1 (2026-08-28)
**A1 — didChange debounce.** Not measured directly *at the time*, and the
arithmetic below is what round 1 recorded: every `didChange` used to run one
`Document::new` plus lint and publish; a burst of *k* changes now runs one.
At 10k lines that is 31 ms saved per keystroke after the first in a burst, at
1k lines 2.6 ms. What the debounce cannot save is the first change in a burst
and the last flush, so the floor is one `Document::new` per burst per buffer.
**Round 2 measured it.** A burst of ten keystrokes over the wire produces
**one** `publishDiagnostics`, counted rather than reasoned about — the count
comes from draining the session at `shutdown`, which every pending flush is
guaranteed to have arrived before. The arithmetic above was right.
The burst is deliberately the **last** thing that measurement does, which is
QA finding IL-1 closed: every `wait_for` in the test accepts *any* publish,
so while the burst ran before the other rows, a second publish it had
produced would have been absorbed by the next row's wait and never counted.
With nothing between the burst and the drain, the count is the count.
**A2 — one disk read per hover.** Measured, two ways.
- The QA round that filed the finding measured a hover into a 31.7 MB closed
file at **34 ms** (`docs/features/hover-declarations/README.md`, finding 4,
2026-08-27, same machine, same test, release build). The same test after
the `disk_view` memo: **16.3 ms**. That is the expected shape — two reads
and two `LineIndex` builds became one — but the two numbers come from
different runs on different days, so read it as "about half", not as
2.08×.
- The `perf::hovering_across_files_into_a_closed_file` measurement takes the
after-number and the cost of one read + `LineIndex` side by side, in the
same run: 142 µs of a 160 µs hover at 10k lines. Removing a second read of
that same file is therefore removing roughly the whole remaining cost of
the request, which is the before/after in the form that does not depend on
an old number.
**A3 — name-keyed symbol lookup.** Measured directly, on the lookup alone:
8.41 µs → 133 ns at 10k lines (5 001 symbols), 763 ns → 106 ns at 1k. The
lookup is only part of what was saved: in `hover::live_symbol` every symbol
the scan used to reach was also an `indexed_def_for_symbol` call — two index
lookups apiece — which the name-sorted lookup never makes. That larger saving
is **not measured here**; the 8.41 µs → 133 ns figure is a floor on it, not
the whole of it.
**B — port detail spans, and comment attachment.** Not measured. The work
added is a second `fenced_sections` call over lines already in memory, and
two integers per declaration in the index and its facts records. No
measurement was taken and none is claimed.
## Before / after — round 2 (2026-08-28)
**C1 — six token lookups stopped sweeping the buffer.** Measured directly,
both halves in the same run against the same token stream
(`perf::finding_one_token_against_sweeping_the_stream`), with the cursor
three quarters of the way down the file — a sweep costs the distance from
token zero, so measuring at either end would flatter it.
| | 1k lines | 10k lines |
|---|---|---|
| the token at the cursor: sweep → binary search | 6.58 µs → 15 ns | 77.5 µs → 20 ns |
| `balanced`'s window: sweep → binary search | 8.63 µs → 27 ns | 130 µs → 36 ns |
Six call sites across `selection.rs`, `on_type.rs`, `completion.rs` and
`inline.rs`; which ones, what each of them wanted, and the per-site argument
that the search returns exactly what the sweep returned are in
`docs/features/interactive-latency/README.md`. Every one is pinned by a test
that walks **every byte** of a buffer full of touching tokens and compares
the two. None of them changed an answer, and the tests are what says so
rather than the claim.
Three sweeps were left alone with the reason written down: `signature.rs`'s
two paren-depth walks (a depth is a function of every bracket before the
cursor), `pairs.rs::analyze` (not a position query at all), and
`completion.rs`'s comment gate (comments are trivia attached to whichever
token happens to be next, so no search of the stream answers "is this byte
inside a comment"). That last one is the remaining per-keystroke
whole-buffer walk on the completion path.
**C2 — the round trip, and nothing else changed.** No stage of a flush was
touched this round, so the flush table above is a baseline rather than an
after. The reasons each candidate was refused, with its number, are in the
next section.
## Before / after — round 3 (2026-08-28)
`docs/features/hover-line-index/README.md` — the owner's report that hovering
an instantiation, and a port on that instantiation, is slow on the first try.
Two suspects were measured before anything was changed; the numbers said which
one this round could fix and which it could only file.
**D1 — the heading stopped reading the file, and the snippet's read is
shared.** Each indexed declaration now carries its line (`Def::lines`,
`FACTS_FORMAT` 3 → 4), so `file:line` costs nothing; the snippet still wants
that file's text, and takes it from a four-entry / 8 MiB LRU of closed files'
text in `Workspace`. So the *first* touch of a file still pays one read and
every touch after it pays nothing.
| | before | after |
|---|---:|---:|
| hover on an instantiation into a 12 MB closed file, first touch | 6.47 ms | 6.23 ms |
| — the same hover again | 5.75 ms | **0.95 µs** |
| hover on a port into the same file, first touch | 5.85 ms | 5.92 ms |
| — the same hover again | 5.71 ms | **0.99 µs** |
| the 31.7 MB probe above, first touch | 17.0 ms | 16.8 ms |
| — the same hover again | 17.0 ms | **4.4 µs** |
| `perf::hovering_across_files_into_a_closed_file`, 1k / 10k (mean of 20) | 39.8 / 157 µs | **4.7 / 12.9 µs** |
The cost, over the 860-file corpus: one `LineIndex::new` per parsed file, which
leaves every scan figure inside its own noise (no cache 338 → 343 ms, cold
372 → 374 ms, warm 197 → 200 ms), and 68 KB more store — 2.9 %.
**D2 — the first request of a session waits out the startup scan.
Measured, filed, not fixed.** `Server::new` runs the whole scan before the
message loop takes its first message, so anything a client sends the instant
the handshake finishes sits in the OS pipe until the scan ends. Over 200 files
of 1 000 lines, through the shipped binary
(`tests/e2e.rs::a_hover_issued_during_the_initial_scan_waits_for_it`):
| the first hover of a session | cold store | warm store |
|---|---:|---:|
| issued the moment `initialized` was sent | **780 ms** | **287 ms** |
| the same hover once the scan is done | 64 µs | 61 µs |
This is four orders of magnitude larger than D1 and is where "the first hover
is slow" mostly lives. Fixing it is a change to request scheduling — answering
while the index is half-built, or scanning off the message-loop thread — and
was explicitly out of this round's scope.
## Before / after — round 4 (2026-08-28)
`docs/features/scan-interleave/README.md`: D2, answered. The scan is per-file
steps with the message queue drained between them, so a startup scan of more
than 64 files answers requests while it runs — single-threaded, interleaved,
not scanned off-thread. Same fixture, same probe, flipped and renamed
(`tests/e2e.rs::a_hover_issued_during_the_initial_scan_is_answered_during_it`):
| the first hover of a session | before | after |
|---|---:|---:|
| issued the moment `initialized` was sent, cold store | **780 ms** | **15.5 ms** |
| — warm store | **287 ms** | **12.8 ms** |
| the same hover once the scan is done | 64 / 61 µs | 191 / 151 µs |
The "after" figures are tens of milliseconds, not three significant figures: a
second run on a busier machine reported 19.8 / 14.0 ms. The claim is the order
of magnitude, and the post-scan row is measured after waiting for the progress
bar rather than racing the scan.
**What it cost the scan: under a percent.** The merge was measured before the
design was chosen, and the numbers ruled out the obvious shape — a merge is a
pass over the whole index, so folding each file in as it is taken would be
quadratic (`perf::publishing_a_half_built_index_mid_scan`, 200 files of 1k
lines: 630 ms of merging against 464 ms of parsing; 800 files: 11.7 s against
1.78 s). Records are staged and folded in once per *drain* instead, and a drain
only happens when a message is waiting:
| 860-file corpus | before | after |
|---|---:|---:|
| no cache | 321.5 ms | 322.0 ms |
| cold, filling the store | 351.3 ms | 353.4 ms |
| warm, every file from the store | 187.0 ms | 188.6 ms |
The floor under the 15.5 ms is one block no drain can break up:
`perf::what_a_scan_does_before_its_first_file` puts **6.9 ms** before the first
file (resolve the scope, read all 200 files, open the store) against 4.0 ms for
one file — so reading the files lazily is what a single-digit number would take,
and it is filed as a deliberate not-done in that feature's README.
## Before / after — round 5 (2026-08-28)
`docs/features/index-scope/README.md`: the owner's opentitan report. Every F12
into a folder the scope had not reached ran a whole rescan of every folder
reached so far, and `must_wait` holds the next request behind it — so the wait
grew with the session. A widen now indexes the folders it added and folds them
in. Measured over the real checkout (3 979 SV files, warm store, folder scope,
`--release` over stdio, the `HEAD` binary and this one alternated in one
session), timing the `textDocument/definition` sent straight after each
`didOpen`:
| the next request after a jump | before | after |
|---|---:|---:|
| `didOpen hw/ip/aes/rtl` | 120 ms | **22 ms** |
| `didOpen hw/ip/kmac/rtl` | 132 ms | **18 ms** |
| `didOpen hw/ip/hmac/rtl` | 137 ms | **12 ms** |
| `didOpen hw/ip/spi_device/rtl` | 169 ms | **44 ms** |
| the session's first definition (waits for the first widen) | 99.7 ms | **0.9 ms** |
| a definition once the scope has settled | 0.06–0.11 ms | 0.05–0.06 ms |
**The shape is the claim, not the ratio.** What is left is proportional to the
folder being opened — `spi_device/rtl` is the big one and costs the most, every
time — and no longer to how long the user has been browsing. Two thirds of the
first row is not parsing at all: `begin_scan` re-opens the persistent store on
every whole rescan, and decoding 3 979 records is ~90 ms of it, which a widen
does not pay because it keeps the handle the last whole rescan left.
Reproducible without that checkout:
`perf::what_a_jump_into_a_new_folder_costs_before_and_after` generates 40
folders × 25 files of 200 lines and runs **both shapes over the same tree in
the same run**, asserting after every jump that the two indexes fingerprint
identically:
| jump | files in scope after it | whole rescan | incremental widen |
|---|---:|---:|---:|
| 0 | 25 | 18.2 ms | 17.8 ms |
| 1 | 50 | 37.1 ms | 18.1 ms |
| 3 | 100 | 71.7 ms | 18.7 ms |
| 5 | 150 | 107.1 ms | 19.2 ms |
The first row being equal is the honest baseline: with nothing indexed yet the
two paths do the same work.
**What it cost the whole scan: nothing measurable.** The include graph now
re-spells every held edge on each `relearn`, which is the one thing this round
added to a path a whole scan runs.
`state::tests::qa_perf_cold_warm_and_half_warm_scans`, 860-file corpus, after:
**361 / 381 / 202 ms** (no cache / cold / warm) against the 322 / 353 / 189 ms
recorded above and the 347 / 387 / 203 ms QA measured on a busier machine — the
same band, and the store is byte-identical at **2 380 790 bytes**, which is the
number machine load cannot move.
## Before / after — round 6 (2026-08-28)
`docs/features/refactor-ports/README.md`: the rest of the owner's "goto
definition is slow" report. The definition itself answered in microseconds —
it was queued behind `textDocument/codeAction`, which VS Code sends on nearly
every cursor move and which read the whole in-scope file set from disk and ran
the refactor engine over it whenever the cursor sat on an instantiation or a
port. The owner's instrumented session: **3 111 ms** and **3 014 ms** per code
action, against 0.01–0.44 ms for every other request. The file set is now the
cursor's module's own fan-out through the index — definers, instantiation
edges, reference postings, open buffers — instead of the workspace.
Measured over the real checkout (3 976 files indexed, `--release`):
| cursor | before | after |
|---|---:|---:|
| a port of `adc_ctrl_core` (action offered, 2 files edited) | 4.56 s | **7.1 ms** |
| a `prim_fifo_sync` instantiation (36-file fan-out) | 2.93 s | **83 ms** |
Both were checked to give the *same* answer as the whole-workspace
computation, which is the point: this is a smaller input to the same engine,
not a cheaper approximation. The second row is the ceiling — a module
instantiated all over OpenTitan really does need its 36 files, and the engine
parses them twice (plan, then verify); 1.3 ms of that 83 ms is reading them.
Reproducible without that checkout:
`perf::a_code_action_at_an_instantiation_before_and_after` generates 500 files
of 200 lines plus a module instantiated in three of them, and runs both shapes
over the same workspace in the same run:
| | |
|---|---:|
| whole workspace (what the handler did until this round) | 725 ms |
| the module's fan-out | **0.41 ms** |
| `sources()` alone — the read, without the engine | 14.5 ms |
| `prepare_rename`, deliberately untouched this round | 249 ms |
The last row is the follow-up this round did not take: a rename must see every
file that could name the symbol, so its subset is a different argument. It is
sent when the user presses the rename key, not per cursor move.
## Before / after — round 7, Lane B (2026-08-28)
`performance.md` §6d: `textDocument/completion` cost **34–66 ms and fired on
every keystroke**, worst at 0–4 typed characters — the beginning of every
identifier. Typing `aes_reg_top` one character at a time cost **201 ms** of
blocked single-threaded loop. The report guessed the cost was "scanning the
3 976-file symbol table"; the probe says otherwise.
**Where it actually was.** `perf::completing_one_keystroke_at_a_time` runs the
same request at the same prefixes with the cursor at module-item position
(every tier runs) and inside an expression (tier 0 is gated off). Over a
generated corpus of 4 000 files:
| prefix | at an item, before | in an expression (no tier 0) |
|---|---:|---:|
| `` (empty) | 53.2 ms | 0.19 ms |
| `aes_` | 49.7 ms | 0.19 ms |
Everything that is not tier 0 — the index tier, the word tier, the scope
gates, building and serialising 512 items — is **0.19 ms**. The whole cost was
**tier 0, the module skeletons**: up to 64 per keystroke, each one a read of
the declaring file and a `parse_source_tolerant` over **all** of it, to read a
header a few hundred bytes long. One skeleton off a 1 214-line file: 2.71 ms
of parse for 16 µs of planning.
Two changes, both of which must leave the items byte-identical (pinned by
`completion::tests::the_header_slice_plans_exactly_what_the_whole_file_plans`
and `candidates::tests::the_module_table_answers_exactly_what_module_names_answers`):
1. **Parse the header, not the file.** `completion::module_header` slices the
declaring file at the `;` that ends the module header — anchored on the
index's own `name_span`, found by lexing a bounded window, and refused
outright for any header shape it does not recognise. The prefix is kept
byte for byte so every span the plan reads still points where it did.
2. **Table the module names.** Tier 0 asked `vlog_refactor::module_names`,
which calls `WorkspaceIndex::workspace_symbols("")` — building and sorting
a record per declaration in the workspace, **per keystroke**.
`Candidates::modules` is that list, built once beside the index.
| generated corpus, 4 000 files of 1 200 lines | before | after |
|---|---:|---:|
| completion at the empty prefix | 53.2 ms | **3.17 ms** |
| at `a` | 52.4 ms | **3.14 ms** |
| at `aes_` | 49.7 ms | **3.26 ms** |
| at `aes_0001` (1 item) | 0.31 ms | **0.017 ms** |
| one skeleton: `instantiation_plan` over the whole file | 2.71 ms | — |
| one skeleton: over its header alone | — | **16.5 µs** (slicing it: 7.1 µs) |
Over the real checkout, driven through the shipped binary with
`performance.md`'s own client (3 976 files, workspace scope, warm):
| request | before (`performance.md` §6d) | after |
|---|---:|---:|
| completion, empty prefix | 63–66 ms | **13.1–15.0 ms** |
| completion, `a` | 58–61 ms | **13.2–13.5 ms** |
| completion, `aes_` | 35 ms | **15.0–15.7 ms** |
| completion, `prim_` | 16–19 ms | **5.8–6.9 ms** |
| completion, `clk` | 5.7–6.0 ms | **2.4–2.8 ms** |
| completion, `aes_reg` | 5.0 ms | **0.32–0.69 ms** |
| completion, `zzzz` | 1.4–2.0 ms | **0.06–0.31 ms** |
| typing `aes_reg_top`, 11 keystrokes | **200.9 ms** | **64.5 ms** |
**The generated corpus is 3.2 ms and the real one is 13 ms, and the difference
is real rather than noise.** `perf::completing_over_a_real_project` — the same
measurement pointed at whatever `LUCISV_PERF_CORPUS` names, skipped when it is
unset — breaks tier 0's remaining bill down over opentitan's own modules:
| prefix | modules planned | read each | slice each | plan each |
|---|---:|---:|---:|---:|
| `` (empty) | 64 | 16.8 µs | 62.2 µs | 68.2 µs |
| `aes_` | 59 | 15.0 µs | 63.8 µs | 101.6 µs |
| `prim_` | 64 | 12.3 µs | 23.5 µs | 19.2 µs |
| `clk` | 34 | 2.1 µs | 0.7 µs | 1.1 µs |
opentitan's headers are simply bigger: `aes_control_fsm_n`'s is 6.6 KB of
commented ports. That measurement is also what set `HEADER_WINDOWS`: at the
first ladder tried (top rung 4 KB) four of the 64 `aes*` modules overflowed it
and paid a whole-file parse of a 24–52 KB file — 10 ms of the 12. Raising the
top rung to 16 KB removed every fallback and cost the common case nothing,
because the common header still ends inside the first 256-byte rung (59% of
opentitan's 344 RTL modules do).
**What is left, and why it was not taken.** ~10 ms of a worst-case opentitan
completion is 64 real header parses, and the items are required to be
identical, so the only ways down are a cache or a protocol change:
- memoize the plan per (module, index generation) — correct only if the cache
is dropped on every unsaved edit to a declaring buffer, which
`Candidates` currently is not (it is rebuilt at `didSave`), so it would need
a new invalidation rule rather than an existing one;
- `completionItem/resolve`: send tier 0's items with labels only and compute
the skeleton on the lightbulb — ~0 ms per keystroke, but it changes what the
first response contains and needs `resolveProvider` in the capabilities.
Both are the same shape as the deferred `codeAction/resolve` item in
`TODO.md` §10 and belong with it.
**`documentHighlight`, `performance.md` §7 — a functional bug, not a perf
one.** It answered 0 results at every position tried while `references`
answered 7 and 10 at the same positions. Root cause and fix are in
`docs/features/references-nav/README.md`; the number here is only that it is
still fast now that it answers: **0.05–0.15 ms** against the 0.03–0.12 ms it
took to answer nothing.
**The scope-depth default, `performance.md` §4.** The shipped
`lucisv.index.scopeDepth` moves 0 → 2.
`perf::what_the_scope_depth_default_costs` measures every rung over an
opentitan-shaped tree (12 blocks of 20 `rtl/` files plus a `dv/tb/` file, the
buffer opened three levels down):
| depth | files indexed | index names | scan |
|---:|---:|---:|---:|
| 0 | **1** | 5 | 0.6 ms |
| 1 | 1 | 5 | 0.3 ms |
| 2 | **21** | 25 | 15.0 ms |
| 3 | 252 | 256 | 185.0 ms |
Depth 0 reproduces the trap exactly: one file indexed, so every cross-file
answer is empty. Depth 2 is the block the file belongs to — 21 files for 15 ms
of scan, once — and depth 3 is the whole of `hw/ip`, which is why the default
is 2 and not 3.
## Before / after — round 7, Lane A (2026-08-28)
`docs/features/refactor-rename/README.md` and
`docs/features/file-operations/README.md`: the three remaining `ws.sources()`
callers, and the two worst rows in `performance.md`'s table.
The framing round 6 inherited — "a rename is user-initiated, so it may be
slow" — was half wrong. **`prepareRename` is what the rename key sends before
the box opens**, and it was the second-worst number in the whole report: 2.5–
3.0 s of a wholly frozen single-threaded server on a keypress that had
committed to nothing, taking hover, definition and highlight down with it.
Its entire answer — the identifier's range and its placeholder — is in the
open buffer already.
Three fixes, three shapes:
- **`prepareRename`** is answered from the buffer's own `Semantics`, the
`ExternalResolutions` overlay beside it and the index. No file is read,
nothing is parsed. The refusal-by-refusal parity table is in the rename
README; four refusals that need the *declaring file's* own text are deferred
to `rename`, which is what LSP's optimistic `prepareRename` is for.
- **`rename`** is computed over the symbol's fan-out through the index — every
declarer of the old *and* the new name (units and members), every reference
posting, every instantiation edge, every macro definition, the containing
units and their fan-out, every file that *spells* the new name in a use the
index had to look outside that file to answer, plus every open buffer. The
sufficiency argument, the escape hatch for an ambiguously-referenced
declaration, and the named residue are in the rename README.
- **`willRenameFiles`** reads the include graph's includers instead of the
workspace: a file with no edge writes no `` `include`` this workspace can
resolve, so its turn in the sweep could only ever `continue`.
Measured over the real OpenTitan checkout (3 976 files indexed, `--release`,
same machine and corpus as `performance.md`):
| request | before | after |
|---|---:|---:|
| `textDocument/prepareRename` on the `aes` instantiation | 1.663 s | **139 ns** |
| `textDocument/rename` of `aes` (7 files edited) | 3.467 s | **105.5 ms** (7-file fan-out) |
| `workspace/willRenameFiles` for one header | 249 ms of `sources()` alone | **14.1 ms**, whole answer (331 includers of 3 976) |
The remaining 105.5 ms is the engine over 7 real files — index build, then an
analysis of each before and after the edit — not the workspace read:
`sources()` alone was 200–241 ms across runs, which is the row with the most
run-to-run spread on a machine that is not quiet. Building the fan-out itself
is **4.75 ms**, of which the one rung that scans the whole index rather than
looking a key up — `WorkspaceIndex::files_spelling`, the dangling-use rung
added in the QA-driven rework — is **852 µs at its worst** (a name nothing
spells, where the walk cannot short-circuit) and 402 µs for `clk_i`, which 681
files spell.
Every row was also checked for **equality** against the whole-workspace
computation, which is the point: this is a smaller input to the same engine,
not a cheaper approximation. Four real cursors in `tb.sv`:
| cursor | fan-out | result |
|---|---:|---|
| `aes` → `aes_core_top` | 7 of 3 976 | edits identical (7 files, 7 edits); **7 macro-invocation warnings lost** — the one accepted residue, see the rename README |
| `aes` → `prim_fifo_sync` | 7 | both refused, verbatim: *"renaming `aes` to `prim_fifo_sync` would change what `prim_fifo_sync` means in tb.sv"* |
| `clk_rst_if` → `clk_rst_thing` | 116 | edits identical (114 files, 275 edits); 64 → 61 warnings |
| `.clk_i` → `clock_in` | **3 976** | edits identical (4 files, 5 edits), all 652 warnings identical — the ambiguity escape hatch fired, so this cursor is correct but not faster |
and `prepare_rename_here` was swept against `prepare_rename` at every 7th byte
of the same file: **564 offsets, all identical, zero deferrals.**
Reproducible without that checkout, over 500 generated files of 200 lines plus
a module instantiated in three of them
(`perf::a_rename_before_and_after`, `perf::a_will_rename_before_and_after`):
| | before | after |
|---|---:|---:|
| `prepareRename` on the module name | 251 ms | **212 ns** |
| `rename` to a new name (4 files edited, 4-file fan-out) | 486 ms | **370 µs** |
| — building that file set | — | 128.7 µs, of which `files_spelling` 49.8 µs |
| `willRenameFiles`, reading the scope vs the includers | 16.1 ms | **18.9 µs** (whole answer 35.4 µs) |
Every OpenTitan and synthetic figure above was re-taken after the QA-driven
rework, so the tables describe the shipped code. The pre-rework round measured
1.604 s → 135 ns, 3.284 s → 103.6 ms, 238 ms → 200 ns and 465 ms → 294 µs on
the same corpora: the sixth rung is inside the run-to-run noise, which the
separate rung measurement says directly rather than by subtraction.
## Before / after — round 8 (2026-08-29)
`performance_take2.md` §5b: the first F12 from a testbench into its own RTL at
the shipped `scopeDepth: 2` raises the scope from one IP block to the whole of
`hw/ip`, and take 2 measured 1.4–1.7 s of frozen loop for it.
**The diagnosis in the brief did not survive the measurement, and that is the
first result.** The widen was *not* falling back to a whole rescan and was *not*
re-indexing the block it already held: with `hw/ip/aes` already in scope, the
jump's bar reads **1 685 files, not 1 807**, and every one of them is a file the
index did not hold. `widen_of` sees an add (the contained directory stays in the
list beside the containing one) and `begin_widen` diffs **by file against the
index**. Both are pinned by tests this round rather than left to be re-derived.
**What the second was actually paying for**, `hw/ip` at the default scope, warm
store, stage by stage:
| stage of the 1 807-file widen | before | after |
|---|---:|---:|
| walk the added folder and read the new files | 100 ms | 100 ms |
| the scan loop (hash, decode the records, **lex for words**) | 405 ms (325 of it the lex) | 405 ms |
| `index.absorb` | 31 ms | 31 ms |
| **`candidates.absorb`** | **403 ms** | **43 ms** |
| `includes.absorb` | 20 ms | 20 ms |
The word table is a sorted `Vec`, and the widen inserted each new word into it
on its own — one memmove of the table's tail per word, quadratic in the batch.
Counted per batch and merged in one pass, it is 9× cheaper and the answer is
the same table `Candidates::build` sorts from the same counts.
End to end, `/Users/guoliangchen/repo/opentitan`, `--release` over stdio, the
`HEAD` binary and this one alternated in one session, timing the request sent
straight after each `didOpen`:
| `didOpen` at `scopeDepth: 2` | before | after |
|---|---:|---:|
| `hw/ip/aes/dv/tb/tb.sv` (widens to `hw/ip/aes`, 124 files) | 51 / 60 ms | 52 / 55 ms |
| `hw/ip/aes/rtl/aes.sv` (raises to `hw/ip`, **1 685 new**) | 935 / 881 ms | **555 / 564 ms** |
| the same jump on a **cold** store (1 683 parses) | 1 529 ms | **1 175 ms** |
| `kmac`, `hmac`, `spi_device` after it (already in scope) | 3–6 ms | 3–6 ms |
The cold row is take 2's own 1.4–1.7 s reproduced. **What is left is real
work**: 1 683 files this index has never seen, of which 325 ms is re-lexing
them for the completion word table — the persistent store holds a file's facts
but not its words, and putting them there is a `FACTS_FORMAT` change, filed in
`TODO.md` §10. The widen still does not interleave, so this is one bar the user
watches, once per session per big widen.
Reproducible without that checkout:
`perf::what_a_widen_that_subsumes_the_old_scope_costs` generates 20 blocks ×
(25 rtl + 10 dv) files whose every name is its own file's, opens a testbench and
then its RTL sibling at depth 2, and asserts the widened index fingerprints
identically to the whole rescan's:
```text
scope 35 -> 700 files; the widen read 667 of them (the 35 already indexed are not re-read)
whole rescan 664 ms, subsuming widen 653 ms (landing it: 62.9 ms before, 51.8 ms after)
```
The two columns being close is honest and is the point of the shape: when the
subsuming folder is twenty times the old scope, skipping the overlap saves 5 %.
What the round bought is in the landing figure, and it grows with the workspace's
vocabulary — which is why the opentitan table above is the one that matters.
## Measurement round — take 3 on opentitan (2026-09-05)
`docs/performance_take3.md` — 0.43.0 (`73799f3`) against a 0.39.0 server built
from the tag for the comparison, plus the first CLI sweeps (`format --check`
and `check` over five opentitan trees, 0.39.0 / 0.41.0 / 0.43.0, wall clock and
peak RSS). Read-only round: nothing was fixed, findings were filed.
The three headline numbers:
- **`codeAction` on the hot path: 37 ms → 5 ms** at the `aes` cursor and
**185 ms → 16 ms** at a 128-file fan-out, for a client that advertises
`codeAction.resolveSupport` — §37.1's lazy offer, and it is flat in the
fan-out where the eager path is linear in it. The whole hot path is now
inside the frame budget; `codeAction` leaves the queue-blocking table it
headed in both earlier takes.
- **The first RTL `didOpen` at the shipped default: 1 411–1 568 ms →
365 ms warm.** Take 2 called this "the wave's one real regression"; round 8
above plus the index cache took it apart, and 0.39.0 already measures it, so
it is closed.
- **The CLI is 0.6 s for `format --check` over `hw/ip`'s 1 807 files** and
0.40 s to lint them, at ~230 MB peak RSS — essentially flat across the three
binaries.
Three findings filed, none fixed: the **eager** `codeAction` path (a client
without `resolveSupport`) is ~1.37× slower than take 2 at every fan-out, and
0.39.0 already shows it; a `didOpen` of a file already in scope delays the next
request by 21–51 ms where take 2 measured 2–4 ms; and `lucisv check` is 6–10%
slower than 0.39.0 (0.367 → 0.400 s on `hw/ip`). Take 3 also has something
neither earlier take did — **a server-side column**, from the shipped
`--verbose` flag, which confirms the wire numbers to within 0.4 ms.
## What it would take to go faster
Ranked by what the measurements above say is there, with what each would
cost. None of these were attempted; each is a future round.
0. **Answer requests during the startup scan — 780 ms cold, 287 ms warm, on
the first request of a session.** New in round 3's measurements (D2 above)
and the largest single number on this page. It is not a code-speed problem:
the work is already as fast as the persistent cache can make it, and what
costs the user is that the message loop has not started yet. Any fix is a
change to what an answer *means* while the index is half-built, so it needs
a design round, not an optimisation.
→ **Done in round 4**, 780 → 15.5 ms cold and 287 → 12.8 ms warm; the
design round it needed is `docs/features/scan-interleave/README.md`, and
what an answer means mid-scan is written down there. What is left of this
item is 6.9 ms of eager file reading before the scan's first file.
1. **Incremental lexing and parsing — 24.5 ms of a 31 ms flush at 10 000
lines (79 %).** This is the only large lever left. It is also the one
change that runs straight into `CLAUDE.md`'s hard invariants 1 and 2: the
parser is what the "never corrupt code" and idempotency guarantees rest
on, and an incremental parser that is right on 99 % of edits is worse than
none. The change debounce already removed most of the *repetition* per
keystroke, which is why this was not attempted here. The number that would
justify it: **37.6 ms**, the felt latency of one keystroke in a
10 000-line buffer, of which roughly 30 ms is lex + parse.
2. **A cheaply-clonable `Token` — 2.40 ms, 7.7 % of a flush.**
`Document.tokens` must be a separate copy because `parse_tolerant` takes
ownership and steals `leading`/`trailing` out of the tokens it parses; the
copy is 94 961 `String` allocations. Interning the text, or an `Rc<str>`,
would remove most of it — but `Token` is `vlog_parser`'s public type and
the formatter reads it everywhere, so this is a cross-crate change for
under 8 %.
3. **One tree walk for the whole lint pass — 1.40 ms, about 4 % on top of a
flush.** `vlog_linter::lint` is `for rule in enabled { rule.check(ctx) }`,
one walk per rule, and the same engine serves `lucisv check`. Fusing them
is a `vlog_linter` refactor, and the editor and CI must not disagree about
what a violation is.
4. **`completion.rs`'s comment gate**, the last whole-buffer walk on a
per-keystroke request path. Not measured on its own; it is one pass over
the token vector plus its trivia, so the sweep figures above (77.5 µs at
10 000 lines) are the right order of magnitude for it. Doing it properly
means giving the lexer a way to answer "which comment covers this byte",
which is a `vlog_parser` question and not a `completion.rs` one.
5. **`CHANGE_DEBOUNCE` itself** is not a code problem: 150 ms of a lone
keystroke's 164 ms round trip is the timer. It only bites clients that ask
for nothing after a change, and it was set deliberately. Now that it is
measured, a future round has the number to argue about.
## Status / TODO
- [x] `crates/lucisv_server/src/perf.rs` — eight `#[ignore]`d measurements,
std only, each with the command to run it.
- [x] `analyze`, `Document::new`, hover (local + closed cross-file),
`WorkspaceIndex::update_file`, at 1k and 10k lines.
- [x] Before/after where it was cheap: A2 (two ways), A3 and C1.
- [x] Machine, command and date recorded above.
- [x] **Round 1's first open TODO, resolved (round 2, 2026-08-28):**
end-to-end request latency over the wire, measured against the shipped
binary — a single `didChange`, a burst of ten (with the publish count
that turns A1's arithmetic into a measurement), and the
change-then-request shape a real editor produces.
`tests/e2e.rs::a_keystroke_round_trip_over_the_wire`.
- [x] **Added in round 2:** one flush stage by stage, including the
`diagnostics::all` pass that runs on every publish and that round 1's
table did not account for.
- [x] **Added in round 3 (2026-08-28):** a hover into a big closed file with
the **first touch and the repeat reported separately**
(`perf::hovering_into_a_big_closed_file_first_touch_and_repeat`) — every
earlier hover probe reported a mean, which hides exactly the split the
owner's report was about — and the first request of a session against
the shipped binary, with a cold store and a warm one
(`tests/e2e.rs::a_hover_issued_during_the_initial_scan_waits_for_it`).
`perf::breaking_down_one_flushed_keystroke`.
- [x] **Added in round 4 (2026-08-28):** what one mid-scan publish costs
against the per-file parse it is interleaved with
(`perf::publishing_a_half_built_index_mid_scan`, at 50 / 200 / 800
files), and what a scan does *before* its first file — the block no
drain can break up (`perf::what_a_scan_does_before_its_first_file`).
The e2e probe above was flipped to
`a_hover_issued_during_the_initial_scan_is_answered_during_it`.
- [x] **Added in round 7, Lane A (2026-08-28):** the rename family's
before/after, over the same generated corpus round 6 uses
(`perf::a_rename_before_and_after`,
`perf::a_will_rename_before_and_after`), with the OpenTitan column and
the parity/equality sweeps taken by throwaway probes against the local
checkout and deleted.
- [ ] **Round 1's second open TODO, restated and still open:** memory.
Nothing in the repo measures resident size. Round 2 added no data
structure — two free functions and no state — so the figure it would
report has not moved, and round 1's name index is still four bytes per
symbol. Worth doing before anything interns tokens, which is item 2 of
*What it would take to go faster* and is a memory trade as much as a
time one.
- [x] **Round 1's last "not measured", closed for completion (round 7,
2026-08-28):** `perf::completing_one_keystroke_at_a_time` measures the
whole request at nine prefixes, in both positions that gate tier 0, over
a 4 000-file corpus — which is how the cost was found to be tier 0 and
not the symbol table `performance.md` suspected.
`perf::completing_over_a_real_project` does the same over a corpus named
by `LUCISV_PERF_CORPUS`, and skips when it is unset.
- [x] **Added in round 7 (2026-08-28):** what the shipped
`lucisv.index.scopeDepth` costs and buys, rung by rung, on an
opentitan-shaped tree (`perf::what_the_scope_depth_default_costs`).
- [x] **Added in round 8 (2026-08-29):** what a widen that *subsumes* the
folder already in scope costs, at the shipped depth, with the files it
actually reads reported beside the scope's size and the landing of the
scan timed on its own — the stage the round's fix is in
(`perf::what_a_widen_that_subsumes_the_old_scope_costs`).
- [ ] Not measured: signature help and semantic tokens end to end. Each has a
whole-buffer pass somewhere; only their token lookups have ever been
measured. Completion was the third of that list and is now done — and it
was 34–66 ms, which is the reason to finish the other two.
## Work log
**2026-08-28 — dev.** Wrote `perf.rs` and took the numbers above (part A4 of
the LSP performance round). Chose one module of six tests over a test per
crate so that a single command produces the whole table. The generated-module
generator lives beside the tests rather than in a shared helper — it has one
user.
Renamed `hover.rs`'s QA measurement
`hovering_into_a_large_closed_file_reads_it_twice` →
`..._reads_it_once`, since the doubled read it was named for is what A2
removed. The QA log in `docs/features/hover-declarations/README.md` still
names the old spelling; that section belongs to QA and was left alone.
**2026-08-28 — dev (QA fixes).** No number above moved, and none was
re-measured, because nothing on a measured path changed shape:
- The hover fixes (PDS-1, PDS-2, PDS-4) are all inside `attached_lines`,
which part **B** already records as unmeasured. The added work is a
`strip_suffix` per composed line and a below-comment walk that now also
runs when a comment sits above — a handful of `line_range` lookups against
the 142 µs *file read* that dominates the "hover closed" figure.
- CD-1 only *removes* work (a closing buffer's `Document::new` and publish),
and the debounce's own A1 numbers are arithmetic over `Document::new`,
which is untouched.
- PDS-3 widens one `bind_port_decl` branch from ports to task/function
arguments: one hash lookup per declarator of a body port declaration
inside a task or function. `perf.rs`'s generated modules contain no
tasks, so the `analyze` / `Document::new` / `update_file` figures cannot
have moved at all.
**2026-08-28 — dev (round 2).** Added
`perf::breaking_down_one_flushed_keystroke`,
`perf::finding_one_token_against_sweeping_the_stream` and
`tests/e2e.rs::a_keystroke_round_trip_over_the_wire`, and **re-measured every
figure in this document** on the same machine from the commands written
beside them — the tables above are one run of each, not a mix of runs across
days. The old figures are gone rather than kept alongside; every pair was
within the noise this document already budgets for, and carrying two columns
of the same measurement would invite reading a difference into scheduling.
Round 1's figures are not lost — the QA log below quotes all of them in its
own table, dated, and that section belongs to QA and was left alone.
The round's changes are in `docs/features/interactive-latency/README.md`.
Only C1 touched shipped code, and it touched no stage of a flush, so the
flush table is a baseline for the next round rather than an after.
Two things are recorded here that a future round should not have to
rediscover. First, the e2e measurement reuses `e2e.rs`'s existing `Live`
session helper; the only shared code that changed is that `Live::finish` now
returns the publish count it saw on the way out, which is what makes the
debounce's coalescing countable. Second, `perf::generated_module` now has a
copy in `tests/e2e.rs` — a binary crate's modules are not reachable from an
integration test — and the two must stay the same shape or the in-crate table
and the over-the-wire table stop being readable against one another.
**2026-08-28 — dev (round 7, Lane B).** Added three measurements and one
before/after section, all under *Before / after — round 7*:
- `perf::completing_one_keystroke_at_a_time` — the completion request at nine
prefixes, in both positions that gate tier 0, over a generated 4 000-file
corpus. The two columns are the whole finding: everything that is not the
module-skeleton tier is 0.19 ms, at every prefix, before and after.
- `perf::completing_over_a_real_project` — the same, over `LUCISV_PERF_CORPUS`,
with tier 0's per-module bill split into read / slice / plan. **Skipped when
the variable is unset**, so this crate still depends on no checkout it does
not ship. It is what caught the four `aes_control*` modules whose 6.6 KB
headers overflowed the first window ladder and paid a whole-file parse; the
shipped `HEADER_WINDOWS` top rung of 16 KB comes from that measurement and
from a survey of opentitan's 344 RTL headers, not from a guess.
- `perf::what_the_scope_depth_default_costs` — every rung of the scope ladder
over an opentitan-shaped tree, which is the number behind the
`lucisv.index.scopeDepth` default moving 0 → 2.
`completion_corpus`'s files are 1 200 lines rather than the 300 first tried:
at 300 the generated corpus reproduced `performance.md`'s 34–66 ms almost
exactly, and going bigger showed the *shape* of the cost (a whole-file parse
per skeleton) far more clearly — 2.71 ms of parse for 16 µs of planning.
No figure in any earlier round was re-measured: nothing on those paths
changed. `completion.rs`'s tier 0 and `candidates.rs`'s tables are on no
earlier table.
**2026-08-28 — dev (round 7, Lane A).** Two probes added,
`a_rename_before_and_after` and `a_will_rename_before_and_after`, both over
the same 500-file generated corpus `a_code_action_at_an_instantiation_before_and_after`
uses — factored into `rename_corpus` so the three read against one another.
Each prints a before column computed the way the handler computed it until
this round (`vlog_refactor::rename` over `ws.sources()`) and an after column
that calls the real handler, so the comparison is one workspace, one cursor,
one run.
The OpenTitan column of round 7's table came from throwaway probes against
the owner's local checkout, run and deleted — no test may depend on a
checkout this repository does not carry. Three of them: the timings, a
**parity sweep** over every 7th byte of `tb.sv` comparing
`prepare_rename_here` against `prepare_rename` (564 offsets, all identical,
zero deferrals), and an **equality sweep** over four real cursors comparing
the fan-out rename against the whole-workspace one. The last is what earned
its keep: it showed the edit sets byte-identical everywhere (7 files at `aes`,
114 at `clk_rst_if`, 4 at `.clk_i`) and the capture refusal firing verbatim on
`aes` → `prim_fifo_sync`, **and** it found the one thing the synthetic suite
could not — the macro-invocation warnings the fan-out cannot see. That finding
is written up in `docs/features/refactor-rename/README.md`; it is also why the
`` `define`` rung of the fan-out is a walk over the index's tables rather than
a `find_define` lookup, which recovered two of the five warnings the
`clk_rst_if` cursor was losing.
Note on `a_rename_before_and_after`'s before column: it is ~480 ms rather than
the 249 ms `a_code_action_…` records for `prepare_rename` on the same corpus,
because a rename does the analysis twice — once to collect, once to verify —
where a prepare stops after locating the cursor. Both rows are printed by the
same run so neither has to be trusted from memory.
**2026-08-28 — dev (round 7 rework).** QA found a lost refusal in the fan-out
and the lead ruled it not shippable; the fix added a sixth rung
(`WorkspaceIndex::files_spelling`) whose cost, unlike the other five, grows
with the workspace rather than with the symbol. So `a_rename_before_and_after`
grew two lines — the whole file-set build, and that rung on its own — because
"the rung is free" is a claim, and a claim in this document needs a number
beside it. Every figure in round 7's tables was re-taken against the reworked
code rather than carried over; the pre-rework numbers are quoted underneath so
the rung's cost can be read as a difference as well as directly.
## QA log
**2026-08-28 — QA.** No findings — every number reproduces within reason.
- **Machine match confirmed.** `sysctl -n machdep.cpu.brand_string` →
`Apple M1 Max`; `sw_vers` → macOS 27.0, build `26A5421a` — exactly the
machine named in the README's own table, on the same checkout.
- **Re-ran the exact reproduce command**, `cargo test --release -p
lucisv_server perf:: -- --ignored --nocapture --test-threads=1`, and
compared every figure against the table:
| what | table | re-measured |
|---|---|---|
| `analyze`, 1k / 10k | 274 µs / 3.79 ms | 287.6 µs / 3.806 ms |
| `Document::new`, 1k / 10k | 2.60 ms / 31.1 ms | 2.600 ms / 31.72 ms |
| hover local, 1k / 10k | 1.79 µs / 0.97 µs | 3.35 µs / 1.01 µs |
| hover closed, 1k / 10k | 35.2 µs / 160 µs | 34.4 µs / 172 µs |
| — one read of it, 1k / 10k | 26.9 µs / 142 µs | 26.7 µs / 147.6 µs |
| `update_file`, 1k / 10k | 2.73 ms / 31.4 ms | 2.695 ms / 32.45 ms |
| — the clone, 1k / 10k | 60 µs / 528 µs | 60.7 µs / 516.7 µs |
| linear scan, 1k / 10k | 763 ns / 8.41 µs | 793 ns / 8.21 µs |
| name-sorted, 1k / 10k | 106 ns / 133 ns | 93 ns / 134 ns |
Every pair is within the noise the README itself budgets for — including
the hover-local 1k figure, which the README already calls out by name as
"that measurement's noise floor, not a result" (mine is higher still,
3.35 µs vs. 1.79 µs, and still a handful of pointer chases either way).
Nothing here is scaled, remembered, or overclaimed.
- **Re-ran the older, separately-commanded measurement** too: `cargo test
--release -p lucisv_server large_closed -- --ignored --nocapture
--test-threads=1` → **17.0 ms** against the documented "34 ms → 16.3 ms."
Matches the README's own honesty caveat exactly ("read it as 'about half',
not as 2.08×" — different runs, different days).
- **`perf.rs` measures what its name says** — spot-checked
`hovering_across_files_into_a_closed_file` and
`looking_up_one_name_against_scanning_every_symbol` against `hover.rs`'s
and `lib.rs`'s actual entry points (`hover::hover`, `Semantics::
symbols_named` vs. a hand-rolled linear scan over `symbols()`) — both call
the real, shipped functions, not a stand-in.
- **A1's "before/after" is correctly labeled "not measured directly"** — it
is arithmetic over the already-verified `Document::new` figures, and the
README says so; no separate claim to check.
- **B's "not measured, none is claimed"** — confirmed true: no perf test
exercises `fenced_sections`/`attached_lines`, and the README does not say
one does.
**2026-08-28 — QA (round 2).** Findings and the full gate output are recorded
in `docs/features/interactive-latency/README.md`'s QA log, which is this
round's owning feature; summarized here since this document is where the
numbers live.
- Every figure in *Over the wire* and *One flush, stage by stage* reproduced
within the noise this document budgets for, from a fresh
`cargo test --release -p lucisv_server perf:: -- --ignored --nocapture --test-threads=1`
and `cargo test --release -p lucisv_server --test e2e a_keystroke -- --ignored --nocapture --test-threads=1`
on this session's run of this machine.
- **C1's identity claim** (six sweeps → binary searches, none changed an
answer) held under a hand-traced check of all six call sites, including
the empty-token and large-file-fast-path edges, and under an independent
check of the `state.rs` monotonicity precondition against `vlog_parser`'s
own much wider corpus/fuzz tests (`tests/spans.rs`, `tests/error_recovery.rs`)
— no gap found.
- **One methodology finding, IL-1 (medium)**, on the e2e round trip's burst
measurement: the "1 publish(es)" figure for a burst of ten is not the
order-independent count its own doc comment claims — a stray extra publish
in the window between the burst and `Live::finish`'s drain could be
silently absorbed by an unrelated `wait_for` later in the same test and
never counted. Full detail and repro in
`docs/features/interactive-latency/README.md`. Not a claim about a real
double-publish (the debounce is understood to coalesce to one), and not
fixed — closing it is a test-restructuring decision for the dev.
- The two `generated_module` copies (this crate's `perf.rs` and `e2e.rs`'s)
differ by one trivia line, not the byte-identical shape their own comment
implies; verified harmless (comments are not tokens, and the tables stay
readable against each other). Detail in the same QA log.
- **Verdict: SHIP WITH FIXES noted, none applied.**
## Review
**2026-08-28 — lead.** Accepted as the round's record.
The discipline here is what makes the numbers usable later: one command, one
machine block, means rather than single runs, `--test-threads=1` justified by
a contaminated first attempt that reported a cross-file hover as cheaper than
the file read it performs. Refusing criterion was the right call against
`CLAUDE.md`'s dependency rule, and the `#[ignore]`d-measurement pattern was
already this repo's idiom rather than an invention for this round.
I re-ran every measurement independently and the figures reproduce. Two
claims were softened at review rather than left as written: the wire-latency
rows are re-measured after the IL-1 methodology fix (164/202 ms lone,
4.35/37.6 ms with a request following), and the lone-keystroke row now says
plainly that round 1 made that case *slower* — 150 ms of it is the debounce
timer, and a client that asks for nothing after a change waits it out. A perf
document that only records wins is not a perf document.
What I want the next round to inherit: the felt-latency number is **37.6 ms**
for one keystroke in a 10 000-line buffer, roughly 30 ms of it lex and parse.
That is the figure any incremental-parsing proposal has to be argued against,
and it now exists.
### 2026-09-05 — the `didOpen` delay (TODO §46, 0.44.0)
Take 3's §8.4 (a `didOpen` of an already-indexed file delaying the next
request by 21–51 ms) measured and fixed. The breakdown, taken with temporary
timings on a release build and re-taken after: the tolerant parse plus the
semantic analysis is 1.3 / 3.0 / 91 ms for a 326- / 1 145- / 42 192-line
opentitan file, and the lint pass was 4.9 / 54 / 1 654 ms — of which
`undriven-net` alone was 4.4 / 52 / 1 608. The rule asked
`WorkspaceIndex::files_mentioning` (a walk over all 3 976 indexed files) once
per declaration, ahead of the local guards that silence almost all of them.
Moved behind them, where `unused-signal` has always asked.
Wire time, `didOpen` → the request behind it, workspace scope, warm store,
three tries, M1 Max:
| file | before | after |
|---|---|---|
| `aes.sv` (326 L) | 8.1 / 5.9 / 10.1 ms | 4.3 / 1.8 / 2.3 ms |
| `aes_core.sv` (1 145 L) | 56.2 / 54.0 / 48.0 ms | 5.9 / 6.9 / 6.3 ms |
| `hmac.sv` | 56.8 / 42.7 / 51.0 ms | 4.7 / 5.7 / 3.3 ms |
| `kmac.sv` | 69.3 / 72.1 / 70.6 ms | 7.9 / 5.3 / 8.8 ms |
| `spi_device.sv` | 94.2 / 103.4 / 88.6 ms | 6.0 / 8.6 / 8.7 ms |
| `pinmux_reg_top.sv` (42 192 L) | 1 742 / 1 740 / 1 757 ms | 116.5 / 116.2 / 117.3 ms |
The same cost was paid on **every keystroke flush**, not just on opens: the
change debounce ends in the same `set_document` + `publish` pair. 0.39.0
measures the same as 0.43.0 everywhere in the "before" column, so this was
never a regression — the rule had been ordered that way since it was
written. Published diagnostics are byte-identical before and after. Full
account: `docs/features/didopen-cost/README.md`.
### 2026-09-07 — take 4
TODO §58. **0.49.0 against 0.43.0** on opentitan `0098135264`, both binaries
measured in the same hour with the same client. Full document:
[`../performance_take4.md`](../performance_take4.md) (§0–§10). Feature
README: `docs/features/performance-take4/README.md`.
**The harness is now in the repository.** Take 2's, take 3's and take 1's
clients all lived in a scratch directory and all three are gone — take 3's
numbers had to be re-derived from take 2's prose. Take 4's lives in
`tools/perf/` (`lspclient.py`, `sites.py`, `bench.py`, `sweep.sh`,
`sweeptable.py`, `outcomes.sh`, `README.md`; Python 3 standard library only,
runs from a clean checkout). Take 5 reuses it. Sites are resolved from the
file text at run time, and the new offer sites were *found* with a `probe`
phase rather than guessed.
**Credits — what got faster.**
| | 0.43.0 | 0.49.0 | credit |
|---|---:|---:|---|
| `didOpen pinmux_reg_top.sv` (42 192 L) → next request | 1 605 / 1 604 / 1 611 ms | **112 / 131 / 128 ms** | **§46**, **14×** |
| `didOpen spi_device.sv` → next request | 98.7 / 75.2 / 99.5 ms | **15.5 / 13.8 / 15.1 ms** | §46, 6× |
| `didOpen aes_core.sv` → next request | 42.6 / 63.0 / 63.1 ms | **11.0 / 4.0 / 10.4 ms** | §46, 7× |
| a `didOpen` of an in-scope file at the default scope | 33–69 ms | **5–21 ms** | §46 — take 3's §8.4 **closed** |
| `completion` after an instance head + `.` | 24 items, 0.52–0.66 ms | **26 items, 0.45–0.53 ms** | §49, free |
| `rename` through an instance tail | 1 file, tail unedited | **2 files, tail edited** | §49, correctness (but see below) |
The 2026-09-05 entry above took its §46 numbers with temporary timings; **the
release build confirms them at the same magnitude**, which was the point of
this round's `didopen` phase.
**Filed findings** (in `performance_take4.md` §8; nothing was fixed here):
- **§8.2 (medium)** — the *lazy* `codeAction` offer costs 2–5 ms more at every
cursor, offered or not: a plain comment line, where **zero** actions are
offered on either binary, went 1.12–1.32 → 3.18–3.84 ms (2.9×), and the
`definition` pipelined behind a `codeAction` went 3.3–7.3 → 11.2–15.9 ms.
The mechanism is the new offers' gates (`inline_site`, `extract_site`) each
parsing the cursor's buffer on every cursor move. Still inside a frame; the
margin is gone.
- **§8.3 (low–medium)** — §49's tail rename is **11.3×** a same-file rename:
751 ms for two edited files against 66 ms for one. The correctness is right;
the cost freezes the serial queue for three quarters of a second.
- **§8.4 (low)** — `check --select error,warning,style` is 1.27× slower on
`hw/ip` (0.45 → 0.57 s). 0.48.0's new `unused-import` rule explains part of
it; `check` with the *default* rules did **not** move, so take 3's §8.5 has
stopped accumulating on the default path.
- **§8.5 (low)** — two instance-head tails on this corpus do not resolve
(`pwrmgr.sv` 178:10 inside a `` ` ``-macro argument; `pinmux.sv` 687:40).
Filed as a question, not a defect claim.
- **§8.6 (watch)** — the index is +13.7% on disk (39.0 → 44.3 MB) and
+12.6/+15.1% resident (482 → 542 MB cold, 509 → 586 MB warm), which is
`FACTS_FORMAT` 18 → 19 and is proportionate.
**Reported, not re-filed:** the eager `codeAction` path (a client without
`codeAction.resolveSupport`) is **1.95–2.07× dearer** at every fan-out —
243 → 470 ms at 128 files. The owner ruled it a non-hot path on 2026-09-05, so
take 4 reports the number and does not file it again.
**Outcome diff, 0.43.0 → 0.49.0** (`format --check --no-cache`, `check`,
`check --select …` over the same five trees): `format --check` and default
`check` are **byte-identical on all five trees** — §54's grammar additions
change no per-file verdict on this corpus, and §38's fixes stay fixed. The
only change anywhere is **20 new `unused-import` style findings** (`hw/ip`
+17, `hw/top_earlgrey/ip` +2, `hw/top_darjeeling/ip` +1), all from the rule
0.48.0 added. No violation disappeared. Nothing is unexplained.
**Two corpus facts worth remembering.** Opentitan has **zero** non-ANSI module
headers (all 1 311 headers scanned), so §51's `convert to ANSI` has no site
here at all. And take 3's "the lightbulb is almost never lit" no longer
describes this corpus: a 205-file, 2 440-position census at 0.49.0 finds
`extract selection` offered at **89%** of positions and `inline` at **11%**,
against exactly **one** port-refactoring offer — the same `aes_wrap.sv` 78:2
take 3 found.
**Caveat, stated because it is the largest one in the document.** The machine
ran a live desktop session throughout (WindowServer 45–51%, load average
3.7–7.1); take 3 measured at load 2–4. The transport floor moved 4× between
two sessions of the same client minutes apart. The mitigation is structural —
both binaries were measured alternating within the hour with one client — and
every conclusion above is a 0.49.0-vs-0.43.0 pair from that window. Nothing
under 0.5 ms is read. No guard kill; the largest resident set anything reached
was 588 MB, 7% of the 8 GB limit. The opentitan checkout was never written and
its `git status --porcelain` was checked after every phase.
---
## 2026-09-07 — take 5 §P0: two take-4 row meanings are superseded
TODO §60.0, `docs/features/perf5-p0/README.md`. **No performance number here
changes**: P0 touched `tools/perf/` only, and the 0.50.0 binaries it measured
are byte-identical to the ones the take-5 baseline used. Two *meanings* do
change, and this note exists so nobody reads a take-4 row the wrong way.
- **The `rss` phase's `ms` field was never a latency.** Take 4's and the take-5
baseline's `rss` rows put idle RSS (KiB) in `ms` and the store size (KiB) in
`n`. Those rows stand as recorded; **new rows use `rss_kib`, `peak_rss_kib`
and `store_kib` with `units: "KiB"` and carry no `ms` at all.** Peak RSS is
new (a 50 ms `ps -o rss=` poll across the scan); on this workload it equals
idle RSS to the KiB in every session, so the resident set has no transient
above its idle value.
- **Take 4's `extract-module resolve` and `inline-module resolve` rows
measured a refusal, not a refactoring.** Those offers carry a *command*, not
an edit; `codeAction/resolve` on them reached the ports resolver, which
rejects an offer without its data. Nothing in take 4's document quoted them
in a conclusion, and the take-5 baseline README already excluded them. They
are now **removed from the harness**, and a new `execute` phase measures the
commands for real: `workspace/executeCommand`, the server's
`workspace/applyEdit` captured and timed, then declined with
`applied: false` so the corpus is never written. First readings on
opentitan at 0.50.0: `lucisv.extractModule` at `aes.sv` 220:0–222:53 costs
**257 / 245–247 ms** and pushes 2 edits across 2 files plus **1 created
file**; `lucisv.inlineModule` at `aes_wrap.sv` 66:2 is **refused**
(a `generate` construct) in 6 ms; and the *extract* offer at that same
cursor spends **793–817 ms** to produce a refusal — a second ~800 ms
user-command path beside §49's tail rename, filed for take 5's P1/P2.
Also fixed: `sweep.sh` deleted the scratch formatter cache once before three
"cold" tries, so tries 2 and 3 read what try 1 wrote. It now deletes it before
**each** cold try and primes warm cells with one untimed run, and
`sweeptable.py` prints the `N files from cache` each try reported. Verified on
`hw/ip` at 0.50.0: cold `0 / 0 / 0`, warm `30 / 30 / 30`. **Take 4's §7 cold
sweep numbers were measured with the old behaviour** and should be read as
"one cold try plus two warm ones", not as three cold tries.
Every new row is schema 2 — version, units, status, result count, client
capability shape, fresh-process flag, edit fingerprint — and **no document may
quote a row whose `status` is not `ok` or `capture`**. `tools/perf/README.md`
has the full vocabulary; the reference measurements are in
`docs/perf/take5-tracking.md`.
### 2026-09-08 — take 5, the implementation round (TODO §60)
The owner's plan (`docs/performance_take5.md`, tracker
`docs/perf/take5-tracking.md`, baseline evidence `docs/perf/take5-baseline/`)
implemented in seven lanes, each dev → QA → lead, each measured by the
committed harness against the §P0 reference on the unchanged 0.50.0 binary.
Feature READMEs: `docs/features/perf5-p{0,1,2,3,4}/`. Every number below is a
repeat median on opentitan `0098135264`, M1 Max, paired against that
reference; the tracker holds the raw rows and the per-stage experiments.
| what | reference (0.50.0) | after | lane |
|---|---:|---:|---|
| `codeAction` on a no-offer comment, 42 192-line file | 310 ms | **24 ms** | P1a/b — lint/config/fence gated by the requested kinds; the fence answer asked only when a fix exists and memoized per `Document`; the four offer selectors read the document's own parse; a parse counter proves a repeated offer parses nothing |
| definition queued behind that comment | 309 ms | **25 ms** | same |
| `codeAction` at `aes_reg_top` (ports family) | 22 ms | **5.5 ms** | P1c — offer predicates: the lightbulb from the plan-time checks, the click still recomputes and verifies |
| `codeAction` at `aes`; organize-imports offer | 8 / 15 ms | **1.7 / 4.9 ms** | P1c |
| tail rename (`state_q`, 238 files) | 780 ms | **388 ms (2.01×)** | P2 — one parse + analysis per file (`FileFacts::analyzed`), the after-index absorbed from the edited files' records, every verifier check unchanged and re-attacked; the `warnings` stage lexes each file once |
| ordinary `aes` rename (9 files) | 141 ms | **92 ms** | P2 |
| extract-module command | 246 ms | **149 ms** | P2 (collateral) |
| CLI `check --select error,warning,style`, hw/ip: the `unused-import` increment | 142 ms | **5 ms** | P3 — one parse in the census, an AST gate sparing the nine files in ten that declare no package |
| warm workspace start, settled | 1 330 ms | **~1 040–1 100 ms** | P4b — no empty default-scope scan (startup staged behind the configuration answer, 2 s bound), the store not rewritten when unchanged, opened at the first step that needs it, the corpus read a file at a time |
| warm idle RSS | 570 MiB | **~423–480 MiB** | P4b |
| first useful answer after opening a file, warm | 208 ms *or* 1.1 s (a race) | **~275 ms, correct, every session** | P4b — open buffers' folders at the head of the work list; a held opening request answered once that head is published |
**Filed, not fixed (TODO's loop-3 list):** the lint-result memo for the
code-action path (24 ms per cursor move on the largest file); the
target-scoped rename selector (P2d's census proved the 133 "unrelated"
selected files are the container files a hierarchical tail folds through —
no narrowing without a whole-scope oracle); the CLI's third parse; the
first-answer gap to the old race's best case (the workspace walk in front
of the open folder, 158 ms warm — `walk::collect_files` could hand on the
metadata it already stat'd); the store's second open (reuse across rescans
refused: it guards a mid-session cache-path change and a second session's
compaction).
**Contracts amended, all recorded in `docs/topo.md`:** the parsed-input
selectors and `vlog_parser::stats`; `FileFacts::analyzed` and the absorbed
after-index; handshake 33 closed by an opt-in word-census rung (stronger
than the transitive walk the row asked for); `package_exports_in`; the
parsed `timing:` lines; the staged startup, the per-step read, the
`staging`/`head_owed` wait clauses, the compaction skip; `state.rs` split
into `state/`. Nothing in `check/`'s comparisons, `fence.rs`, or
`verify.rs` changed.
### 2026-09-08 — the review round (TODO §61)
The independent review of 0.51.0 (`docs/performance_take5_review.md`,
tracker rows R1–R4) implemented in five lanes, same protocol as §60, each
paired against the 0.51.0 review baseline or the commit it started from.
Feature READMEs: `docs/features/perf5r-{preflight,lint-snapshot,first-answer,publication,scope-reuse}/`.
| what | before | after | lane |
|---|---:|---:|---|
| `rename` on a cursor with no symbol (a refusal) | 2.0 s, 3 975 parses | **0.34 ms, 0 parses** | §61.1 — an engine-owned preflight over the request buffer alone; index-answered refusals stay on the slow road (a wrong rename refusal is terminal) |
| `codeAction` on the 42k-line no-offer comment, unchanged buffer | 22.6 ms (all of it the three semantic rules) | **1.0 ms** | §61.2 — one lint pass per document revision shared by diagnostics and quick fixes, keyed by value on every input (waiver *contents* included), cleared by every index mutation's overlay refresh |
| the definition queued behind it | 22.4 ms | **0.8 ms** | §61.2 |
| first `codeAction` after a one-character edit | 126 ms | **107 ms** (the rest is the buffer's own parse) | §61.2 |
| first useful definition after opening a file, workspace scope | 266 ms cold / 301 warm (0.51.0); 84 / 208 in 0.50.0 *when a race was won*, over 1 s otherwise | **78 cold / 115 warm, correct every session** | §61.3 — the open buffer's folders walked, stepped and published before the rest of the workspace is discovered; the walk hands on the lengths it already has; a subtree walk carries the ancestor ignore stack down |
| warm quiet workspace start | 1 034 ms | **985–997 ms** | §61.3/§61.4 |
| a loaded warm scan (a definition every 100 ms), median wait / scan time | 112 ms / 4.2 s | **1.9 ms / ~1.9 s** at the same offered load | §61.4 — a publish per 512 files instead of per burst (a publish costs the size of the index); the first useful answer exempt |
| an empty navigation answer mid-scan | answered `[]` if the target was not scanned yet | **deferred to the publish that holds it, or scan end**; unsettled answers 0 | §61.4 |
| the tail rename (`state_q`, 238 selected files) | 380 ms, 240 parses | **314 ms, 137 parses** (−21 % against the review's 398) | §61.5 — a rename builds its index from the store's own records for closed files whose bytes hash to what the record was written for, and parses only the files it must analyse; the record and its hash come from one store entry, never the workspace index |
| the duplicate-module rename refusal (`rstmgr_por`, 3 976 files) | 2.05 s, 3 975 parses | **0.7 s, 14 parses** | §61.5 |
**Trades and rulings recorded:** the loaded-scan max in four single-buffer
cells rose (worst 168 → 422 ms warm) — cadence spacing, accepted against
the median and the completion; the duplicate-declaration rename refusal
stays on the slow road (the index is written on save, not on a keystroke);
the bounded local record load of the index store stays unshipped (the
checksum is owed either way, and it would break the canonical load the
compaction skip rests on); a config-discovery memo refused (0.04 ms, and
the only thing noticing an unwatched `lucisv.toml` change).
**Filed, not fixed:** the cross-folder first answer's remaining 89 ms is
the store open; the two-phase discovery walks the open folder twice (+2.5–
5 % on the 1/10-buffer settle); `format::indent_width` over an already-read
`FileConfig`; the `absorb` whole-index merge as the next publication lever.
### 2026-09-09 — the 0.52.0 review (TODO §62)
An independent review of 0.52.0 (`docs/performance_052_review.md`,
evidence `docs/perf/review-052-20260909/`) confirmed the review-round
numbers and found one correctness defect and two harness defects. All
three are fixed in 0.53.0; no performance number moved.
- **F1 — directory aliases in the split startup scan.** The open folder's
walk and the rest-of-workspace walk kept separate visited sets, so a
directory reachable by two spellings (`a_alias -> z_real`) was indexed
twice at startup: two definition targets and a valid rename refused as
ambiguous until a rescan. Fixed: one directory-identity tracker shared
across both walks; a pre-check that takes the single canonical walk
when an alias sorts before the open folder or an ancestor; an alias
found only by the remaining walk requests one ordinary rescan so the
spellings converge; the open-buffer alias gate applied to both walks
and stat'ing only same-named files (`stats` 0 on opentitan). Nine
fixtures assert startup, rescan and restart agree on index paths,
definitions, prepareRename and diagnostics; a genuine duplicate is
still refused. First answer, settle, discovery and the buffer cells
are within noise of 0.52.0 (`docs/features/perf5r-first-answer/README.md`).
- **F2/F3 — the load probe.** A warm `scanload` cell now primes an empty
store untimed and records per-trial cache hits (a warm trial with none
is an error); scan completion is stamped from the scan's own end event
and responses are partitioned by it, not by the request window. The
0.52.0 review's whole-window numbers stand; its `settled_ms`/mid-scan
fields at 0.52.0 do not.
- **N1–N3** (the dirty-buffer parse on the first action after an edit,
the retained-analysis parse work and the 31 ms facts decode, the
whole-index merge per publication) are filed with the review's
baselines and deferred to loop 3.
### 2026-09-12 — loop 3, round 1 (TODO §63)
**§63.1 is a correctness lane, not a performance one**, recorded here
because its parity ran through this harness: a `bind` file's own
occurrence of a renamed name is now edited (resolvable) or warned about
(not), never silent — the resolver had asked the bind target's
*connection* surface for a bare name and rooted a bind's hierarchical
path in the writing scope (`FACTS_FORMAT` 19 → 20). `renamewarn` 1 758 →
1 764 sentences, 1 758 − 8 = 1 750 held; every one of the 28 paired keys
that moved is a bind file's new edit or warning; tail rename 326 ms
(gate ≤ 330). `docs/features/rename-bind-occurrences/README.md`.
**§63.2 — the first request after an edit (N1 of the 0.52.0 review).**
The 40 267-line pinmux cell — one-character `didChange`, then the
all-family `codeAction` menu — **109 → 88 ms paired (−19.2 % dev;
−19.6 % / −16.3 % on QA's re-take, order alternated)**; the
unchanged-repeat cell and every other `offeredit`/`offerkinds`/`flush`/
`diagnostics` row within noise; cold-scan RSS ~25 MiB lower, warm flat.
The flush is now split on the `timing: codeaction` line
(`rebuild{lex parse defines analyze external lines publish documents}`),
which is what named the cost: **lex 29 ms and parse 26 ms of a 100 ms
flush**, and *no* second lint and *no* second analysis of the revision
(the snapshot and `with_semantics` already had those). Three changes, all
in `vlog_parser`: the lexer's two phases fused (the intermediate
`Vec<RawTok>` gone; `tokenize` 27.8 → 24.7 ms), `Parser::skip` for the
178 `bump()` sites that discarded the token (`parse_tolerant` 17.5 →
16.0 ms), and a first-byte test in front of the 42-entry operator table
(`tokenize` 24.7 → **11.6 ms**, the single largest win). Token stream,
parse diagnostics, AST and symbol table digested per file over 4 807
files, re-derived by QA against a rebuilt 1b8723c: 0 differ; the five
gap fuzzers at their pinned counts; `format --stdout` byte-identical over
corpus and opentitan `hw/ip`; diagnostics and menus identical on the
edited buffer (87 lines). **Filed, not fixed** (TODO loop-3 list): the
token clone into `parse_tolerant` (3.9 ms — the parser mutates the
stream it is given, so it cannot be handed over while `Document::tokens`
is read for comments), `analyze` (9.4 ms), `resolve_external` (4.7 ms),
and ~6 ms dropping the previous revision's products on the request path.
`docs/features/perf-first-after-edit/README.md`; evidence
`~/.cache/lucisv-perf/63-2/`.
### 2026-09-12 — loop 3, round 2 (TODO §64)
**§64.1 is a correctness lane, not a performance one**, recorded here
because it moves one harness row on purpose. `textDocument/references`
now judges a declaration's cross-file reach on the **hierarchical**
surface (`nav::leaves_this_file` / `indexed_def_in_file` ask
`member_in(…, Surface::Hierarchical)` instead of `member`), so a module's
net, variable or instance — which a `bind` connection or a `u_x.sig`
tail names from another file — is answered workspace-wide instead of
silently in-file. Two costs, both measured on the real opentitan tree:
- **A local net's `references` in a 40 267-line open buffer** now walks
the indexed path (two map probes plus the name-prefiltered pass over
open buffers) instead of returning the in-file answer directly:
**1.22 → 1.54 ms median** (QA, throwaway worktree at 9d1eb16 for the
before). Accepted: the gate still saves the walk for every name the
index holds nowhere.
- **A cross-file request into a *closed* declaring file** (the shape that
used to answer incompletely) parses exactly that file once, fresh from
disk: 0.1–0.2 ms → **0.4–1.5 ms** on `state_q` from
`entropy_src_core.sv` with `entropy_src_main_sm.sv` shut — the price
of the in-file uses that answer used to omit. The index deliberately
posts no `Local` reference for a hierarchical-only member (the §49
ruling: a reference table sized by every RTL body for a rarely-asked
answer), so the one-file re-analysis is the same trade the rename
already makes.
Every connection-surface row of the `nav` harness is unchanged in result
count and within noise in time (`aes` 14 locations / 9 files, `.clk_i`
12 / 9). Every closed-file span is now guarded by `hover::spells_exactly`
before it is rendered — one slice compare per location, unmeasurable —
so a stale index can omit a location but never point at a wrong line
(QA findings 1–4). `docs/features/references-hierarchical-surface/README.md`.
### 2026-09-23 — MCP: `lucisv-mcp` startup and the per-call sweep (TODO-MCP M6)
`lucisv-mcp` builds its index at the first tool call and can start it from
the language server's `index-cache` (read only) or its own
`index-cache-mcp` beside it (`docs/features/mcp-cache-and-census/README.md`).
Release build, the whole opentitan checkout (3 944 files), two runs of
`tests/opentitan.rs::opentitan_startup_cold_and_warm_and_the_stat_sweep`:
| what | wall | the language server's nearest row |
|---|---|---|
| cold start, no store | 1 854–1 887 ms | — |
| warm, own store (3 944 hits) | 837–847 ms | warm quiet workspace start 985–997 ms (§61), workspace scope |
| warm, the editor's store (3 944 hits) | 821–832 ms | — |
| exit, writing the own store (46.3 MB) | 251–272 ms | compaction skipped when unchanged (§P4b) |
| freshness sweep per call (median, 21 calls) | 5.6–6.1 ms (floor `tools/list` 0.38 ms) | — |
| `rename` dry run, whole set (`op_i` in `aes_cipher_core.sv`) | 2 227–2 276 ms | — (MCP-7) |
A warm build is walk 210 ms + store read 87 ms + read/hash/decode 318 ms +
merge 204 ms; a cold one parses instead (1 387 ms). The rows are not
like-for-like with the server's (it scans in stages and answers during the
scan); they sit side by side so a regression in either shows.
### 2026-11-19 — localized reindex (TODO §71.1)
What one save costs the index on the full OpenTitan `hw` tree (4 058 files,
scope `workspace`, 10 buffers open), measured over LSP with the real release
server and in-process with `state::tests::reindex_perf` (release,
`--test-threads=1`); medians, the machine shared with another lane's builds.
Details and the method: `docs/features/localized-reindex/README.md`.
| | before (7408fac) | after |
|---|---:|---:|
| `reindex_one`, any edit, any file | 141–158 ms | — |
| …the watcher's echo of a save / an unchanged record | 153–176 ms, everything republished | 0.07–1.1 ms, nothing sent |
| …a local signal in a module (`uart_tx`, `prim_flop`) | 144–145 ms | 5.2 ms |
| …a package member added (`uart_reg_pkg`) | 148 ms | 11.7 ms |
| …a line above everything in `prim_flop.sv` (125 instantiating files) | 144 ms | 61 ms |
| watcher event for a `.sv` the scope cannot take | 746 ms whole rescan | 3.5 ms, nothing |
| whole merge (`absorb`, startup / cached rescan) | 135 / 165 ms | 158 / 189 ms |
| warm startup scan (fix round, QA's `perf.py`, two runs) | 1 113 / 1 124 ms | 1 171 / 1 148 ms |
| `prim_mubi_pkg` member added, 677 importers (fix round) | 162 ms | 92 ms |
| readers table | — | 13 806 keys, 69 222 entries |
| mention census, one lint pass (average / worst file) | 51 µs / 2.8 ms | unchanged |
Probes: `tools/guard.sh -- cargo test --release -p lucisv_server reindex_perf -- --ignored --nocapture --test-threads=1`.