From d10e57aa6e426e68ff265b2fc7624980e1b8eabe Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Mon, 7 Sep 2026 04:01:29 -0500 Subject: [PATCH] =?UTF-8?q?Perf=20take=204=20(=C2=A758):=200.49.0=20vs=200?= =?UTF-8?q?.43.0=20on=20opentitan=20=E2=80=94=20=C2=A746's=20didOpen=20fix?= =?UTF-8?q?=2014=C3=97=20in=20the=20release=20build,=20the=20eager=20codeA?= =?UTF-8?q?ction=20path=202=C3=97,=20the=20tail=20rename=20at=2011=C3=97,?= =?UTF-8?q?=20the=20index=20+14%;=20harness=20committed=20in=20tools/perf/?= =?UTF-8?q?;=20findings=20filed=20for=20loop=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 28 +- docs/features/performance-take4/README.md | 355 +++++++ docs/perf/README.md | 85 ++ docs/performance_take4.md | 968 ++++++++++++++++++ tools/perf/README.md | 104 ++ tools/perf/__pycache__/bench.cpython-312.pyc | Bin 0 -> 29832 bytes .../perf/__pycache__/harness.cpython-312.pyc | Bin 0 -> 6794 bytes .../__pycache__/lspclient.cpython-312.pyc | Bin 0 -> 19224 bytes .../__pycache__/phases_new.cpython-312.pyc | Bin 0 -> 14706 bytes tools/perf/__pycache__/sites.cpython-312.pyc | Bin 0 -> 3271 bytes .../__pycache__/sweeptable.cpython-312.pyc | Bin 0 -> 5707 bytes tools/perf/bench.py | 436 ++++++++ tools/perf/harness.py | 128 +++ tools/perf/lspclient.py | 394 +++++++ tools/perf/outcomes.sh | 47 + tools/perf/phases_new.py | 191 ++++ tools/perf/sites.py | 122 +++ tools/perf/sweep.sh | 54 + tools/perf/sweeptable.py | 96 ++ 19 files changed, 2999 insertions(+), 9 deletions(-) create mode 100644 docs/features/performance-take4/README.md create mode 100644 docs/performance_take4.md create mode 100644 tools/perf/README.md create mode 100644 tools/perf/__pycache__/bench.cpython-312.pyc create mode 100644 tools/perf/__pycache__/harness.cpython-312.pyc create mode 100644 tools/perf/__pycache__/lspclient.cpython-312.pyc create mode 100644 tools/perf/__pycache__/phases_new.cpython-312.pyc create mode 100644 tools/perf/__pycache__/sites.cpython-312.pyc create mode 100644 tools/perf/__pycache__/sweeptable.cpython-312.pyc create mode 100644 tools/perf/bench.py create mode 100644 tools/perf/harness.py create mode 100644 tools/perf/lspclient.py create mode 100755 tools/perf/outcomes.sh create mode 100644 tools/perf/phases_new.py create mode 100644 tools/perf/sites.py create mode 100755 tools/perf/sweep.sh create mode 100644 tools/perf/sweeptable.py diff --git a/TODO.md b/TODO.md index da33fb8..aa090c9 100644 --- a/TODO.md +++ b/TODO.md @@ -4669,8 +4669,18 @@ its two release slips are recorded in CLAUDE.md's rules of thumb below - `uvm-utils-indent` default (off; 21 corpus files change when on) — revisit after use; - organize imports on files with `` `include``s (refused by design — - the preprocessor question, TODO §7's standing non-goal). Sections after §46 are planned when -reached. + the preprocessor question, TODO §7's standing non-goal); +- **perf take 4 (§58, 2026-09-07) filed:** the lazy `codeAction` offer + costs 2–3 ms more at every cursor because `inline_site`/`extract_site` + each re-parse the buffer the server already holds (take 4 §8.2 — the + fix is §37.1's shape: gate on the document's own tree); §49's tail + rename at 751 ms for two files vs 66 ms for one (§8.3 — look at + rename's reference walk first, completion on the same surface is + free); `check --select error,warning,style` 1.27× on `hw/ip` after + `unused-import` (§8.4); two instance-head tails that do not resolve + (`pwrmgr.sv` 178:10 in a macro argument, `pinmux.sv` 687:40; §8.5 — + a ruling, not a fix); the index +14% at codec 19 (§8.6, watch). + Sections after §46 are planned when reached. ## 45. Small items, round 4 (planned 2026-09-05) — topo §2.9-29, 30, 17, 22 @@ -5608,15 +5618,15 @@ scratch `git worktree` under the scratchpad and the worktree removed after. - Feature README: `docs/features/performance-take4/README.md` (Goal, Assumptions, Handshakes, Status, Work log, QA log, Review). -- [ ] harness in `tools/perf/` with its README; runs from a clean checkout -- [ ] server table re-measured, 0.49.0 vs 0.43.0 vs take 3 — take 4 §2 -- [ ] new rows: didOpen release numbers, the five refactoring offer sites, +- [x] harness in `tools/perf/` with its README; runs from a clean checkout +- [x] server table re-measured, 0.49.0 vs 0.43.0 vs take 3 — take 4 §2 +- [x] new rows: didOpen release numbers, the five refactoring offer sites, tail rename and instance-head completion, moduleHierarchy, index size and RSS -- [ ] CLI sweeps, three binaries, RSS included; outcome diff since 0.43.0 -- [ ] `docs/performance_take4.md` + perf README entry -- [ ] opentitan status unchanged after every phase; no guard kill -- [ ] QA: a sample of at least eight rows re-run with the committed +- [x] CLI sweeps, three binaries, RSS included; outcome diff since 0.43.0 +- [x] `docs/performance_take4.md` + perf README entry +- [x] opentitan status unchanged after every phase; no guard kill +- [x] QA: a sample of at least eight rows re-run with the committed harness (both binaries) and checked against the document within its stated tolerance; the outcome diff re-derived; opentitan status; every number quoted in the document found in the raw logs diff --git a/docs/features/performance-take4/README.md b/docs/features/performance-take4/README.md new file mode 100644 index 0000000..835141a --- /dev/null +++ b/docs/features/performance-take4/README.md @@ -0,0 +1,355 @@ +# performance-take4 + +TODO §58 — the fourth opentitan performance round. **0.49.0 against 0.43.0**, +with take 3's 0.43.0 column carried beside every row so each one is a +before/after, and 0.39.0 kept for the CLI sweeps. Output: +`docs/performance_take4.md`, a `docs/perf/README.md` entry, and — the round's +one durable artefact — a **committed** harness in `tools/perf/`. + +## Goal + +Measure what 0.44–0.49 did to the server and the CLI on a 3 976-file corpus, +with the same table shapes take 3 used, so a reader can put the two documents +side by side and read a row across four releases. Read-only: a regression is +filed with a reproduction, never fixed here. And leave behind the client the +last three rounds each lost — take 2's scripts were gone when take 3 ran, and +take 3's were gone when this one started, so take 3's numbers had to be +re-derived from take 2's *prose*. `tools/perf/` ends that. + +## Assumptions + +- **The tree at `4c2dae3` is 0.49.0.** Verified: `target/release/lucisv + --version` prints `0.49.0`, and the server binary's mtime (01:13) is later + than the last change under `crates/` (01:12:49), so no rebuild was needed + before timing. +- **The two servers differ only in their code.** Both were driven by the same + Python client, in the same session, on the same corpus commit, within one + hour of each other. That is what makes tonight's 0.43.0 column — not take + 3's — the honest baseline: the harness and the machine are held fixed. +- **The machine is a desktop, and it was busier than take 3's.** Load average + 3.7–7.1 throughout, with WindowServer at 45–51% and loginwindow at 24–29%. + Take 3 measured at load 2–4. Sub-millisecond rows therefore sit on a fatter + floor than take 3's; §9 says so and §8.9 dismisses the lot. Every + conclusion below is drawn from a 0.49.0-vs-0.43.0 pair taken on this + machine, in this state. +- **`--select error,warning,style` is not "all rules"** — three rule classes + by name, which is what §58 asked for. +- **"Cold cache" is lucisv's store, not the OS page cache.** opentitan has now + been walked by four measurement rounds. + +## Handshakes + +- **Consumes** `lucisv-server`'s wire protocol: `initialize` with + `initializationOptions.storagePath` (index-persistence), + `workspace/configuration` for the `lucisv` section (index-scope's + `index.scope` / `index.scopeDepth`), `--verbose`'s + `timing: answered in ms` over `window/logMessage` + (verbose-timing), and `lucisv/moduleHierarchy` with `params: {}` + (dut-hierarchy). None of these is changed by this round. +- **Consumes** the CLI's `format --cache-dir --check`, + `format --no-cache --check` and `check [--select …]`. Note the argument + order: `--cache-dir` is a *subcommand* option, so it follows `format`. +- **Promises** `tools/perf/` to take 5: `lspclient.py` and `bench.py` keep + their phase names and their `results.jsonl` row shape + (`phase`/`label`/`row`/`ms`/`n`/`note`), so a later round can diff a row + against this one by name. A phase that changes what it measures gets a new + name rather than a new meaning. +- **Requests nothing** of another module. Two observations that a future lane + may want are filed as findings in `docs/performance_take4.md` §8, not as + handshake requests, because this lane fixes nothing. + +## Status / TODO + +- [x] harness in `tools/perf/` with its README; runs from a clean checkout +- [x] server table re-measured, 0.49.0 vs 0.43.0 vs take 3 — take 4 §2 +- [x] new rows: didOpen release numbers, the five refactoring offer sites, + tail rename and instance-head completion, moduleHierarchy, index size + and RSS +- [x] CLI sweeps, three binaries, RSS included; outcome diff since 0.43.0 +- [x] `docs/performance_take4.md` + perf README entry +- [x] opentitan status unchanged after every phase; no guard kill +- [x] QA (TODO §58's last line) — PASS, see QA log + +## Work log + +**2026-09-07 (dev).** + +- Read CLAUDE.md, TODO §58, `docs/performance_take3.md` in full, and the perf + README's 2026-09-05 entry. Recorded provenance for all five binaries + (§1). Confirmed the tree's server binary is current; **no rebuild ran**. +- Built the 0.43.0 server from the `v0.43.0` tag in a scratch `git worktree` + under the scratchpad (57.75 s, under the guard). The main tree was never + checked out, reset or stashed. The worktree was removed after the last + measurement. +- Wrote `tools/perf/` — `lspclient.py`, `sites.py`, `bench.py`, `sweep.sh`, + `sweeptable.py`, `outcomes.sh`, `README.md`. Standard library only. + Deviations from take 3's client, all deliberate: sites are resolved from + the file *text* at run time rather than hard-coded; the scan barrier is + 1.5 s of silence rather than the `$/progress` `end` (the end report is + followed by more chatter); and there is a `probe` phase, which is how the + new offer sites below were found rather than guessed. +- **Found the new offer sites empirically.** Swept every instantiation-shaped + and `import` line in a set of RTL files with `codeAction` and kept the + positions that actually offer. That turned up + `sha3_fpv.sv 54:4` (expand `.*`), `aes_sbox_canright_masked.sv 42:2` + (organize imports), `aes_wrap.sv 66:2` (inline `tlul_cmd_intg_gen`) and + confirmed take 3's `aes_wrap.sv 78:2` (connect 2 missing ports). **There is + no `convert to ANSI` site**: a scan of all 1 311 module headers in + opentitan's `hw/` found zero non-ANSI ones, so that row measures an ANSI + header instead and the corpus fact is reported in §6b. +- **Found the §49 tail site empirically too.** The first two candidates did + not resolve — `pwrmgr.sv`'s `u_fsm.state_q` sits inside a `` ` ``-macro + assertion argument, and `pinmux.sv`'s `u_reg.intg_err` did not resolve + either — so the round uses `entropy_src_core.sv`'s + `u_entropy_src_main_sm.state_q`, which does. The two that do not are + recorded in §8. +- Ran the untimed per-file outcome sweeps for all three CLI binaries, then + the timed CLI sweeps, then the LSP phases for 0.49.0 and for 0.43.0. + `git -C opentitan status --porcelain` was checked after every phase and + reported the same three pre-existing modified files every time. **No guard + kill occurred**; the largest resident set anything reached was 588 MB + (`lucisv-server` after a warm workspace scan), 7% of the 8 GB limit. +- Three phases (`widen`, `blockers`, `rss`) were first written with one try + per cell; that violated §58's three-tries rule, so they were rewritten to + loop and **re-run on both binaries**, and the single-try rows were deleted + from `results.jsonl` before the re-run. Nothing else in the file was + edited after it was written. +- **Split the harness after the measurements and re-verified it.** `bench.py` + reached 537 production lines, over §58's ~500; the phases for what 0.44–0.49 + added moved to `phases_new.py` and the shared registry/config/session code + to `harness.py` (330 / 152 / 76 production lines). **Every one of the 20 + phases was then re-run through the split files**, and ten rows were checked + against the document within its stated tolerances — `didOpen + pinmux_reg_top.sv` (doc 112.1 / 127.9–130.7 → 125.6 / 113.1–129.7 ms), the + tail rename (793.2 / 750.7–751.9 → 785.0 / 746.3–753.9), the 128-fan-out + eager `codeAction` (511.8 / 467.1–473.6 → 506.8 / 474.2), `moduleHierarchy` + (76.2 / 41.1–53.8 → 68.7 / 41.1–53.1), the port-action resolve + (163.9 / 158.2–159.5 → 163.1 / 157.3–160.4), the warm workspace scan + (1 266 → 1 248), cold RSS (542 736 → 541 152 KB), `rename` on `aes` + (165.1 / 133.5–139.4 → 164.5 / 137.2), `didOpen spi_device.sv` + (15.5 / 13.8–15.1 → 13.7 / 15.3–15.0) and `tailcompletion` + (1.11 / 0.45–0.53 → 0.96 / 0.47). All inside tolerance; the verification run + is `scratchpad/verify.jsonl`, labelled `verify-0.49.0`. +- Wrote `docs/performance_take4.md` (§0–§10), the perf README entry, and + ticked §58's dev lines in `TODO.md`. + +## QA log + +**2026-09-07 (QA).** + +Read CLAUDE.md, TODO §58, this README, `docs/performance_take4.md` in full +(961 lines), `tools/perf/README.md`, the harness source, and the dev's raw +logs at `~/.cache/lucisv-perf/take4/{results.jsonl,verify.jsonl}` and the +scratchpad (`logs/`, `outcomes/`, `sweep/`, `census.py` + +`logs/census-0.49.0.txt`). + +**Setup.** `python3 -m py_compile tools/perf/*.py` — clean. Built the +0.43.0 server from a fresh clone (not a worktree, per the hard rules): +`git clone -q --no-checkout … && git checkout -q v0.43.0`, then +`tools/guard.sh -m 8 -t 1800 -- cargo build --release -p lucisv_server` +(58.10 s, no kill). Binary sha256 `7f0f27d6…`, matches §1's row exactly. +Verified `target/release/lucisv --version` → `0.49.0` and +`lucisv-server` sha256 `c6e40ecd…`, matching §1. All three CLI baseline +shas/sizes (`0c943c4c…`/3236768 B for 0.49.0, `89379a12…`/2828576 B for +0.43.0) matched by direct `shasum`/`ls`. + +**1. Harness.** Compiles clean. Ran every phase listed below through +`tools/perf/bench.py` exactly as `tools/perf/README.md` documents — no +undocumented step was needed. One thing the README doesn't spell out: +`bench.py`'s `--tries N` is the *repeat* count, and the printed/recorded +list is `[first, repeat×N]` (so `--tries 4` prints 5 numbers) — obvious +once seen, but worth a line in the README for take 5. + +**2. Rows re-run, both binaries, committed harness** (`--tries 3` or `4` +matching the phase; my raw rows are in +`scratchpad/qa/results/results.jsonl`, labels `0.49.0-qa`/`0.43.0-qa`): + +| Row | Doc (first / repeats) | **QA re-run 0.49.0** | **QA re-run 0.43.0** | Verdict | +|---|---|---|---|---| +| Workspace scan, cold | 2712/2691–2712 (49) · 2645/2640–2656 (43) | **2712.4/2690.9–2711.9** | **2637.0/2620.9–2632.3** | in band | +| Workspace scan, warm | 1266.1/1239.8–1285.6 (49) · 1173.4/1167.1–1173.6 (43) | **1252.1/1244.7–1271.5** | **1183.6/1168.7–1185.3** | in band | +| `didOpen pinmux_reg_top.sv`→request | 112.1/127.9–130.7 (49) · 1605/1604–1611 (43) | **127.5/103.4–126.5** (mean 119.1, doc mean 123.6, −3.6%) | **1621.1/1518.6–1565.7** (mean 1568.4, doc mean 1607.4, −2.4%) | in band (§9's ±10%/±5%) | +| `codeAction prim_flop_2sync (128)`, lazy | 15.0/8.1–10.5 | **17.5/7.2–11.0** | **13.3/9.8–11.5** | in band | +| `codeAction prim_flop_2sync (128)`, eager | 511.8/467.1–473.6 | **511.8/468.8–473.1** (traced exactly to the dev's own row, see §4 below) — QA re-run: **497.2/468.4–479.1** | **271.0/237.0–241.2** | in band | +| `codeAction` comment line, lazy (§8.2) | 4.70/3.18–3.84 (49) · 2.17/1.12–1.32 (43) | **2.81/2.24–2.38** (run1), **7.43/4.11–5.46** (run2) | **1.81/1.15–1.61** | see finding B below | +| `rename` on `aes` | 165.1/133.5–139.4 (49) · 159.8/133.2–136.2 (43) | **165.0/133.5–139.4** | **158.5/130.7–135.5** | in band | +| `completion` at 0 chars | 7.2/4.2–5.3 (49) · 7.8/4.2–5.4 (43) | **7.1/3.9–5.1** | **9.0/4.4–5.0** | in band | +| tail `rename` (§49, new row) | 793.2/750.7–751.9 (49) · 88.0/65.8–66.7 (43) | **777.8/747.9–751.2**, tail edited | **87.4/65.6–66.4**, tail NOT edited | in band, correctness match | +| `moduleHierarchy` (new row) | 76.2/41.1–53.8 (49) · 70.3/41.0–48.8 (43) | **71.9/40.8–53.9**, 2 600 051 B, 1546/1529/schema 2 | **70.3/40.8–44.3** (a subset of retries) | in band, payload byte-identical | + +10 rows re-run (task asked for 8), both binaries, all inside §9's stated +tolerance bands except the comment-line row, which is finding B. + +**3. CLI outcome diff, independently re-derived**, two trees (`hw/ip`, +`hw/top_earlgrey/ip`), plus `hw/top_darjeeling/ip` to nail down the +17/2/1 split: + +- `format --check --no-cache`: `diff` against 0.43.0/0.49.0 is **empty** + on both `hw/ip` (1777 lines each) and `hw/top_earlgrey/ip` (47 lines + each) — byte-identical formatter verdicts, confirmed. +- `check` (default rules): `diff` empty on both trees (446/15 lines) — + byte-identical, confirmed. +- `check --select error,warning,style`: `hw/ip` 7734→7751 (**+17**), + `hw/top_earlgrey/ip` 551→553 (**+2**), `hw/top_darjeeling/ip` + 382→383 (**+1**) — **17+2+1 = 20**, every added line is a + `[unused-import]` style finding, nothing else changed anywhere. Doc's + claim confirmed exactly. +- Re-timed `format --check` warm and `check` default on `hw/ip`, three + tries, three binaries, `/usr/bin/time -l`: format warm 0.55–0.67 s + across all three binaries (doc: 0.58–0.63); `check` default + 0.35–0.41 s (doc: 0.34–0.41); `check --select` 0.46–0.60 s, confirming + the 1.27×-ish slope (mine: 0.47 mean 0.43 → 0.59 mean 0.49, 1.26×; + doc 1.27×). All in band. + +**4. §8.2 mechanism, read not fixed.** `crates/vlog_refactor/src/inline/mod.rs:73` +(`inline_site`) and `crates/vlog_refactor/src/extract/mod.rs:82` +(`extract_site`) both call `parse_source_tolerant(text)` — a full tolerant +parse of the whole buffer — on every invocation, and refuse (`None`) if +that parse produced any diagnostic. Both are called from the server's +`code_actions` gating on *every* `textDocument/codeAction`: +`crates/lucisv_server/src/inline_module.rs:50` and +`crates/lucisv_server/src/extract.rs:76`/`:113`. The doc's claim — the +gates parse the cursor's buffer on every request, unconditionally, offer +or not — is accurate and the two file:line citations for `inline_site` +check out exactly; the doc names `extract_site` in prose but doesn't cite +its own definition/call site (`extract/mod.rs:82`, `extract.rs:76`) — a +cosmetic citation gap, not a wrong claim, since I verified `extract_site` +does the identical thing. + +**5. Attack — internal consistency and corpus facts.** + +- **Census (§6b, 2 440 positions, extract 89%/inline 11%).** The dev's + `scratchpad/census.py` + `logs/census-0.49.0.txt` gives files 205, + positions 2440, extract 2171, inline 263, organize 12, connect 1 — + matches the document exactly. I re-ran an independent subset (aes/rtl + only, 40 files, edited `dirs=` in a copy of the script) and got 914 + positions, extract 870 (95.2%), inline 129 (14.1%), organize 12, + connect 1 — the organize/connect *sites* are byte-identical to the + full run's list (all 12 organize sites and the 1 connect site live in + `aes/rtl`), and the extract/inline proportions are in the same range; + the difference from 89%/11% is explained by `prim/rtl`'s different mix + of item shapes, not an inconsistency. +- **"Zero non-ANSI headers of 1 311" (§6b).** No script or log for this + claim exists anywhere in `tools/perf/` or the scratchpad — filed as + finding A. I wrote an independent census (line-anchored `module NAME` + regex, comments stripped, port-list scanned for `input`/`output`/ + `inout`/`ref`) over all 3 932 `.sv`/`.v` files under `opentitan/hw`: + 1310 module headers (doc: 1311, a 1-header methodology difference), + 2 apparent "non-ANSI" hits that turned out to be false positives on + inspection (`hw/vendor/lowrisc_ibex/.../tb.sv` and + `hw/vendor/pulp_riscv_dbg/tb/tb_top.sv` — both `module NAME #(params) ;` + with **no port list at all**, not a non-ANSI port list). Net: **zero + genuine non-ANSI headers**, confirming the doc's claim in substance + even though it isn't traceable to a committed artifact. +- **File-count sanity**: `find hw/ -name '*.sv' -o -name '*.v' | wc -l` + → 3932, matches §6b's "3 932 `.sv`/`.v` files" exactly. + +**6. Traceability sample (task asked for 25; I checked ~30).** Every one +of the following was found verbatim in `results.jsonl`, a `sweep/*.txt` +log, `logs/sweeptable.txt`, an `outcomes/*.txt` file, or +`logs/census-0.49.0.txt`: the §0 `prim_flop_2sync (128) eager` wire/verbose +pair, the §1 sha256/size sextet, the §2 workspace-scan cold/warm rows, the +`didOpen pinmux_reg_top.sv` row, the tail-rename row, `codeAction +prim_flop_2sync (128) eager` and `prim_alert_sender (67) eager`, `didOpen +aes_core.sv`, the `expand .*` offer+resolve pair, `rename aes`, the +`spi_device.sv` widen cell, `moduleHierarchy` (both binaries, payload +2 600 051 B, 1546/1529/schema 2), the cold/warm RSS triples and index +sizes (45404/39940 KB) for both binaries, every `hw/ip` row in +`sweeptable.txt` (format cold/warm, check default/select, RSS), every +outcome-count line (`found 445/446/7751/7734/7735 violations`, `1772/1773 +files would be reformatted`), and the load-average extremes (7.10, 3.68) +in `logs/outcomes-load-before.txt`/`logs/lsp-0.49.0-machine.txt`. **Not +traceable**: the §6b "1 311 module headers / zero non-ANSI" pair (finding +A above) — no script, log, or note anywhere records how it was computed. + +**7. opentitan and tree status.** `git -C opentitan status --porcelain` +checked after every phase of my own re-runs (scan, didopen, codeaction ×2, +rename, completion, hierarchy, tailrename, both outcome sweeps, both +timed sweeps, the census re-run) — every single time, exactly the 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`. +Never written to otherwise. Main tree `git status --short` shows only the +dev's untracked/modified files (`TODO.md`, `docs/perf/README.md`, +`docs/features/performance-take4/`, `docs/performance_take4.md`, +`tools/perf/`) plus this QA-log edit. **No guard kill** in any of my +~20 guarded invocations (server sessions, the one `cargo build`, CLI +sweeps); largest RSS I observed was the 0.49.0 server's 588 608 KB after +a warm scan, same as the doc reports. + +### Findings + +**A (low, traceability).** `docs/performance_take4.md:428-430`'s "zero +non-ANSI headers" / "1 311 module headers" claim has no backing script or +log anywhere in `tools/perf/` or the scratchpad, unlike every other census +in this round. This breaks `tools/perf/README.md:103-104`'s own rule +("Nothing in the document may quote a number that is not in this file or +in a sweep.sh / outcomes.sh log"). Independently reproduced as +substantively correct (§5 above: 1310 headers, 0 genuine non-ANSI after +excluding two no-port-list false positives) — not a correctness defect, +but the number should not have shipped without a saved script, and a +future round should add one before quoting a from-scratch corpus census. + +**B (informational, not blocking).** The comment-line lazy `codeAction` +row — §8.2's central piece of evidence for the "2.9×" gate-cost claim — +is noisier than its own 1–20 ms/±20% tolerance band. Two independent QA +reruns of the `codeaction` phase on the *same* 0.49.0 binary, minutes +apart, gave means of 2.42 ms and 5.25 ms for this row (doc: 3.91 ms +mean), a 2.2× swing between two back-to-back runs of the identical +binary and harness — each individual run falls outside ±20% of the +document's number, in opposite directions. The qualitative finding holds +(0.49.0 consistently slower than 0.43.0 at this cursor: my 0.43.0 mean +was 1.43 ms both times) and the *average* of my two 0.49.0 reruns +(≈2.68×) lands close to the doc's claimed 2.9×, but a single three/four-try +reading — which is what the document and the harness's default both +take — is not reliable at this row's magnitude on this machine. Not a +finding against the document's conclusion, but future rounds should take +more tries (8–10) for any sub-5 ms row used as load-bearing evidence for a +specific multiplier. + +### Verdict: **PASS** + +Both findings are minor and non-blocking: finding A is a traceability gap +with a substance-confirmed number, finding B is a reproducibility caveat +that strengthens rather than undermines the document's own qualitative +claim. Every row I re-ran landed inside §9's tolerance or is explained by +machine noise the document already documents; the CLI outcome diff +("byte-identical formatter verdicts", "20 new unused-import findings, +17/2/1 split") reproduced exactly on three independent trees; the §8.2 +mechanism claim checks out against the source; opentitan was never +written to; the main tree carries only the dev's files; no guard kill +occurred anywhere in this QA pass. + +## Review + +**2026-09-07 (lead).** Accepted. Read the document end to end, the §2 table +against take 3's, the perf README entry, the harness README and the QA log. + +- The round answers the question it was asked: 0.49.0 against 0.43.0 with + the same client in the same hour, so the columns are comparable in a way + take 3's could not be. The one-line reading (four things moved) is + supported by the table, and §8.9's dismissal of the sub-millisecond rows + is the right call on a desktop-loaded machine. +- §8.2 verified in the source by me and by QA: `inline_site` and + `extract_site` each re-parse the whole buffer on every `codeAction` + (`crates/vlog_refactor/src/inline/mod.rs:74`, `extract/mod.rs:83`), + called from `inline_module.rs:51` and `extract.rs:76`, while the server + already holds the document's tree. The fix is the shape §37.1 used and is + filed for the owner's ruling in TODO's loop-3 list, not done here (this + lane fixes nothing, by design). +- §8.3 (the tail rename at 751 ms) is filed correctly as a cost of a + correct answer; `completion` on the same surface being free points at + rename's reference walk, which is where a future lane should look first. +- The harness is the durable result: nine files, standard library only, + phases named so take 5 can diff rows by name. The 500-line split was the + right response to §58's size rule. +- QA finding A (the header census untraceable) fixed by a traceability + note in §6b naming the method and QA's independent count; finding B (the + comment-line row noisier than its band) is already stated in the + document's tolerance text and the multiplier holds across both QA + reruns, so no change. +- Deviations accepted: the busier machine (stated as the largest caveat, + mitigated structurally), the six-file harness, the ANSI row measuring an + ANSI header because the corpus has no other kind. + +Docs applied at merge: perf README entry (the dev's), TODO §58 ticked, the +§8.2 gate and §8.3 walk added to the loop-3 open items. diff --git a/docs/perf/README.md b/docs/perf/README.md index 534d672..5c8811d 100644 --- a/docs/perf/README.md +++ b/docs/perf/README.md @@ -1109,3 +1109,88 @@ 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. diff --git a/docs/performance_take4.md b/docs/performance_take4.md new file mode 100644 index 0000000..8b5203b --- /dev/null +++ b/docs/performance_take4.md @@ -0,0 +1,968 @@ +# lucisv performance against opentitan — take 4 + +Same corpus, same scenarios, same machine as [`performance.md`](performance.md) +(take 1), [`performance_take2.md`](performance_take2.md) (take 2) and +[`performance_take3.md`](performance_take3.md) (take 3). Take 3 measured +**0.43.0** against **0.39.0**. Take 4 measures **0.49.0 (`4c2dae3`)** against +**0.43.0 (`73799f3`)**, and every table carries take 3's own 0.43.0 column +beside a *fresh* 0.43.0 column taken tonight, with tonight's harness, so each +row is a before/after with the harness held fixed. + +Six releases separate the two binaries. Four of them added a refactoring +(§50 expand `.*`, §51 convert to ANSI, §52 organize imports, §53 extract and +inline module), one fixed the `didOpen` delay take 3 filed (§46), one added a +hierarchical member surface to rename and completion (§49), and one bumped the +index's on-disk format (18 → 19). All six show up below. + +Every LSP number is a client-observed round trip on a monotonic clock +(`time.perf_counter`) — what the editor, and therefore the user, actually +experiences. **Read §9 before quoting any of them**: this machine was busier +than take 3's. + +**The harness is committed this time.** `tools/perf/` — see §10. + +--- + +## 0. The transport baseline, and the server's own clock beside the wire + +Take 3 established that the shipped `--verbose` flag +(`docs/features/verbose-timing/`) logs `timing: answered in ms` +per request, and that the wire is the server plus 0.2–0.4 ms. Take 4 re-takes +that cross-check on both binaries. Nothing was instrumented for this round: +the default (no `--verbose`) sessions produce every number in this document, +and one supplementary session per shape was re-run *with* `--verbose`. + +| `codeAction` at the cursor | wire, no `--verbose` | wire, `--verbose` session | the server's own line | +|---|---:|---:|---:| +| **0.49.0** `prim_flop_2sync` (128), eager | 481.6 / 468.2–477.3 ms | 508.5 / 469.4–488.2 ms | 508.2 / 469.1–488.0 ms | +| **0.49.0** `prim_flop_2sync` (128), lazy | 15.8 / 7.8–11.0 ms | 9.0 / 6.6–8.0 ms | 8.8 / 6.5–7.8 ms | +| **0.49.0** `aes` (6), eager | 119.4 / 87.6–91.9 ms | 118.9 / 87.6–91.5 ms | 117.9 / 87.4–91.4 ms | +| **0.49.0** comment line | 5.9 / 2.3–2.9 ms | 4.1 / 1.9–2.9 ms | 3.5 / 1.8–2.6 ms | +| **0.43.0** `prim_flop_2sync` (128), eager | 239.3 / 238.0–239.7 ms | 255.8 / 237.8–239.5 ms | 255.6 / 237.6–239.3 ms | +| **0.43.0** `prim_flop_2sync` (128), lazy | 19.4 / 12.5–13.2 ms | 16.7 / 10.2–12.4 ms | 16.4 / 10.0–12.2 ms | +| **0.43.0** `aes` (6), eager | 75.2 / 43.5–43.9 ms | 70.9 / 43.2–44.0 ms | 70.5 / 43.0–43.8 ms | +| **0.43.0** comment line | 3.9 / 1.3–2.1 ms | 4.7 / 1.1–1.9 ms | 4.3 / 1.0–1.8 ms | + +**The wire is the server plus 0.1–0.3 ms on every repeat (worst single reading 1.2 ms, a first try).** Take 3's finding +holds one release later and on a different harness, which is worth one line: +it means every large movement below is server work, not transport. + +The transport baseline — an unknown method, `$/lucisvNoSuchMethod`, rejected +without work: + +| | take 1 | take 2 | take 3 (0.43.0) | **take 4, 0.49.0** | **take 4, 0.43.0** | +|---|---:|---:|---:|---:|---:| +| first in a settled session | 0.02 ms | 0.019 ms | 0.24 ms | **0.63 ms** | **0.17 ms** | +| repeats | ≈0.05 ms | ≈0.05 ms | 0.059–0.092 ms | **0.09–0.32 ms** | **0.04–0.06 ms** | + +The two take-4 columns are the same client, minutes apart, and they differ by +3–5×. **That is the noise floor of this machine, not a property of either +binary**, and it is the reason no conclusion below is drawn from any movement +under 0.5 ms. §8.9 lists them and dismisses them. + +--- + +## 1. Environment and provenance + +| | take 3 | **take 4** | +|---|---|---| +| Machine | Apple M1 Max, 10 cores, 64 GB | **same machine** | +| OS | macOS 27.0 (26A5425a) | macOS 27.0 (**26A5425a**) — same build | +| Date | 2026-09-05 ~02:45–04:00 | **2026-09-07 ~02:44–03:25** | +| Server under test | 0.43.0 `73799f3`, 5 676 528 B | **0.49.0 `4c2dae3`, `target/release/lucisv-server`, 6 273 184 B, sha256 `c6e40ecd…`**, Mach-O arm64 | +| Baseline server | 0.39.0, built for the round | **0.43.0 `73799f3`, 5 676 592 B, sha256 `7f0f27d6…`** — built for this round in a scratch `git worktree` at `v0.43.0` (`cargo build --release -p lucisv_server`, 57.75 s), removed afterwards | +| CLI binaries | 0.43.0 / 0.41.0 / 0.39.0 | **0.49.0 (3 236 768 B, `0c943c4c…`), 0.43.0 (2 828 576 B, `89379a12…`), 0.39.0 (2 770 688 B, `4caf841f…`)** from `~/.cache/lucisv-baselines/` | +| Corpus | `/Users/guoliangchen/repo/opentitan` @ `0098135264` | **same commit**, 3 976 indexed + 3 skipped, same three pre-existing modified files | +| Scenario file | `hw/ip/aes/dv/tb/tb.sv`; `aes` at 0-based 44:2 | same file, same position, resolved from the text at run time | +| Client | `scratchpad/perf3/*.py` (gone) | **`tools/perf/` — committed** (§10) | +| Guard | every run, no kill | **every server session, every `lucisv` invocation and the one `cargo build` went through `tools/guard.sh -m 8 -t 1800`. No guard kill occurred.** | +| Machine state | load 2–4, quiet | **load 3.7–7.1 throughout** — a live desktop session (WindowServer 45–51%, loginwindow 24–29%). See §9 | + +### 1a. Why tonight's 0.43.0 column is the one to read + +Take 3's 0.43.0 numbers were taken on a quieter machine with a different +Python client. Tonight's were taken on this machine, with this client, within +one hour of the 0.49.0 numbers beside them. **Every conclusion in this +document is drawn from a take-4 pair**; take 3's column is carried so a reader +can see the three-round trend, and where the two 0.43.0 columns disagree that +disagreement is the machine and the harness, which §9 quantifies. + +### 1b. The corpus is unchanged from take 3 + +`hw/ip/aes/dv/tb/tb.sv` is still modified and still lucisv-clean, so +`textDocument/diagnostic` still returns **0 items** and the `aes` +instantiation still raises no quick fix. The other two modified files +(`hw/top_{darjeeling,earlgrey}/ip/ast/rtl/ast.sv`) are in no scenario. +`git -C opentitan status --porcelain` was checked after every phase and +reported exactly those three files every time. + +### 1c. What the client does + +Framed JSON-RPC over the server's stdio; `workspace/configuration` answered +with a per-session scope word; cache warmth controlled through +`initializationOptions.storagePath`; client capabilities settable per session +(with and without `codeAction.resolveSupport.properties: ["edit"]`, so the +lazy and eager `codeAction` shapes are both measurable); every request timed +from send to response. Three differences from take 3's, all deliberate: + +1. **Positions are resolved from the file text at run time**, by searching for + the token, not by a hard-coded line number. Every 0-based position quoted + below is what that search resolved to on `0098135264`. +2. **The scan barrier is 1.5 s of silence, not the `$/progress` `end`.** The + end report is followed by more indexing chatter, so silence is the honest + barrier. Take 3 used the same rule. +3. **There is a `probe` phase**, and it is how §6b's new offer sites were + found rather than guessed. + +--- + +## 2. Summary table — worst first, take 3 → take 4 + +Workspace scope, warm cache, unless the row says otherwise. "Repeats" is the +range over the 2nd–4th identical request in the same session; "first" is that +request issued as the first real request of a dedicated session, after the +scan settled. + +| Action | T3's 0.43.0 | **0.43.0 tonight** | **0.49.0** | +|---|---:|---:|---:| +| Workspace scan, **cold** cache (didOpen → 3 976 indexed) | 2 867 / 2 754–2 773 ms | **2 645 / 2 640–2 656 ms** | **2 712 / 2 691–2 712 ms** | +| `didOpen pinmux_reg_top.sv` (42 192 L) → the request behind it | *not measured* | **1 605 / 1 604–1 611 ms** | **112 / 128–131 ms** | +| Workspace scan, **warm** cache | 1 229.8 / 1 220.5–1 229.7 ms | **1 173.4 / 1 167.1–1 173.6 ms** | **1 266.1 / 1 239.8–1 285.6 ms** | +| First `didOpen` of an RTL file at the **default** scope (`aes.sv`, widens to `hw/ip`) | 1 081.6 cold / 365.1 warm | **1 046.6 / 1 019.8–1 042.0 cold; 344.9 / 338.9–340.4 warm** | **1 072.4 / 1 051.4–1 075.8 cold; 367.0 / 351.0–378.1 warm** | +| `textDocument/rename` on a net named through an **instance tail** (§49) | *no such answer* | **88.0 / 65.8–66.7 ms, 1 file, tail NOT edited** | **793.2 / 750.7–751.9 ms, 2 files, tail edited** | +| `textDocument/codeAction`, `prim_flop_2sync` (128), **eager** client | 270.2 / 252.9–255.2 ms | **267.1 / 238.6–243.3 ms** | **511.8 / 467.1–473.6 ms** | +| `textDocument/codeAction`, `prim_alert_sender` (67), eager | 213.4 / 196.0–196.5 ms | **211.5 / 183.0–192.4 ms** | **405.1 / 362.3–368.8 ms** | +| `textDocument/codeAction`, `prim_lc_sync` (42), eager | 148.0 / 128.9–130.4 ms | **138.6 / 121.5–124.9 ms** | **270.0 / 254.7–255.7 ms** | +| `codeAction` at `aes_wrap.sv` 78:2, eager (the one offering cursor) | 143.8 / 123.9–124.4 ms | **145.6 / 115.4–118.6 ms** | **167.9 / 159.9–160.9 ms** | +| `codeAction/resolve` at that cursor | 119.5 / 119.5–121.9 ms | **111.0 / 110.4–112.7 ms** | **163.9 / 158.2–159.5 ms** | +| `textDocument/rename` on `aes` (edits computed, not applied) | 151.8 / 139.1–140.7 ms (9 files) | **159.8 / 133.2–136.2 ms (9)** | **165.1 / 133.5–139.4 ms (9)** | +| — anything queued behind that rename | 160.8 ms | **159.3 / 132.8–157.9 ms** | **160.7 / 145.1–161.7 ms** | +| diagnostics **publish** after a `didChange` (~150 ms is the debounce) | 161.1 / 159.6–163.4 ms | **164.0 / 164.3–167.4 ms** | **164.5 / 153.5–160.7 ms** | +| `textDocument/codeAction`, `aes` (6), eager | 66.1 / 45.7–48.2 ms | **61.5 / 43.5–46.1 ms** | **114.0 / 88.3–90.7 ms** | +| `didOpen spi_device.sv` (1 985 L) → the request behind it | *not measured* | **98.7 / 75.2–99.5 ms** | **15.5 / 13.8–15.1 ms** | +| `expand .*` resolve at `sha3_fpv.sv` 54:4 (32 connections) | *no such action* | *no such action* | **67.8 / 66.9–67.0 ms** | +| `didOpen aes_core.sv` (1 145 L) → the request behind it | *not measured* | **42.6 / 63.0–63.1 ms** | **11.0 / 4.0–10.4 ms** | +| `codeAction` offer at `aes_wrap.sv` 78:2, **lazy** | 33.3 / 21.2–26.8 ms | **20.8 / 18.9–20.2 ms** | **28.6 / 23.6–24.4 ms** | +| `codeAction`, `aes_reg_top` (fan-out 1), lazy | 27.1 / 16.4–20.6 ms | **17.6 / 14.2–15.2 ms** | **29.8 / 21.8–23.5 ms** | +| `lucisv/moduleHierarchy` (1 546 modules, 2.6 MB) | *not measured* | **70.3 / 41.0–48.8 ms** | **76.2 / 41.1–53.8 ms** | +| `codeAction`, `prim_flop_2sync` (128), **lazy** (the offer) | 24.0 / 15.6–16.9 ms | **16.7 / 10.5–13.2 ms** | **15.0 / 8.1–10.5 ms** | +| `workspace/symbol "aes"` (256 results) | 8.8 / 7.2–7.9 ms | **18.2 / 8.2–13.3 ms** | **18.2 / 8.7–12.7 ms** | +| — anything queued behind it | 11.0 ms | **17.7 / 17.9–18.4 ms** | **18.4 / 15.2–18.0 ms** | +| `codeAction`, `prim_alert_sender` (67), lazy | 14.8 / 8.6–10.8 ms | **14.7 / 8.5–12.2 ms** | **13.2 / 9.0–11.5 ms** | +| `codeAction` **on the `aes` instantiation**, lazy | 5.15 / 4.05–4.24 ms | **7.4 / 4.0–4.9 ms** | **14.2 / 7.9–9.8 ms** | +| — definition pipelined behind that codeAction | 5.15 ms | **7.6 / 3.4–7.6 ms** | **14.7 / 11.4–16.2 ms** | +| `codeAction`, `prim_lc_sync` (42), lazy | 17.3 / 7.2–8.6 ms | **18.1 / 7.4–9.4 ms** | **7.0 / 6.0–6.2 ms** | +| `didOpen aes.sv` (326 L) → the request behind it | *not measured* | **11.3 / 4.3–11.4 ms** | **5.1 / 3.5–3.7 ms** | +| `organize imports` resolve at `aes_sbox_canright_masked.sv` 42:2 | *no such action* | *no such action* | **9.6 / 9.6–9.6 ms** | +| `textDocument/completion` at 0 typed characters (512 items) | 9.5 / 2.3–2.8 ms | **7.8 / 4.2–5.4 ms** | **7.2 / 4.2–5.3 ms** | +| `textDocument/completion` at `aes` (512 items) | 10.4 / 7.8–9.2 ms | **8.6 / 6.8–7.4 ms** | **9.1 / 7.0–8.2 ms** | +| `codeAction` on a **comment line** (contrast), lazy | 1.69 / 0.66–0.81 ms | **2.2 / 1.1–1.3 ms** | **4.7 / 3.2–3.8 ms** | +| `textDocument/references` on `.clk_i` (12 hits) | 0.56 / 0.51–0.72 ms | **1.54 / 0.70–0.81 ms** | **1.65 / 1.01–1.15 ms** | +| `textDocument/signatureHelp` inside the port list | 0.70 / 0.57–0.62 ms | **2.50 / 1.09–1.24 ms** | **3.06 / 1.12–1.26 ms** | +| `didChange` flush (`foldingRange` barrier) | 0.95 / 0.58–0.80 ms | **2.32 / 1.04–1.28 ms** | **1.79 / 0.89–0.97 ms** | +| `textDocument/references` on `aes` (14 hits) | 0.85 / 0.54–0.61 ms | **2.80 / 1.32–1.50 ms** | **0.92 / 0.58–0.60 ms** | +| `textDocument/completion` after an instance head + `.` (26 items) | *no such answer* | **1.72 / 0.52–0.66 ms (24 items)** | **1.11 / 0.45–0.53 ms (26)** | +| `textDocument/inlayHint` (whole file, 4 hints) | 0.49 / 0.26–0.43 ms | **1.90 / 0.65–0.85 ms** | **2.04 / 0.57–0.81 ms** | +| `textDocument/semanticTokens/full` | 0.21 / 0.19–0.25 ms | **1.03 / 0.45–0.57 ms** | **0.39 / 0.23–0.30 ms** | +| `textDocument/diagnostic` (pull, 0 items — §1b) | 0.34 / 0.17–0.19 ms | **1.02 / 0.46–0.68 ms** | **0.93 / 0.38–0.47 ms** | +| `textDocument/documentSymbol` | 0.18 / 0.12–0.15 ms | **0.69 / 0.27–0.31 ms** | **0.61 / 0.25–0.31 ms** | +| `textDocument/prepareRename` on `aes` (pressing F2) | 0.31 / 0.08–0.16 ms | **0.37 / 0.13–0.15 ms** | **0.71 / 0.12–0.91 ms** | +| — anything queued behind that prepareRename | 0.37 ms | **0.26 / 0.36–0.83 ms** | **0.78 / 0.24–0.63 ms** | +| `textDocument/definition` on `aes` | 0.19 / 0.07–0.09 ms | **0.87 / 0.11–0.16 ms** | **0.47 / 0.13–0.17 ms** | +| `textDocument/hover` on `aes` | 0.18 / 0.06–0.08 ms | **0.26 / 0.05–0.08 ms** | **0.86 / 0.15–0.18 ms** | +| `textDocument/foldingRange` | 0.10 / 0.05–0.07 ms | **0.44 / 0.08–0.10 ms** | **0.73 / 0.12–0.18 ms** | +| `textDocument/documentHighlight` | 0.10 / 0.04–0.05 ms | **0.19 / 0.07–0.08 ms** | **0.61 / 0.16–0.21 ms** | +| `textDocument/selectionRange` | 0.09 / 0.05 ms | **0.95 / 0.13–0.28 ms** | **1.79 / 0.17–0.27 ms** | +| `textDocument/codeLens` | 0.07 / 0.04–0.05 ms | **0.47 / 0.15–0.17 ms** | **0.23 / 0.09–0.10 ms** | +| `textDocument/typeDefinition` on `aes` | 0.06 / 0.05–0.06 ms | **0.46 / 0.14–0.17 ms** | **0.67 / 0.11–0.17 ms** | +| `textDocument/documentLink` | 0.06 / 0.04–0.05 ms | **0.49 / 0.13–0.16 ms** | **1.09 / 0.08–0.11 ms** | +| `initialize` → response | 2.3 – 4.4 ms | **233.5 ms** (a cold `exec`, the session's first spawn) | **0.27 ms** | +| *transport baseline (does no work)* | *0.06 – 0.24 ms* | *0.04 – 0.17 ms* | *0.09 – 0.63 ms* | + +**The one-line reading of that table.** Four things moved, and only four: + +1. **§46's `didOpen` fix is real in the release build, and it is the round's + headline** — a 42 192-line file's open costs **1 605 ms at 0.43.0 and + 112 ms at 0.49.0**, a **14×**; every RTL file measured is 3–7× cheaper + (§5c). +2. **The eager `codeAction` path is ~2× dearer** at every fan-out. It is a + ruled non-hot path (owner, 2026-09-05), so it is reported, not re-filed — + but the number crossed 500 ms and §6a says who pays it. +3. **§49's tail rename buys correctness at 11.3× the cost**: 66 ms answering + one file and warning about the tail, against 751 ms answering two files + and editing it (§6c). Filed as §8.3. +4. **The index costs ~14% more**, on disk and in the server's resident set + (§6e), which is what `FACTS_FORMAT` 18 → 19 bought. + +Everything else in the table is inside the machine's noise, and §8.9 says so +one row at a time. In particular: **the lazy `codeAction` offer, `rename`, +`completion`, the scan, the diagnostics publish and every sub-millisecond +navigation request are the same on both binaries.** + +--- + +## 3. The queue-blocking analysis + +The server still runs a single-threaded request loop, so the latency a user +feels for request *R* is *R*'s cost plus everything queued ahead of it. Each +slow request was sent, then — back to back, no wait — the three requests a +real editor fires on every cursor move. Three tries; `definition` is the +first follower. + +| Sent first (the blocker) | Its own cost, T3 0.43.0 | **0.43.0 tonight** | **0.49.0** | `definition` behind it, **0.43.0** | **0.49.0** | +|---|---:|---:|---:|---:|---:| +| `codeAction` on the `aes` token (lazy) | 5.07 ms | **7.55 / 3.35–7.56 ms** | **14.67 / 11.40–16.20 ms** | 3.28 – 7.34 ms | 11.24 – 15.94 ms | +| `prepareRename` on `aes` | 0.34 ms | **0.26 / 0.36–0.83 ms** | **0.78 / 0.24–0.63 ms** | 0.19 – 0.38 ms | 0.15 – 0.44 ms | +| `rename` on `aes` | 160.8 ms | **159.3 / 132.9–157.9 ms** | **160.7 / 145.2–161.7 ms** | 132.8 – 159.2 ms | 145.1 – 161.5 ms | +| `workspace/symbol "aes"` | 11.0 ms | **17.7 / 17.9–18.4 ms** | **18.4 / 15.2–18.0 ms** | 17.1 – 17.3 ms | 14.8 – 17.7 ms | + +`hover` and `documentSymbol` behind each leader land 0.01–0.3 ms after the +`definition`, as in all three earlier takes: **the queue is still strictly +serial and the follower still pays the leader's bill almost exactly.** + +Take 3's structural conclusion was that "the hot path is clean" — `codeAction` +5 ms and `completion` 2–3 ms, both inside a 16 ms frame. **That conclusion +survives, with one qualification.** The lazy `codeAction` on the `aes` token +is 11.4–16.2 ms at 0.49.0 against 3.4–7.6 at 0.43.0: still under the frame +budget, but no longer comfortably. The cost is the new offers' own gates — +`inline_site` and `extract_site` each parse the cursor's buffer — and it is +paid on every cursor move whether or not anything is offered. §8.2 files it. + +What is left genuinely slow is unchanged in kind: user-initiated (`rename`, +160 ms; the tail rename, 751 ms), once-per-session (the scan, 1.2–2.7 s), or +paid only by a client that cannot resolve a code action (§6a). + +--- + +## 4. Startup and scan, per scope config and cache state + +`didOpen tb.sv` → 1.5 s of silence, three runs per cell. "Cold" = the +`storagePath` directory was `rm -rf`'d immediately before; "warm" = it carries +a previous run's store. + +| Scope config | Cache | T3 0.43.0 | **0.43.0 tonight** | **0.49.0** | files | +|---|---|---:|---:|---:|---| +| **default** (`[{}]`) | cold | 81.9 / 92.5 / 93.1 ms | **95.0 / 101.7 / 101.6** | **83.8 / 110.3 / 103.6** | 124 | +| **default** | warm | 39.4 / 40.3 / 41.8 ms | **53.1 / 54.8 / 55.5** | **55.8 / 54.7 / 56.6** | 124, 123 from cache | +| `{"index":{}}` | cold | 88.8 / 90.1 / 94.5 ms | **96.6 / 91.3 / 103.9** | **98.1 / 95.2 / 103.6** | 124 | +| `{"index":{}}` | warm | 34.7 / 39.1 / 39.3 ms | **44.6 / 58.4 / 54.2** | **41.8 / 54.8 / 56.4** | 124 | +| explicit `scopeDepth: 0` | cold | 93.5 / 101.6 / 105.5 ms | **107.4 / 114.8 / 106.1** | **107.4 / 108.8 / 115.8** | 1 (after a ~100 ms 124-file scan is thrown away) | +| explicit `scopeDepth: 0` | warm | 42.3 / 49.3 / 49.6 ms | **56.6 / 60.4 / 58.9** | **58.8 / 62.3 / 67.9** | 1 | +| `workspace` | cold | 2 754 / 2 773 / 2 867 ms | **2 645 / 2 640 / 2 656** | **2 712 / 2 691 / 2 712** | 3 976, 3 skipped | +| `workspace` | warm | 1 220.5 / 1 229.7 / 1 229.8 ms | **1 173.4 / 1 167.1 / 1 173.6** | **1 266.1 / 1 239.8 / 1 285.6** | 3 975 from cache | + +- **The scan did not change.** Cold workspace is +2.4% at 0.49.0, warm is + +8.7%; the warm band across both binaries is 1 167–1 286 ms, and 0.43.0's + own two columns (take 3's 1 220–1 230 and tonight's 1 167–1 174) differ by + 4.5% on their own. §8.9. +- **Every small-scope cell is 10–40% dearer than take 3's**, on *both* + binaries, in lockstep. That is the machine (§9), not a release: the 0.43.0 + binary is the same binary take 3 measured. +- **Persistence still buys ~54%** on the workspace scan (2 676 → 1 218 ms, + mean of six runs across both binaries) and ~44% on the default scope + (99.3 → 55.1 ms). Take 3 measured 57% / 57% + on a quieter machine. +- **A cold workspace scan is still not fully cold**: the trace is + `0 files → 124 files → 3 976 files`, and the workspace bar reports "123 from + cache" even on a wiped store — those 123 are the default scan's own writes, + read back seconds later. Unchanged from take 3. +- `initialize` still does no scanning. The one 233 ms reading is the session's + very first process spawn — a cold `exec`, exactly the outlier take 3 saw. + +### 4b. What each scope answers, at 0.49.0 + +Take 3's §4b table, re-taken at both binaries. The `aes` instantiation in +`tb.sv`. **Every count below is identical on 0.43.0 and 0.49.0.** + +| Request | default | explicit `scopeDepth 0` | workspace | +|---|---|---|---| +| `definition` | **1 result**, 0.11–0.21 ms | 0 results | 1 result, 0.22–0.30 ms | +| `typeDefinition` | 1 result | 0 results | 1 result | +| `hover` | 1 result | 0 results | 1 result | +| `references` | **11 results**, 0.44–0.50 ms | 0 results | **14 results**, 1.07–1.14 ms | +| `documentHighlight` | 1 result | 0 results | 1 result | +| `signatureHelp` | 0 results | 0 results | 0 results | +| `workspace/symbol "aes"` | 256, 3.4–4.0 ms | 0 results, 0.09 ms | 256, 9.0–12.3 ms | +| `inlayHint` (whole file) | **0** | 0 | **4** | + +Take 3's §4b holds on every row, at both binaries: the counts (1 / 11 / 14 / +256 / 0-vs-4) are byte-for-byte what take 3 recorded, and §37.2's ruling that +`inlayHint`'s zero at the default scope is a scope-reach result rather than an +inlay defect still stands. + +--- + +## 5. The `didOpen` widen and the `didOpen` delay + +### 5a. At `scopeDepth 0` — apples to apples with all three earlier takes + +`tb.sv` open, then RTL files opened one at a time; the request sent +immediately afterwards waits for the widen. Three tries. + +| Widening `didOpen` | T3 0.43.0 cold | T3 warm | **0.43.0 cold** | **0.43.0 warm** | **0.49.0 cold** | **0.49.0 warm** | +|---|---:|---:|---:|---:|---:|---:| +| `hw/ip/aes/rtl/aes.sv` | 19.3 ms | 18.5 ms | **28.4 / 16.3 / 29.0** | **27.8 / 24.3 / 29.3** | **29.5 / 18.8 / 27.9** | **30.3 / 27.7 / 30.7** | +| `hw/ip/kmac/rtl/kmac.sv` | 32.9 ms | 25.9 ms | **46.7 / 56.0 / 56.0** | **33.5 / 32.8 / 35.3** | **52.3 / 53.7 / 53.0** | **35.6 / 34.2 / 37.3** | +| `hw/ip/hmac/rtl/hmac.sv` | 30.4 ms | 20.4 ms | **42.4 / 36.9 / 45.9** | **32.9 / 33.4 / 36.2** | **34.8 / 36.0 / 44.0** | **34.7 / 32.7 / 31.8** | +| `hw/ip/spi_device/rtl/spi_device.sv` | 85.2 ms | 37.0 ms | **93.5 / 101.9 / 102.0** | **54.7 / 58.0 / 57.5** | **105.4 / 107.5 / 102.1** | **56.9 / 56.0 / 60.0** | + +`spi_device` is still the ceiling, for the reason take 1 gave. **The two +binaries are the same on every cell**, and both are 20–50% above take 3's +0.43.0 column, which is the machine. At this scope each open *is* a rescan, so +§46 has nothing to remove. + +### 5b. At the default scope — the widen row, and the three that follow it + +| Widening `didOpen` | T3 0.43.0 cold | T3 warm | **0.43.0 cold** | **0.43.0 warm** | **0.49.0 cold** | **0.49.0 warm** | +|---|---:|---:|---:|---:|---:|---:| +| `aes.sv` (widens `hw/ip/aes` → **`hw/ip`, 1 807 files**) | 1 081.6 ms | 365.1 ms | **1 046.6 / 1 042.0 / 1 019.8** | **344.9 / 340.4 / 338.9** | **1 072.4 / 1 075.8 / 1 051.4** | **367.0 / 351.0 / 378.1** | +| `kmac.sv` (already in scope) | 24.3 ms | 31.1 ms | **53.4 / 23.9 / 48.5** | **35.3 / 45.0 / 44.7** | **12.7 / 5.5 / 9.6** | **6.6 / 9.5 / 11.6** | +| `hmac.sv` (already in scope) | 22.6 ms | 21.1 ms | **31.7 / 38.4 / 26.2** | **36.4 / 35.7 / 33.5** | **17.5 / 9.1 / 7.4** | **9.3 / 11.6 / 4.9** | +| `spi_device.sv` (already in scope) | 47.6 ms | 51.2 ms | **68.8 / 35.3 / 55.8** | **46.5 / 58.2 / 68.9** | **19.9 / 6.2 / 18.0** | **8.5 / 21.0 / 15.4** | + +**The widen row itself did not move**: 340 ms warm at 0.43.0, 365 ms at +0.49.0, against take 3's 365 — the same number, three ways. Take 2's +"1.5-second hang on the most common navigation a Verilog user performs" stays +closed. + +**The three rows under it are take 3's §8.4, and they are fixed.** A `didOpen` +of a file already in scope cost 21–51 ms in take 3 and 33–69 ms here at +0.43.0; at 0.49.0 it is **5–21 ms**, a 3–5× on every cell. That is §46, and +§5c measures it properly. + +### 5c. §46 on the wire, in the release build — the round's headline + +Take 3 filed the delay (§8.4); 0.44.0 fixed it; the perf README's 2026-09-05 +table was taken with *temporary* timings on a release build. These are the +release numbers, workspace scope, warm store, `didOpen` → the +`textDocument/definition` behind it, three tries. + +| file | lines | perf README "before" | **0.43.0, tonight** | perf README "after" | **0.49.0, tonight** | factor | +|---|---:|---|---:|---|---:|---:| +| `aes.sv` | 326 | 8.1 / 5.9 / 10.1 ms | **11.3 / 4.3 / 11.4** | 4.3 / 1.8 / 2.3 ms | **5.1 / 3.5 / 3.7** | ~2× | +| `aes_core.sv` | 1 145 | 56.2 / 54.0 / 48.0 ms | **42.6 / 63.0 / 63.1** | 5.9 / 6.9 / 6.3 ms | **11.0 / 4.0 / 10.4** | **7×** | +| `spi_device.sv` | 1 985 | 94.2 / 103.4 / 88.6 ms | **98.7 / 75.2 / 99.5** | 6.0 / 8.6 / 8.7 ms | **15.5 / 13.8 / 15.1** | **6×** | +| `pinmux_reg_top.sv` | 42 192 | 1 742 / 1 740 / 1 757 ms | **1 605 / 1 604 / 1 611** | 116.5 / 116.2 / 117.3 ms | **112.1 / 127.9 / 130.7** | **13×** | + +The release build **confirms the fix at the same magnitude the temporary +timings reported**, and the largest file in opentitan opens in a tenth of a +frame-budget-heavy second rather than in a second and a half. The absolute +values here run 1.3–2× above the perf README's on the small files and are +level on the large one, which is the expected shape when the machine is +busier: a 4 ms row is mostly floor, a 1 600 ms row is mostly work. + +**The same cost was paid on every keystroke flush**, not just on opens +(`docs/features/didopen-cost/`), so this is a typing-latency fix as much as a +navigation one. That is the strongest single result in this document. + +--- + +## 6. `codeAction`, refactorings, rename and the index + +### 6a. Cost against the module's fan-out — the eager path doubled + +Workspace scope, warm cache, cursor on a module instantiation, four tries +each. "Lazy" is a client that advertises +`textDocument.codeAction.resolveSupport.properties: ["edit"]` (what VS Code +sends); "eager" is a client that does not. Fan-outs re-derived with take 3's +`grep -rlE '^\s*( |#|$)' --include='*.sv'` and **identical to take 2's +and take 3's** (1 / 6 / 42 / 67 / 128). + +| Module at the cursor | files | T3 0.43 eager | **0.43 eager** | **0.49 eager** | T3 0.43 lazy | **0.43 lazy** | **0.49 lazy** | actions at 0.49 | +|---|---:|---:|---:|---:|---:|---:|---:|---:| +| `aes_reg_top` (in `aes.sv` 103:0) | 1 | 27.7 / 16.3–21.8 | **36.2 / 16.0–22.6** | **30.6 / 22.8–24.2** | 27.1 / 16.4–20.6 | **17.6 / 14.2–15.2** | **29.8 / 21.8–23.5** | **2** | +| `aes` (in `tb.sv` 44:2) | 6 | 66.1 / 45.7–48.2 | **61.5 / 43.5–46.1** | **114.0 / 88.3–90.7** | 5.15 / 4.05–4.24 | **7.4 / 4.0–4.9** | **14.2 / 7.9–9.8** | **1** | +| `prim_lc_sync` (in `aes.sv` 118:2) | 42 | 148.0 / 128.9–130.4 | **138.6 / 121.5–124.9** | **270.0 / 254.7–255.7** | 17.3 / 7.2–8.6 | **18.1 / 7.4–9.4** | **7.0 / 6.0–6.2** | **1** | +| `prim_alert_sender` (in `aes.sv` 235:4) | 67 | 213.4 / 196.0–196.5 | **211.5 / 183.0–192.4** | **405.1 / 362.3–368.8** | 14.8 / 8.6–10.8 | **14.7 / 8.5–12.2** | **13.2 / 9.0–11.5** | **1** | +| `prim_flop_2sync` (in `aon_timer.sv` 83:2) | 128 | 270.2 / 252.9–255.2 | **267.1 / 238.6–243.3** | **511.8 / 467.1–473.6** | 24.0 / 15.6–16.9 | **16.7 / 10.5–13.2** | **15.0 / 8.1–10.5** | **2** | +| *(contrast) a comment line* | — | 1.80 / 0.71–0.78 | **2.41 / 1.33–1.58** | **7.44 / 4.34–4.95** | 1.69 / 0.66–0.81 | **2.17 / 1.12–1.32** | **4.70 / 3.18–3.84** | **0** | +| **`aes` in `aes_wrap.sv` 78:2 — the offering cursor** | 6 | 143.8 / 123.9–124.4 | **145.6 / 115.4–118.6** | **167.9 / 159.9–160.9** | 33.3 / 21.2–26.8 | **20.8 / 18.9–20.2** | **28.6 / 23.6–24.4** | **2** | + +Two readings, in opposite directions. + +**The lazy offer is still `O(1)` in the fan-out and is unchanged where it +matters.** 6.0 ms at 42 files, 9.0 at 67, 8.1 at 128 — flat, and slightly +*better* than 0.43.0 at the two largest fan-outs. Take 2's "reads as a hang" +line at 200 ms is nowhere near crossed for a resolving client. + +**The eager path is 1.95–2.07× dearer at every fan-out above 1**: 46 → 90 ms +at 6 files, 125 → 255 at 42, 192 → 368 at 67, 243 → 473 at 128. A consistent +factor across four fan-out points, on the same night, on the same machine, +with the `--verbose` server's own clock agreeing to 0.5 ms (§0). **The eager +`codeAction` path is a ruled non-hot path (owner, 2026-09-05), so this is +reported and not re-filed** — but the number is now half a second at the +largest fan-out, and §6b shows the eager client also computes strictly more +offers than it used to. + +**The two small-cursor rows moved the wrong way for a lazy client too**, and +this one *is* filed (§8.2): the `aes` cursor is 4.0–4.9 → 7.9–9.8 ms and a +plain comment line is 1.1–1.3 → 3.2–3.8 ms. Nothing is offered at a comment +line on either binary; the extra 2 ms is the new offers' gates asking, on +every cursor move. + +### 6b. What is offered now, and how often — the census re-taken + +Take 3 swept every instantiation-shaped line in **205 RTL files** — all 165 of +`hw/ip/prim/rtl` and all 40 of `hw/ip/aes/rtl` — and found **exactly one +position offering a port refactoring**. Take 4 re-ran that sweep at 0.49.0 +over the same 205 files, adding `import` lines, and classified every offer. +**2 440 positions:** + +| Offer | positions offering it | where | +|---|---:|---| +| `lucisv: extract selection into module…` (§53.1) | **2 171** (89%) | nearly everywhere a whole module item starts | +| ``lucisv: inline `M` here`` (§53.2) | **263** (11%) | every instantiation whose buffer parses clean | +| `lucisv: organize imports (removes 1, sorts 1)` (§52) | **12** | 2 files: `aes_sbox_canright_masked{,_noreuse}.sv` | +| `lucisv: connect N missing ports` (§37/ports) | **1** | `hw/ip/aes/rtl/aes_wrap.sv` 0-based 78:2 — take 3's cursor, unmoved | +| `lucisv: expand .* (N connections)` (§50) | **0** | no `.*` in these 205 files (8 files corpus-wide have one) | +| `lucisv: remove port …` | **0** | refuses when the module's body uses the port — real RTL always does | + +**Take 3's §8.7 — "the lightbulb is almost never lit" — is no longer true, and +that is the mechanism behind §6a's eager number.** At 0.43.0 a cursor on an +instantiation offered nothing at all on this corpus except at one position; at +0.49.0 it offers one or two things almost everywhere. Both new offers are +cheap by construction — `extract` and `inline` carry a `Command`, not an edit, +so neither reads the workspace at offer time — but each has a *gate* that +parses the cursor's buffer, and that gate runs on every `codeAction`. + +**There is no `convert to ANSI` (§51) site on this corpus.** A scan of all +**1 311 module headers** in opentitan's `hw/` (3 932 `.sv`/`.v` files) found +**zero** non-ANSI headers — every one declares its ports in the header. So +that row below measures an ANSI header, where the action is correctly not +offered, and §51's cost on this corpus is exactly the cost of saying no. + +*Traceability note (lead, after QA).* The header scan was a one-off census, +not a harness phase, so it has no log: a line-anchored `module NAME` match +over every `.sv`/`.v` under `hw/`, comments stripped, the port list checked +for a direction keyword. QA re-derived it independently: 1 310 headers, two +apparent non-ANSI hits that are `module NAME #(…);` with **no** port list at +all, net zero genuine non-ANSI headers. Read "1 311" as "all of them"; the +one-header difference is the two scans' treatment of a macro-wrapped header. + +### 6c. The five new offer sites, offer and resolve + +Lazy client, workspace scope, warm cache, four tries. Each row names a real +opentitan position, 0-based. + +| Site | file, position | actions offered | **offer, 0.49.0** | **resolve, 0.49.0** | **0.43.0 offer** | +|---|---|---:|---:|---:|---:| +| **expand `.*`** — `sha3 #(…) u_sha3 ( .* );` | `hw/ip/kmac/fpv/tb/sha3_fpv.sv` 54:4 | 2 (`expand .* (32 connections)`, `extract`) | **8.2 / 6.2–7.3 ms** | **67.8 / 66.9–67.0 ms**, 1 file | 0 actions, 2.1 / 1.7–1.8 ms | +| **organize imports** — 2 imports, 1 unused | `hw/ip/aes/rtl/aes_sbox_canright_masked.sv` 42:2 | 2 (`organize imports (removes 1, sorts 1)`, `extract`) | **30.1 / 13.8–19.5 ms** | **9.6 / 9.6–9.6 ms**, 1 file | 0 actions, 18.5 / 12.7–15.1 ms | +| **inline module** — a separate-file instance with named connections | `hw/ip/aes/rtl/aes_wrap.sv` 66:2 (`tlul_cmd_intg_gen u_…`) | 2 (``inline `tlul_cmd_intg_gen` here``, `extract`) | **31.7 / 13.9–19.5 ms** | **0.05 / 0.03–0.04 ms** (a `Command`) | 0 actions, 27.1 / 10.8–16.7 ms | +| **extract module** — a 3-item selection | `hw/ip/aes/rtl/aes.sv` 220:0–222:53 (three status `assign`s) | 1 (`extract selection into module…`) | **8.0 / 3.7–5.0 ms** | **0.19 / 0.08–0.13 ms** (a `Command`) | 0 actions, 20.1 / 5.3–7.4 ms | +| **port actions** — take 3's cursor | `hw/ip/aes/rtl/aes_wrap.sv` 78:2 | 2 (`connect 2 missing ports`, `extract`) | **28.6 / 23.6–24.4 ms** | **163.9 / 158.2–159.5 ms**, 1 file | 1 action, 20.8 / 18.9–20.2 ms | +| **convert to ANSI** — *no site exists* (§6b); an ANSI header instead | `hw/ip/aes/rtl/aes.sv` 8:0 (`module aes`) | 0 | **2.8 / 2.2–2.4 ms** | *n/a* | 0 actions, 5.2 / 3.5–3.9 ms | + +Three things worth stating plainly: + +- **`inline` and `extract` cost nothing to *pick*** — 0.05 and 0.19 ms — + because the action carries a `workspace/executeCommand`, not an edit. The + work happens when the command runs, which this round does not measure + (running it would edit the corpus). The design is deliberate and is + documented in `crates/lucisv_server/src/inline_module.rs`'s own header. +- **`organize imports` is the opposite shape**: the offer computes the whole + edit (30 / 14–19 ms, because judging it means reading the package closure), + and the resolve is a cheap re-run at 9.6 ms. +- **`expand .*` is `O(connections)` on resolve**: 68 ms for 32 connections, + against an 8 ms offer. That is the right split. + +**The port-actions resolve is 1.44× dearer at 0.49.0** (110 → 159 ms) at the +one cursor on this corpus that offers it, and the eager one-shot is 1.36× +(117 → 160 ms). Filed with §8.2. + +### 6d. `prepareRename`, `rename`, and §49's hierarchical tail + +`prepareRename` remains flat and free — 0.12–0.91 ms at 0.49.0, 0.13–0.15 at +0.43.0 — with the byte-identical answer take 2 pinned +(`{"placeholder":"aes","range":{"start":{"line":44,"character":2},"end":{"line":44,"character":5}}}`). + +`rename` on `aes` is **165.1 / 133.5–139.4 ms at 0.49.0** against +**159.8 / 133.2–136.2 at 0.43.0**, both editing **9 files** — flat, and level +with take 3's 151.8 / 139.1–140.7. + +**The tail rename is the round's one large regression, and it is a regression +that buys a correctness fix.** §49 gave a module a second, *hierarchical* +member surface — its nets, variables and instances, not only its ports — so a +rename can follow `u_x.sig` across a file boundary. + +| | **0.43.0** | **0.49.0** | +|---|---:|---:| +| `rename` `state_q` at `hw/ip/entropy_src/rtl/entropy_src_main_sm.sv` 41:19 | **88.0 / 65.8–66.7 ms** | **793.2 / 750.7–751.9 ms** | +| files edited | **1** (`entropy_src_main_sm.sv`) | **2** (+ `entropy_src_core.sv`) | +| the tail `u_entropy_src_main_sm.state_q` | **not edited**, warned about | **edited** | + +**11.3× for one extra edited file.** The rename is user-initiated and rare, so +this is a low-severity finding — but it is 0.75 s of a frozen single-threaded +queue on a keystroke-shaped gesture (F2, type, Enter), and everything queued +behind it pays the same. Filed as §8.3. + +**Two tails on this corpus do *not* resolve**, and both are worth recording so +nobody re-derives them as bugs: + +- `hw/top_earlgrey/ip_autogen/pwrmgr/rtl/pwrmgr.sv` 178:10, + `u_fsm.state_q` — inside a `` ` ``-macro assertion argument. The rename + edits `pwrmgr_fsm.sv` alone. +- `hw/top_earlgrey/ip_autogen/pinmux/rtl/pinmux.sv` 687:40, `u_reg.intg_err` — + likewise not edited, and `completion` after `u_reg.` there returns 0 items. + +§49's own README rules a *generate-block-scoped* tail an honest refusal; these +two are a different shape and are filed as §8.5 for a future round to classify. + +### 6e. `completion`, the instance-head tail, `moduleHierarchy`, the index + +**`completion` did not move.** Every prefix is within 0.6 ms of 0.43.0 and +every one returns the same item count: + +| Typed prefix | items | **0.43.0** | **0.49.0** | T3 0.43.0 | +|---|---:|---:|---:|---:| +| `` (empty) | 512 | 7.8 / 4.2–5.4 ms | **7.2 / 4.2–5.3 ms** | 9.5 / 2.3–2.8 | +| `a` | 512 | 4.4 / 3.1–3.3 | **4.5 / 3.1–3.3** | 3.2 / 2.5–2.7 | +| `ae` | 512 | 3.5 / 2.6–2.7 | **3.6 / 2.7–2.9** | 4.0 / 2.6–2.9 | +| `aes` | 512 | 8.6 / 6.8–7.4 | **9.1 / 7.0–8.2** | 10.4 / 7.8–9.2 | +| `aes_` | 512 | 6.8 / 6.2–6.4 | **7.1 / 6.7–6.9** | 7.5 / 6.8–8.2 | +| `prim_` | 512 | 4.2 / 3.4–3.6 | **4.1 / 3.6–3.8** | 5.1 / 4.0–4.4 | +| `clk` | 512 | 3.9 / 3.3–3.3 | **4.2 / 3.3–3.5** | 4.4 / 3.3–3.9 | +| `aes_reg` | 512 | 3.2 / 2.6–2.8 | **3.3 / 2.7–2.9** | 3.8 / 2.9–3.0 | +| `zzzz` | 1 | 1.2 / 0.29–0.31 | **1.2 / 0.31–0.35** | 1.4 / 0.31–0.34 | + +**Completion after an instance head and a `.`** — §49's other surface, at +`hw/ip/entropy_src/rtl/entropy_src_core.sv` 3091:29 +(`u_entropy_src_main_sm.`): + +| | **0.43.0** | **0.49.0** | +|---|---:|---:| +| round trip | 1.72 / 0.52–0.66 ms | **1.11 / 0.45–0.53 ms** | +| items | **24** | **26** | + +**Two more members for no time at all** — the hierarchical surface arrives +free on this path, which is the shape §49 wanted and the opposite of the +rename row above. + +**`lucisv/moduleHierarchy`** — the flat snapshot the VS Code DUT sidebar +consumes (`params: {}`; the sections are client-side and not measured here): + +| | **0.43.0** | **0.49.0** | +|---|---:|---:| +| round trip | 70.3 / 41.0–48.8 ms | **76.2 / 41.1–53.8 ms** | +| payload | 2 600 051 B | **2 600 051 B** — byte-identical | +| content | 1 546 modules over 1 529 files, `schemaVersion` 2 | same | + +Unchanged, and the payload is 2.6 MB — the compaction its own module +documents (11.6 MB → 1.9 MB) is holding. It is sent on demand, not on every +save, so 40–76 ms is a fair price; it is also the single largest message this +server writes, and it blocks the queue for that whole time (§3's rule). + +**The index's size, on disk and resident.** `FACTS_FORMAT` 18 → 19 added the +hierarchical member table and the re-export group: + +| | **0.43.0** | **0.49.0** | change | +|---|---:|---:|---:| +| index store on disk, after a workspace scan | **39 940 KB** (39.0 MB) | **45 404 KB** (44.3 MB) | **+13.7%** | +| server RSS after a **cold** workspace scan (3 tries) | 479 520 / 483 056 / 481 936 KB | **544 800 / 539 392 / 542 736 KB** | **+12.6%** | +| server RSS after a **warm** workspace scan (3 tries) | 512 544 / 512 400 / 501 872 KB | **581 072 / 588 608 / 587 264 KB** | **+15.1%** | + +**+13.7% on disk and +12.6/+15.1% resident, which is a proportionate price** for what §49 and §48 +bought — a 3 976-file design costs the editor 530–590 MB resident and 44 MB on +disk. Worth a glance next round rather than a finding: the disk and the +resident set moved by the same fraction, so this is the index growing, not a +leak. Also worth knowing: **a warm scan holds more than a cold one on both +binaries** — 27 MB more at 0.43.0, 42 MB more at 0.49.0 — because the store +is read into memory as well as built. + +--- + +## 7. The CLI sweeps + +`format --check` and `check` over five trees, three binaries, three tries each, +wall clock and peak RSS from `/usr/bin/time -l`, everything under +`tools/guard.sh`. The formatter cache lives in a scratch `--cache-dir` outside +the corpus. File counts: `hw/ip` 1 807, `hw/top_earlgrey/ip` 46, +`hw/top_darjeeling/ip` 49, `hw/dv` 365, `hw/vendor` 287 — unchanged from +take 3. + +| Tree | command | **0.49.0** | **0.43.0** | 0.39.0 | peak RSS, 0.49 → 0.43 → 0.39 (MB) | +|---|---|---:|---:|---:|---:| +| `hw/ip` | `format --check`, cold cache | 0.60 / 0.64–0.67 | 0.64 / 0.60–0.64 | 0.60 / 0.60–0.62 | 216 → 237 → 238 | +| `hw/ip` | `format --check`, warm cache | 0.60 / 0.62–0.63 | 0.58 / 0.60–0.63 | 0.63 / 0.56–0.57 | 217 → 214 → 228 | +| `hw/ip` | `check` (default rules) | 0.37 / 0.38–0.40 | 0.41 / 0.38–0.41 | 0.34 / 0.35 | 190 → 176 → 186 | +| `hw/ip` | `check --select error,warning,style` | **0.57 / 0.58–0.60** | 0.45 / 0.44–0.47 | 0.40 / 0.40–0.41 | 212 → 175 → 190 | +| `hw/top_earlgrey/ip` | `format --check`, cold / warm | 0.04 / 0.04 | 0.04 / 0.04 | 0.03 / 0.04 | 34 → 32 → 31 | +| `hw/top_earlgrey/ip` | `check` / `--select …` | 0.03 / 0.04 | 0.02 / 0.03 | 0.03 / 0.03 | 33 → 38 → 30 | +| `hw/top_darjeeling/ip` | `format --check`, cold / warm | 0.04 / 0.03 | 0.03 / 0.03 | 0.03 / 0.03 | 22 → 22 → 24 | +| `hw/top_darjeeling/ip` | `check` / `--select …` | 0.02 / 0.03 | 0.02 / 0.02 | 0.02 / 0.03 | 27 → 27 → 26 | +| `hw/dv` | `format --check`, cold / warm | 0.07 / 0.07 | 0.07 / 0.07 | 0.06 / 0.06 | 27 → 27 → 29 | +| `hw/dv` | `check` / `--select …` | 0.05 / 0.08 | 0.06 / 0.07 | 0.05 / 0.06 | 30 → 33 → 31 | +| `hw/vendor` | `format --check`, cold / warm | 0.10 / 0.10 | 0.12 / 0.09 | 0.10 / 0.10 | 45 → 44 → 44 | +| `hw/vendor` | `check` / `--select …` | 0.08 / 0.11 | 0.08 / 0.09 | 0.07 / 0.09 | 53 → 50 → 48 | + +- **`format --check` did not move at all.** Every cell on every tree is inside + the three binaries' own spread. The biggest tree, 1 807 files, is checked + for formatting in 0.6 s on ten cores at ~220 MB, exactly as in take 3. +- **`check --select error,warning,style` is 1.27× slower than 0.43.0 on + `hw/ip`** (0.45 → 0.57 s), 1.22× on `hw/vendor` (0.09 → 0.11) and 1.14× on + `hw/dv` (0.07 → 0.08). **Most of this is more work, not slower work**: + 0.49.0 runs the new `unused-import` rule (0.48.0, §52's shared judgement) + and finds 17 more violations on `hw/ip`. §8.4 files what is left. +- **`check` with default rules did *not* slow down** (0.41 → 0.37 s on + `hw/ip`), which is the same reading from the other side: `unused-import` is + Style and off by default, so the default rule set is untouched. Take 3's + §8.5 ("`check` is 6–10% slower than 0.39.0") therefore **stops + accumulating** on the default path: 0.34–0.35 s at 0.39.0, 0.38–0.41 at + 0.43.0, 0.37–0.40 at 0.49.0. +- **The formatter cache still buys nothing on opentitan**, and for the reason + take 3 gave: it remembers already-formatted files, and opentitan has 30 of + 1 807 in `hw/ip`, 3 of 365 in `hw/dv`, 12 of 287 in `hw/vendor`. The cold + and warm rows are within noise everywhere. +- **Peak RSS scales with the tree, not the version.** 22–53 MB for the four + small trees, 175–238 MB for `hw/ip`; no version is consistently above + another and the ordering flips between rows, so nothing is claimed. + +### 7a. Failure counts, and every per-file outcome that changed + +`format --check --no-cache`, `check` and `check --select error,warning,style`, +full runs, all three binaries, paths made relative and sorted so two runs +differ only where an *outcome* did. + +| Tree | 0.39.0 `format --check` | 0.43.0 | **0.49.0** | +|---|---|---|---| +| `hw/ip` | 1773 would reformat, 30 unchanged, 4 failed | 1772, 30, 4 | **1772, 30, 4** | +| `hw/top_earlgrey/ip` | 46 would reformat | 46 | **46** | +| `hw/top_darjeeling/ip` | 48 would reformat, 1 failed | 48, 1 | **48, 1** | +| `hw/dv` | 361, 3 unchanged, 1 failed | 362, 3, 0 | **362, 3, 0** | +| `hw/vendor` | 270, 12 unchanged, 5 failed | 271, 12, 4 | **271, 12, 4** | + +**`format --check --no-cache` is byte-identical between 0.43.0 and 0.49.0 on +all five trees** — not one per-file verdict changed, and not one parse error +appeared or disappeared. §54's grammar additions (`randsequence`, `->>`, +casts, drive strengths, `let`, clocking skews) were the expected candidates; +**none of them changes an outcome on this corpus**, because none of those +shapes appears in a file that lucisv did not already handle. §38's fixes stay +fixed. + +**`check` with default rules is byte-identical too** — `hw/ip` 445, +`hw/top_earlgrey/ip` 14, `hw/top_darjeeling/ip` 23, `hw/dv` 85, `hw/vendor` +231 + 1 file that cannot be checked, at both 0.43.0 and 0.49.0. + +**`check --select error,warning,style` changed in exactly one way: 20 new +`unused-import` findings, and nothing else.** + +| Tree | 0.43.0 | **0.49.0** | delta | +|---|---:|---:|---:| +| `hw/ip` | 7 734 | **7 751** | +17 | +| `hw/top_earlgrey/ip` | 551 | **553** | +2 | +| `hw/top_darjeeling/ip` | 382 | **383** | +1 | +| `hw/dv` | 1 158 | **1 158** | 0 | +| `hw/vendor` | 1 666 | **1 666** | 0 | + +Every one of the 20 is a line of the form +``::: style: `pkg::*` is imported but nothing in this scope +uses it [unused-import]``, and **no violation disappeared**. `unused-import` +is the rule 0.48.0 added out of organize-imports' judgement (CHANGELOG 0.48.0: +"Style, off by default, safe fix"), which is why the default rule set is +untouched. **The outcome diff is fully explained; there is no unexplained +change on any tree, for any command, at any rule set.** + +The files that still fail to parse, unchanged from take 3 apart from the two +0.42/0.43 fixes it recorded: +`hw/ip/edn/dv/env/edn_env_cfg.sv`, `hw/ip/kmac/fpv/tb/keccak_2share_fpv.sv`, +`hw/ip/kmac/pre_dv/kmac_reduced_tb/rtl/kmac_reduced_tb.sv`, +`hw/ip/spi_device/dv/env/spi_device_scoreboard.sv`, +`hw/top_darjeeling/ip/ast/rtl/ast.sv` (a locally modified file), +`hw/vendor/lowrisc_ibex/dv/formal/check/peek/compare_helper.sv`, +`hw/vendor/lowrisc_ibex/dv/uvm/core_ibex/riscv_dv_extension/riscv_core_setting.tpl.sv` +(a template, not SystemVerilog), +`hw/vendor/lowrisc_ibex/syn/rtl/latch_map.v`, +`hw/vendor/lowrisc_ibex/vendor/google_riscv-dv/src/riscv_instr_cover_group.sv`. + +--- + +## 8. Findings — filed, not fixed + +Ordered by how much they matter. Nothing here was fixed in this round. + +### 8.1 CREDIT, not a finding — what got faster + +Stated first so the rest reads in proportion. + +| What | 0.43.0 | **0.49.0** | Credit | +|---|---:|---:|---| +| `didOpen` of opentitan's largest file → the next request | 1 605 / 1 604–1 611 ms | **112 / 128–131 ms** | **§46** (0.44.0) — **14×** | +| `didOpen spi_device.sv` → the next request | 98.7 / 75.2–99.5 ms | **15.5 / 13.8–15.1 ms** | **§46** — 6× | +| `didOpen aes_core.sv` → the next request | 42.6 / 63.0–63.1 ms | **11.0 / 4.0–10.4 ms** | **§46** — 7× | +| A `didOpen` of a file already in scope, default scope (take 3's §8.4) | 33–69 ms | **5–21 ms** | **§46** — 3–5×; **take 3's §8.4 is closed** | +| `rename` through an instance tail | 1 file, tail unedited | **2 files, tail edited** | **§49** — correctness, at a cost (§8.3) | +| `completion` after an instance head + `.` | 24 items, 1.72 / 0.52–0.66 ms | **26 items, 1.11 / 0.45–0.53 ms** | **§49** — free | +| `codeAction` lazy offer at 42 files | 18.1 / 7.4–9.4 ms | **7.0 / 6.0–6.2 ms** | unattributed; §37.1's shape holding | + +**§46 closes take 3's §8.4 outright**, and it is the largest improvement any +of the four rounds has measured on a per-keystroke path. + +### 8.2 FINDING (medium) — the lazy `codeAction` offer costs 2–3 ms more at every cursor, offered or not + +**What.** For a resolving client — the majority since 0.41.0, and what VS Code +sends — `textDocument/codeAction` costs 2–5 ms more at 0.49.0 than at 0.43.0 +at the *small* cursors, including cursors where nothing is offered: + +| cursor | 0.43.0 repeats | **0.49.0 repeats** | factor | +|---|---:|---:|---:| +| a plain comment line (0 actions on both) | 1.12 – 1.32 ms | **3.18 – 3.84 ms** | **2.9×** | +| `aes` in `tb.sv` (1 action at 0.49, 0 at 0.43) | 4.0 – 4.9 ms | **7.9 – 9.8 ms** | 2.0× | +| `aes_reg_top` in `aes.sv` (2 actions at 0.49, 0 at 0.43) | 14.2 – 15.2 ms | **21.8 – 23.5 ms** | 1.5× | +| pipelined `definition` behind the `aes` codeAction (§3) | 3.3 – 7.3 ms | **11.2 – 15.9 ms** | 2.2× | + +**Why it matters.** `codeAction` fires on every cursor move, and every request +behind it in the serial queue pays its bill (§3). At 0.43.0 a cursor move cost +the queue 3–7 ms; at 0.49.0 it costs 11–16 ms. Still inside a 16 ms frame, but +the margin is gone, and this is a request the user never asked for. + +**The mechanism, as far as this round can see it without bisecting.** The +comment-line row is the cleanest evidence: **zero** actions are offered on +either binary, so the extra 2 ms is not the cost of producing an offer. It is +the cost of the new offers' *gates* — `vlog_refactor::inline_site` and +`extract_site` each run a tolerant parse of the cursor's buffer +(`crates/vlog_refactor/src/inline/mod.rs:73`, +`crates/lucisv_server/src/inline_module.rs:50`) — asked on every cursor move. +Not bisected; candidates are §52, §53.1 and §53.2, which are the three that +added a gate. + +**Reproduce.** `bench.py codeaction`, then read the `comment line, lazy` rows +for the two labels; or `bench.py probe --probe hw/ip/aes/dv/tb/tb.sv:43:2`. +Workspace scope, warm store, `tb.sv` open, four tries. The `--verbose` +server's own line agrees with the wire to 0.5 ms (§0), so this is server work. + +**A cheap direction, if a future round wants one:** the two gates parse the +same buffer the server already has parsed for diagnostics and symbols. Take 3 +made the same observation about the port offer, and §37.1's answer — do not +compute what nobody asked for — is the shape that worked. + +### 8.2b REPORTED, not filed — the eager `codeAction` path is ~2× dearer + +The eager path (a client without +`codeAction.resolveSupport.properties: ["edit"]` — Vim/Neovim setups and +simple clients) is **1.95–2.07× slower at 0.49.0 than 0.43.0** at every +fan-out above 1: 46 → 90 ms at 6 files, 125 → 255 at 42, 192 → 368 at 67, +243 → 473 at 128 (§6a). Take 3 filed the earlier 1.37× step as its §8.2; **the +owner ruled the eager path a non-hot path on 2026-09-05**, so take 4 reports +the number and does not re-file it. Two facts for whoever reads it next: it +now crosses half a second at the largest fan-out, and the resolve at the one +offering cursor moved with it (110 → 159 ms, §6c), which the *lazy* client +pays too — but only on a click. + +### 8.3 FINDING (low–medium) — §49's tail rename is 11× a same-file rename + +**What.** Renaming a variable that a hierarchical tail names from another file +costs **793.2 / 750.7–751.9 ms at 0.49.0** against **88.0 / 65.8–66.7 ms at +0.43.0**, for one extra edited file. + +**Reproduce.** `bench.py tailrename`. `textDocument/rename` on `state_q` at +`hw/ip/entropy_src/rtl/entropy_src_main_sm.sv` 0-based 41:19, newName +anything, workspace scope, warm store, with +`hw/ip/entropy_src/rtl/entropy_src_core.sv` also open. 0.43.0 returns 1 file +and warns about the tail; 0.49.0 returns 2 files and edits it. The edits are +discarded. + +**Why it is filed and not credited.** The correctness is unambiguously right — +§49's whole point is that the old answer handed back a design that no longer +elaborates — and a rename is user-initiated and rare. But 0.75 s freezes the +single-threaded queue for three quarters of a second on an F2-shaped gesture, +and everything behind it waits (§3). Compare the ordinary `rename` on `aes`, +which edits **nine** files in 133–139 ms: the tail rename edits **two** in +751 ms, so this is not "more files", it is a different and much more expensive +lookup. `completion` on the same surface is *free* (§6e), which suggests the +cost is in rename's reference walk rather than in the surface itself. + +**Not bisected.** The candidate is §49's hierarchical member walk in +`workspace/record.rs` / `resolve.rs::head_surface`. + +### 8.4 FINDING (low) — `check --select error,warning,style` is 1.27× slower, beyond the new rule's own work + +`hw/ip`: 0.45 → 0.57 s (mean of three); `hw/vendor` 0.09 → 0.11; +`hw/dv` 0.07 → 0.08. 0.49.0 does find 20 more violations (§7a), all from +0.48.0's `unused-import`, so **some** of this is honest extra work — but 20 +extra findings across 2 554 files is not obviously 120 ms of work on `hw/ip`, +and `check` with the *default* rules did not move at all (0.41 → 0.37 s), so +the whole difference sits in the Style class. Take 3's §8.5 asked whether its +6–10% would keep accumulating; on the default path the answer is **no**, and +on the Style path it is **yes, once, when a rule was added**. Not bisected. +120 ms on the largest tree in opentitan is not a user-visible cost; filed so +the next round can see whether adding the *next* Style rule costs the same +again. + +**Reproduce.** `tools/perf/sweep.sh