Review round §61.2 (R1a/R1b): one lint pass per document revision shared by the diagnostics publish and quick-fix discovery, keyed by value on every input of lint_with (waiver contents included) and cleared by every index mutation's overlay refresh; a --verbose codeaction stage trace first showed the 23 ms is three semantic rules and the first-after-edit is the flush; pinmux menu 22.6 → 1.0 ms, queued definition 22.4 → 0.8, publish and memory unchanged
ci / checks (push) Successful in 1m10s
ci / corpus (push) Successful in 35s

This commit is contained in:
lucio committed 2026-09-08 18:26:44 -05:00
1 parent 51cbfd27df
commit a1c77c053f
17 files changed
+2637 -103

No files matched your search

@@ -0,0 +1,602 @@
# perf5r-lint-snapshot — the code-action path on a large file
Take 5 **review** round (`docs/performance_take5_review.md` §1), TODO §61.2,
tracker rows **R1b** (the stage trace) and **R1a** (the lint-result snapshot).
Baseline is 0.51.0; the paired reference for this lane is trunk at `51cbfd2`,
which is 0.51.0 plus §61.1's rename preflight — a change on the rename path
that this lane does not touch.
## Goal
A `textDocument/codeAction` on a comment in `pinmux_reg_top.sv` (42 192 lines,
1.3 MB, generated) costs **25 ms**, of which **23 ms is the quickfix family**,
and the first request after a one-character edit costs **136 ms**. The review's
own reading is that `lint.rs::fixable` calls `lint_with` on every request and
nothing memoizes the result; take 5 §P1's lane deferred that memo because "its
key is a different shape from anything else in this lane" and its failure mode
is a **stale fix offer**.
This lane does the two halves the review asks for, in its order:
* **R1b, first: measure.** One `timing: codeaction …` line per request behind
`--verbose`, splitting the request into config discovery, `LintRun` build,
lint pass, fence filter and action serialization — and, separately, the
**flush**: the debounced `Document` rebuild that `answer_request` performs
before any handler runs, with the diagnostics pass that publishes inside it
split the same five ways. No behaviour change.
* **R1a, then: reuse.** One lint-result snapshot per open `Document`, keyed by
every input the result depends on, read by the **diagnostics** pass and by
**quick-fix discovery** alike, recomputed whenever the key does not match.
The fence authority and execute-time validation are untouched.
**What must not move:** which diagnostics are published, which fixes are
offered, and their bytes. A menu that is fast because it is stale is a
failure, and so is a fix offered for a finding the current buffer no longer
has.
## What the measurement said (R1b)
`tools/perf/phases_r1.py::actionprofile`, three cursors, four request shapes,
`--verbose`, one warm session each. Milliseconds, `--tries 3`, repeat median
of the wire time and the trace of the last request.
| pinmux comment | wire | flush wall | flush parses | flush lint | action config | action build | action lint | fence | serialize |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| first request of the session | 25.10 | 0.00 | 0 | 0.00 | 0.20 | 0.06 | **22.43** | 0.00 | 0.05 |
| repeated, unchanged buffer | 21.97 | 0.00 | 0 | 0.00 | 0.04 | 0.01 | **20.87** | 0.00 | 0.03 |
| definition queued behind it | 22.33 | 0.00 | 0 | 0.00 | 0.04 | 0.02 | **20.96** | 0.00 | 0.03 |
| first request after a `didChange` | 127.54 | **99.72** | 1 | **21.08** | 0.03 | 0.01 | **20.22** | 0.00 | 0.03 |
Read off those numbers:
* **The 23 ms is the rules.** Config discovery — the `lucisv.toml` walk,
`ProjectLint::read` and the waiver reads — is **0.04 ms** on a repeat
(0.20 ms on the first request of a session, which is the OS cache warming).
The `LintRun` build is 0.01–0.06 ms. The fence filter costs **nothing**:
this buffer has **zero** violations, so §P1a's "no fix, no fence parse" gate
answers before the memo is asked. Serialization is 0.03 ms. **99% of the
quickfix menu is `lint_with`.**
* **Which rules.** `tools/perf/phases_r1.py::ruleablation` pushes
`lucisv.lint.select` one rule at a time through `didChangeConfiguration`
and times the same quickfix-only menu under each. The floor — one cheap
rule, so context construction and transport alone — is **1.3–1.4 ms**.
Three rules stand out, and they are the three **semantic** ones that read
the buffer's `Semantics` and the workspace census:
| rule | repeat median | over the floor |
|---|---:|---:|
| `unused-signal` | 9.52 | **+8.2** |
| `undriven-net` | 8.69 | **+7.4** |
| `multiply-driven` | 8.88 | **+7.5** |
| every other default rule (55 of them) | 1.24–3.51 | ≤ +2.2 |
| control, all 57 default rules | 20.19 | +18.9 |
The three semantic rules are effectively the whole of it; the remaining 55
rules together account for about 2 ms. (Single-rule rows each pay the
shared context setup once, so the three do not add up to 18.9 exactly —
the ranking is what this row set establishes, not an exact partition.)
* **The 136 ms first-after-edit is mostly *not* the lint pass.** Of 127.5 ms:
**99.7 ms is the flush** (one whole-file parse and the analysis of 1.3 MB,
plus the diagnostics publish it triggers) and **20.2 ms is the handler's own
lint pass**. Inside the flush, the diagnostics pass is **21.1 ms** of the
99.7 — so the `Document` rebuild itself is about **78.6 ms**, and the
request runs **`lint_with` twice on the same revision**: once to publish
diagnostics, once to discover quick fixes.
That is the review's item 4 answered with a number: **a lint cache alone
cannot fix the 136 ms**, because 79 ms of it is `Document::new`. What a
snapshot can take out of it is one of the two 21 ms passes.
The small-file controls behave as expected and are recorded in full:
`tb.sv` 0.52 ms unchanged / 0.98 ms after a change (flush 0.49 ms), the
`aes.sv` `aes_reg_top` cursor 3.2 ms / 4.19 ms (flush 1.10 ms).
## The dependency / invalidation table
Written **before** any cache, as the review requires. One row per input that
can change a lint result or a fix. "How the key observes it" is the mechanism,
not a hope; "test" is the test that flips that row and asserts a fresh result.
`lint_with(ctx, rules, external)` is a pure function of its three arguments,
and `ctx = LintContext::from_parse(text, tokens, tree, line_index, path)
.with_semantics(&doc.semantics).with_options(options).with_line_length(w)
.with_tab_width(t)` plus the oracle. So the table below is complete by
construction: every argument of that expression is a row.
| # | input | how it can change | how the key observes it | test |
|---|---|---|---|---|
| 1 | document text, tokens, tree, `semantics`, line index, path | `didOpen`, `didChange`, a text-carrying `didSave`, `willRenameFiles` | **identity.** The snapshot is a field on the `Document`, and `Workspace::set_document` builds a **new** `Document` for every flushed change and drops the old one. There is no revision number to compare because there is no way to hold the wrong one — the same argument `crate::fences` already rests on | `an_edited_buffer_is_relinted` |
| 2 | `doc.large` | a buffer crossing `lucisv.largeFile.threshold` in either direction | identity (row 1: the mode is re-taken in `set_document`, which builds a new `Document`). A large buffer never reaches the pass at all: `codeAction` is answered `[]` by `large_file.rs` before any handler, and `diagnostics::all_in` returns empty | `a_large_buffer_lints_nothing_and_stores_nothing` |
| 3 | the enabled rule set | `lucisv.lint.select` / `ignore` / `severity.<class>` / `rules.<name>` pushed by `didChangeConfiguration`; `[lint] select` / `ignore` in the buffer's `lucisv.toml` | `Key.rules`: the `&'static str` names the ladder produced, in registry order, compared **exactly** (not hashed) | `a_pushed_rule_selection_is_relinted`, `a_rewritten_toml_is_relinted` |
| 4 | merged rule options | `[lint.<rule>]` tables in `lucisv.toml`; `lucisv.lint.options` from the editor | `Key.options`: the merged `RuleOptions`, compared exactly (`PartialEq`) | `a_rewritten_toml_is_relinted` |
| 5 | line width | `line-length` in `lucisv.toml`; `lucisv.lineLength` | `Key.line_length` | `a_rewritten_toml_is_relinted` |
| 6 | tab width (fix **text** only) | `indent` in `lucisv.toml`; `lucisv.indent` | `Key.tab_width`. Since this lane the width lives on the `LintRun` — read there through `format::indent_width`, which used to be called by the dispatcher — so the diagnostics pass and the quick-fix pass build the *same* context and share one snapshot. Only `no-tabs`' fix string reads it, and the diagnostics path never reads a fix, so no published diagnostic moves | `a_tab_width_change_rewrites_the_fix` |
| 7 | external waiver file **contents** | any edit of a file named by `[lint] waivers` or by `lucisv.lint.waivers` | `Key.waivers`: `(path, text)` per file, in the order they are read — the **exact text** `ExternalWaivers::parse` was handed, not a hash and not an mtime. One read, not two: `lint.rs` now reads the bytes itself and parses them, reproducing `ExternalWaivers::read`'s error sentence byte for byte | `a_rewritten_waiver_file_is_relinted` |
| 8 | the `lucisv.toml` itself | any edit of the discovered config file; a new config file appearing in a parent directory | **through rows 3–7.** Nothing in a `lucisv.toml` reaches a lint result except the selection, the options, the width, the indent and the waiver paths, and all five are in the key. `LintRun::for_document` re-runs `Discovery::for_file` on **every** request (0.04 ms, measured above), so a rewritten file is in the key at the next request | `a_rewritten_toml_is_relinted` |
| 9 | the workspace index the census oracle reads | `publish_scan`, both `finish_scan` paths, `update_one` — i.e. a scan step, a scan finishing, a `didSave` or a watcher event in **another** file | **not a key field: an explicit drop.** All four of those call sites end with `for doc in self.docs.values_mut() { doc.refresh_overlay(&self.index) }`, and `refresh_overlay` — the one place a `Document` is told the index moved — clears the snapshot. Verified by exhaustion: `self.index.{absorb,remove_file,update_facts,update_file}` occurs nowhere else in `state/` | `a_change_in_another_file_relints_this_one` |
| 10 | whether there is an oracle at all | the first scan of a session that began with an empty index | `Key.has_oracle`, **and** row 9's drop | `a_workspace_appearing_turns_the_semantic_rules_on` |
| 11 | client settings generation | `workspace/didChangeConfiguration`, or the reply to `workspace/configuration` | through rows 3–7; `apply_settings` also republishes every open buffer, which recomputes under the new key immediately | `a_pushed_rule_selection_is_relinted` |
| 12 | file-watcher events on the `lucisv.toml` / the waiver files | **there are none.** `watch::SOURCE_GLOB` is `**/*.{v,vh,sv,svh}` and the only other watcher is the configured filelist's own path | rows 7 and 8 are what make this safe: both files are re-read per request, so no watcher is needed and none is added | `a_rewritten_toml_is_relinted` (no watcher event is sent) |
| 13 | close and reopen | `didClose` then `didOpen` | identity: `close_document` removes the `Document`, and with it the snapshot | `a_closed_and_reopened_buffer_is_relinted` |
| 14 | UTF-16 ranges | — | **not an input.** `Positions` is built from `doc.text` per request in `code_action.rs` and `lint::diagnostics_in`; nothing positional is stored in the snapshot, which holds byte spans exactly as `lint_with` returned them | `a_snapshot_fix_keeps_its_utf16_range` |
Two things are deliberately **not** in the key:
* **A hash of anything.** Every field is compared by value. A 64-bit digest
would have been smaller and would have made "no stale fix" an argument
about collision probability instead of a fact.
* **A time or a generation number for the config files.** An mtime is a
weaker statement than the contents and is wrong across a same-second
rewrite; the contents are already in hand because the pass reads them.
## What R1a bought (paired)
Reference `51cbfd2` (`5d2a7aa2a4fd…`) against the same tree plus this lane's
diff (`827c7ac222c8…`), both `--release --locked`, the same schema-2 harness,
phase order alternating which binary went first, no build during any timed
run, `--tries 3`, repeat medians. Load 2.5–5.9 one-minute, inside the review's
own 2.8–6.0 band; zero guard kills; opentitan `git status --porcelain` = the
same three pre-existing files after every phase.
| workload | `51cbfd2` | this lane | change |
|---|---:|---:|---|
| pinmux comment, **all** action families, unchanged | 22.61 | **0.98** | **−95.6%** |
| pinmux comment, **quickfix only**, unchanged | 24.51 | **0.11** | **−99.5%** |
| pinmux comment, empty family filter | 0.05 | 0.05 | unchanged |
| pinmux menu, repeated on the unchanged buffer (`offeredit`) | 23.44 | **0.18** | **−99.2%** |
| **definition queued** behind the pinmux menu (leader / follower, pipeline 3) | 22.39 / 22.38 | **0.78 / 0.76** | **−96.5%** |
| pinmux comment, **first offer after a `didChange`** | 125.65 | **106.89** | **−14.9%** |
| `tb.sv` comment, unchanged / after a change | 0.19 / 1.26 | 0.23 / 1.45 | +0.04 / +0.19 ms |
| `aes.sv` `aes_reg_top`, unchanged / after a change | 2.86 / 3.83 | 2.58 / 3.62 | −9.7% / −5.5% |
| diagnostics publish after `didChange` (≈150 ms of it is the debounce) | 162.29 | 162.75 | **+0.3%** |
| `didOpen pinmux_reg_top.sv` → definition | 120.45 | 110.42 | −8.3% |
| `didOpen aes.sv` / `aes_core.sv` / `spi_device.sv` → definition | 4.53 / 5.72 / 8.68 | 3.49 / 5.56 / 8.15 | −23% / −3% / −6% |
| take-3 `codeaction` cells (eager, fan-out 1 / 6 / comment) | 21.37 / 88.44 / 1.67 | 21.60 / 89.74 / 1.56 | +1.1% / +1.5% / −6.7% |
| idle RSS, 100 open buffers each asked for quick fixes (MiB) | 574.0 | **574.6** | **+0.1%** |
| idle RSS, 10 / 1 buffers (MiB) | 429.4 / 420.9 | 428.4 / 422.2 | ±0.3% |
**Gates.**
* *unchanged pinmux menu ≤ 16 ms* — **met, 0.98 ms** (quickfix-only 0.11 ms).
* *queued definition ≤ 16 ms* — **met, 0.76 ms**.
* *first-after-edit improved, reported separately with its stage split* —
**125.65 → 106.89 ms, −14.9%**, and the split says exactly why that is the
whole of what a lint cache can do here: of the candidate's 109 ms, **106 ms
is the flush**, of which **21.9 ms is the diagnostics pass** and the
remaining ~84 ms is `Document::new` on 1.3 MB. The handler's own lint pass
is **0.00 ms — it does not run**. The remaining stage is named and is not
this lane's: the parse and analysis of a 1.3 MB buffer.
* *diagnostics publish unchanged* — **met, +0.3%** (inside the run-to-run
spread of a 150 ms debounce).
* *no higher retained memory* — **met, +0.1% at 100 open buffers**, all of
them holding a snapshot.
* *no stale diagnostic or fix under any invalidation row* — 11 server tests
and 10 unit tests, one per row plus the attack; see below.
The candidate's own trace, at the same three cursors:
| pinmux comment | wire | flush wall | flush lint | flush snapshot | action lint | action snapshot |
|---|---:|---:|---:|---|---:|---|
| first request of the session | 2.07 | 0.00 | 0.00 | — | **0.01** | **hit** |
| repeated, unchanged | 0.72 | 0.00 | 0.00 | — | **0.00** | **hit** |
| definition queued behind it | 0.23 | 0.00 | 0.00 | — | **0.00** | **hit** |
| first after a `didChange` | 109.39 | 106.09 | **21.87** | miss | **0.00** | **hit** |
The first request of a *session* already hits: the `didOpen` published
diagnostics, and that pass is the one the menu reads. A queued definition logs
no trace line of its own at all — it lints nothing — which is what the
`result_count` of those rows says.
**The config-discovery decision: leave it.** The review allows memoizing the
`FileConfig` read "if the trace says that I/O is material". It does not:
0.04–0.16 ms on a repeat, against a 21 ms pass. Memoizing it would have added
a second key (path, mtime, length) whose failure mode is a *stale rule
selection* — and the `lucisv.toml` and the waiver files are not watched
(table row 12), so that per-request read is the only thing that ever notices
one of them changing. It stays.
The one thing that did move is where the **indent width** is read. It used to
be `format::indent_width`, called by the dispatcher; it is now the same
function, called by `LintRun::for_document`, because the two doors must build
the same context to share one snapshot. A code-action request therefore does
the same two `Discovery` walks it always did (one in `configured`, one in
`indent_width`); the **diagnostics publish now does two where it did one**.
Measured, that moved the config stage from about **0.04 to 0.15 ms** on a
repeat and left the publish row at **+0.3%**, inside the spread of a 150 ms
debounce. It is stated rather than hidden, and the fix is a handshake request
below, not a second spelling of the indent ladder here.
## Assumptions
- **`lint_with` is deterministic and side-effect-free** given `(ctx, rules,
external)`. Not enforced by a type; it is what makes a snapshot legitimate
at all. Pinned by `a_recomputed_snapshot_equals_a_fresh_pass`, which lints
the same document twice through the two doors and compares every violation.
- **A `Document`'s derived fields are a pure function of its text.** The same
assumption `crate::fences` (§P1b) already ships on, and the reason identity
can stand in for a revision number in row 1.
- **`refresh_overlay` is called for every open buffer at every index
mutation.** Established by exhaustion over `state/mod.rs` (row 9) rather
than by a type. A new index mutation that skipped it would be a stale
oracle for `external` resolution too, which is a pre-existing contract this
lane now also depends on — stated in Handshakes.
- **`format::indent_width` stays the one authority on the indent ladder.**
`LintRun::for_document` calls it rather than re-deriving the width from the
`FileConfig` it already read, which costs a second `Discovery` walk — worth
hundredths of a millisecond against a 21 ms pass, and worth not having two
spellings of a rule that decides a fix's bytes. Pinned rung by rung by
`the_runs_tab_width_is_the_formatters_own_ladder`. The dispatcher's own call
to it is gone, so the request as a whole does not walk more often than
before.
## Handshakes
**Consumed**
- `vlog_linter::{lint_with, ExternalWaivers::parse, RuleOptions}` — unchanged.
`ExternalWaivers::parse` (already public) is now called directly instead of
`ExternalWaivers::read`, so the file's text is in hand for the key; the
error sentence for an unreadable file is reproduced verbatim
(`format!("{}: {e}", path.display())`).
- `vlog_formatter::fence::protected_regions` through `crate::fences` — the
shared-fence-filter contract (`docs/features/shared-fence-filter/`) is
**not** amended. `fences.rs` gains one read-only predicate, `held`, which
the trace uses to say whether a request paid the parse; it decides nothing.
- `crate::state::Document::refresh_overlay` — the existing "the index moved"
hook. This lane makes it also drop the lint snapshot.
- `vlog_parser::stats::parses` — the flush's parse count in the trace.
**Promised**
- `crate::lint::violations_in` and `crate::lint::fixable` now return
`Arc<[Violation]>` instead of `Vec<Violation>`, and `fixable` no longer
takes a `tab_width` — the width comes from the `LintRun`. In-crate callers
only (`lucisv_server` is a binary crate): `diagnostics.rs`, `code_action.rs`
and their tests.
- `crate::lint_trace` is new and is written to from `lint.rs`,
`code_action.rs` and `server/dispatch.rs`. It is a thread-local
accumulator, armed per request; nothing outside `--verbose` observes it.
**Requested of another module**
- `crate::format` (not this lane's file): `indent_width(path, client)` runs its
own `Discovery` walk, and `LintRun::for_document` has already discovered the
same `FileConfig` a line earlier. A form taking that `FileConfig`
— `indent_width_of(&FileConfig, &ClientSettings)`, with today's function as a
one-line wrapper — would let the lint pass pay one walk instead of two. The
cost of not having it is measured above (about **+0.11 ms** on the config
stage, publish row +0.3%), which is why this lane did not spell the ladder a
second time to avoid it: one authority on a fix's bytes is worth more than
0.11 ms. Nothing else is needed in `vlog_linter`, `vlog_formatter`,
`fence.rs` or `state/scan.rs`.
**`docs/topo.md`** — this lane adds one edge (`lint.rs ──▶ lint_snapshot.rs`,
`lint.rs ──▶ lint_trace.rs`, `state/mod.rs ──▶ lint_snapshot.rs` for the
field) and amends the `server-lint ◀──▶ diagnostics` edge to say the two now
share one computed result. `topo.md` is not this lane's file: the amendment is
requested here for the lead to apply at merge.
## Status / TODO
- [x] R1b — the `timing: codeaction …` stage trace (`lint_trace.rs`), with the
flush group and its parse count; `fences::held` for the memo hit
- [x] R1b — the harness: `tools/perf/phases_r1.py`, phases `actionprofile`
(three cursors × four request shapes) and `ruleablation` (one row per
default-on rule)
- [x] R1b — measured, and the 23 ms / 136 ms attributed (above)
- [x] the dependency/invalidation table, written before the cache
- [x] R1a — `lint_snapshot.rs`, the `Document` field, both consumers
- [x] R1a — one invalidation test per table row, plus the stale-fix attack
- [x] R1a — measured paired against `51cbfd2`; the 100-buffer RSS cell
- [x] tracker cells R1a/R1b and both experiment records; TODO §61.2
## Work log
**2026-09-08 — dev (Opus), R1b.**
- `crates/lucisv_server/src/lint_trace.rs` (new): a thread-local stage
accumulator in `vlog_parser::stats`' shape — per thread because a request is
answered on one thread, and armed only by the request wrapper when
`--verbose` asked. Off costs one `Cell<bool>` read per traced site: no clock,
no allocation, no line. Two groups per request, `flush` and `action`,
divided by `close_flush`, so the diagnostics pass that publishes during the
debounced flush is readable beside the handler's own pass.
- `lint.rs`: `LintRun::for_document`'s body split into `Discovered::read`
(everything read from disk) and `Discovered::into_run` (the oracle and the
rule ladder), so the I/O has a stage of its own. The calls, their order and
the order the config problems are collected in are unchanged. One place now
calls `lint_with` (`found`), which is what makes one trace site enough.
- `dispatch.rs`: `flush_dirty_traced` wraps the flush with a clock and a
`vlog_parser::stats::parses()` delta, but only when a trace is armed;
`Server::request` arms one and logs `timing: codeaction method=… total=… ` +
the two groups, for any request that linted anything — which is the code
actions and any request whose flush published diagnostics, so the queued
definition gets its own line.
- Deviation, stated: the flush is traced as **one** stage plus its parse
count, not split into parse / analysis / overlay-refresh. Those three live
inside `Document::new` and `Workspace::set_document` in `state/mod.rs`,
which this lane owns only for the snapshot field and its initializers;
splitting them means threading a trace through `set_document`'s signature.
The number the review asks for — dirty-buffer stage versus lint pass — is
fully answered without it: flush 99.7 ms of which the diagnostics lint is
21.1, so the rebuild is ~78.6 ms.
- Measured (§R1b cells above). Zero guard kills; opentitan
`git status --porcelain` = the three known files after every phase; load
1.9–3.6 one-minute, inside the review's own 2.8–6.0 band.
**2026-09-08 — dev (Opus), R1a.**
- `crates/lucisv_server/src/lint_snapshot.rs` (new): `Key` — the inputs, by
value — and `Slot`, a `Mutex<Option<Held>>` on the `Document`. `read_or`
answers from the slot when the key matches and otherwise computes with the
lock released and replaces what is held. No hash anywhere: the waiver files'
**text** is compared, not a digest, so "can this offer a stale fix?" is a
`PartialEq` question. `Mutex` rather than `RefCell` so a `Document` stays
`Sync` exactly as its `OnceLock` fence memo leaves it; a poisoned lock (which
a single message loop with no panicking library code cannot produce)
degrades to computing every time.
- `state/mod.rs`: **one field** (`Document::lint`), its two initializers, and
one line in `refresh_overlay` — the hook that already exists for "the index
moved" — which clears it. That line is the whole of the index invalidation
and is why there is no generation counter to keep in step. Four lines of
production code in that file; it is over the size threshold already (1 063 →
1 067 by the CLAUDE.md measure) and TODO §55 owns that.
- `lint.rs`: one `found(doc, run)` reads the slot and both doors call it, so
the diagnostics publish and quick-fix discovery are **one** pass. Both now
return `Arc<[Violation]>`; `fixable` copies only when the fence filter
actually drops something, which on a buffer with no `// lucisv: off` region
is never. The **tab width moved onto the `LintRun`** (read through
`format::indent_width`, whose call the dispatcher no longer makes) — without
that the two doors would build different contexts and thrash one slot.
Waiver files are read with `read_to_string` + `ExternalWaivers::parse`
instead of `ExternalWaivers::read`, one read still, so the text is in hand
for the key; the unreadable-file sentence is reproduced verbatim.
- Found by an existing test, and worth recording: the first version let a test
helper set `external` without the matching text, so two runs with different
waivers shared a key. `with_external` became `with_waivers(path, text)`,
which writes both — the invariant is now structural, and the field's doc
comment says so.
- Tests: 21 added, none removed (4 322 → 4 343 in the guarded workspace run).
11 in `server/tests/lint_snapshot.rs`, one per table row through the real
doors plus the **stale-fix attack** (a buffer edited so the span a previously
offered fix named no longer exists — nothing is offered, and the wire answer
is empty); 4 in `lint_snapshot.rs` (every field of the key forces a
recompute; a waiver rewritten in place is a different key); 4 in
`lint_trace.rs`; 2 in `lint.rs` (the tab-width ladder rung by rung, and a
reused snapshot compared violation for violation and fix for fix against a
fresh `lint_with`).
- Reuse is asserted **by pointer** (`Arc::ptr_eq`), never by a stopwatch: a
timing assertion on a lint pass is a flake.
- Harness fix during the run: `actionprofile`'s queued rows attributed trace
lines by position, and a definition that lints nothing logs no line, so two
leaders were recorded as a leader and a follower. Lines are now attributed
by their own `method` field and `result_count` says how many the follower
logged. The `r1a-cand` `actionprofile` rows in the evidence file predate that
fix and are superseded by `r1a-cand-2`; no number quoted anywhere came from
the mis-attributed field (the R1b table's queued row is the leader's split,
which is what it always was).
- Measured (above). Zero guard kills; opentitan clean after every phase.
## QA log
**2026-09-08 — QA (Sonnet).**
Read CLAUDE.md, TODO §61.2, `docs/performance_take5_review.md` §1, this
README in full, `perf5-p1`'s deferral memo, `semantic-lints-on`'s oracle
handshake, and `docs/perf/take5-tracking.md`'s R1a/R1b records plus both
experiment records, before touching anything.
**Gates, guarded, main tree.** `cargo fmt --all -- --check` clean.
`cargo clippy --all-targets --workspace` clean after touching every changed
file to defeat the incremental cache — no new `#[allow]` anywhere in the
diff. `cargo test --workspace` (guarded, `tools/guard.sh -m 8 -t 1800`):
**4 343 passed, 0 failed**, matching the dev's own count exactly. Cross-checked
independently: cloned trunk `51cbfd27dfd22720856c501c9c17277460cc6a68` fresh
into scratch (no diff), built and tested the same way — **4 322 passed, 0
failed**. `cargo test --workspace -- --list`, name-sorted and `comm`-diffed
between the two trees: **zero names removed, exactly 21 added**, and the 21
match the dev's own breakdown byte for byte (11 in
`server::tests::lint_snapshot`, 4 in `lint_snapshot::tests`, 4 in
`lint_trace::tests`, 2 in `lint::tests`). Production line counts (non-blank,
non-comment, up to `mod tests`): `lint.rs` 334, `dispatch.rs` 464,
`lint_snapshot.rs` 54, `lint_trace.rs` 207 — all four numbers match what the
dev's own measure would produce; note for whoever wrote my brief: the file
names for the last two are transposed there (the *smaller* file is
`lint_snapshot.rs`, holding `Key`/`Slot`, and the *larger* is `lint_trace.rs`,
holding `Stage`/`Group`/`Trace`) — a wording slip, not a code finding.
`state/mod.rs`: read the diff directly rather than counting — exactly one
field (`pub lint: crate::lint_snapshot::Slot`), two initializers (`Document::new`
and the large-file constructor), and one line in `refresh_overlay`
(`self.lint.clear();`). All files well inside the 300–600 target; no file
pushed over a threshold.
**The invalidation table, derived independently first.** Read `found`'s call
to `lint_with` and `LintRun::context`/`LintRun::key` and listed every input
that reaches `lint_with(ctx, rules, external)`: buffer text/tokens/tree/
line_index/path (`context(doc)`), `options`, `line_length`, `tab_width`
(fix text only), the oracle (`has_oracle` plus the index's own answers),
`rules`, `external` (waiver contents), and `doc.large` (gates the whole path
before any of this runs) — nine independent inputs, matching the table's 14
rows exactly once the table's own splits (rows 3/11 both being "the rule
selection", 4/5/8/12 all being "the toml", 9/10 both being "the index") are
collapsed back to the inputs of the call. Nothing reaches `lint_with` that
the table's rows do not name. Read `state/mod.rs`'s four index-mutating call
sites (`publish_scan`, `finish_whole_scan`, `finish_widen`, `update_one`) in
full: all four end in `for doc in self.docs.values_mut() { doc.refresh_overlay(&self.index); }`,
confirming row 9's "verified by exhaustion" claim directly rather than
trusting it. `Document` has no custom `Drop`; `lint: Slot` is dropped by the
default field-wise drop whenever a `Document` is dropped (`didClose`, or
replaced by `set_document`), confirming item 8's memory-bound claim.
**The wire matrix (a)–(l), attacked twice, independently of the dev's own
tests.** Wrote two standalone Python scripts
(`wire_probe.py`, `wire_probe2.py`, in the QA scratchpad) speaking real
JSON-RPC over stdio (`Content-Length` framing) to the actual
`--release --locked` candidate binary, against a fixture workspace this QA
built from scratch (not the dev's fixtures, not the Rust in-process
`Session`): a `lucisv.toml`, a waiver file, a tabbed module, and a
`dut.sv`/`tb.sv` pair for the oracle row. Every row, all passing on the first
clean run (after two script bugs of my own — a premature
`take_notifications()` and a stale waiver directive shadowing a later
section — found and fixed, noted so the evidence is legible):
| row | attack | result |
|---|---|---|
| (a) | edit the buffer | covered by (g)/(k)'s edits and the dev's own `an_edited_buffer_is_relinted` |
| (b) | `didChangeConfiguration` toggling `lucisv.lint.ignore` twice | fresh both times |
| (c) | `lucisv.toml` `[lint] select` rewritten on disk with **no watcher event**, twice | fresh at the very next request both times |
| (d) | waiver file rewritten to the **same length**, different content (`--line=1` vs `--line=2`) | fresh, not stale |
| (e) | waiver file **deleted** entirely | fresh (finding un-silenced) |
| (f) | `tb.sv` — **never opened** — rewritten on disk, reaching `dut.sv` only through a bare `workspace/didChangeWatchedFiles` (no `didChange` anywhere) | `dut.sv`'s republished diagnostics flip `unused-signal` on, then back off when `tb.sv` mentions the signal again |
| (g) | close, then reopen with different text | fresh |
| (h) | a buffer over `lucisv.largeFile.threshold` | offers nothing (fast path answers before any handler) |
| (i) | a UTF-16 fix range (`é` + a non-BMP `🎉` before the tab) on a snapshot asked for twice | the reused answer is byte-identical to the computed one; range is `character: 9` (UTF-16 units), not the byte offset |
| (j) | `indent` in `lucisv.toml` changed between two quick-fix requests on the same open buffer | the `no-tabs` fix text changes from `" "` to `" "` at the very next request |
| (k) | offer a fix, edit the buffer so both fixes' spans (one of them 40+ lines deep) are gone, ask again over a range that would be out-of-bounds for a stale answer | nothing offered, and the server's own view of the buffer is the post-edit text |
| (l) | `source.fixAll.lucisv` after the buffer is edited back down to one violation | offers exactly the one-tab fresh edit, not the earlier two-tab one |
**Sabotage, in a fresh clone with the working diff applied
(`scratchpad/qa-61-2/cand`), one at a time, each reverted before the next and
confirmed clean (`git diff --stat` back to the original 341/16 insertion
counts, `grep -rn SABOTAGE` empty):**
1. Stripped the waiver **text** out of `LintRun::key()` (kept the path,
blanked the string) → `server::tests::lint_snapshot::a_rewritten_waiver_file_is_relinted`
**FAILED** (14 passed, 1 failed), exactly the row-7 test and nothing else.
2. Removed `self.lint.clear()` from `Document::refresh_overlay` (early
`return` right after the `external` line) → `a_change_in_another_file_relints_this_one`
**FAILED** (14 passed, 1 failed), exactly the row-9 test.
3. Hard-coded `tab_width: 0` in `LintRun::key()` (context still builds with
the real width, so the *fix* would be correct but the *key* blind to a
change) → `a_tab_width_change_rewrites_the_fix` **FAILED** (1 passed, 1
failed alongside the unrelated `the_runs_tab_width_is_the_formatters_own_ladder`,
which stayed green because it never reuses a snapshot across a config
change — consistent, not a miss).
All three cuts were caught by exactly the test the row predicts and no other
test in the same run flipped. Nothing else was sabotaged (hashing the key,
an index-generation counter, etc. — the README's own rejected-alternatives
list — since none of those are what shipped).
**Trace.** Confirmed `lint_trace::arm()` is reachable only through
`Server::request`'s `let Some(started) = self.timer() else { return … }`
branch, and `timer()` is `self.verbose.then(Instant::now)` — so a
non-`--verbose` session allocates nothing and logs nothing, by construction,
not by convention. Re-ran `tools/perf/phases_r1.py::actionprofile` and
`::ruleablation` against my own fresh `--release --locked` build of the
candidate (sha256 `827c7ac222c8…`, byte-identical to the dev's own candidate
binary hash — confirms the evidence file and my build are the same code) over
the read-only OpenTitan corpus:
- unchanged pinmux menu 0.57–0.88 ms, queued definition 0.24–0.26 ms, first
after a `didChange` 103.5–118.0 ms (repeat median ≈106 ms) — all inside or
close to the dev's own range, on the same machine, at a different time of
day.
- the trace fields on the first-after-edit row: `trace_flush_lint=21.85ms`
(dev: 21.1–21.9 across the two records), `trace_flush_snapshot=miss`,
`trace_action_lint=0.00ms`, `trace_action_snapshot=hit` on **every** row
including the first-after-edit one — the handler's own pass really is
0.00 ms, reproduced independently.
- `ruleablation` on the *candidate*: every row is cheap (≤~1.5 ms), which is
the **expected** consequence of R1a and not a re-derivation of the R1b
per-rule costs — `didChangeConfiguration` republishes every open buffer
before the timed `codeAction` requests run, so the expensive single-rule
pass happens during the republish and the timed request always hits. I did
**not** rebuild a snapshot-free (`51cbfd2` + `lint_trace.rs` only, no
`lint_snapshot.rs`) variant to re-derive the three-semantic-rules-cost
attribution itself; that number is R1b's, marked "attribution, no
behaviour change" in the tracker, and the flush-lint figure above (21.85 ms)
is consistent with it. Flagged as a scope limitation, not a finding.
**Re-measured cells.** `snapshotrss` re-run on both my own ref and candidate
builds (100 open buffers, quickfix-only on each, 3 tries): candidate median
574.2 MiB (dev: 574.6), reference median 575.2 MiB (dev: 574.0) — both inside
noise of the dev's own numbers and confirming the "+0.1%, no higher retained
memory" gate independently. `codeAction`-family latency reproduced via
`actionprofile` above; did not separately re-run `offerkinds`/`offerqueue`/
`offeredit`/`diagnostics`/`didopen` as their own named phases (time budget) —
`actionprofile`'s four request shapes at the same three cursors cover the
same underlying behaviour (unchanged menu, quickfix-only, queued definition,
first-after-edit) those phases measure. Also a scope limitation, not a
finding.
**Traceability.** Pulled `~/.cache/lucisv-perf/take5r-2/results.jsonl` and
checked all 12 numbers named in the tracker's R1a/R1b rows and experiment
records: `22.61, 24.51, 22.39/22.38, 0.98, 0.11, 0.78/0.76, 574.0, 574.6,
162.29, 162.75` match raw sample values in the file to within 0.005; `125.65`
and `106.89` are not raw samples but are exactly the median of the *last two*
of the three `ms` samples for the reference and candidate "first offer after
`didChange`" rows respectively (`128.96` was the first, so 125.65 = median of
127.76/123.54; `106.07` was the first, so 106.89 = median of 108.64/105.14) —
consistent with the tracker's own "first / repeat median" convention, not a
fabricated number. Same check for `574.0`/`574.6`: exact medians of the three
100-buffer `rss_kib` samples in the file.
**Guard / opentitan / cleanup.** Every cargo invocation (fmt, clippy, test ×3
trees, `-- --list` ×2 trees) and every perf phase (`actionprofile`,
`ruleablation`, `snapshotrss` ×2 binaries) ran through
`tools/guard.sh -m 8 -t 1800`; zero guard kills. `git -C
/Users/guoliangchen/repo/opentitan status --porcelain` checked before, during
and after every phase: the same three pre-existing files
(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
`hw/top_earlgrey/ip/ast/rtl/ast.sv`), nothing else, every time. All sabotage
was done in `scratchpad/qa-61-2/cand`, a fresh clone with the working diff
applied; the main tree was never `git checkout`/`reset`/`stash`/`clean`ed and
nothing outside this README's QA log and the TODO line below was edited. No
background loop or server process left running at the end of this session
(checked `ps aux` — only a pre-existing, unrelated VS Code extension server
survives).
**Verdict: PASS.** No stale diagnostic or fix found or produced under any of
the 14 table rows, over the real wire, on a fixture this QA built
independently, with three targeted sabotage cuts each caught by exactly one
predicted test. Gates green and cross-checked against a from-scratch clone of
`51cbfd2` with matching binary hashes; test count +21/-0 confirmed by name,
not just by count. Two scope limitations disclosed above (no snapshot-free
rebuild for the R1b per-rule ablation; five perf-phase names not re-run under
their own headings) are attribution/measurement gaps, not correctness gaps,
and do not change the verdict.
**Topo edges for the lead to apply at merge** (from this README's own
Handshakes section, confirmed absent from `docs/topo.md` today): `lint.rs
──▶ lint_snapshot.rs`, `lint.rs ──▶ lint_trace.rs`, `state/mod.rs ──▶
lint_snapshot.rs` (the field), and the `server-lint ◀──▶ diagnostics` edge
amended to say the two doors now share one computed result. The
`format::indent_width_of(&FileConfig, …)` request to `crate::format`'s owner
is still open and unclaimed by this round; it is a 0.11 ms/request cost, not
a correctness issue.
## Review
**2026-09-08 (lead).** Accepted. Read `lint_snapshot.rs`, the `state/`
hunks (one field, two initializers, one clear in `refresh_overlay`), the
`lint.rs` door, the invalidation table and both logs; QA's independent
derivation of the input list and its wire matrix through a real client
are the acceptance.
- R1b answered the review's question before anything was built: the
23 ms is three semantic rules over a 42k-line file, and the 136 ms
first-after-edit is the flush (one parse of 1.3 MB plus the
diagnostics pass) with the handler's second pass on top. That is why
the snapshot is shaped as one pass per revision shared by both doors.
- The key is the design: every input of `lint_with` by value — waiver
*contents*, not an mtime, because nothing watches them — and identity
for what identity settles (the `Document`, and the index through the
overlay refresh every mutation ends in, checked by exhaustion by dev,
QA and me). No hash, no generation counter, no map: a stale fix is a
question about `PartialEq`.
- Gates met by an order of magnitude (menu 22.6 → 1.0 ms, queued
definition 22.4 → 0.8) with the publish and memory unchanged. The
first-after-edit residue is the parse of the buffer, named, not this
lane's.
- The config-discovery memo was correctly refused: 0.04 ms of I/O that
is the only thing noticing an unwatched `lucisv.toml` change.
- Deviations accepted: the flush traced as one stage; the indent-width
read moved into the run (+0.1 ms on publish) with the
`format::indent_width(FileConfig)` request filed.
Docs applied at merge: topo (the snapshot and trace modules, the
diagnostics/quick-fix shared result, the parsed `timing: codeaction`
line); the `format::indent_width` request to the loop-3 list.
+237 -2
View File
@@ -2009,8 +2009,8 @@ checks in its full experiment record. Targets are proposed gates, not promises.
| ID | Hypothesis / proposed work | 0.51.0 review baseline | Proposed gate | Owner / candidate commit | Candidate result / raw evidence | Decision |
|---|---|---|---|---|---|---|
| R1a | Dependency-correct lint-result reuse removes repeated quickfix work | pinmux all 25.0 ms; quickfix 23.1 ms; queued definition 24.2 ms | unchanged all/queued ≤16 ms; current results after every invalidation | — | — | Pending |
| R1b | Profile then reduce dirty-buffer analysis on the first action after an edit | pinmux 135.9 ms; unchanged repeat about 24 ms | first-edit reduction shown separately; didChange ordering preserved | — | — | Pending |
| R1a | Dependency-correct lint-result reuse removes repeated quickfix work | pinmux all 25.0 ms; quickfix 23.1 ms; queued definition 24.2 ms | unchanged all/queued ≤16 ms; current results after every invalidation | dev (Opus), §61.2, tree at `51cbfd2` + the §61.2 diff | Paired against this session's own reference (`51cbfd2`, 22.61 / 24.51 / 22.39 ms): **all families 0.98 ms (−95.6%)**, **quickfix only 0.11 ms (−99.5%)**, **queued definition leader/follower 0.78 / 0.76 ms (−96.5%)**. Snapshot on the `Document`, key compared by value; idle RSS at 100 open buffers 574.0 → 574.6 MiB (+0.1%); diagnostics publish +0.3%. 21 tests added, one per invalidation row plus a stale-fix attack. [Record R1a-2026-09-08](#experiment-record--r1a-2026-09-08-stage-r1a); `~/.cache/lucisv-perf/take5r-2/` | Retained — QA PASS → lead; committed 2026-09-08 |
| R1b | Profile then reduce dirty-buffer analysis on the first action after an edit | pinmux 135.9 ms; unchanged repeat about 24 ms | first-edit reduction shown separately; didChange ordering preserved | dev (Opus), §61.2, trace-only build of `51cbfd2` + `lint_trace.rs` | **Attribution, no behaviour change.** The unchanged 22 ms menu is **20.9 ms `lint_with`**, 0.04 ms config I/O, 0.01 ms run build, 0.03 ms serialization, fence skipped (zero violations). Of the 127.5 ms first-after-edit: **99.7 ms flush** (1 parse of 1.3 MB + the diagnostics publish, itself **21.1 ms**) and **20.2 ms** the handler's own second pass — so a lint cache can only remove one 21 ms pass, which R1a then did (**125.65 → 106.89 ms, −14.9%**). Per-rule ablation: `unused-signal` +8.2, `undriven-net` +7.4, `multiply-driven` +7.5 ms over a 1.3 ms floor; the other 55 default rules ≤ +2.2 ms each. [Record R1b-2026-09-08](#experiment-record--r1b-2026-09-08-stage-r1b) | Retained — QA PASS → lead; committed 2026-09-08 |
| R2a | Remove redundant discovery metadata/config work | traced warm discovery 205.0 ms; first useful answer 328.2 ms paired | first useful answer ≤200 ms milestone, correct settled target | — | — | Pending |
| R2b | Begin useful local-folder work before full discovery/cache loading finishes | warm cache open 92.3 ms in traced session; cold/warm first answer 286.8/328.2 ms | single coherent scan, correct results across startup ordering cases | — | — | Pending |
| R3a | Engine-owned empty-cursor preflight avoids whole-workspace materialization | no-symbol refusal 2,192 ms; 3,975 parses, candidate-only trace | ≤16 ms; zero closed-workspace parses; exact refusal/precedence | dev (Opus), §61.1, tree at `e13ae4c` + the §61.1 diff | **0.3 ms** repeat median (paired reference 2,012.3 ms, −100.0%); `trace_parses` **0**, `trace_selected` **0** off the wire; refusal byte-identical; peak RSS 909 → 429 MiB. [Record R3a-2026-09-08](#experiment-record--r3a-2026-09-08-stage-r3a); `~/.cache/lucisv-perf/take5r-1/` | Retained — QA PASS → lead; committed 2026-09-08 |
@@ -2024,6 +2024,241 @@ warm idle memory gain and all source-selection/fence/after-index contracts in
[topo.md](../topo.md). Cross-module API changes need their handshake recorded
before implementation; no verifier forgiveness may be weakened for speed.
## Experiment record — R1b-2026-09-08 (stage R1b)
- **Experiment ID / stage / date / owner:** `R1b-2026-09-08` / R1b (TODO
§61.2) / 2026-09-08, America/Chicago / dev agent (Opus).
- **Hypothesis and exact expected work reduction:** none — this is the
review's "trace the stages first". The expected *output* is an attribution
of the 23 ms quickfix menu and the 136 ms first-after-edit across config
discovery, `LintRun` build, lint, fence and serialization, plus the dirty
buffer flush measured apart from the handler.
- **Reference commit, candidate commit or diff hash, binary hashes:** the
traced build is trunk `51cbfd27dfd22720856c501c9c17277460cc6a68` plus
`lint_trace.rs` and its call sites — behaviour-identical, the trace armed
only under `--verbose`. Release, rustc 1.97.1 (Homebrew). The R1b numbers
are candidate-only by construction: the reference has no trace to read.
- **Files changed / API contracts amended / topology references:**
`crates/lucisv_server/src/lint_trace.rs` (new), `lint.rs` (two stages around
the discovery and the run build, one around `lint_with`), `fences.rs` (a
read-only `held` predicate), `code_action.rs` (the serialization stage),
`server/dispatch.rs` (`flush_dirty_traced`, and the line). No contract
amended. `tools/perf/phases_r1.py` (new): phases `actionprofile` and
`ruleablation`.
- **Workload, corpus/input hashes, open files, cursor/range, rules, client
capabilities:** OpenTitan, the three known pre-existing modified files,
`git status --porcelain` checked after every phase. Cursors are
`phases_p1.EDIT_CURSORS` — the pinmux comment, the `tb.sv` comment, the
`aes.sv` `aes_reg_top` instance — so the profile rows sit beside the
`offeredit` latency rows they explain. Lazy resolving client. 57 default
rules (the workspace set).
- **Machine, compiler/profile, threads, load before/after, competing
activity:** M1 Max, macOS 27.0, release profile, default worker count. Load
1.9–3.6 one-minute across both phases. No build or test suite overlapped a
timed run.
- **Commands, cache reset/prime steps, trial ordering and fresh-session
count:** `bench.py actionprofile --tries 3` and `bench.py ruleablation
--tries 3`, each through `tools/guard.sh -m 8 -t 1800`. One fresh
`--verbose` session per cursor; the ablation is one warm session with
`lucisv.lint.select` pushed by `didChangeConfiguration` per row (a selection
change rescans nothing — `notification.rs::apply_settings`), with the
unrestricted control taken first **and** last.
- **Raw evidence path, explicit units, full sample arrays:**
`~/.cache/lucisv-perf/take5r-2/results.jsonl`, label `r1b-cand`. Latency in
`ms`; every field of the trace line is a `trace_*` row field
(`trace_action_lint`, `trace_flush_wall`, `trace_flush_parses`, …).
- **Reference first / repeat median / range; candidate first / repeat median /
range:** pinmux comment — first request of a session 25.10; unchanged
repeats **21.97** (21.82–22.01); queued behind a definition 22.33; first
after a `didChange` **127.54** (121.84–130.67). `tb.sv` 0.52 / 0.98;
`aes.sv` 3.20 / 4.19.
- **Work counts: reads, parses, analyzed/selected/watched/edited files and
bytes:** the unchanged menu performs **0** whole-file parses and **1**
`lint_with` pass over 57 rules finding **0** violations; the fence filter is
skipped (no fix to protect, §P1a). The first request after a `didChange`
performs **1** parse — the flush's — and **2** `lint_with` passes over the
same revision.
- **Result/status/count/fingerprint comparisons, warnings and refusal
checks:** every row `status=ok`; result counts unchanged from the reference
rows of the same cursors. No edit-bearing row in this phase.
- **Idle RSS / peak RSS / cache size / guard outcomes:** not sampled here (the
memory cell belongs to R1a). **Zero guard kills.**
- **Target achieved or missed; paired improvement and variability:** not a
target — an attribution. The two numbers the review asked for:
**the 23 ms is `lint_with` (20.9 of 22.0)**, config I/O being 0.04 ms; and
**the 136 ms is 78% dirty-buffer flush** (99.7 ms of 127.5, of which 21.1 ms
is the diagnostics pass, leaving ~78.6 ms of `Document::new`), with the
handler's own 20.2 ms lint pass the only part a cache can remove.
- **Where the reference disagrees with the baseline beyond tolerance (neither
number adjusted):** the review's cells are 25.0 (all families), 23.1
(quickfix) and 135.9 (first after change); this session reads 22.0–22.6,
24.5 and 127.5 — within 3–7% and in both directions, on a machine whose load
was at the low end of the review's band. Nothing is adjusted.
- **Correctness tests and logs:** 4 unit tests in `lint_trace.rs` (an unarmed
trace records nothing and returns the work; `close_flush` divides the
request; one recompute makes the whole request a miss; the line names every
stage in both groups). The whole workspace suite is reported under R1a,
which is the change that could break something.
- **Interpretation, remaining bottleneck, tradeoffs, rejected alternatives:**
the per-rule ablation is the finding the previous lane guessed at ("it may
be cheaper to ask *which* rules cost 24 ms than to cache their answer"):
three semantic rules — `unused-signal` **+8.2 ms**, `multiply-driven`
**+7.5**, `undriven-net` **+7.4** over a **1.3 ms** floor — are effectively
the whole pass, and the other 55 default rules together are about 2 ms.
Making *those* cheaper is a `vlog_linter` change and is not this lane's; a
snapshot is what removes the repetition without touching a rule. **Rejected
alternative:** splitting the flush into parse / analysis / overlay stages,
which lives inside `Document::new` and `Workspace::set_document` — outside
this lane's file ownership, and unnecessary for the question asked, since
flush-minus-diagnostics answers it.
- **Decision: retain / revise / reject / defer; next stage justified by
evidence:** **retain** the trace (it is what R1a is judged by, and what a
future lane will read when it goes after the 78 ms rebuild). The rule cost
is filed as evidence for whoever takes the semantic rules on.
- **QA result and lead review link:** pending —
`docs/features/perf5r-lint-snapshot/README.md`.
## Experiment record — R1a-2026-09-08 (stage R1a)
- **Experiment ID / stage / date / owner:** `R1a-2026-09-08` / R1a (TODO
§61.2) / 2026-09-08, America/Chicago / dev agent (Opus).
- **Hypothesis and exact expected work reduction:** R1b measured a request
that runs `lint_with` **twice** on one revision — once to publish
diagnostics, once to discover quick fixes — and a repeat menu that runs it
again on a revision nothing has touched. If one snapshot per open
`Document`, keyed by every input of that call, is read by both doors, the
expected reduction is **the whole 21 ms pass on every unchanged request**
and **one of the two passes** on the first request after an edit.
- **Reference commit, candidate commit or diff hash, binary hashes:**
reference = trunk `51cbfd27dfd22720856c501c9c17277460cc6a68` (0.51.0 plus
§61.1's rename preflight, which this lane does not touch), built from a
clean clone in scratch, binary
`5d2a7aa2a4fd0d1747aec4011a482defd2d8a1dccc08b6156b17d9a820375770`.
Candidate = that tree plus the §61.2 diff, binary
`827c7ac222c829d12a4e245b4d720b67a3dca6c799fd6bb8ee525fe697587b12`. Both
`--release --locked`, rustc 1.97.1 (Homebrew).
- **Files changed / API contracts amended / topology references:**
`crates/lucisv_server/src/lint_snapshot.rs` (new), `lint.rs`,
`code_action.rs`, `server/dispatch.rs`, `state/mod.rs` (**one field**, its
two initializers and one line in `refresh_overlay`),
`server/tests/lint_snapshot.rs` (new). In-crate signature changes:
`lint::violations_in` and `lint::fixable` return `Arc<[Violation]>`, and
`fixable`/`code_action::code_actions` no longer take a `tab_width` — the
width is on the `LintRun`, read through `format::indent_width`, whose call
the dispatcher no longer makes. `vlog_linter`, `vlog_formatter` and
`fence.rs` are untouched; the shared-fence-filter contract is not amended. A
`docs/topo.md` amendment is *requested* in the feature README's Handshakes
and was not applied by this lane.
- **Workload, corpus/input hashes, open files, cursor/range, rules, client
capabilities:** OpenTitan, the three known pre-existing modified files,
`git status --porcelain` checked after **every** phase invocation. Cursors
are `tools/perf/sites.py`'s and `phases_p1.EDIT_CURSORS`', unchanged. Client
shapes are in every row.
- **Machine, compiler/profile, threads, load before/after, competing
activity:** M1 Max, macOS 27.0, release profile, default worker count. Load
recorded before every phase: **2.47–5.88** one-minute, inside the review's
own 2.82–6.00 band. **No build, test suite or second benchmark overlapped
any timed run** — both binaries and both test suites finished first.
- **Commands, cache reset/prime steps, trial ordering and fresh-session
count:** 12 guarded `bench.py <phase>` invocations, `--tries 3`, each
through `tools/guard.sh -m 8 -t 1800`. Phases `offerkinds offeredit
offerqueue codeaction diagnostics didopen snapshotrss`, each once per
binary, with reference/candidate order **alternated between phases**
(`offerkinds` ref→cand, `offeredit` cand→ref, `offerqueue` ref→cand,
`codeaction` cand→ref, `diagnostics` ref→cand, `didopen` cand→ref,
`snapshotrss` ref→cand), plus `actionprofile` on the candidate for its
trace. Separate `--storage` per (label, phase); `snapshotrss` and `didopen`
open a fresh process per try.
- **Raw evidence path, explicit units, full sample arrays:**
`~/.cache/lucisv-perf/take5r-2/results.jsonl`, labels `r1a-ref`,
`r1a-cand`, `r1a-cand-2` (the corrected trace run). Units in every row:
latency `ms`, memory `rss_kib` / `peak_rss_kib`. Trace fields are `trace_*`.
- **Reference first / repeat median / range; candidate first / repeat median /
range:** pinmux all families — reference 30.84 / **22.61** / 21.9–24.5;
candidate 2.42 / **0.98** / 0.41–1.24. Quickfix only — reference 22.35 /
**24.51**; candidate 0.15 / **0.11**. `offeredit` repeat — reference 23.88 /
**23.44**; candidate 0.23 / **0.18**. First after `didChange` — reference
128.96 / **125.65** / 123.5–129.0; candidate 106.07 / **106.89** /
105.1–108.6. Queued definition (leader / follower, pipeline 3) — reference
22.39 / 22.38; candidate **0.78 / 0.76**. Diagnostics publish — reference
**162.29**, candidate **162.75**. The full arrays are in the JSONL.
- **Work counts: reads, parses, analyzed/selected/watched/edited files and
bytes:** the unchanged menu now runs **zero** `lint_with` passes
(`trace_action_lint=0.00ms`, `trace_action_snapshot=hit`) and **zero**
parses. The first request after a `didChange` runs **one** pass, the
diagnostics publish's, inside the flush (`trace_flush_lint=21.87ms`,
`snapshot=miss`) and **none** in the handler (`snapshot=hit`) — down from
two. Config discovery still runs per request; the
indent-width read moved from the dispatcher into the run, so a code-action
request does the same two `Discovery` walks it always did and the
diagnostics publish now does two where it did one — about **+0.11 ms** on
the config stage, publish row **+0.3%**. A handshake request to give
`format::indent_width` a form that takes an already-read `FileConfig` is
recorded in the feature README.
- **Result/status/count/fingerprint comparisons, warnings and refusal
checks:** every row `status=ok`, and every row's `result_count` equal
between the two binaries — the pinmux cursor offers nothing before and
after, the `aes_reg_top` cursor offers the same port actions, the take-3
`codeaction` cells answer the same counts. The correctness argument is the
test matrix rather than a fingerprint: this lane changes no edit, only when
one is computed.
- **Idle RSS / peak RSS / cache size / guard outcomes:** a new `snapshotrss`
phase opens 1 / 10 / 100 RTL buffers, sends one quickfix-only `codeAction`
into each so that every open document holds a snapshot, and reads idle RSS a
second after the session goes quiet: **420.9 → 422.2 MiB (1 buffer)**,
**429.4 → 428.4 (10)**, **574.0 → 574.6 (100, +0.1%)**. **Zero guard
kills.**
- **Target achieved or missed; paired improvement and variability:**
**achieved.** Gate ≤16 ms unchanged menu → **0.98 ms** (quickfix-only
0.11); gate ≤16 ms queued definition → **0.76 ms**; gate "first-after-edit
improved and reported separately with its stage split" → **125.65 → 106.89
ms (−14.9%)**, with the split saying the remaining 106 ms is 84 ms of
`Document::new` plus the 22 ms diagnostics pass and **0.00 ms** of
code-action lint; gate "diagnostics publish must not regress" → **+0.3%**;
gate "no higher retained memory" → **+0.1% at 100 buffers**. Unchanged rows
move −23% to +15% on sub-10 ms cells, in both directions and with no
pattern: `didopen` (median of three fresh processes) 4.53 → 3.49, 5.72 →
5.56, 8.68 → 8.15, and the `tb.sv` menu 0.19 → 0.23 / 1.26 → 1.45. None of
these is read as movement at that scale.
- **Where the reference disagrees with the baseline beyond tolerance (neither
number adjusted):** the review's 0.51.0 cells are 25.0 / 23.1 / 24.2 /
135.9 ms; this session's own reference reads 22.6 / 24.5 / 22.4 / 125.7 —
within about 8% in both directions. The improvement is stated against **this
session's own reference**, so the ratios are unaffected.
- **Correctness tests and logs:** `cargo fmt` clean; guarded `cargo clippy
--all-targets` clean, no new `#[allow]`; guarded `cargo test --workspace`
**4 343 passed, 0 failed** against the reference tree's **4 322 passed, 0
failed** measured the same way — **+21, none removed**, confirmed by
diffing `cargo test -- --list` between the two trees. The 21 are: 11 in
`server/tests/lint_snapshot.rs` (one per invalidation-table row — an edited
buffer, a large buffer, a pushed rule selection, a rewritten `lucisv.toml`,
a rewritten waiver file, a changed indent width, a change in **another**
file that moves the census, close/reopen, a UTF-16 fix range, the shared
pass, and the **stale-fix attack**), 4 in `lint_snapshot.rs` (every field of
the key forces a recompute; a same-length waiver rewrite is a different
key), 4 in `lint_trace.rs`, 2 in `lint.rs` (the indent ladder rung by rung;
a reused snapshot compared violation for violation and fix for fix against a
fresh `lint_with`).
- **Interpretation, remaining bottleneck, tradeoffs, rejected alternatives:**
the code-action path is now transport-bound on the largest file in
opentitan. What is left of the edit-time pause is **not** lint: ~84 ms of
`Document::new` on 1.3 MB, which is a parser/analysis question and belongs
with the review's item 4 as a separate lane. **Rejected alternatives:**
hashing the key (a digest would make "no stale fix" a collision argument
instead of a `PartialEq` fact); keying on the waiver files' mtime or length
(weaker than the contents, and wrong across a same-second rewrite);
memoizing the `FileConfig` read (the trace measures it at 0.04–0.16 ms, and
its failure mode would be a stale *rule selection* on files nothing
watches); an index generation counter (`refresh_overlay` is already called
at every index mutation, so a counter would be a second thing to keep in
step); a bounded map keyed by URI (a field on the `Document` is dropped by
`didClose` for free and cannot outlive its text).
- **Decision: retain / revise / reject / defer; next stage justified by
evidence:** **retain.** The next lever on this path is the 84 ms
`Document::new`, not the linter.
- **QA result and lead review link:** pending —
`docs/features/perf5r-lint-snapshot/README.md`.
## Experiment record — R3a-2026-09-08 (stage R3a)
- **Experiment ID / stage / date / owner:** `R3a-2026-09-08` / R3a (TODO §61.1)
+1 -1
View File
@@ -289,7 +289,7 @@ spans two layers — the include graph *and* the `documentLink` handler;
| loop | `server/` (since 2026-09-02: `mod` = the loop; `dispatch`, `client`, `index`, `notification`, `progress`, `diagnostics`, `batch`, `formatting`, `large_file`, `semantic_tokens`; tests in `server/tests/`) | the message loop + queue/burst (cancel-request), dispatch, `Pending` map for server-initiated requests, stepped startup scans with mid-scan request drains, held-request ordering for rescans, reindex/widen orchestration, progress/log senders, optional `timing:` instrumentation |
| state | `state.rs` | `Workspace` (roots, scope ladder, index, include graph, candidates, index cache, open `Document`s with overlay, bounded closed-file `FileView` cache), `Scan` (whole or additive widen), fan-out source selectors (`module_sources`, `rename_sources`, `include_sources`), and `Document` (text, tokens, tree, semantics, diagnostics, `large` flag) |
| substrate | `convert.rs`, `uri.rs`, `locate.rs`, `pairs.rs`, `includes.rs`, `candidates.rs`, `index_cache.rs`, `watch.rs`, `settings.rs`, `templates.rs`, `sync.rs` | position math, URI↔path, location building, the begin/end scope matcher, the include graph, completion word/module tables and their scan-batch forms, the persistent index store, watcher registration, `lucisv.*` settings parsing, snippet registry, incremental text sync |
| handlers | one file per capability: `format.rs`, `diagnostics.rs`, `lint.rs` (with `fences.rs`: the formatter's text-only fence answer memoized once per `Document` — perf5-p1; the shared-fence-filter contract is unamended), `rename_trace.rs` (perf5-p2: `Rung`/`Wanted`/`SelectionTrace` — the path set the rename fan-out ladder fills, remembering which rung asked for each file; `Workspace::rename_sources_traced` is the ladder with that sink), `hover.rs`, `expand.rs`, `nav.rs`, `type_def.rs`, `type_hierarchy.rs`, `hierarchy.rs`, `design_hierarchy.rs`, `symbols.rs`, `tokens.rs`, `completion/` (`mod`, `member`, `module`, `tiers`, `word`, `site`; test harness in `harness`), `signature.rs`, `inlay.rs`, `inline.rs`, `lens.rs`, `code_action.rs`, `rename.rs`, `ports.rs`, `imports.rs`, `extract.rs`, `inline_module.rs`, `folding.rs`, `selection.rs`, `linked.rs`, `on_type.rs`, `includes.rs` (links), `file_ops.rs`, `instantiate.rs`, `large.rs` | each is a mostly-pure function over `Document`/`Workspace`; protocol only, no language analysis of its own (anything that looks like analysis in here is a bug or a Handshake request — lucisv-server README) |
| handlers | one file per capability: `format.rs`, `diagnostics.rs`, `lint.rs` (with `fences.rs`: the formatter's text-only fence answer memoized once per `Document` — perf5-p1; the shared-fence-filter contract is unamended; and `lint_snapshot.rs` + `lint_trace.rs` — perf5r-lint-snapshot, 2026-09-08: one `lint_with` pass per document revision shared by the diagnostics publish and quick-fix discovery, keyed by value on every input of that call — rule names, merged options, line width, tab width, oracle presence, external waiver *contents* — held in a `Slot` on the `Document` and cleared by `Document::refresh_overlay`, which every index mutation ends in; a `timing: codeaction … key=value` line under `--verbose`, parsed by `tools/perf/phases_r1.py`), `rename_trace.rs` (perf5-p2: `Rung`/`Wanted`/`SelectionTrace` — the path set the rename fan-out ladder fills, remembering which rung asked for each file; `Workspace::rename_sources_traced` is the ladder with that sink), `hover.rs`, `expand.rs`, `nav.rs`, `type_def.rs`, `type_hierarchy.rs`, `hierarchy.rs`, `design_hierarchy.rs`, `symbols.rs`, `tokens.rs`, `completion/` (`mod`, `member`, `module`, `tiers`, `word`, `site`; test harness in `harness`), `signature.rs`, `inlay.rs`, `inline.rs`, `lens.rs`, `code_action.rs`, `rename.rs`, `ports.rs`, `imports.rs`, `extract.rs`, `inline_module.rs`, `folding.rs`, `selection.rs`, `linked.rs`, `on_type.rs`, `includes.rs` (links), `file_ops.rs`, `instantiate.rs`, `large.rs` | each is a mostly-pure function over `Document`/`Workspace`; protocol only, no language analysis of its own (anything that looks like analysis in here is a bug or a Handshake request — lucisv-server README) |
**`editors/vscode`** — `extension.js` (spawn + rainbow decorations + storage
path; ~everything else is `vscode-languageclient` driven off advertised