diff --git a/TODO.md b/TODO.md index 6ab352d..8fd5d54 100644 --- a/TODO.md +++ b/TODO.md @@ -5665,3 +5665,168 @@ amended: the key now names the option). - [x] QA: attack the key (another option, another version, a store line with four fields); confirm the audit's probe passes on the fix and fails on 0.49.0 + +## 60. Performance take 5 — the implementation plan (owner request 2026-09-07) + +`docs/performance_take5.md` is the spec; `docs/perf/take5-tracking.md` +is the ledger every stage fills (baseline columns are the owner's, at +0.50.0 / bbdbfe9 — never overwritten); `docs/perf/take5-baseline/` is +the evidence. This section only sequences the plan into lanes and names +the gates. **Serial, one lane at a time in the main tree** (the plan +forbids parallel lanes: P1–P4 share `state.rs`, the selectors and open +handshake 33), dev (Opus) → QA (Sonnet) → lead review → commit, the +§36 protocol. Every stage: its own feature README +(`docs/features/perf5-/README.md`), the tracker's candidate +columns and an experiment entry filled at the exact candidate commit, +measured with `tools/perf/` under `tools/guard.sh -m 8 -t 1800`, no +build during a timed session, opentitan read-only. A stage's numbers +are taken by its dev and re-taken by its QA on the same binary; the +lead accepts a number only when both agree within the tracker's +tolerance. Targets are the plan's provisional goals: missing one is +reported with the measured remaining stage, never hidden. + +### 60.0 P0 — the harness tells the truth (tools/perf only) + +Plan §P0. Files: `tools/perf/*` and its README; no production change. +- [ ] units and status on every new record (`ms` is latency only; RSS + and store size in their own fields with units; `status` + ok/error/refused; result counts; a normalized fingerprint of + edits/warnings); the schema versioned, the take-4 rows still + readable +- [ ] edit-bearing offers → `codeAction/resolve`; command-bearing + offers (extract, inline) → a separate execute-command scenario + that captures the server's `workspace/applyEdit` payload and + replies `applied: false` (reason recorded as a client capture, + distinct from an engine refusal or an error); created files, + edits, refusals, warnings counted +- [ ] the owner's two supplemental probes become phases + (`offerkinds`: the `context.only` families at the five cursors; + `offerqueue`: leader/follower); scan completion vs first useful + answer separated; fresh-process rows distinguished from repeats +- [ ] `sweep.sh`: the scratch format cache reset before *each* cold + try, warm rows explicitly primed; cold rows show zero hits +- [ ] the baseline reproduced on the unchanged binary with the + corrected harness — the tracker's "Reference" cells for every + row P1/P2 will touch (pinmux comment all-family and `only: []`, + `aes`/`aes_reg_top`/`tb.sv` offers, tail rename, `aes` rename, + blockers, refactor resolves, the CLI cells) — and a + `docs/perf/README.md` note if any baseline row changes meaning +- [ ] QA: a deliberately rejected request lands as an error; the + inline/extract rows show a command and an applyEdit payload or a + refusal; cold sweep rows have zero hits; a sample of reference + cells re-taken + +### 60.1 P1 — code-action discovery stops repeating work + +Plan §P1a then §P1b, one lane, then measured; §P1c only if the ports / +import offers still dominate after that measurement (a lead ruling). +Files: `lucisv_server/src/{server/dispatch.rs,code_action.rs,lint.rs, +ports.rs,imports.rs,extract.rs,inline_module.rs}` plus a *new small +module* for any per-revision memo (`state.rs` is over size — §55); +`vlog_refactor/src/{ports/,imports.rs,extract/,inline/,lib.rs}` for +additive parsed-input selectors beside the text ones. `fence.rs` is +NOT touched: the text-only fence authority stays and is memoized per +document revision, computed only when a fix needs it +(shared-fence-filter's contract). +- [ ] P1a: the `only` filter checked before config discovery, lint and + fence work; `only: []` returns at once; fence regions computed + only when a candidate fix exists; kind-prefix semantics, + fixes spanning the cursor, fix-all, action order, and a cursor + (empty range) still offering extract — all pinned +- [ ] P1b: selectors over the document's existing parse + diagnostics + (large-file mode and parse-diagnostic checks exactly as before); + text wrappers retained for standalone consumers and parity + tests; fence memo keyed by exact source revision; any lint-result + reuse keyed by revision + effective lint/format settings + + waivers + workspace generation, or not done +- [ ] work counters (parses per request) prove "no additional parse on + a repeated offer" — asserted in tests by count, not by stopwatch +- [ ] parity pinned at every sampled cursor/range: no-offer comments, + parse errors, CRLF, UTF-16 positions, unsaved edits, untitled and + large buffers, action filters, fence insertions, waivers, config + change, index refresh +- [ ] measured: repeated lazy offers < 5 ms; `aes_reg_top` < 10 ms; + the pinmux no-offer comment < 16 ms on an unchanged buffer; + first-after-edit tracked separately; the pipelined definition + re-measured; tracker + experiment entry filled +- [ ] lead ruling on P1c from the measurement +- [ ] QA: parity attacks as above, the counters, the numbers re-taken + +### 60.2 P2 — rename reuses its analysis, verification untouched + +Plan §P2a → §P2b/§P2c → §P2d only with proof. Handshake 33 (transitive +`wrap.u_S.x` users missed by `module_sources`) is resolved and tested +*before* any narrower selector is shared with inline/ports. Files: +`lucisv_server/src/{rename.rs,state.rs}`, `vlog_refactor/src/{scope.rs, +rename/,check/,lib.rs}`, `vlog_semantic/src/workspace/{record.rs, +index.rs,update.rs,mod.rs}` as the plan lists — the dev inspects the +real paths first and names them in the README. +- [ ] P2a: stage timings and work counts for the tail rename, `aes`, + a unique internal name, `clk`/`rst_n`, an existing/conflicting + new name, an unresolved new-name use, the all-sources fallback: + selector time, selected paths + bytes with the reason each was + included, parses/analyses, occurrence collection, before/after + verification, serialization, peak RSS — behind a flag or the + `--verbose` channel, never in the default output +- [ ] P2b: one parse/analysis per file inside the request-local scope + (`FileFacts::from_analysis` the starting point); additive + prepared-input API, the text API and its answers/refusals + unchanged; no workspace-wide AST cache +- [ ] P2c: the after-index from unchanged facts plus the edited files' + one new analysis; untouched watched files keep local semantics + and re-resolve externally; token identity, parse-diagnostic + preservation, comments/attributes, before/after resolution all + still checked; clone/merge/remap cost measured +- [ ] handshake 33 closed with tests (multi-level hierarchy, generated + scopes, interface/package/class names, macros, duplicate modules, + unsaved references) before P2d +- [ ] P2d (only with proof): exact-name postings; the selected set + unchanged; every edit, warning, ambiguous-use refusal, + unresolved new-name capture and unsaved-buffer contribution + compared against the whole-scope engine on adversarial cases +- [ ] measured: tail rename ≥ 2× faster (stretch < 200 ms), `aes` + rename not slower, edit/warning parity exact; queued definition + follows; tracker + experiment entries +- [ ] QA: whole-scope parity suite, the verifier invariant (a faster + partial edit is a failure), handshake-33 attacks, numbers re-taken + +### 60.3 P3 — one parse for the CLI package census + +Plan §P3. Files: `lucisv/src/lint.rs`, `vlog_linter/src/{interfaces.rs, +lib.rs}`; a semantic fact-extraction API only if needed, additive; the +CLI keeps no direct semantic dependency. +- [ ] package exports from the census's existing parse; files without a + package declaration skip the index work by AST, never by text + search; duplicate/unknown packages, nested declarations, malformed + source, re-export chains handled exactly as before +- [ ] default `check` output byte-identical; all-style retains every + `unused-import` finding; fixes, waivers, exit codes stable +- [ ] measured: ≥ half of the 123 ms all-style increment removed on + `hw/ip`, default time and peak RSS not materially worse; the + paired three-configuration experiment; tracker filled +- [ ] QA: full findings/fixes/waivers diffed, not counts; RSS re-taken + +### 60.4 P4 — startup and memory, only after P1–P3 + +Plan §P4a (instrument: discovery/config wait, read/hash, decode, merge, +completion/include tables, overlay refresh, cache write/compaction, +first useful answer; 1/10/100 open buffers; requests during a scan) +then §P4b (the dominant measured stage only). Files: `server/index.rs`, +`state.rs`, `index_cache.rs`, `candidates.rs`, `includes.rs` and the +semantic build/facts owners. Serialized after 60.1–60.3. +- [ ] P4a instrumentation and the measured breakdown in the tracker +- [ ] lead ruling: which stage, or none +- [ ] P4b if ruled: warm < 1 s / cold < 2.3 s / idle RSS −15% as + investigation goals; interrupted-store recovery, coherent + index/candidate/include prefix, content-based freshness, the + 16 MiB parser stack on any new thread, §46's open path — all + preserved and pinned +- [ ] QA + +### 60.5 Closing + +- [ ] P5 stays deferred unless a stage's measurement reopens it (lead) +- [ ] `docs/perf/README.md` entry with the accepted numbers; topo + edges/handshakes for every contract amended; the plan's status + line updated; a release cut from the clean tree with its assets + verified