Perf take 4 (§58): 0.49.0 vs 0.43.0 on opentitan — §46's didOpen fix 14× in the release build, the eager codeAction path 2×, the tail rename at 11×, the index +14%; harness committed in tools/perf/; findings filed for loop 3
ci / checks (push) Successful in 59s
ci / corpus (push) Successful in 33s

This commit is contained in:
lucio committed 2026-09-07 04:01:29 -05:00
1 parent 414d501847
commit d10e57aa6e
19 files changed
+2999 -9

No files matched your search

+19 -9
View File
@@ -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
+355
View File
@@ -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: <method> answered in <n> 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 <path> --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.
+85
View File
@@ -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.
+968
View File
@@ -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: <method> answered in <n> 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*<module>( |#|$)' --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
``<file>:<line>:<col>: 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 <binary> <label> <opentitan> <outdir> 3`,
then `sweeptable.py <outdir>`; read the `hw/ip` / `check --select …` row.
### 8.5 FINDING (low) — two hierarchical tails on this corpus do not resolve
`hw/top_earlgrey/ip_autogen/pwrmgr/rtl/pwrmgr.sv` 178:10 (`u_fsm.state_q`,
inside a `` ` ``-macro assertion argument) and
`hw/top_earlgrey/ip_autogen/pinmux/rtl/pinmux.sv` 687:40 (`u_reg.intg_err`)
are both instance-head tails whose head is instantiated in the same file and
whose target is declared in another. Neither is edited by a rename at
0.49.0, and `completion` after `u_reg.` at the second returns **0 items**.
§49's README rules a *generate-block-scoped* tail an honest refusal and pins
it with a test; neither of these is that shape. This is filed as a question,
not an assertion of a defect: a future round (or §49's author) should say
which of the two rules applies, so the refusal is documented rather than
observed.
**Reproduce.** `bench.py probe` is for `codeAction`; for these, issue
`textDocument/rename` at the declaration
(`pwrmgr_fsm.sv` 109:28 for the first) with both files open at workspace
scope, and read the edit set.
### 8.6 WATCH — the index is 14% bigger, on disk and resident
39.0 → 44.3 MB on disk, 482 → 542 MB resident cold (+12.6%), 509 → 586 MB warm (+15.1%) (§6e).
Proportionate to what `FACTS_FORMAT` 18 → 19 added and consistent across the
two measures, so not a leak. Recorded because half a gigabyte is what an
editor session on this design now holds, and because a fifth round should see
whether the next format bump costs another 14%.
### 8.7 STILL SLOW — the cold workspace scan at ~2.7 s
2 640–2 712 ms across both binaries, essentially unmoved across four takes
(3 003 → 2 958 → 2 767 → 2 676 mean) and still the largest absolute number in
the document. Once per session per cold cache; never any round's target.
### 8.8 CLOSED — take 3's findings, one by one
| Take 3 finding | Status at 0.49.0 |
|---|---|
| §8.2 eager `codeAction` 1.37× slower than take 2 | **Superseded.** Another 1.95–2.07× on top, but the path was ruled non-hot; reported as §8.2b |
| §8.3 `rename` ~1.4× slower in absolute terms | **Still true, still flat.** 133–139 ms at both binaries, 9 files, ~15 ms per edited file |
| §8.4 `didOpen` of an in-scope file delays the next request 21–51 ms | **CLOSED — fixed by §46**, measured in the release build at §5c |
| §8.5 `check` 6–10% slower than 0.39.0 | **Partly closed.** Default rules stopped accumulating (§7); the Style class took one more step when a rule was added (§8.4) |
| §8.6 `workspace/symbol` keeps drifting up | **Not readable this round.** 8.7–12.7 ms at 0.49.0 and 8.2–13.3 at 0.43.0 — the two binaries' bands overlap almost entirely, and both are above take 3's 7.2–7.9 on a busier machine. No conclusion |
| §8.7 the port refactorings are offered at 1 of 205 RTL files | **Still 1 of 205 for the *port* refactorings** — the same `aes_wrap.sv` 78:2. But §6b's census now finds `extract` at 89% of positions and `inline` at 11%, so "the lightbulb is almost never lit" is no longer the corpus's shape |
| §8.8 the cold workspace scan at ~2.8 s | **Unchanged.** §8.7 above |
### 8.9 Movements inside the noise, listed and dismissed
Every sub-millisecond navigation row: `definition` (0.87 → 0.47 first),
`hover` (0.26 → 0.86), `typeDefinition` (0.46 → 0.67), `documentHighlight`
(0.19 → 0.61), `foldingRange` (0.44 → 0.73), `codeLens` (0.47 → 0.23),
`documentLink` (0.49 → 1.09), `selectionRange` (0.95 → 1.79),
`semanticTokens/full` (1.03 → 0.39), `documentSymbol` (0.69 → 0.61),
`diagnostic` (1.02 → 0.93), `prepareRename` (0.37 → 0.71), the `didChange`
flush (2.32 → 1.79), `inlayHint` (1.90 → 2.04), `references` on `aes`
(2.80 → 0.92) and on `.clk_i` (1.54 → 1.65), `signatureHelp` (2.49 → 3.06),
`workspace/symbol` (both bands overlapping), the diagnostics publish
(164.0 → 164.5), and every `scan` cell.
**Every one of these sits on a transport floor that measured 0.04–0.17 ms on
one binary and 0.09–0.63 ms on the other, minutes apart, on the same machine
(§0).** They move in both directions with no pattern, their result counts are
identical on both binaries (§4b), and take 3 measured the *same* 0.43.0 binary
at a third set of values. **No conclusion should be drawn from any of them.**
---
## 9. Methodology and caveats — read before quoting any number
Take 1's, take 2's and take 3's caveats still apply. The take-4-specific ones:
- **Three tries per row, first try and repeat range both reported.** "First"
is the request issued as the first real request of a dedicated session,
after the scan settled; "repeats" is the 2nd–4th identical request in that
same session. Where a row needed its own session (`codeAction`, `rename`,
the tail rename, each fan-out cursor, each scope/cache cell, each widen
cell) it got one — and where a phase is a once-per-session event (the scan,
the widen, the `didOpen` delay, RSS) each try is a **fresh server process**.
- **The comparison is binary-to-binary, on one night, with one client.**
0.49.0 is the tree's own `target/release/lucisv-server` at `4c2dae3`,
verified current against the last change under `crates/` — **no `cargo
build` ran for it**. 0.43.0 was built for this round from the `v0.43.0` tag
in a scratch `git worktree` under the scratchpad, and the worktree was
removed before this document was finished. The main tree was never checked
out, reset or stashed.
- **Machine state, and it is the biggest caveat in this document.** Apple M1
Max, 10 cores, 64 GB, macOS 27.0 (26A5425a). **This machine runs a live
desktop session**, and throughout the round WindowServer sat at 45–51% of a
core, loginwindow at 24–29%, with a wallpaper extension and two consumer
apps at 8–11% each. **Load average was 3.7–7.1** for every phase; take 3
measured at 2–4. Nothing unrelated to the desktop was burning CPU — no
`rustc`, no build, no other agent — so the round proceeded rather than
waiting, and the mitigation is structural: **both binaries were measured in
the same window, alternating within the hour, with the same client.** Every
comparison in §2–§7 is 0.49.0 against tonight's 0.43.0; take 3's column is
context, never a conclusion. The load average was recorded before and after
every phase.
- **No `cargo` command ran in any tree while a timed measurement was
running.** The one `cargo build` (the 0.43.0 worktree) finished 20 minutes
before the first timed run.
- **The guard.** Every server session, every `lucisv` invocation and the one
`cargo build` went through `tools/guard.sh -m 8 -t 1800`. **No guard kill
occurred**, and the largest resident set anything reached was 588 MB
(`lucisv-server` after a warm workspace scan), 7% of the 8 GB limit; the
largest a CLI run reached was 238 MB.
- **The opentitan checkout was never written.**
`git -C /Users/guoliangchen/repo/opentitan status --porcelain` was checked
after every phase and reported the same three pre-existing modified files
throughout: `hw/ip/aes/dv/tb/tb.sv`,
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`.
`rename`, `codeAction/resolve` and the refactoring resolves all return
edits; the client discarded every one. The formatter cache was directed to a
scratch `--cache-dir` and the index cache to a scratch
`initializationOptions.storagePath`; neither default lands inside the corpus,
and both were overridden anyway.
- **Tolerances.** Sub-millisecond rows: **±0.5 ms**, and nothing under that is
read (§0 measured a 0.04→0.63 ms floor swing between two sessions of the
same client). Rows of 1–20 ms: **±20%**. Rows of 20–500 ms: **±10%**.
Multi-second rows: **±5%** (the six warm workspace scans span 118 ms across
two binaries, 10%; the six cold ones span 72 ms, 2.7%). Take 3's tolerances
were tighter on every band because its machine was quieter; a number here
that differs from take 3's by less than these bands has not moved.
- **Item and result counts are reported beside every timing** where the answer
could have changed size, and every one of them is identical on the two
binaries except the two the document names (`completion` after an instance
head: 24 → 26 items; the tail rename: 1 → 2 files).
- **The fan-out counts in §6a are `grep`-derived**
(`grep -rlE '^\s*<module>( |#|$)'` over `*.sv`), reproducing take 2's and
take 3's counts exactly (1 / 6 / 42 / 67 / 128).
- **The offer sites in §6b/§6c were found, not chosen.** Every position was
discovered by sweeping `codeAction` over candidate lines and keeping what
actually offered; the two sites this document reports as *not* offering
(§8.5) are the two candidates that failed, kept rather than dropped.
- **`--select error,warning,style` is not "all rules"** — it is the three rule
classes by name, which is what §58 asked for.
- **Page cache is hot and hotter than ever** — opentitan has now been walked
by four measurement rounds plus tonight's outcome sweeps. "Cold cache"
means *lucisv's* store was deleted, not that the OS file cache was dropped.
- **No code in the lucisv repo was modified for this round** except the
creation of `tools/perf/`, this file,
`docs/features/performance-take4/README.md`, the `docs/perf/README.md`
entry and §58's ticks in `TODO.md`. No Rust source was touched.
---
## 10. Raw logs, and where the harness lives
**The harness is committed**: `tools/perf/` — `lspclient.py`, `sites.py`,
`harness.py`, `bench.py`, `phases_new.py`, `sweep.sh`, `sweeptable.py`,
`outcomes.sh`, `README.md`. Python 3 standard library only; runs from a clean
checkout given an opentitan path and the binaries. `tools/perf/README.md` says
how to run each phase. **Take 5 reuses it rather than reimplementing it from
this document's prose.**
The Python was split after the measurements were taken (`bench.py` had reached
537 production lines), so **every phase was re-run through the split files and
ten rows re-checked against this document within §9's tolerances** — all
inside. That verification run is in the raw logs as `verify.jsonl`, labelled
`verify-0.49.0`; the feature README lists the ten rows and both readings.
The raw measurements are under
`…/7b09ba01-…/scratchpad/`, and `results.jsonl` is additionally copied to
`~/.cache/lucisv-perf/take4/results.jsonl` so it survives the scratchpad.
| File | What |
|---|---|
| `verify.jsonl` | the post-split re-run of every phase, label `verify-0.49.0` (§10 above) |
| `results.jsonl` | every LSP row, machine-readable: `phase`, `label`, `row`, `ms` (try list), `n`, `titles`, `note`. **Every LSP number in this document is in this file.** Copy at `~/.cache/lucisv-perf/take4/` |
| `logs/lsp-0.49.0.log`, `logs/lsp-0.43.0.log` | the phase transcripts, in order |
| `logs/lsp-0.49.0-machine.txt`, `logs/lsp-0.43.0-machine.txt` | `uptime` and the top CPU processes, before and after the LSP phases |
| `logs/sweep-machine.txt`, `logs/outcomes-load-{before,after}.txt` | the same for the CLI phases |
| `sweep/<label>__<tree>__<command>__<cache>.txt` | §7 — the three tries' `/usr/bin/time -l` blocks per cell, 60 files |
| `logs/sweeptable.txt` | §7's rendered table and the summary line each cell reported |
| `outcomes/<label>.{format,check,check-select}.txt` | §7a — the per-file outcome listings for all three binaries; the diff in §7a is `diff outcomes/0.43.0.* outcomes/0.49.0.*` |
| `logs/census-0.49.0.txt` | §6b — the 205-file, 2 440-position offer census |
| `caches/` | the scratch `storagePath` stores and the scratch formatter `--cache-dir`; nothing here is inside the corpus |
+104
View File
@@ -0,0 +1,104 @@
# `tools/perf` — the lucisv performance harness
Take 1's, take 2's and take 3's measurement 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*. This directory is the fix. Everything a performance round
needs is here, in Python 3 with **no third-party packages**, so it runs from a
clean checkout given an opentitan path and a pair of binaries.
Written for take 4 (`docs/performance_take4.md`, TODO §58). Take 5 reuses it.
| File | What it is |
|---|---|
| `lspclient.py` | framed JSON-RPC over a `lucisv-server` child process: the `workspace/configuration` pull answered per session, per-session client capabilities (with and without `codeAction.resolveSupport`), `storagePath` cache control, `window/logMessage` capture including a `--verbose` server's own `timing:` lines |
| `sites.py` | every opentitan position a phase measures, named by the *text* it wants rather than a line number |
| `harness.py` | what every phase shares: the registry, the run's configuration, the session factory, the recorder |
| `bench.py` | the command line, and the phases that reproduce take 3's tables |
| `phases_new.py` | the phases for what 0.44–0.49 added: the new offer sites, §49's surface, §46's `didOpen` fix, `moduleHierarchy`, index size and RSS |
| `sweep.sh` | the timed CLI sweeps (`format --check`, `check`) over five trees, `/usr/bin/time -l` |
| `sweeptable.py` | those logs → the document's §7 Markdown table |
| `outcomes.sh` | the untimed per-file outcome runs, for the release-to-release outcome diff |
## The rules every run obeys
- **Everything goes through the guard.** `tools/guard.sh -m 8 -t 1800 --
<command>` wraps every server session, every `lucisv` invocation and every
`cargo` build. `sweep.sh` and `outcomes.sh` wrap their own children; wrap
`bench.py` yourself. A guard kill is a finding — report the command and the
limit, never raise it.
- **The corpus is read-only.** The formatter cache goes to a scratch
`--cache-dir`, the index cache to a scratch `storagePath`
(`bench.py --storage`), and every edit a request returns (`rename`,
`codeAction/resolve`) is discarded by the client. Check
`git -C <opentitan> status --porcelain` after every phase.
- **No `cargo` command runs anywhere while a timed phase is running**, and the
machine's load average is noted before and after each phase.
- **Three tries per row**, first try and repeat range both reported.
## Running a phase
```sh
SP=/tmp/perf # scratch: caches, logs, results.jsonl
OT=$HOME/repo/opentitan
tools/guard.sh -m 8 -t 1800 -- python3 tools/perf/bench.py nav \
--server target/release/lucisv-server \
--label 0.49.0 --opentitan "$OT" \
--storage "$SP/caches/0.49.0" --out "$SP/results.jsonl" --tries 3
```
Every phase takes the same arguments. `--label` is what tells two binaries
apart in `results.jsonl`; run each phase once per binary.
| Phase | Document section | What it does |
|---|---|---|
| `baseline` | §0 | `initialize`, and the transport floor (`$/lucisvNoSuchMethod`, rejected without work) |
| `verbose` | §0 | four `codeAction` shapes, each with and without `--verbose`, so the server's own `timing:` line sits beside the wire |
| `scan` | §4 | the (scope × cache state) startup matrix: `default`, `{"index":{}}`, `scopeDepth 0`, `workspace`, cold and warm |
| `scopes` | §4b | what each scope *answers* at the `aes` instantiation — counts, not just times |
| `nav` | §2 | the cheap per-cursor requests at workspace scope, one dedicated session each |
| `flush` | §2 | the `didChange` flush, measured with a `foldingRange` barrier |
| `codeaction` | §6a | the five fan-out cursors (1 / 6 / 42 / 67 / 128 files), lazy and eager |
| `portaction` | §6 | the one opentitan cursor that offers a port refactoring: offer and `codeAction/resolve` |
| `refactor` | §6b | the offer sites 0.44–0.49 added — expand `.*`, organize imports, inline module, port actions, and an ANSI header as the contrast — plus the extract-module *selection* |
| `rename` | §6c | `prepareRename` and `rename` on `aes` |
| `tailrename` | §6c | §49's hierarchical tail: a variable renamed at its declaration, named through an instance from another file |
| `blockers` | §3 | the queue-blocking analysis: a slow leader, then the three requests an editor fires on every cursor move |
| `widen` | §5 | the `didOpen` widen at `scopeDepth 0` and at the default scope, cold and warm |
| `didopen` | §5/§46 | `didOpen` → the request behind it, workspace scope, the four files the perf README's 2026-09-05 table used |
| `diagnostics` | §2 | the publish after a `didChange` (≈150 ms of it is the debounce) |
| `completion` | §6d | the typed-prefix curve |
| `tailcompletion` | §6d | completion after an instance head and a `.` |
| `hierarchy` | §6 | `lucisv/moduleHierarchy`, the snapshot the DUT sidebar consumes |
| `rss` | §6 | server RSS after the workspace scan, and the index store's size on disk |
| `probe` | — | ad-hoc: `--probe FILE:LINE:CHAR` (0-based) prints what a cursor offers. This is how `sites.REFACTOR_SITES` was found |
## The CLI sweeps
```sh
tools/perf/sweep.sh ~/.cache/lucisv-baselines/lucisv-0.49.0 0.49.0 "$OT" "$SP/sweep" 3
python3 tools/perf/sweeptable.py "$SP/sweep" --labels 0.49.0,0.43.0,0.39.0
```
`sweep.sh` writes one log per (label, tree, command, cache state) holding the
three tries' `/usr/bin/time -l` blocks; `sweeptable.py` reads them all and
prints the table plus the summary line each run reported, so a timing that
moved because the *work* moved is not mistaken for a timing change.
## The outcome diff
```sh
tools/perf/outcomes.sh ~/.cache/lucisv-baselines/lucisv-0.43.0 0.43.0 "$OT" "$SP/outcomes"
tools/perf/outcomes.sh ~/.cache/lucisv-baselines/lucisv-0.49.0 0.49.0 "$OT" "$SP/outcomes"
diff "$SP/outcomes/0.43.0.format.txt" "$SP/outcomes/0.49.0.format.txt"
```
Untimed, `--no-cache`, paths rewritten relative to the corpus root and sorted,
so two runs differ only where a per-file *outcome* did. Every difference is
either explained by a TODO section or is a finding.
## `results.jsonl`
One JSON object per row: `phase`, `label`, `row`, `ms` (the try list, first
try first), and whatever else the phase knows — `n` (a result count, a file
count, a byte count), `titles`, `note`. Nothing in the document may quote a
number that is not in this file or in a `sweep.sh` / `outcomes.sh` log.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+436
View File
@@ -0,0 +1,436 @@
#!/usr/bin/env python3
"""The lucisv LSP performance phases — take 3's request table.
python3 tools/perf/bench.py <phase> --server <path> --label <name> \
--opentitan DIR --storage DIR --out results.jsonl [--tries N]
Every phase opens its own `lucisv-server` sessions, times requests on the wire
with `time.perf_counter`, and appends one JSON object per row to
`results.jsonl`. Nothing is ever written into the corpus: the index cache is
directed at `--storage`, and every edit a request returns (`rename`,
`codeAction/resolve`) is discarded.
This file holds the phases that reproduce `docs/performance_take3.md`'s
tables; `phases_new.py` holds the phases for what 0.44–0.49 added, and
`harness.py` holds what both share. Run every invocation under
`tools/guard.sh -m 8 -t 1800 --`; see `tools/perf/README.md`.
"""
import argparse
import json
import os
import sys
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import harness # noqa: E402
import sites # noqa: E402
from harness import ( # noqa: E402
ARGS, at, code_action_params, doc, phase, pos, record, result_count,
session, settled, tries,
)
import phases_new # noqa: E402,F401 — registers its own phases
# =========================================================================
# §0 — the transport baseline and the `--verbose` cross-check
# =========================================================================
@phase("baseline")
def phase_baseline():
with session("workspace") as s:
init = s.initialize()
record(phase="baseline", row="initialize", ms=[init])
s.did_open(sites.path(sites.TB))
s.wait_quiet(1.5)
s.take_notifications()
ms = tries(s, "$/lucisvNoSuchMethod", {}, 4)
record(phase="baseline", row="transport baseline ($/lucisvNoSuchMethod)", ms=ms)
@phase("verbose")
def phase_verbose():
"""The wire beside the server's own `timing:` line, three shapes (§0)."""
shapes = [
("prim_flop_2sync (128), eager", False, sites.AON_TIMER, "prim_flop_2sync #(", 2),
("prim_flop_2sync (128), lazy", True, sites.AON_TIMER, "prim_flop_2sync #(", 2),
("aes (6), eager", False, sites.TB, " aes #(", 2),
("comment line", True, sites.TB, "// ", 2),
]
for label, lazy, relative, needle, offset in shapes:
for verbose in (False, True):
with session("workspace", resolve_support=lazy, verbose=verbose) as s:
settled(s)
s.did_open(sites.path(relative))
s.wait_quiet(0.6)
s.take_notifications()
s.take_timings()
params = at(relative, needle, 1, offset)
params["range"] = {"start": params.pop("position"), "end": None}
params["range"]["end"] = params["range"]["start"]
params["context"] = {"diagnostics": []}
ms = tries(s, "textDocument/codeAction", params, 4)
server_ms = [t[1] for t in s.take_timings("textDocument/codeAction")]
record(phase="verbose", row=label, ms=ms,
note="verbose" if verbose else "quiet",
server_ms=server_ms)
# =========================================================================
# §4 — startup and scan, per scope config and cache state
# =========================================================================
@phase("scan")
def phase_scan():
"""§4 — one cell per (scope, cache state), `--tries` runs each.
"Cold" wipes the `storagePath` directory immediately before each run;
"warm" leaves the previous run's store in place. The barrier is 1.5 s of
silence after the `didOpen`, not the `$/progress` `end`, because the end
report is followed by more indexing chatter.
"""
for scope in ("default", "empty-index", "depth0", "workspace"):
for cache in ("cold", "warm"):
runs, note = [], ""
for _ in range(ARGS.tries):
cold = cache == "cold"
with session(scope, cold=cold, storage_name="scan-" + scope) as s:
s.initialize()
started = time.perf_counter()
s.did_open(sites.path(sites.TB))
s.wait_quiet(1.5)
runs.append((time.perf_counter() - started) * 1000.0 - 1500.0)
ends = [
n["params"]["value"].get("message", "")
for n in s.notifications
if n["method"] == "$/progress"
and n["params"]["value"].get("kind") == "end"
]
note = " | ".join(ends[-2:])
record(phase="scan", row="%s, %s cache" % (scope, cache), ms=runs, note=note)
@phase("scopes")
def phase_scopes():
"""§4b — what each scope answers at the `aes` instantiation in `tb.sv`."""
asks = [
("definition", "textDocument/definition", {}),
("typeDefinition", "textDocument/typeDefinition", {}),
("hover", "textDocument/hover", {}),
("references", "textDocument/references", {"context": {"includeDeclaration": True}}),
("documentHighlight", "textDocument/documentHighlight", {}),
("signatureHelp", "textDocument/signatureHelp", {}),
]
for scope in ("default", "depth0", "workspace"):
with session(scope, storage_name="scopes-" + scope) as s:
settled(s)
for name, method, extra in asks:
params = dict(at(sites.TB, " aes #(", 1, 2))
params.update(extra)
ms = tries(s, method, params)
_, message = s.request(method, params)
record(phase="scopes", row="%s @ %s" % (name, scope), ms=ms,
n=result_count(message))
ms = tries(s, "workspace/symbol", {"query": "aes"})
_, message = s.request("workspace/symbol", {"query": "aes"})
record(phase="scopes", row="workspace/symbol 'aes' @ %s" % scope, ms=ms,
n=result_count(message))
hint = {"textDocument": doc(sites.TB),
"range": {"start": {"line": 0, "character": 0},
"end": {"line": 9999, "character": 0}}}
ms = tries(s, "textDocument/inlayHint", hint)
_, message = s.request("textDocument/inlayHint", hint)
record(phase="scopes", row="inlayHint @ %s" % scope, ms=ms,
n=result_count(message))
# =========================================================================
# §2 — the navigation table at workspace scope
# =========================================================================
@phase("nav")
def phase_nav():
rows = [
("definition on aes", "textDocument/definition", at(sites.TB, " aes #(", 1, 2)),
("hover on aes", "textDocument/hover", at(sites.TB, " aes #(", 1, 2)),
("typeDefinition on aes", "textDocument/typeDefinition", at(sites.TB, " aes #(", 1, 2)),
("documentHighlight", "textDocument/documentHighlight", at(sites.TB, " aes #(", 1, 2)),
("references on aes", "textDocument/references",
dict(at(sites.TB, " aes #(", 1, 2), context={"includeDeclaration": True})),
("references on .clk_i", "textDocument/references",
dict(at(sites.TB, " .clk_i", 1, 5), context={"includeDeclaration": True})),
("signatureHelp in the port list", "textDocument/signatureHelp",
at(sites.TB, " .clk_i", 1, 22)),
("documentSymbol", "textDocument/documentSymbol", {"textDocument": doc(sites.TB)}),
("foldingRange", "textDocument/foldingRange", {"textDocument": doc(sites.TB)}),
("codeLens", "textDocument/codeLens", {"textDocument": doc(sites.TB)}),
("documentLink", "textDocument/documentLink", {"textDocument": doc(sites.TB)}),
("selectionRange", "textDocument/selectionRange",
{"textDocument": doc(sites.TB), "positions": [pos(sites.TB, " aes #(", 1, 2)]}),
("semanticTokens/full", "textDocument/semanticTokens/full",
{"textDocument": doc(sites.TB)}),
("inlayHint (whole file)", "textDocument/inlayHint",
{"textDocument": doc(sites.TB),
"range": {"start": {"line": 0, "character": 0},
"end": {"line": 9999, "character": 0}}}),
("diagnostic (pull)", "textDocument/diagnostic", {"textDocument": doc(sites.TB)}),
("workspace/symbol 'aes'", "workspace/symbol", {"query": "aes"}),
]
for row, method, params in rows:
with session("workspace") as s:
settled(s)
ms = tries(s, method, params, ARGS.tries + 1)
_, message = s.request(method, params)
record(phase="nav", row=row, ms=ms, n=result_count(message), method=method)
@phase("flush")
def phase_flush():
"""The `didChange` flush, measured with a `foldingRange` barrier."""
with session("workspace") as s:
settled(s)
text = open(sites.path(sites.TB), encoding="utf-8", errors="replace").read()
runs = []
for version in range(2, 2 + ARGS.tries + 1):
s.did_change(sites.path(sites.TB), text + "\n// take4 %d\n" % version, version)
runs.append(s.ms("textDocument/foldingRange", {"textDocument": doc(sites.TB)}))
record(phase="flush", row="didChange flush (foldingRange barrier)", ms=runs)
# =========================================================================
# §6 — codeAction, offer and resolve
# =========================================================================
@phase("codeaction")
def phase_codeaction():
for lazy in (True, False):
for label, relative, needle, occurrence, fanout, offset in sites.FANOUT_CURSORS:
with session("workspace", resolve_support=lazy) as s:
settled(s)
if relative != sites.TB:
s.did_open(sites.path(relative))
s.wait_quiet(0.6)
s.take_notifications()
params = code_action_params(relative, needle, occurrence, offset)
ms = tries(s, "textDocument/codeAction", params, ARGS.tries + 1)
_, message = s.request("textDocument/codeAction", params)
record(phase="codeaction",
row="%s (fan-out %d), %s" % (label, fanout, "lazy" if lazy else "eager"),
ms=ms, n=result_count(message),
titles=[a.get("title") for a in (message.get("result") or [])])
with session("workspace", resolve_support=lazy) as s:
settled(s)
params = code_action_params(sites.TB, " // ", 1, 2)
ms = tries(s, "textDocument/codeAction", params, ARGS.tries + 1)
_, message = s.request("textDocument/codeAction", params)
record(phase="codeaction", row="comment line, %s" % ("lazy" if lazy else "eager"),
ms=ms, n=result_count(message))
@phase("portaction")
def phase_portaction():
"""The one opentitan cursor that offers a port refactoring: offer + resolve."""
for lazy in (True, False):
with session("workspace", resolve_support=lazy) as s:
settled(s)
s.did_open(sites.path(sites.AES_WRAP))
s.wait_quiet(0.6)
s.take_notifications()
params = code_action_params(sites.AES_WRAP, " aes #(", 1, 2)
ms = tries(s, "textDocument/codeAction", params, ARGS.tries + 1)
_, message = s.request("textDocument/codeAction", params)
offered = message.get("result") or []
record(phase="portaction",
row="aes_wrap.sv offer, %s" % ("lazy" if lazy else "eager"),
ms=ms, n=len(offered),
titles=[a.get("title") for a in offered],
has_edit=[("edit" in a) for a in offered])
if lazy and offered:
resolves = [s.ms("codeAction/resolve", offered[0])
for _ in range(ARGS.tries + 1)]
_, resolved = s.request("codeAction/resolve", offered[0])
edit = (resolved.get("result") or {}).get("edit") or {}
files = edit.get("changes") or {u: 1 for u in
(c.get("textDocument", {}).get("uri")
for c in edit.get("documentChanges") or [])}
record(phase="portaction", row="aes_wrap.sv codeAction/resolve", ms=resolves,
n=len(files), titles=[(resolved.get("result") or {}).get("title")])
# =========================================================================
# §6c / §49 — rename, and the hierarchical tail
# =========================================================================
@phase("rename")
def phase_rename():
with session("workspace") as s:
settled(s)
where = at(sites.TB, " aes #(", 1, 2)
ms = tries(s, "textDocument/prepareRename", where, ARGS.tries + 1)
_, message = s.request("textDocument/prepareRename", where)
record(phase="rename", row="prepareRename on aes", ms=ms,
note=json.dumps(message.get("result")))
params = dict(where, newName="aes_renamed")
ms = tries(s, "textDocument/rename", params, ARGS.tries + 1)
_, message = s.request("textDocument/rename", params)
record(phase="rename", row="rename aes -> aes_renamed", ms=ms,
n=len(phases_new.edited_uris(message)))
@phase("blockers")
def phase_blockers():
leaders = [
("codeAction on the aes token", "textDocument/codeAction",
lambda: code_action_params(sites.TB, " aes #(", 1, 2)),
("prepareRename on aes", "textDocument/prepareRename",
lambda: at(sites.TB, " aes #(", 1, 2)),
("rename on aes", "textDocument/rename",
lambda: dict(at(sites.TB, " aes #(", 1, 2), newName="aes_renamed")),
("workspace/symbol 'aes'", "workspace/symbol", lambda: {"query": "aes"}),
]
followers = [
("definition", "textDocument/definition", lambda: at(sites.TB, " aes #(", 1, 2)),
("hover", "textDocument/hover", lambda: at(sites.TB, " aes #(", 1, 2)),
("documentSymbol", "textDocument/documentSymbol",
lambda: {"textDocument": doc(sites.TB)}),
]
for row, method, make in leaders:
own, behind = [], []
for _ in range(ARGS.tries):
with session("workspace") as s:
settled(s)
lead = s.send(method, make())
ids = [(name, s.send(m, mk())) for name, m, mk in followers]
own.append(s.await_id(lead)[0])
behind.append([(name, s.await_id(rid)[0]) for name, rid in ids])
record(phase="blockers", row=row, ms=own,
note=" | ".join("; ".join("%s %.2f" % (n, v) for n, v in one)
for one in behind))
# =========================================================================
# §5 / §46 — the didOpen widen, and the didOpen delay
# =========================================================================
@phase("widen")
def phase_widen():
"""§5 — a `didOpen` that may widen the scope, then the request behind it.
One session per (scope, cache, try): the widen is a once-per-session event,
so a second try inside the same session would measure nothing.
"""
for scope in ("depth0", "default"):
for cache in ("cold", "warm"):
runs = {relative: [] for relative in sites.WIDEN_FILES}
seconds = {relative: [] for relative in sites.WIDEN_FILES}
for _ in range(ARGS.tries):
with session(scope, cold=(cache == "cold"),
storage_name="widen-" + scope) as s:
settled(s)
for relative in sites.WIDEN_FILES:
started = time.perf_counter()
s.did_open(sites.path(relative))
s.ms("textDocument/definition", at(relative, "module ", 1, 0))
runs[relative].append((time.perf_counter() - started) * 1000.0)
seconds[relative].append(
s.ms("textDocument/definition", at(relative, "module ", 1, 0)))
s.wait_quiet(0.5)
s.take_notifications()
for relative in sites.WIDEN_FILES:
record(phase="widen",
row="%s @ %s, %s" % (os.path.basename(relative), scope, cache),
ms=runs[relative],
note="second definition " + " / ".join(
"%.2f" % v for v in seconds[relative]))
# =========================================================================
# diagnostics, completion, hierarchy, RSS
# =========================================================================
@phase("diagnostics")
def phase_diagnostics():
with session("workspace") as s:
settled(s)
text = open(sites.path(sites.TB), encoding="utf-8", errors="replace").read()
runs = []
for version in range(2, 2 + ARGS.tries + 1):
s.take_notifications()
started = time.perf_counter()
s.did_change(sites.path(sites.TB), text + "\n// take4 %d\n" % version, version)
while True:
s.drain()
if any(n["method"] == "textDocument/publishDiagnostics"
for n in s.notifications):
break
if time.perf_counter() - started > 30:
raise TimeoutError("no diagnostics published")
time.sleep(0.001)
runs.append((time.perf_counter() - started) * 1000.0)
record(phase="diagnostics", row="publish after didChange (incl. ~150 ms debounce)",
ms=runs)
@phase("completion")
def phase_completion():
with session("workspace") as s:
settled(s)
text = open(sites.path(sites.TB), encoding="utf-8", errors="replace").read()
base = text.rstrip("\n")
for version, prefix in enumerate(sites.COMPLETION_PREFIXES, start=2):
body = base + "\n" + prefix + "\n"
s.did_change(sites.path(sites.TB), body, version)
where = {"textDocument": doc(sites.TB),
"position": {"line": body.count("\n") - 1, "character": len(prefix)}}
ms = tries(s, "textDocument/completion", where, ARGS.tries + 1)
_, message = s.request("textDocument/completion", where)
record(phase="completion", row="completion after %r" % prefix, ms=ms,
n=result_count(message))
@phase("probe")
def phase_probe():
"""Ad-hoc: what does a cursor offer? `--probe FILE:LINE:CHAR` (0-based)."""
relative, line, character = ARGS.probe.rsplit(":", 2)
where = {"line": int(line), "character": int(character)}
with session("workspace", resolve_support=True) as s:
settled(s)
s.did_open(sites.path(relative))
s.wait_quiet(0.8)
s.take_notifications()
params = {"textDocument": doc(relative), "range": {"start": where, "end": where},
"context": {"diagnostics": []}}
ms = tries(s, "textDocument/codeAction", params, 2)
_, message = s.request("textDocument/codeAction", params)
offered = message.get("result") or []
record(phase="probe", row="%s %s:%s" % (relative, line, character), ms=ms,
n=len(offered), titles=[a.get("title") for a in offered])
def main():
parser = argparse.ArgumentParser()
parser.add_argument("phase", choices=sorted(harness.PHASES))
parser.add_argument("--server", required=True)
parser.add_argument("--label", required=True)
parser.add_argument("--opentitan", default=sites.ROOT)
parser.add_argument("--storage", required=True)
parser.add_argument("--out", required=True)
parser.add_argument("--tries", type=int, default=3)
parser.add_argument("--probe", default="",
help="for the `probe` phase: FILE:LINE:CHAR, 0-based")
harness.configure(parser.parse_args())
harness.PHASES[ARGS.phase]()
if __name__ == "__main__":
main()
+128
View File
@@ -0,0 +1,128 @@
"""What every phase shares: the registry, the session factory, the recorder.
`bench.py` owns the command line and the take-3 table's phases; `phases_new.py`
owns the phases for what 0.44–0.49 added. Both import from here, so the run's
configuration lives in exactly one place.
`ARGS` is a `Namespace` that is *mutated* by [`configure`], never rebound, so
`from harness import ARGS` in another module keeps seeing the live values.
"""
import argparse
import json
import os
import time
import sites
from lspclient import Session, find_position, summarize, uri # noqa: F401
PHASES = {}
#: The run's configuration. Filled by `configure()`; never reassigned.
ARGS = argparse.Namespace(
server=None, label=None, opentitan=None, storage=None, out=None,
tries=3, probe="",
)
def configure(parsed):
"""Adopt a parsed command line, and point `sites` at the corpus."""
for key, value in vars(parsed).items():
setattr(ARGS, key, value)
ARGS.opentitan = os.path.abspath(ARGS.opentitan)
ARGS.out = os.path.abspath(ARGS.out)
sites.ROOT = ARGS.opentitan
os.makedirs(ARGS.storage, exist_ok=True)
def phase(name):
"""Register a phase under the name `bench.py <name>` runs."""
def register(fn):
PHASES[name] = fn
return fn
return register
def record(**fields):
"""Append one row to results.jsonl and echo it as a readable line."""
fields.setdefault("ts", time.strftime("%Y-%m-%dT%H:%M:%S"))
fields.setdefault("label", ARGS.label)
with open(ARGS.out, "a", encoding="utf-8") as handle:
handle.write(json.dumps(fields) + "\n")
ms = fields.get("ms")
shown = " ".join("%.3f" % v for v in ms) if ms else ""
print("%-11s %-52s %s %s" % (fields["phase"], fields.get("row", ""), shown,
fields.get("note", "")), flush=True)
def session(scope="workspace", cold=False, resolve_support=True, verbose=False,
storage_name=None):
"""A session at one scope, its index store under `--storage/<name>`.
Never the default store: the corpus must not be written near, and cache
warmth has to be controllable per cell.
"""
store = os.path.join(ARGS.storage, storage_name or scope)
return Session(
server=ARGS.server,
root=sites.ROOT,
storage=store,
scope=sites.SCOPES[scope],
resolve_support=resolve_support,
verbose=verbose,
cold=cold,
)
def settled(s, open_file=sites.TB):
"""Initialize, open a buffer, and wait for the scan to go quiet."""
s.initialize()
s.did_open(sites.path(open_file))
s.wait_quiet(1.5)
s.take_notifications()
return s
def tries(s, method, params, n=None):
"""`n` identical requests; returns the millisecond list."""
n = n or ARGS.tries
return [s.ms(method, params) for _ in range(n)]
def pos(relative, needle, occurrence=1, offset=0):
"""0-based `{line, character}` of a token, resolved from the file text."""
line, character = find_position(sites.path(relative), needle, occurrence, offset)
return {"line": line, "character": character}
def doc(relative):
return {"uri": uri(sites.path(relative))}
def at(relative, needle, occurrence=1, offset=0):
"""A position request's params at a token."""
return {"textDocument": doc(relative), "position": pos(relative, needle, occurrence, offset)}
def code_action_params(relative, needle, occurrence=1, offset=0):
"""A zero-width `textDocument/codeAction` range at a token."""
where = pos(relative, needle, occurrence, offset)
return {
"textDocument": doc(relative),
"range": {"start": where, "end": where},
"context": {"diagnostics": []},
}
def result_count(message):
"""How many things an answer carried — a list, an item list, or one thing."""
result = message.get("result")
if result is None:
return 0
if isinstance(result, list):
return len(result)
if isinstance(result, dict) and "items" in result:
return len(result["items"])
return 1
+394
View File
@@ -0,0 +1,394 @@
"""A minimal LSP client for the lucisv performance rounds.
Framed JSON-RPC over a `lucisv-server` child process's stdio. Python 3
standard library only, no third-party packages, so it runs from a clean
checkout with nothing installed.
What it does that a generic client does not, and why each exists:
- **The configuration pull is answered per session.** `lucisv-server` pulls
`workspace/configuration` for the `lucisv` section; the index scope it gets
back decides how many files are scanned, which is the single biggest lever
on every number in a perf round. `Session(scope=...)` writes that reply.
- **Client capabilities are settable per session.** A session that advertises
`textDocument.codeAction.resolveSupport.properties: ["edit"]` gets the lazy
`codeAction` offer (TODO §37.1); one that does not gets the eager shape.
Both must be measurable from one harness.
- **`storagePath` is always ours.** The index cache is directed at a scratch
directory so cache warmth is controlled (delete it = cold) and so nothing
is ever written near the corpus.
- **`window/logMessage` is captured**, so a `--verbose` server's own
`timing: <method> answered in <n> ms` lines can be read beside the wire.
Everything is timed with `time.perf_counter` from just before the write to
just after the matching response is parsed: what an editor experiences.
"""
import json
import os
import re
import shutil
import subprocess
import threading
import time
# The server's own timing line, from `--verbose` (docs/features/verbose-timing).
TIMING_LINE = re.compile(r"timing: (\S+) answered in ([0-9.]+) ?ms")
def uri(path):
"""A `file://` URI for an absolute path, percent-encoding what LSP needs."""
from urllib.parse import quote
return "file://" + quote(os.path.abspath(path))
class Session:
"""One `lucisv-server` process, driven over stdio.
Use as a context manager; the process is shut down and reaped on exit.
"""
def __init__(
self,
server,
root,
storage,
scope=None,
resolve_support=True,
verbose=False,
cold=False,
guard=None,
):
self.server = server
self.root = os.path.abspath(root)
self.storage = os.path.abspath(storage)
self.scope = scope if scope is not None else {}
self.resolve_support = resolve_support
self.verbose = verbose
self.next_id = 1
self.notifications = [] # every server->client notification, in order
self.log_messages = [] # window/logMessage texts only
self.timings = [] # (method, ms) from a --verbose server
self.pending = {} # id -> (method, sent_at) for in-flight requests
self.proc = None
self._reader = None
self._lock = threading.Lock()
self._inbox = [] # parsed messages not yet consumed
self._cond = threading.Condition(self._lock)
self._cold = cold
self._guard = guard or []
# -- lifecycle ---------------------------------------------------------
def __enter__(self):
if self._cold:
shutil.rmtree(self.storage, ignore_errors=True)
os.makedirs(self.storage, exist_ok=True)
cmd = list(self._guard) + [self.server]
if self.verbose:
cmd.append("--verbose")
cmd.append("--stdio")
self.proc = subprocess.Popen(
cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
self._reader = threading.Thread(target=self._read_loop, daemon=True)
self._reader.start()
return self
def __exit__(self, *_):
self.close()
return False
def close(self):
if self.proc is None:
return
try:
self.notify("exit", None)
except Exception:
pass
try:
self.proc.stdin.close()
except Exception:
pass
try:
self.proc.wait(timeout=10)
except Exception:
self.proc.kill()
self.proc.wait()
self.proc = None
# -- framing -----------------------------------------------------------
def _write(self, message):
body = json.dumps(message).encode("utf-8")
header = ("Content-Length: %d\r\n\r\n" % len(body)).encode("ascii")
self.proc.stdin.write(header + body)
self.proc.stdin.flush()
def _read_loop(self):
stream = self.proc.stdout
while True:
length = None
while True:
line = stream.readline()
if not line:
return
line = line.decode("utf-8", "replace").strip()
if line == "":
break
if line.lower().startswith("content-length:"):
length = int(line.split(":", 1)[1].strip())
if length is None:
continue
payload = b""
while len(payload) < length:
chunk = stream.read(length - len(payload))
if not chunk:
return
payload += chunk
try:
message = json.loads(payload.decode("utf-8"))
except ValueError:
continue
self._dispatch(message)
def _dispatch(self, message):
with self._cond:
self._inbox.append(message)
self._cond.notify_all()
# Server->client requests must be answered from the reader thread, or
# the server blocks and every timing after it is a lie.
if "method" in message and "id" in message:
self._answer_server_request(message)
def _answer_server_request(self, message):
method = message["method"]
if method == "workspace/configuration":
items = message.get("params", {}).get("items", [])
self._write(
{
"jsonrpc": "2.0",
"id": message["id"],
"result": [self.scope for _ in items] or [self.scope],
}
)
elif method in ("window/workDoneProgress/create", "client/registerCapability"):
self._write({"jsonrpc": "2.0", "id": message["id"], "result": None})
else:
self._write({"jsonrpc": "2.0", "id": message["id"], "result": None})
# -- traffic -----------------------------------------------------------
def notify(self, method, params):
self._write({"jsonrpc": "2.0", "method": method, "params": params})
def send(self, method, params):
"""Send a request without waiting; returns its id (for pipelining)."""
rid = self.next_id
self.next_id += 1
self.pending[rid] = (method, time.perf_counter())
self._write({"jsonrpc": "2.0", "id": rid, "method": method, "params": params})
return rid
def await_id(self, rid, timeout=300.0):
"""Wait for the response to `rid`; returns (elapsed_ms, message)."""
deadline = time.time() + timeout
while True:
with self._cond:
for i, message in enumerate(self._inbox):
if message.get("id") == rid and "method" not in message:
self._inbox.pop(i)
done = time.perf_counter()
_, sent = self.pending.pop(rid)
self._drain_locked()
return (done - sent) * 1000.0, message
self._drain_locked()
remaining = deadline - time.time()
if remaining <= 0:
raise TimeoutError("no response to request %d" % rid)
self._cond.wait(min(remaining, 0.05))
def request(self, method, params, timeout=300.0):
"""Send and wait. Returns (elapsed_ms, result_or_error_message)."""
return self.await_id(self.send(method, params), timeout)
def ms(self, method, params, timeout=300.0):
"""Just the round trip in milliseconds."""
return self.request(method, params, timeout)[0]
# -- notification bookkeeping -----------------------------------------
def _drain_locked(self):
"""Move server notifications out of the inbox into the log."""
kept = []
for message in self._inbox:
if "method" in message and "id" not in message:
self.notifications.append(message)
if message["method"] == "window/logMessage":
text = message.get("params", {}).get("message", "")
self.log_messages.append(text)
found = TIMING_LINE.search(text)
if found:
self.timings.append((found.group(1), float(found.group(2))))
else:
kept.append(message)
self._inbox[:] = kept
def drain(self):
with self._cond:
self._drain_locked()
def wait_quiet(self, quiet=1.5, timeout=300.0):
"""Block until no notification has arrived for `quiet` seconds.
The scan's end is not one message: `$/progress` `end` can be followed
by more indexing chatter, so silence is the reliable barrier. Returns
the seconds from entry to the last notification seen.
"""
started = time.perf_counter()
last = time.perf_counter()
seen = len(self.notifications)
deadline = time.time() + timeout
while True:
self.drain()
if len(self.notifications) != seen:
seen = len(self.notifications)
last = time.perf_counter()
if time.perf_counter() - last >= quiet:
return (last - started) * 1000.0
if time.time() > deadline:
raise TimeoutError("server never went quiet")
time.sleep(0.005)
def take_notifications(self, method=None):
"""Consume and return the notifications logged so far."""
self.drain()
found = [n for n in self.notifications if method is None or n["method"] == method]
self.notifications = []
return found
def take_timings(self, method=None):
self.drain()
found = [t for t in self.timings if method is None or t[0] == method]
self.timings = []
return found
# -- protocol shortcuts ------------------------------------------------
def capabilities(self):
"""The client capabilities this session advertises."""
code_action = {
"codeActionLiteralSupport": {
"codeActionKind": {"valueSet": ["", "quickfix", "refactor", "source"]}
},
"dataSupport": True,
}
if self.resolve_support:
code_action["resolveSupport"] = {"properties": ["edit"]}
return {
"workspace": {
"configuration": True,
"workspaceEdit": {"documentChanges": True},
"symbol": {"dynamicRegistration": False},
"didChangeConfiguration": {"dynamicRegistration": False},
},
"textDocument": {
"synchronization": {"dynamicRegistration": False},
"codeAction": code_action,
"completion": {"completionItem": {"snippetSupport": True}},
"hover": {"contentFormat": ["markdown", "plaintext"]},
"rename": {"prepareSupport": True},
"publishDiagnostics": {"relatedInformation": True},
"semanticTokens": {
"requests": {"full": True},
"tokenTypes": [],
"tokenModifiers": [],
"formats": ["relative"],
},
"inlayHint": {"dynamicRegistration": False},
},
"window": {"workDoneProgress": True},
}
def initialize(self):
"""`initialize` + `initialized`; returns the request's milliseconds."""
params = {
"processId": os.getpid(),
"rootUri": uri(self.root),
"capabilities": self.capabilities(),
"initializationOptions": {"storagePath": self.storage},
"workspaceFolders": [{"uri": uri(self.root), "name": "opentitan"}],
}
elapsed, _ = self.request("initialize", params)
self.notify("initialized", {})
return elapsed
def did_open(self, path, language="systemverilog"):
with open(path, "r", encoding="utf-8", errors="replace") as handle:
text = handle.read()
self.notify(
"textDocument/didOpen",
{
"textDocument": {
"uri": uri(path),
"languageId": language,
"version": 1,
"text": text,
}
},
)
return text
def did_change(self, path, text, version=2):
self.notify(
"textDocument/didChange",
{
"textDocument": {"uri": uri(path), "version": version},
"contentChanges": [{"text": text}],
},
)
def at(self, path, line, character, method, extra=None):
"""A position request's params, 0-based line and UTF-16 character."""
params = {
"textDocument": {"uri": uri(path)},
"position": {"line": line, "character": character},
}
if extra:
params.update(extra)
return method, params
def find_position(path, needle, occurrence=1, offset=0):
"""0-based (line, character) of the `occurrence`th `needle` in a file.
Positions are resolved from the text at run time rather than hard-coded,
so a corpus that moves by a line does not silently measure the wrong
token. `offset` shifts the character within the match.
"""
with open(path, "r", encoding="utf-8", errors="replace") as handle:
seen = 0
for number, line in enumerate(handle):
start = 0
while True:
found = line.find(needle, start)
if found < 0:
break
seen += 1
if seen == occurrence:
return number, found + offset
start = found + 1
raise LookupError("%r not found %dx in %s" % (needle, occurrence, path))
def summarize(values):
"""(first, min_of_repeats, max_of_repeats) from a try list."""
if not values:
return None, None, None
if len(values) == 1:
return values[0], values[0], values[0]
return values[0], min(values[1:]), max(values[1:])
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# The per-file outcome runs, for the release-to-release outcome diff.
#
# tools/perf/outcomes.sh <lucisv-binary> <label> <opentitan-dir> <out-dir>
#
# `format --check --no-cache` and `check` over the five trees, with every
# per-file line kept. `--no-cache` so the verdict is computed, never recalled,
# and so the two binaries are compared on the same work. Paths are rewritten
# relative to the corpus root, so two runs differ only where an *outcome* did.
#
# Writes `<out-dir>/<label>.format.txt`, `<label>.check.txt`,
# `<label>.check-select.txt`. Diff two labels with:
#
# diff <out-dir>/0.43.0.format.txt <out-dir>/0.49.0.format.txt
#
# Untimed — correctness, not timing — so it is safe to run beside other work.
# Still guarded, like every `lucisv` invocation in this round.
set -u
BIN=${1:?usage: outcomes.sh <binary> <label> <opentitan> <outdir>}
LABEL=${2:?}
OT=${3:?}
OUT=${4:?}
HERE=$(cd "$(dirname "$0")" && pwd)
GUARD="$HERE/../guard.sh"
TREES="hw/ip hw/top_earlgrey/ip hw/top_darjeeling/ip hw/dv hw/vendor"
mkdir -p "$OUT"
emit() {
local suffix=$1
shift
local out="$OUT/${LABEL}.${suffix}.txt"
: >"$out"
for tree in $TREES; do
echo "=== $tree ===" >>"$out"
"$GUARD" -m 8 -t 1800 -- "$BIN" "$@" "$OT/$tree" 2>&1 |
sed "s#$OT/##g" |
LC_ALL=C sort >>"$out"
done
echo "wrote $out"
}
emit format format --no-cache --check
emit check check
emit check-select check --select error,warning,style
+191
View File
@@ -0,0 +1,191 @@
#!/usr/bin/env python3
"""The phases for what 0.44–0.49 added: the new offer sites, §49's
hierarchical surface, §46's `didOpen` fix on the wire, `lucisv/moduleHierarchy`
and the index's cost on disk and in memory.
Imported by `bench.py`, which owns the registry and the command line; nothing
here is run directly. Split out of `bench.py` so each file stays inside
CLAUDE.md's size rule and each has one sentence: `bench.py` is the take-3
table, this is what changed since it.
"""
import json
import os
import subprocess
import time
from harness import (
ARGS, Session, at, code_action_params, doc, phase, pos, record,
result_count, session, settled, sites, tries,
)
@phase("refactor")
def phase_refactor():
"""The offer sites 0.44–0.49 added: what is offered, and what it costs."""
for label, relative, needle, occurrence, offset in sites.REFACTOR_SITES:
with session("workspace", resolve_support=True) as s:
settled(s)
s.did_open(sites.path(relative))
s.wait_quiet(0.6)
s.take_notifications()
params = code_action_params(relative, needle, occurrence, offset)
ms = tries(s, "textDocument/codeAction", params, ARGS.tries + 1)
_, message = s.request("textDocument/codeAction", params)
offered = message.get("result") or []
record(phase="refactor", row="%s offer" % label, ms=ms, n=len(offered),
titles=[a.get("title") for a in offered],
file=relative, position=params["range"]["start"])
for action in offered:
if "edit" in action:
continue
resolves = [s.ms("codeAction/resolve", action) for _ in range(ARGS.tries + 1)]
_, resolved = s.request("codeAction/resolve", action)
edit = (resolved.get("result") or {}).get("edit") or {}
record(phase="refactor", row="%s resolve: %s" % (label, action.get("title")),
ms=resolves, n=len(edit.get("changes") or
edit.get("documentChanges") or []))
# `extract module` is a selection, not a point.
relative, first, first_n, last, last_n = sites.EXTRACT_SELECTION
start = pos(relative, first, first_n)
end = pos(relative, last, last_n)
end = {"line": end["line"], "character": end["character"] + len(last)}
with session("workspace", resolve_support=True) as s:
settled(s)
s.did_open(sites.path(relative))
s.wait_quiet(0.6)
s.take_notifications()
params = {"textDocument": doc(relative),
"range": {"start": start, "end": end},
"context": {"diagnostics": []}}
ms = tries(s, "textDocument/codeAction", params, ARGS.tries + 1)
_, message = s.request("textDocument/codeAction", params)
offered = message.get("result") or []
record(phase="refactor", row="extract-module offer (selection)", ms=ms, n=len(offered),
titles=[a.get("title") for a in offered], file=relative,
position=start, note="selection %d:%d-%d:%d" % (
start["line"], start["character"], end["line"], end["character"]))
for action in offered:
if "edit" in action:
continue
resolves = [s.ms("codeAction/resolve", action) for _ in range(ARGS.tries + 1)]
record(phase="refactor", row="extract-module resolve: %s" % action.get("title"),
ms=resolves)
@phase("tailrename")
def phase_tailrename():
"""§49 — a net renamed at its declaration, named through an instance tail."""
relative, needle, occurrence, offset = sites.TAIL_RENAME
with session("workspace") as s:
settled(s)
s.did_open(sites.path(relative))
s.did_open(sites.path(sites.TAIL_TAIL_FILE))
s.wait_quiet(0.8)
s.take_notifications()
where = at(relative, needle, occurrence, offset)
record(phase="tailrename", row="tail rename cursor", ms=[0.0],
note=json.dumps(where["position"]), file=relative)
params = dict(where, newName="state_q_x")
ms = tries(s, "textDocument/rename", params, ARGS.tries + 1)
_, message = s.request("textDocument/rename", params)
uris = edited_uris(message)
tail = os.path.basename(sites.TAIL_TAIL_FILE)
record(phase="tailrename",
row="rename state_q (tail through u_entropy_src_main_sm)",
ms=ms, n=len(uris),
note="tail edited" if any(tail in u for u in uris) else "TAIL NOT EDITED",
titles=sorted(os.path.basename(u) for u in uris))
def edited_uris(message):
"""The URIs a `WorkspaceEdit` touches, whichever shape it came in."""
edit = message.get("result") or {}
if not isinstance(edit, dict):
return []
if edit.get("changes"):
return list(edit["changes"].keys())
return [c.get("textDocument", {}).get("uri", "")
for c in edit.get("documentChanges") or []]
@phase("didopen")
def phase_didopen():
"""§46 — `didOpen` → the request behind it, workspace scope, warm store."""
for relative in sites.DIDOPEN_FILES:
runs, seconds = [], []
for _ in range(ARGS.tries):
with session("workspace") as s:
settled(s)
started = time.perf_counter()
s.did_open(sites.path(relative))
s.ms("textDocument/definition", at(relative, "module ", 1, 0))
runs.append((time.perf_counter() - started) * 1000.0)
seconds.append(s.ms("textDocument/definition", at(relative, "module ", 1, 0)))
lines = sum(1 for _ in open(sites.path(relative), encoding="utf-8", errors="replace"))
record(phase="didopen", row="didOpen %s -> definition" % os.path.basename(relative),
ms=runs, n=lines,
note="second definition " + " / ".join("%.2f" % v for v in seconds))
@phase("tailcompletion")
def phase_tailcompletion():
"""Completion after `u_x.` on an instance head (§49's surface)."""
relative, needle, occurrence, offset = sites.TAIL_HEAD_COMPLETION
with session("workspace") as s:
settled(s)
s.did_open(sites.path(relative))
s.wait_quiet(0.8)
s.take_notifications()
where = at(relative, needle, occurrence, offset)
ms = tries(s, "textDocument/completion", where, ARGS.tries + 1)
_, message = s.request("textDocument/completion", where)
items = (message.get("result") or {})
items = items.get("items", items) if isinstance(items, dict) else items
record(phase="tailcompletion",
row="completion after an instance head + '.' (%s)" % os.path.basename(
sites.path(relative)),
ms=ms, n=result_count(message),
titles=[i.get("label") for i in (items or [])[:8]])
@phase("hierarchy")
def phase_hierarchy():
with session("workspace") as s:
settled(s)
ms = tries(s, "lucisv/moduleHierarchy", {}, ARGS.tries + 1)
_, message = s.request("lucisv/moduleHierarchy", {})
result = message.get("result") or {}
payload = len(json.dumps(result))
record(phase="hierarchy", row="lucisv/moduleHierarchy", ms=ms, n=payload,
note="modules %d, files %d, schema %s" % (
len(result.get("modules") or []), len(result.get("files") or []),
result.get("schemaVersion")))
@phase("rss")
def phase_rss():
"""Server peak RSS after the workspace scan, and the index store on disk.
RSS is read with `ps -o rss=` on the server's own pid a second after the
scan settles, so it is the resident set of a server that has finished
indexing and is idle — what an editor session actually holds.
"""
store = os.path.join(ARGS.storage, "rss")
for cache in ("cold", "warm"):
rss, size = [], "0"
for _ in range(ARGS.tries):
s = Session(server=ARGS.server, root=sites.ROOT, storage=store,
scope=sites.SCOPES["workspace"], cold=(cache == "cold"))
with s:
settled(s)
time.sleep(1.0)
rss.append(float(subprocess.run(
["ps", "-o", "rss=", "-p", str(s.proc.pid)],
capture_output=True, text=True).stdout.strip()))
size = subprocess.run(["du", "-sk", store], capture_output=True,
text=True).stdout.split()[0]
record(phase="rss", row="server RSS after workspace scan, %s cache" % cache,
ms=rss, n=int(size),
note="RSS KB above; index store %s KB" % size)
+122
View File
@@ -0,0 +1,122 @@
"""The opentitan positions every perf phase measures, resolved at run time.
Nothing here is a hard-coded line number: each site names the *text* it wants
and `lspclient.find_position` locates it when the phase runs, so a corpus that
moves by a line measures the same token rather than a silent neighbour. The
0-based positions in `docs/performance_take4.md` are what these resolve to on
opentitan `0098135264`.
`ROOT` is overridden by `bench.py --opentitan`; every path below hangs off it.
"""
import os
ROOT = os.environ.get("OPENTITAN", "/Users/guoliangchen/repo/opentitan")
def path(relative):
return os.path.join(ROOT, relative)
# -- the take-3 scenario files ---------------------------------------------
TB = "hw/ip/aes/dv/tb/tb.sv"
AES = "hw/ip/aes/rtl/aes.sv"
AES_CORE = "hw/ip/aes/rtl/aes_core.sv"
AES_WRAP = "hw/ip/aes/rtl/aes_wrap.sv"
AON_TIMER = "hw/ip/aon_timer/rtl/aon_timer.sv"
KMAC = "hw/ip/kmac/rtl/kmac.sv"
HMAC = "hw/ip/hmac/rtl/hmac.sv"
SPI_DEVICE = "hw/ip/spi_device/rtl/spi_device.sv"
PINMUX_REG_TOP = "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv"
AES_BIND = "hw/ip/aes/dv/sva/aes_bind.sv"
ENTROPY_SRC_CORE = "hw/ip/entropy_src/rtl/entropy_src_core.sv"
ENTROPY_SRC_SM = "hw/ip/entropy_src/rtl/entropy_src_main_sm.sv"
SHA3_FPV = "hw/ip/kmac/fpv/tb/sha3_fpv.sv"
AES_SBOX_MASKED = "hw/ip/aes/rtl/aes_sbox_canright_masked.sv"
# The take-3 `codeAction` cursors:
# (label, file, needle, occurrence, fan-out, cursor offset into the needle).
# The cursor lands on the module name. The fan-out is
# `grep -rlE '^\s*<module>( |#|$)' --include='*.sv'` over the corpus,
# re-derived for take 4 and identical to take 3's (1 / 6 / 42 / 67 / 128).
# The fan-out is `grep -rlE '^\s*<module>( |#|$)' --include='*.sv'` over the
# tree, re-derived for take 4 and identical to take 3's (1 / 6 / 42 / 67 / 128).
FANOUT_CURSORS = [
("aes_reg_top", AES, "aes_reg_top u_reg (", 1, 1, 0),
("aes", TB, " aes #(", 1, 6, 2),
("prim_lc_sync", AES, "prim_lc_sync #(", 1, 42, 0),
("prim_alert_sender", AES, "prim_alert_sender #(", 1, 67, 0),
("prim_flop_2sync", AON_TIMER, "prim_flop_2sync #(", 1, 128, 0),
]
# The scope replies handed back to `workspace/configuration`, by name.
SCOPES = {
"default": {},
"empty-index": {"index": {}},
"depth0": {"index": {"scopeDepth": 0}},
"workspace": {"index": {"scope": "workspace"}},
}
# Files opened one at a time in the widen phases (§5), with their sizes.
WIDEN_FILES = [AES, KMAC, HMAC, SPI_DEVICE]
# §46's didOpen → next-request files, the perf README's 2026-09-05 set.
DIDOPEN_FILES = [AES, AES_CORE, SPI_DEVICE, PINMUX_REG_TOP]
# The five refactoring offer sites 0.44–0.49 added, each a real opentitan
# position. `kind` names the action the site is meant to raise; the phase
# records what is actually offered, which is the point of measuring it.
# Each site was found by sweeping every instantiation-shaped and `import` line
# in a set of RTL files and keeping the positions that actually offer (the
# sweep is `bench.py probe`, one cursor at a time). The 0-based positions these
# resolve to on opentitan `0098135264` are named in `docs/performance_take4.md`
# §6b. There is **no** `convert to ANSI` site: opentitan has zero non-ANSI
# module headers (§6b), so the last row measures an ANSI header, where the
# action is correctly not offered.
REFACTOR_SITES = [
# A wildcard connection: `sha3 #(.EnMasking(...)) u_sha3 ( .* );` → 54:4.
("expand-wildcard", SHA3_FPV, " ) u_sha3 (", 1, 4),
# Two imports, one unused and one out of order → 42:2.
("organize-imports", AES_SBOX_MASKED, " import aes_pkg::*;", 1, 2),
# A separate-file instance written with named connections → 66:2.
("inline-module", AES_WRAP, " tlul_cmd_intg_gen tlul_cmd_intg_gen (", 1, 2),
# The take-3 offer site, still the one port-refactoring cursor found → 78:2.
("port-actions", AES_WRAP, " aes #(", 1, 2),
# An ANSI module header: the contrast row for `convert to ANSI` → 8:0.
("ansi-header (no offer expected)", AES, "module aes", 1, 0),
]
# The `extract module` site is a *selection*, not a point: three contiguous
# whole module items — `aes.sv`'s three status `assign`s. The span runs from
# the first needle's start to the end of the second needle.
EXTRACT_SELECTION = (
AES,
" assign idle_o", 1,
" assign input_ready_o = reg2hw.status.input_ready.q;", 1,
)
# §49's hierarchical tail. `entropy_src_main_sm.sv` declares `state_q` — a
# variable, not a port, so only the *hierarchical* surface reaches it — and
# `entropy_src_core.sv` instantiates that module as `u_entropy_src_main_sm`
# and names `u_entropy_src_main_sm.state_q`. The rename is issued at the
# declaration; the row records whether the tail's file joins the edit set,
# which is exactly what §49 changed.
TAIL_RENAME = (ENTROPY_SRC_SM, "state_d, state_q;", 1, len("state_d, "))
TAIL_TAIL_FILE = ENTROPY_SRC_CORE
TAIL_HEAD_COMPLETION = (
ENTROPY_SRC_CORE,
"u_entropy_src_main_sm.state_q", 1, len("u_entropy_src_main_sm."),
)
# The completion prefixes of take 3 §6d, typed at a fresh line in `tb.sv`.
COMPLETION_PREFIXES = ["", "a", "ae", "aes", "aes_", "prim_", "clk", "aes_reg", "zzzz"]
# The five CLI sweep trees (`sweep.sh` reads the same list).
TREES = [
"hw/ip",
"hw/top_earlgrey/ip",
"hw/top_darjeeling/ip",
"hw/dv",
"hw/vendor",
]
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# The timed CLI sweeps: `format --check` (cold and warm cache) and `check`
# (default rules, and `--select error,warning,style`) over five opentitan
# trees, one binary at a time, three tries per cell, wall clock and peak RSS
# from `/usr/bin/time -l`.
#
# tools/perf/sweep.sh <lucisv-binary> <label> <opentitan-dir> <out-dir> [tries]
#
# Each cell writes `<out-dir>/<label>__<tree>__<command>__<cache>.txt`, which
# holds the three runs' `/usr/bin/time -l` blocks; `sweeptable.py` reads them.
# The formatter cache is a scratch `--cache-dir` under `<out-dir>`, so nothing
# is ever written into the corpus.
#
# Every `lucisv` invocation goes through `tools/guard.sh -m 8 -t 1800`.
set -u
BIN=${1:?usage: sweep.sh <binary> <label> <opentitan> <outdir> [tries]}
LABEL=${2:?}
OT=${3:?}
OUT=${4:?}
TRIES=${5:-3}
HERE=$(cd "$(dirname "$0")" && pwd)
GUARD="$HERE/../guard.sh"
CACHE="$OUT/fmtcache"
TREES="hw/ip hw/top_earlgrey/ip hw/top_darjeeling/ip hw/dv hw/vendor"
mkdir -p "$OUT"
run_cell() {
local tree=$1 name=$2 cache=$3
shift 3
local safe=${tree//\//_}
local log="$OUT/${LABEL}__${safe}__${name}__${cache}.txt"
: >"$log"
if [ "$cache" = cold ]; then rm -rf "$CACHE"; fi
local i
for i in $(seq 1 "$TRIES"); do
echo "--- try $i ---" >>"$log"
# `-l` puts the resource block on stderr; both streams are kept.
"$GUARD" -m 8 -t 1800 -- /usr/bin/time -l "$BIN" "$@" >>"$log" 2>>"$log"
echo "--- exit $? ---" >>"$log"
done
echo "$log"
}
for tree in $TREES; do
echo "== $LABEL $tree"
run_cell "$tree" format cold format --cache-dir "$CACHE" --check "$OT/$tree"
run_cell "$tree" format warm format --cache-dir "$CACHE" --check "$OT/$tree"
run_cell "$tree" check default check "$OT/$tree"
run_cell "$tree" check select check --select error,warning,style "$OT/$tree"
done
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env python3
"""Turn `sweep.sh`'s `/usr/bin/time -l` logs into the document's §7 table.
python3 tools/perf/sweeptable.py <out-dir> [--labels 0.49.0,0.43.0,0.39.0]
Reads every `<label>__<tree>__<command>__<cache>.txt` in `<out-dir>`, pulls the
`real` seconds and the `maximum resident set size` out of each try's block, and
prints a Markdown table with one row per (tree, command, cache) and one column
per label — first try, then the range over the repeats, then peak RSS.
It also prints the summary line each run reported (`N files would be
reformatted`, the finding count), because a timing that moved because the work
moved is not a timing finding.
"""
import argparse
import os
import re
import sys
REAL = re.compile(r"([0-9.]+)\s+real")
RSS = re.compile(r"(\d+)\s+maximum resident set size")
COMMANDS = [("format", "cold"), ("format", "warm"), ("check", "default"), ("check", "select")]
COMMAND_NAMES = {
("format", "cold"): "`format --check`, cold cache",
("format", "warm"): "`format --check`, warm cache",
("check", "default"): "`check` (default rules)",
("check", "select"): "`check --select error,warning,style`",
}
TREES = ["hw/ip", "hw/top_earlgrey/ip", "hw/top_darjeeling/ip", "hw/dv", "hw/vendor"]
def cell(directory, label, tree, command, cache):
"""(reals, peak_rss_mb, summary_lines) for one cell, or None if absent."""
name = "%s__%s__%s__%s.txt" % (label, tree.replace("/", "_"), command, cache)
path = os.path.join(directory, name)
if not os.path.exists(path):
return None
text = open(path, encoding="utf-8", errors="replace").read()
reals = [float(v) for v in REAL.findall(text)]
rss = [int(v) for v in RSS.findall(text)]
# The run's own total line, not its per-file lines: a timing that moved
# because the *work* moved is not a timing finding.
summary = [
line.strip()
for line in text.splitlines()
if re.match(r"^(\d+ files? would be reformatted|found \d+ violations|"
r"no violations|All \d+)", line.strip())
]
return reals, (max(rss) / 1048576.0 if rss else 0.0), summary
def render(reals):
if not reals:
return "—"
if len(reals) == 1:
return "%.2f" % reals[0]
rest = reals[1:]
if abs(max(rest) - min(rest)) < 0.005:
return "%.2f / %.2f" % (reals[0], min(rest))
return "%.2f / %.2f–%.2f" % (reals[0], min(rest), max(rest))
def main():
parser = argparse.ArgumentParser()
parser.add_argument("directory")
parser.add_argument("--labels", default="0.49.0,0.43.0,0.39.0")
args = parser.parse_args()
labels = args.labels.split(",")
print("| Tree | command | " + " | ".join(labels) + " | peak RSS (MB) |")
print("|---|---|" + "---:|" * (len(labels) + 1))
for tree in TREES:
for command, cache in COMMANDS:
cells = [cell(args.directory, label, tree, command, cache) for label in labels]
if not any(cells):
continue
times = " | ".join(render(c[0]) if c else "—" for c in cells)
rss = " → ".join("%.0f" % c[1] for c in cells if c)
print("| `%s` | %s | %s | %s |" % (tree, COMMAND_NAMES[(command, cache)], times, rss))
print()
print("Summary lines, per cell (what the run reported):")
for tree in TREES:
for command, cache in COMMANDS:
for label in labels:
found = cell(args.directory, label, tree, command, cache)
if not found or not found[2]:
continue
print(" %-22s %-8s %-8s %-8s %s" % (
tree, command, cache, label, found[2][0]))
return 0
if __name__ == "__main__":
sys.exit(main())