Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23e2e4bca5 | ||
|
|
a2a22adad8 | ||
|
|
9d1eb1671e | ||
|
|
5d70cb89cc | ||
|
|
da32237a0e | ||
|
|
c82978c3db | ||
|
|
1b8723ca1f | ||
|
|
2675131f8c | ||
|
|
409acae087 | ||
|
|
f5edac9197 | ||
|
|
7df86fe979 | ||
|
|
b4a0668b24 | ||
|
|
41945912a3 | ||
|
|
faf890d9f0 | ||
|
|
3ceba21bb2 | ||
|
|
b12e0cc2c4 | ||
|
|
01843eb75a | ||
|
|
5e02142a8f | ||
|
|
07ef771a35 | ||
|
|
eb54042032 | ||
|
|
a1c77c053f | ||
|
|
51cbfd27df | ||
|
|
e13ae4c89b | ||
|
|
b2bb912bbb | ||
|
|
126a6bcdac |
No files matched your search
+143
@@ -4,6 +4,149 @@ All notable changes to lucisv are recorded here. Versions follow
|
||||
[semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes
|
||||
(see `README.md`) are the only frozen contract.
|
||||
|
||||
## 0.55.0 — 2026-09-17
|
||||
|
||||
### Loop 3, round 2 — find-references reaches a module's internals
|
||||
|
||||
- **References see every cross-file use of a module's nets, variables
|
||||
and instances.** With `module leaf` declaring `logic sig` and another
|
||||
file writing `assign w = u_leaf.sig;` (or a `bind` directive naming
|
||||
`sig` in a connection), Find All References from the declaration
|
||||
answered `leaf.sv` alone — while a rename already edited both files.
|
||||
The two index questions behind references asked the module's
|
||||
*connection* surface (ports and parameters), which cannot hold an
|
||||
internal net; they now ask the *hierarchical* surface, the one a path
|
||||
in another file actually reaches the declaration by. Every answer for
|
||||
a port, parameter, package member, class field or struct field is
|
||||
byte-for-byte what it was. Hover's declaration snippet uses the same
|
||||
lookup and now shows the live line for such a signal in an edited
|
||||
buffer. On the opentitan tree, references on `aes.sv`'s
|
||||
`entropy_masking_req` now list `aes_bind.sv`, and `state_q` in
|
||||
`entropy_src_main_sm.sv` lists its use in `entropy_src_core.sv`.
|
||||
(`docs/features/references-hierarchical-surface/README.md`.)
|
||||
- **A closed declaring file's own uses are in the answer.** The index
|
||||
deliberately posts no in-file references for a module's internal
|
||||
signals (a table sized by every RTL body, for a rarely asked
|
||||
question), so a request from another file into a declaring file
|
||||
nobody has open used to list the cross-file sites and silently omit
|
||||
that file's own `assign … = sig;` lines. That one file is now parsed
|
||||
once, on exactly that request shape — 0.4–1.5 ms on a real design
|
||||
file, the same trade a rename already makes.
|
||||
- **A stale index may omit a location; it can never point at a wrong
|
||||
line.** Three QA rounds found that a span recorded at index time, or
|
||||
computed against one read of a closed file, could be rendered against
|
||||
a different read of the same file after an external edit (another
|
||||
tool, `git checkout`, a build step) and land on a line that no longer
|
||||
holds the name. Each closed file is now read exactly once per
|
||||
request, and every index-time span — closed files and the
|
||||
open-buffer declaration fallback alike — must still spell the name
|
||||
exactly where it is rendered, or it is dropped. Escaped identifiers,
|
||||
UTF-8 boundaries, a deleted declaring file and a name that is both a
|
||||
port and a net are covered by tests; references and rename are
|
||||
asserted to agree with the whole-scope engine.
|
||||
- Cost, accepted and recorded in `docs/perf/README.md`: a references
|
||||
request on a heavily used local net in a 40 000-line buffer now
|
||||
walks the indexed path, 1.22 → 1.54 ms median; every other harness
|
||||
row unchanged.
|
||||
|
||||
## 0.54.0 — 2026-09-12
|
||||
|
||||
### Loop 3, round 1 — a rename correctness fix and a faster first edit
|
||||
|
||||
- **Rename edits a `bind` file's own occurrences.** Renaming a module's
|
||||
internal net that a `bind` directive's connection names bare
|
||||
(`bind aes chk u (.req(entropy_masking_req))`), or reaches by a
|
||||
hierarchical path (`u_aes_core.u_aes_prng_clearing.seed_en`), used to
|
||||
leave the bind file untouched and say nothing — the design no longer
|
||||
elaborated after the rename. The resolver had asked the bind target's
|
||||
connection surface (ports and parameters) for a bare name, and rooted a
|
||||
bind's hierarchical path in the scope the directive is written in,
|
||||
which declares nothing. A bind connection is now a reference on the
|
||||
target's hierarchical surface, a bind's path is rooted at the target
|
||||
(a multi-segment target such as `bind tb.u_aes …` included), and an
|
||||
occurrence the engine cannot resolve is warned about by file and line,
|
||||
never silent. Definition, hover and references answer over bind files
|
||||
the same way. The index store format is bumped (`FACTS_FORMAT` 20): a
|
||||
0.53.0 store is rebuilt once. (Found by the previous round's QA on the
|
||||
opentitan tree.)
|
||||
- **The first request after an edit is ~19 % faster.** On a 40 000-line
|
||||
generated register file the first code-action menu after a
|
||||
one-character change costs 88 ms instead of 109: the lexer's raw and
|
||||
comment-attachment phases are fused (no intermediate token vector), the
|
||||
parser no longer clones a token it is about to discard, and the
|
||||
operator table is filtered by first byte before the longest-match
|
||||
scan. Token stream, diagnostics, AST and symbols are byte-for-byte what
|
||||
they were over 4 807 files; every formatter and linter output is
|
||||
identical.
|
||||
- `--verbose` timing lines carry a third group, `rebuild{…}`, that splits
|
||||
the document rebuild after an edit into its stages.
|
||||
- Known remainder, filed: cross-file *references* from a module's
|
||||
internal net (bind or not) still stop at the connection surface; the
|
||||
rest of the rebuild (the token clone, analysis, external resolution).
|
||||
|
||||
## 0.53.0 — 2026-09-09
|
||||
|
||||
### The 0.52.0 review — one correctness fix
|
||||
|
||||
- **A symlink-aliased directory is indexed once at startup.** 0.52.0's
|
||||
startup scan walks the open file's folder before the rest of the
|
||||
workspace, and the two walks kept separate visited sets: a directory
|
||||
reachable by two spellings (`a_alias -> z_real`) was indexed twice, so
|
||||
go-to-definition offered two targets and a valid rename was refused as
|
||||
ambiguous until the next rescan (found by the independent review of
|
||||
0.52.0). The two walks now share one directory identity; when an alias
|
||||
sorts before the open folder the scan takes the single canonical walk;
|
||||
an alias only the remaining walk can see requests one ordinary rescan
|
||||
so the spellings converge; and a same-named symlink to an open buffer
|
||||
is never a second copy of it. Startup, rescan and restart agree on
|
||||
index paths, definitions, rename and diagnostics across nine alias
|
||||
shapes, and a genuine duplicate declaration is still refused.
|
||||
- The load probe in `tools/perf/` primes a warm store before timing and
|
||||
stamps scan completion from the scan's own end event.
|
||||
- No performance number moved; the CLI is unchanged.
|
||||
|
||||
## 0.52.0 — 2026-09-09
|
||||
|
||||
### Performance take 5 — the review round
|
||||
|
||||
An independent review of 0.51.0 (`docs/performance_take5_review.md`)
|
||||
named four remaining costs with gates; all four are implemented and
|
||||
measured (`docs/perf/README.md`, the 2026-09-08 review-round entry).
|
||||
Behaviour is unchanged everywhere the suites and byte-identity gates can
|
||||
see; two pre-existing gaps the round found are filed, not hidden.
|
||||
|
||||
- **A rename refuses cheaply.** A cursor with no symbol used to read,
|
||||
parse and index every file in the workspace before refusing (2 s on
|
||||
opentitan); an engine-owned preflight now refuses from the request
|
||||
buffer alone in 0.3 ms with the same sentence and precedence. Refusals
|
||||
the workspace index would have to answer stay on the slow road, because
|
||||
a wrong rename refusal is terminal.
|
||||
- **One lint pass per buffer revision.** The diagnostics publish and the
|
||||
quick-fix discovery share one result, keyed by value on every input
|
||||
(rule set, options, width, tab width, waiver *contents*) and cleared by
|
||||
every index change; a cursor move on a 42 000-line file costs 1 ms
|
||||
instead of 23, and the navigation queued behind it likewise.
|
||||
- **The first answer after opening a file.** A workspace start now
|
||||
walks, indexes and publishes the open file's own folders before it
|
||||
discovers the rest of the workspace, one scan, every file once: the
|
||||
first go-to-definition answers in about 80 ms cold and 115 ms warm,
|
||||
correct every session, and a warm start settles under one second.
|
||||
- **Scans under load.** A scan publishes at most once per 512 files
|
||||
instead of once per burst of requests (a publish costs the size of the
|
||||
index): at the same offered load the median request wait falls from
|
||||
112 ms to 2 ms and the scan finishes about twice as fast. An empty
|
||||
navigation answer computed while the index is still growing is no
|
||||
longer an answer — it is asked again at the next publish or at the
|
||||
scan's end — and a cancel for such a request is honoured where it
|
||||
lands.
|
||||
- **Rename reuses the index's own records.** For the files a rename
|
||||
selects but never analyses, the engine now takes the index cache's
|
||||
record instead of parsing, and only when the file's bytes hash to what
|
||||
that record was written for. The hierarchical-tail rename falls from
|
||||
380 to 314 ms, the duplicate-module refusal from 2 s to 0.7 s; every
|
||||
edit and every warning byte-identical.
|
||||
- The CLI is unchanged in this release.
|
||||
|
||||
## 0.51.0 — 2026-09-08
|
||||
|
||||
### Performance take 5 — the implementation round
|
||||
|
||||
Generated
+8
-8
@@ -97,7 +97,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lucisv"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
dependencies = [
|
||||
"lucisv_core",
|
||||
"rayon",
|
||||
@@ -108,11 +108,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lucisv_core"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
|
||||
[[package]]
|
||||
name = "lucisv_server"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
dependencies = [
|
||||
"lsp-server",
|
||||
"lsp-types",
|
||||
@@ -248,14 +248,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "vlog_formatter"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
dependencies = [
|
||||
"vlog_parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vlog_linter"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
dependencies = [
|
||||
"lucisv_core",
|
||||
"vlog_formatter",
|
||||
@@ -265,11 +265,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vlog_parser"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
|
||||
[[package]]
|
||||
name = "vlog_refactor"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
dependencies = [
|
||||
"vlog_formatter",
|
||||
"vlog_parser",
|
||||
@@ -278,7 +278,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vlog_semantic"
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
dependencies = [
|
||||
"vlog_parser",
|
||||
]
|
||||
+1
-1
@@ -12,7 +12,7 @@ members = [
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.51.0"
|
||||
version = "0.55.0"
|
||||
authors = ["Guoliang Chen"]
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
@@ -4714,6 +4714,38 @@ in 0.49.0. Take 4's findings are in the loop-3 list above.
|
||||
already stat'd and could hand on), then `cache_open` 89 ms; warm settle
|
||||
~1.04–1.10 s against the plan's < 1 s, the rest being the store open
|
||||
the refused reuse would remove.
|
||||
- **review round §61.2 filed:** a `format::indent_width` form taking an
|
||||
already-read `FileConfig`, so the code-action path's run and the
|
||||
publish path do one `Discovery` walk, not two (+0.1 ms today).
|
||||
- **review round §61.3 filed:** a bounded local-record load of the index
|
||||
store for the open folder's head (measured ~26 ms vs the 89 ms whole
|
||||
open, but the 61 ms checksum verification is owed either way and it
|
||||
breaks `Load::canonical`) — its own experiment if the first answer
|
||||
needs the 89 ms; and a walk that can skip an already-walked subtree so
|
||||
the two-phase discovery stops walking the open folder twice (+2.5–5 %
|
||||
on the 1/10-buffer settle).
|
||||
- **review round §61.5 filed (QA, pre-existing):** a `bind` file's own
|
||||
occurrence of a renamed name (`aes_bind.sv` for a bound name or a
|
||||
two-level hierarchical tail) is neither edited nor warned about,
|
||||
identically before and after the reuse — the whole-scope engine's
|
||||
answer, so a missing warning at least (QA task `task_834abda3`); the
|
||||
scope reuse's collateral for the other refactorings (`_with` doors for
|
||||
extract/inline/imports/ports/references — the resolves and the extract
|
||||
edit are the candidates, the 805 ms refusal is after the build); the
|
||||
31 ms store decode the one-place tie costs.
|
||||
- **§63.1 QA (2026-09-12, pre-existing, `task_d8afe80f`):** cross-file
|
||||
`references` cannot see a hierarchical-surface-only declaration (a
|
||||
module's net, variable or instance), bind or not — `nav.rs`'s
|
||||
`leaves_this_file` and `indexed_def_in_file` (shared with hover) ask
|
||||
`WorkspaceIndex::member`, the connection surface; the fix is the
|
||||
hierarchical-surface lookup in both call sites plus a fixture sweep
|
||||
across definition/references/hover/documentHighlight.
|
||||
- **§63.2 filed (2026-09-12):** the rest of the first-after-edit flush —
|
||||
the token clone into `parse_tolerant` (3.9 ms; the parser mutates the
|
||||
stream it is given, and `Document::tokens` is read for comments by
|
||||
semantic tokens and the linter), `analyze` (9.4 ms), `resolve_external`
|
||||
(4.7 ms against the 3 975-file index), and ~6 ms dropping the previous
|
||||
revision's products on the request path (drop it after answering).
|
||||
Sections after §46 are planned when reached.
|
||||
|
||||
## 45. Small items, round 4 (planned 2026-09-05) — topo §2.9-29, 30, 17, 22
|
||||
@@ -5836,9 +5868,10 @@ document revision, computed only when a fix needs it
|
||||
— residues named, not hidden: the declaring file's parse (2.2–2.4 ms
|
||||
of the ports offer's 3.27) and the buffer's own share of the imports
|
||||
index (~0.8 ms), the second a `vlog_semantic` handshake request
|
||||
- [ ] lead ruling on a lint-result reuse item (new, from P1b's number:
|
||||
- [x] lead ruling on a lint-result reuse item (new, from P1b's number:
|
||||
24.0 ms, the whole of the pinmux row, for a client that sends no
|
||||
`only`) — a keyed cache in §59's shape, not this lane's to add
|
||||
— **closed by §61.2 (0.52.0): `lint_snapshot.rs`**
|
||||
- [x] QA (P1c): the every-offset parity suites re-attacked, the two
|
||||
counters sabotaged, the numbers re-taken on the same binary
|
||||
— 2026-09-07: ports side clean (three refusal fixtures old vs new
|
||||
@@ -6139,13 +6172,15 @@ semantic build/facts owners. Serialized after 60.1–60.3.
|
||||
true with no scan running), and the include graph and completion
|
||||
tables against a text-built pair on a tree with duplicate
|
||||
spellings and `+incdir+`s
|
||||
- [ ] the walk, filed by P4b3 for the next lane: `discovery` is 158 ms of
|
||||
- [x] the walk, filed by P4b3 for the next lane: `discovery` is 158 ms of
|
||||
scope walk plus one `fs::metadata` per file for the size cap, and
|
||||
it is the floor under every first useful answer. Two things to
|
||||
measure before building anything — the cap taking its size from the
|
||||
walk's own metadata (`lucisv_core::walk::collect_files` is not
|
||||
P4b3's file: a handshake request) and handing the first folder to
|
||||
`scan_step` before the walk has finished the workspace
|
||||
— **closed by §61.3 (0.52.0): two-phase discovery and the walk
|
||||
metadata hand-off (per-file `stat`s 3 979 → 0, cap 6.92 → 0.10 ms)**
|
||||
- [x] QA (P4a only, 2026-09-08: gates green, 4272/4272, no behaviour
|
||||
change verified by hunk review and by running both binaries —
|
||||
44/44 identical result_counts and identical scan file-counts;
|
||||
@@ -6166,7 +6201,735 @@ semantic build/facts owners. Serialized after 60.1–60.3.
|
||||
— 2026-09-08: nothing reopened it; the first-after-edit row after
|
||||
P1 is inside the frame, and no user command still blocks navigation
|
||||
for a whole scan on the startup path
|
||||
- [ ] `docs/perf/README.md` entry with the accepted numbers; topo
|
||||
- [x] `docs/perf/README.md` entry with the accepted numbers; topo
|
||||
edges/handshakes for every contract amended; the plan's status
|
||||
line updated; a release cut from the clean tree with its assets
|
||||
verified
|
||||
verified — done 2026-09-08: **0.51.0** (bc59336, v0.51.0), 8
|
||||
assets, the darwin-arm64 vsix at 0.51.0 with both binaries,
|
||||
`hierarchySections.js`, `extract.js`, no `*_test.js`.
|
||||
|
||||
## 61. Performance take 5 — the review round (owner request 2026-09-08)
|
||||
|
||||
`docs/performance_take5_review.md` (Codex, 2026-09-08, at 0.51.0) is the
|
||||
spec; its "Follow-up experiment queue" in `docs/perf/take5-tracking.md`
|
||||
(R1a–R4) is the ledger every lane fills; `docs/perf/take5-review-20260908/`
|
||||
is the baseline evidence (0.51.0 review cells are fixed). Same protocol as
|
||||
§60: serial lanes in the main tree, dev (Opus) → QA (Sonnet) → lead
|
||||
review → commit; a feature README per lane under
|
||||
`docs/features/perf5r-<lane>/`; every number by `tools/perf/` under
|
||||
`tools/guard.sh -m 8 -t 1800`, opentitan read-only, no build during a
|
||||
timed session, paired against the 0.51.0 review baseline cells;
|
||||
no `sleep` over 60 s, waits bounded and keyed on a PID or a file, never
|
||||
`pgrep -f`. Order chosen by cost-of-entry and what each measurement
|
||||
unlocks: the preflights first (cheap, large), then the action path, then
|
||||
the first answer, then the scan, then rename reuse if its measurement
|
||||
justifies it.
|
||||
|
||||
### 61.1 R3a + the refusal preflights (engine-owned)
|
||||
|
||||
Review §3 items 5–6. A `textDocument/rename` on a cursor with no symbol
|
||||
materializes the whole workspace (`server/rename.rs`: `rename_name_at`
|
||||
→ `None` → `ws.sources()`, 3 976 files) and the engine builds the scope
|
||||
(3 975 parses, 1.9 s) before `locate` refuses in 0.1 ms; the duplicate-
|
||||
module refusal and the "meaning would change" refusal take the same
|
||||
road; the extract at the `aes_wrap.sv` inline-site selection spends
|
||||
805 ms building a scope before its safety checks refuse. Files:
|
||||
`vlog_refactor/src/{rename/mod.rs,extract/mod.rs,lib.rs}`,
|
||||
`lucisv_server/src/{rename.rs,extract.rs}`, tests.
|
||||
- [x] engine-owned rename preflight over the request file alone (its
|
||||
parse + analysis; `prepare_rename_here` is the existing one-file
|
||||
shape — reuse it): `check_new_name`, then the cursor refusal, with
|
||||
today's error precedence (invalid new name → out-of-scope /
|
||||
unavailable file → no symbol here) and the exact sentences; the
|
||||
server calls it before selecting sources and materializes nothing
|
||||
when it refuses; a symbol found → today's path unchanged
|
||||
— `vlog_refactor::rename_preflight` (`rename/preflight.rs`), additive,
|
||||
**without** the `external`/`index` parameters the brief proposed: every
|
||||
refusal they could answer is one the staleness argument forbids taking,
|
||||
so they would have been unused. Takes rules 1, 4, 5, 6, 11a and — only
|
||||
for a non-file-scope declaration in the buffer — rule 2
|
||||
- [x] duplicate-declaration refusal moved ahead of materialization ONLY
|
||||
with the evidence the review asks for (the index is current and
|
||||
authoritative for that name — the workspace's `declared_twice`
|
||||
already gates the ports offer on it; state the argument or leave
|
||||
it on the slow road)
|
||||
— **left on the slow road, with the argument.** `state/mod.rs::set_document`
|
||||
reads the index and never writes it, so an unsaved edit that adds or
|
||||
removes a file-scope declaration is not in it; `rename` is the authority
|
||||
that re-derives the count. A wrong *offer* costs a lightbulb, a wrong
|
||||
*refusal* costs the work. `rstmgr_por` keeps its ~2.0 s, asserted by
|
||||
`a_name_declared_in_two_files_stays_on_the_slow_road`
|
||||
- [x] extract preflight: the selection's own checks that read only the
|
||||
request file's parse (the region, the item kinds, the refusal
|
||||
shapes `extract_site`/`Region::read` already know) run before
|
||||
`Scope::build`; exact refusal sentence preserved, no optimistic edit
|
||||
— **they already do, by two mechanisms**, which the new `extractrefuse`
|
||||
phase measures: `execute`'s `site_at` gate *is* `extract_site_in`, whose
|
||||
first two statements are the parse-diagnostic check and `Region::read`;
|
||||
and `plain_identifier`/occupied are `extract_module`'s own first
|
||||
statements, ahead of `Extraction::plan`. A preflight was written, wired,
|
||||
measured and **removed** as redundant
|
||||
- [x] measured: no-symbol rename ≤ 16 ms with zero closed-workspace
|
||||
parses; the `aes_wrap.sv` extract refusal with its parse count;
|
||||
the successful renames and the extract capture unchanged
|
||||
(fingerprints); R3a/R3c cells + experiment entries
|
||||
— no-symbol **2 012.3 → 0.34 ms**, `trace_parses` **3 975 → 0**,
|
||||
peak RSS 909 → 429 MiB, sentence identical. `aes_wrap.sv` extract
|
||||
refusal **761.1 → 767.8 ms (unchanged)**; its stage is
|
||||
`boundary::Crossing::read`, scope-dependent at depth — deferred to §61.5.
|
||||
All fingerprints identical (`b39defb21265…`, `fa7e31c78382…`,
|
||||
`090e92e7736e…`). R3a/R3c cells and both experiment records filed
|
||||
- [x] QA: refusal-precedence matrix old vs new (13 shapes: invalid name,
|
||||
keyword, unsaved/closed file, untitled, no symbol, comment, string,
|
||||
macro, duplicate module, existing name, same name, large-file
|
||||
buffer, cursor on a reference vs a declaration); parse counts;
|
||||
fingerprints; numbers re-taken
|
||||
— **PASS.** Rule table rebuilt independently from `renaming`/`Scope::
|
||||
locate`/`declaration` vs `rename_preflight`/`declared_here`, agrees
|
||||
with the dev's; oracle sabotaged twice (an invented refusal, a
|
||||
reworded sentence) and caught both; gates clean (fmt/clippy/4 322-test
|
||||
guarded run, matching a same-tree baseline + the 17 added tests
|
||||
exactly — the README's "4 328" was a slip, corrected); fresh guarded
|
||||
wire re-runs against the sha256-matched candidate binary over
|
||||
OpenTitan reproduce no-symbol 0/0 parses and ≤1 ms, the duplicate-
|
||||
module and common-port rows unchanged (3 975 parses, same sentence),
|
||||
the `aes_wrap.sv` extract refusal unchanged with its `Crossing::read`
|
||||
sentence, and the `aes.sv` capture fingerprint identical; all 12
|
||||
tracker R3a/R3c-x numbers and 5 fingerprints traced verbatim in
|
||||
`~/.cache/lucisv-perf/take5r-1/`. QA log in
|
||||
`docs/features/perf5r-preflight/README.md`
|
||||
|
||||
### 61.2 R1a + R1b — the code-action path on a large file
|
||||
|
||||
Review §1. `lint.rs::fixable` still runs `lint_with` on every request:
|
||||
23 of the 25 ms all-family menu on the pinmux comment; the first action
|
||||
after an edit is 136 ms. Files: `lucisv_server/src/{lint.rs,
|
||||
code_action.rs,fences.rs,server/dispatch.rs}` + a new small module for
|
||||
the snapshot; `state/` for one field at most; tests.
|
||||
- [x] R1b first: a `--verbose` stage trace for one `codeAction` on the
|
||||
pinmux comment — config/waiver load, dirty-buffer flush (the
|
||||
`Document` rebuild), lint, fence, serialization — for the first
|
||||
request, an unchanged repeat, the first after a one-character
|
||||
edit, and the definition queued behind each; harness rows
|
||||
— `lint_trace.rs`, one `timing: codeaction …` line per request that
|
||||
linted anything, two groups (`flush{…} action{…}`) divided by the
|
||||
flush; phases `actionprofile` and `ruleablation` in
|
||||
`tools/perf/phases_r1.py`. **The 23 ms is `lint_with`** (20.9 of 22.0;
|
||||
config I/O 0.04, run build 0.01, serialization 0.03, fence skipped) and
|
||||
**three semantic rules are the whole of it** — `unused-signal` +8.2,
|
||||
`multiply-driven` +7.5, `undriven-net` +7.4 ms over a 1.3 ms floor, the
|
||||
other 55 default rules ≤ +2.2 each. **The 136 ms is 78% the flush**:
|
||||
99.7 of 127.5 ms, of which 21.1 is the diagnostics pass, leaving
|
||||
~78.6 ms of `Document::new` on 1.3 MB; the handler then lints the same
|
||||
revision a **second** time for 20.2 ms. Deviation: the flush is one
|
||||
traced stage plus its parse count, not split into parse/analysis/overlay
|
||||
— those live in `state/mod.rs`, outside this lane's ownership, and
|
||||
flush-minus-diagnostics answers the question asked
|
||||
- [x] the dependency/invalidation table written BEFORE any cache:
|
||||
document content/revision, effective rules and options, tab width,
|
||||
external waiver contents, project/index inputs the workspace rules
|
||||
read (index generation); each row names the test that flips it
|
||||
— 14 rows in `docs/features/perf5r-lint-snapshot/README.md`, derived from
|
||||
the arguments of the `lint_with(ctx, rules, external)` call it guards, so
|
||||
the list is complete by construction. Three mechanisms only: **identity**
|
||||
(the buffer, `doc.large`, close/reopen — `set_document` builds a new
|
||||
`Document`), the **key by value** (rules, options, width, indent, waiver
|
||||
*contents*), and **one explicit drop** (`Document::refresh_overlay`, which
|
||||
every index mutation in `state/` already ends in). Row 12 is the one that
|
||||
decides the config question: the `lucisv.toml` and the waiver files are
|
||||
**not watched** (`watch::SOURCE_GLOB` is sources plus the filelist), so
|
||||
the per-request read is the only thing that ever notices them changing
|
||||
- [x] R1a: a lint-result snapshot keyed by that table, consumed by the
|
||||
diagnostics pass and the quick-fix discovery alike; recomputed on
|
||||
any mismatch; bounded (one per open document); the fence authority
|
||||
and execute-time validation untouched
|
||||
— `lint_snapshot.rs`: `Key` compared **by value, never hashed**, and
|
||||
`Slot`, one `Mutex<Option<…>>` field on the `Document`. One `found(doc,
|
||||
run)` in `lint.rs` that both doors call; the tab width moved onto the
|
||||
`LintRun` (read through `format::indent_width`, whose call the dispatcher
|
||||
no longer makes) so the two doors build the same context and share one
|
||||
slot. `fence.rs` and the shared-fence contract untouched; `vlog_linter`
|
||||
untouched
|
||||
- [x] measured: unchanged pinmux menu and queued definition ≤ 16 ms;
|
||||
first-after-edit improved and reported separately with its stage
|
||||
split; no stale diagnostic or fix under any invalidation; R1a/R1b
|
||||
cells + experiments
|
||||
— paired against trunk `51cbfd2`: **all families 22.61 → 0.98 ms
|
||||
(−95.6%)**, **quickfix only 24.51 → 0.11 (−99.5%)**, **queued definition
|
||||
22.39/22.38 → 0.78/0.76 (−96.5%)** — both gates met with two orders of
|
||||
magnitude of margin. **First-after-edit 125.65 → 106.89 ms (−14.9%)**,
|
||||
and its split names the remaining stage: ~84 ms `Document::new` plus the
|
||||
21.9 ms diagnostics pass, with the code-action lint at **0.00 ms**.
|
||||
Diagnostics publish +0.3%, idle RSS at 100 open buffers each holding a
|
||||
snapshot 574.0 → 574.6 MiB (+0.1%), take-3 `codeaction` cells within
|
||||
1.5%. Config-discovery memo **not taken**: the trace measures that I/O at
|
||||
0.04–0.16 ms and its failure mode would be a stale rule selection.
|
||||
R1a/R1b cells and both experiment records filed
|
||||
- [x] QA: every invalidation row forces a fresh result (change the
|
||||
buffer, the config, a waiver file, a dependency file the workspace
|
||||
rules read, close/reopen, a UTF-16 range); stale-fix attack; memory
|
||||
bound; numbers re-taken
|
||||
— PASS. All 14 rows attacked over real stdio JSON-RPC against the
|
||||
release binary on an independent fixture workspace (two standalone
|
||||
scripts, not the dev's own tests); three targeted sabotage cuts
|
||||
(waiver text, the `refresh_overlay` drop, `tab_width` in the key)
|
||||
each caught by exactly the predicted test and reverted clean; gates
|
||||
cross-checked against a from-scratch clone of `51cbfd2` with
|
||||
matching binary sha256es and a name-level test diff (+21/-0);
|
||||
100-buffer RSS and the stage trace reproduced independently within
|
||||
noise; 12 tracker numbers traced verbatim (some as documented
|
||||
medians) in `~/.cache/lucisv-perf/take5r-2/`; opentitan clean and
|
||||
zero guard kills throughout. QA log in
|
||||
`docs/features/perf5r-lint-snapshot/README.md`
|
||||
|
||||
### 61.3 R2a + R2b — the first useful answer
|
||||
|
||||
Review §2. Warm first answer 325 ms = 205 ms workspace discovery +
|
||||
92 ms store open before the open buffer's folder is even stepped.
|
||||
Files: `lucisv_core/src/walk.rs` (an additive handshake: hand on the
|
||||
metadata the walk already stat'd), `lucisv_server/src/{state/,
|
||||
scan_order.rs,server/startup.rs,server/index.rs,index_cache.rs}`, tests.
|
||||
- [x] R2a: measure the walk's stages (gitignore/config handling, the
|
||||
size-cap `metadata` per file, path sorting) and the store open;
|
||||
then the walk metadata hand-off (one `stat` per file, not two) —
|
||||
the handshake recorded in `lucisv_core`'s README and topo before
|
||||
the interface changes — **the split says the cap's second `stat` is
|
||||
6.9 ms of a 165 ms discovery, not the ~45 §P4b3 guessed, and the
|
||||
walk is 95 % of it; the hand-off (`collect_files_with`, additive)
|
||||
takes `stats` 3 979 → 0 and `cap` 6.92 → 0.10 ms, and the first
|
||||
answer does not move. Kept as a tidy-up; R2b is the lever.** The
|
||||
handshake went into the code's doc comments as the interface
|
||||
changed and into the feature README after, not before — recorded
|
||||
as a deviation; the topo edge is a request for the lead
|
||||
- [x] R2b: the raised-folder work begins before the remaining discovery
|
||||
finishes — one coherent scan (the folder walked, stepped and
|
||||
published first; the rest of the workspace discovered and stepped
|
||||
after; paths and facts deduplicated; configured scope, exclusions,
|
||||
filelists, size cap, unsaved-buffer precedence preserved; never two
|
||||
complete scans, never an answer from only the open file); if the
|
||||
store open remains the barrier, a measured design for bounded
|
||||
local-record loading before any format change — **shipped, bounded
|
||||
twice (rung 2 only, strict descendants of a root only,
|
||||
`HEAD_WALK_MAX` 512) and `collect_files_below` carries the root's
|
||||
`.gitignore` down so the two halves of one scan cannot disagree
|
||||
about which files exist. `OPENING_FILE_WAIT` (25 ms, inside the
|
||||
staging window) closes the didOpen-vs-configuration race that left
|
||||
2 sessions in 8 paying the old cost. The store open is 61 ms of
|
||||
checksum: the bounded local load was designed and measured (~26 ms,
|
||||
~50 ms first answer) and NOT shipped — it moves cost rather than
|
||||
removing it and changes `Load::canonical`, which the compaction
|
||||
skip and the byte-identical store rest on. Filed as its own
|
||||
experiment.**
|
||||
- [x] measured: first definition ≤ 200 ms warm and cold, equal to the
|
||||
settled target (not merely non-empty); warm quiet scan ≤ 1.0 s if
|
||||
reachable, reported honestly; RSS reduction kept; startup ordering
|
||||
cases (config before/after didOpen, late/no reply, unsaved buffer,
|
||||
multiple folders, root-level file, a dependency outside the first
|
||||
folder) pinned; R2a/R2b cells + experiments — **first definition
|
||||
265.9 → 77.9 ms cold (−70.7 %) and 301.3 → 115.1 warm (−61.8 %),
|
||||
result count 1 in 12 of 12; warm quiet settle 1 033.9 → 997.4 ms
|
||||
(≤ 1 s, first time, by less than the spread); idle RSS −8.6 % cold;
|
||||
store byte-identical (three sha256s over 28 stores); 24 of 24 scope
|
||||
cells; `mismatched_answers` 0 AND the new stricter
|
||||
`unsettled_answers` 0. Named costs: settled +2.5 % / +4.8 % at 1/10
|
||||
open buffers (the neighbourhood subtree walked twice), and the
|
||||
"equal to the settled target" gate is met on the measured cursor
|
||||
and all 54 probe requests but is NOT true by construction for a
|
||||
cross-folder cursor — pinned by a test and filed as a
|
||||
`server/dispatch.rs` handshake.** Feature README
|
||||
`docs/features/perf5r-first-answer/`; 4 343 → 4 360 tests
|
||||
- [x] QA: the ordering matrix; coherence (`mismatched_answers` 0 with the
|
||||
settled-equality check, not the non-empty one); persistence
|
||||
attacks re-run; numbers re-taken
|
||||
— PASS. Gates green (4 360 tests, +17/−0 vs `a1c77c0`, fmt/clippy
|
||||
clean); walk hand-off sabotage caught by exactly the predicted 12
|
||||
tests; `collect_files_below` attacked with 5 fixtures beyond the
|
||||
dev's own 4 (nested exclusion, intermediate `.gitignore`, symlink
|
||||
outside root — pinned, agrees with the plain walk, not a
|
||||
regression — missing folder, `gitignore:false`), all correct;
|
||||
`HEAD_WALK_MAX` fallback has **no shipped test** but independently
|
||||
verified correct via a constructed fixture (filed for the lead);
|
||||
ordering matrix (a–h) read and sampled across 17 wire tests, `f`
|
||||
pinned (`open_next` finishes the *whole* pending discovery before
|
||||
reordering, never a targeted walk); `unsettled_answers` confirmed
|
||||
to count empty mid-scan answers against a non-empty settled one;
|
||||
cross-folder `[]` exception reported, not failed; `index_cache.rs`
|
||||
diff confirmed empty; opentitan clean, zero guard kills. QA log in
|
||||
`docs/features/perf5r-first-answer/README.md`
|
||||
|
||||
### 61.4 R4 — publication cost under load
|
||||
|
||||
Review §4. Files: `tools/perf/` (a fixed-arrival-rate probe), then
|
||||
`lucisv_server/src/{server/index.rs,state/,candidates.rs,includes.rs}`.
|
||||
- [x] the probe: a definition every N ms of wall clock (not after the
|
||||
previous response), recording queue latency, publications, per-
|
||||
publication cost (index absorb / candidates / includes / overlays)
|
||||
and scan completion under the same offered load, 1 / 10 / many
|
||||
buffers — **`tools/perf/phases_r4.py`: `scanload` (warm),
|
||||
`scanloadcold`, `scanloadcross`, plus a quiet control in the same
|
||||
series. A fixed request *count* over a fixed window, because the
|
||||
first draft stopped sending when the server went quiet, which made
|
||||
the offered load a function of the server — `scanserve`'s own
|
||||
confound in a new place. The split at `eb54042`, warm, one open
|
||||
buffer, a definition every 100 ms: 34 publishes, `absorb` 2 433 ms
|
||||
(78 %), `candidates` 623 (20 %), `includes` 47, `overlay` 2.4
|
||||
(0.08 %) — 3 105 ms of publication in a 4 206 ms scan whose quiet
|
||||
form takes 1 005. Cold: 88 publishes, 7 973 of 10 675 against a
|
||||
2 766 ms quiet scan. `absorb` is the cost because it ends in a
|
||||
whole-index merge; the overlay refresh, which this item expected to
|
||||
matter, is 0.08 % at one buffer and 9.6 % at 101**
|
||||
- [x] then reduce duplicate publication work (incremental candidates and
|
||||
includes tables, or a bounded publish cadence) preserving the
|
||||
coherent-prefix contract; quiet-scan decode/merge only after an
|
||||
allocation profile shows duplication — **the cadence
|
||||
(`Scan::publish_is_due`, `PUBLISH_EVERY` 512): one merge per 512
|
||||
staged records instead of one per burst of requests, with the drain
|
||||
that has something *waiting* — the session's first useful answer —
|
||||
exempt. A quiet scan still publishes nothing. The candidates
|
||||
rebuild and the overlay refresh were **measured and not rebuilt**:
|
||||
the cadence takes both down with it, and the overlay is noise at
|
||||
every buffer count an editor has. `WorkspaceIndex::absorb`'s
|
||||
whole-index merge is named as a finding for a later lane —
|
||||
`update_facts` has a targeted merge beside it and `absorb` does
|
||||
not, but that is a `vlog_semantic` change this lane may not make**
|
||||
- [x] measured: same offered load, better queue latency AND completion;
|
||||
never fewer served requests reported as a speedup; R4 cells —
|
||||
**same offered load, requests answered equal in every cell:
|
||||
publication −78 to −88 %, the traced scan −48 to −65 %, the median
|
||||
request wait −98 to −99.5 % (warm 112.3 → 1.9 ms at one buffer,
|
||||
1 960 → 10.4 at 101; cold 137.7 → 1.5, and 4 706 → 2.1 at two).
|
||||
Across the sixteen loaded cells the tail improved in ten, was level
|
||||
in two and rose in four — three of them single-open-buffer cells,
|
||||
worst warm 168 → 422 ms, against cold 9 308 → 1 583 at 101 buffers.
|
||||
Quiet warm scan 1 005 → 985 ms (≤ 1 s kept), quiet cold 2 724 →
|
||||
2 694, first useful answer 78.2 → 80.8 cold / 115.1 → 115.8 warm,
|
||||
idle RSS −0.2 %, store size identical, 24 of 24 scope cells equal,
|
||||
`scanserve` cold median 122.2 → 45.6 with the same 13 requests
|
||||
served. `mismatched_answers` 0 and `unsettled_answers` 0
|
||||
everywhere — and on a new cross-folder cursor the reference is
|
||||
unsettled 12 of 270 with one buffer and 270 of 270 with eleven
|
||||
where the candidate is 0. Feature README
|
||||
`docs/features/perf5r-publication/`; 4 360 → 4 365 tests**
|
||||
- [x] the lead's §61.3 rulings, both on this drain path: **an empty
|
||||
navigation answer computed mid-startup-scan is not answered — the
|
||||
request is asked again at the next publish and at the latest when
|
||||
the scan ends, where `[]` is honest. Three methods
|
||||
(definition / typeDefinition / references), a hover untouched and
|
||||
pinned. The `HEAD_WALK_MAX` fixture QA asked for is in
|
||||
`server/tests/startup.rs` and was sabotage-checked**
|
||||
- [x] QA: coherence under load; the probe's arrival discipline verified;
|
||||
numbers re-taken — **PASS. Coherence sabotage-tested (a direct
|
||||
index/candidates-agreement test, failed when `publish_scan`'s
|
||||
candidates absorb is disabled). The "never re-ask" sabotage produces
|
||||
the lost-request failure this task guards against; the shipped rule
|
||||
does not. `HEAD_WALK_MAX` sabotage reproduces "515 files (the folder
|
||||
first)". `scanload`/`scanloadcross` re-run independently on the dev's
|
||||
own binaries: `mismatched_answers` 0 and `unsettled_answers` 0 for the
|
||||
candidate in every cell, matching the archived record. Quiet
|
||||
scan/RSS controls re-run within ±10% (widest +6.9%). Tail
|
||||
characterized: the CAND max attributed to cadence spacing, not
|
||||
deferral; a T=100 ms secondary bound estimated to give back most of
|
||||
this cell's publication win since the reference's own pre-cadence
|
||||
publish spacing (~123 ms) is already close to 100 ms. One
|
||||
non-blocking gap found and pinned by a new test: a `$/cancelRequest`
|
||||
against a request sitting in `Server::deferred`, arriving outside a
|
||||
batch that reunites it with a publish, is silently ineffective
|
||||
(exactly-one-response held; `cancel-request`'s README needs a dated
|
||||
amendment, filed as a handshake). QA log in
|
||||
`docs/features/perf5r-publication/README.md`**
|
||||
|
||||
### 61.5 R3b + R3c — rename scope reuse (conditional)
|
||||
|
||||
Review §3 items 1–4, after 61.1's measurement of the 229 ms scope stage
|
||||
(parse / analysis / index assembly / allocation split). Request-local
|
||||
reuse of open documents' analyses and closed files' cached facts, tied
|
||||
to the selected source bytes, unsaved-buffer precedence kept, cross-file
|
||||
resolution rebuilt for the candidate workspace, a memory budget stated;
|
||||
the 51 ms warning pass profiled and tightened without changing a
|
||||
sentence; the selection set stays the correctness reference (P2d).
|
||||
- [x] lead ruling from 61.1's split: go / defer — **go — 34.3 %.** The
|
||||
tail rename's 242.4 ms scope stage is `lead` 0.4 + `kept` 133.5 +
|
||||
**`other` 83.1** + `merge` 23.4, where `other` is the 103 container
|
||||
files analysed for their index record and never read again; 83.1 /
|
||||
242.4 = 34.3 %, against a 30 % condition. Agreed by every other
|
||||
multi-file row (25.0 / 33.0 / 35.8 / 36.0 %, and **87.8 %** on the
|
||||
duplicate-module refusal); 0 % on the two rows where every selected
|
||||
file spells the name, which is the case the reuse is not for. The
|
||||
split is now shipped in the engine's trace (`IndexTrace`,
|
||||
`WarnTrace`), and a trace-only build put the inside of one analysis
|
||||
at **lex 34 %, parse 32 %, analyse 20 %, read-off 13 %** — the
|
||||
review's "parser versus index" question answered as *parser*. The
|
||||
49.7 ms warning pass is **84 % the macro-argument scan**, which is
|
||||
one per-file lex already shared by all five scans (§P2d): no
|
||||
duplicated work left in it, and retaining tokens instead is refused
|
||||
on the `clk_i` row's 1.9 GiB peak
|
||||
- [x] if go: the reuse, ≥ 20 % wire-time on the large rename at bounded
|
||||
peak RSS, ordinary / common-port / collision / macro-bind /
|
||||
hierarchical-tail / fallback cases compared, verifier untouched —
|
||||
**shipped as an engine door (`vlog_refactor::KnownFacts`) with one
|
||||
server implementation: a caller may hand back the index record it
|
||||
holds for exactly the bytes it is handing over, and the engine skips
|
||||
that file's parse. The tie is `IndexCache`'s own store entry —
|
||||
record and FNV-1a written by one read and compared in one function —
|
||||
never the workspace index's record, which carries no hash. No
|
||||
persistent decoded-analysis cache; nothing retained past the
|
||||
request; unsaved-buffer precedence falls out of the content key.
|
||||
Paired against `07ef771` with the order alternated per phase: tail
|
||||
**380.2 → 314.0 ms (−17.4 %)**, parses **240 → 137** = `(K − 103) +
|
||||
E`; fallback `clk_i` −17.4 %, conflict −18.8 %, new-name-many-uses
|
||||
−18.5 %, duplicate-module refusal **2 053 → 695 ms (−66.1 %, 3 975
|
||||
→ 14 parses)**; `aes` −0.5 %, extract refusal −0.7 %, resolves
|
||||
within ±1.4 %; peak RSS lower or level everywhere. Parity: 36 rows
|
||||
equal on fingerprint/message/status/counts/titles and **1 750
|
||||
warning sentences compared line by line** by a new `renamewarn`
|
||||
phase — identical. `check/` no diff. **The ≥ 20 % gate is missed at
|
||||
−17.4 %** against the paired reference (−21.2 % against the review's
|
||||
own 398.3 baseline; the absolute ≤ 318 ms form met at 314.0), and
|
||||
the remaining stage is named: the reuse's own **31.1 ms of store
|
||||
decode**, the price of the one-place tie. Collateral for the other
|
||||
refactorings **not taken** — measured nil, and reaching them needs a
|
||||
`_with` entry point in five files this lane does not own. Feature
|
||||
README `docs/features/perf5r-scope-reuse/`; 4 366 → 4 374 tests**
|
||||
- [x] QA — **PASS** (2026-09-09). The tie verified as one comparison
|
||||
(`entry_for`) fed by one store entry, never the workspace index;
|
||||
stale-disk, unsaved-buffer, misfiled-record and identical-content
|
||||
cross-path attacks all forgiven correctly; two sabotage variants
|
||||
(hash check removed; workspace-index record substituted) both caught
|
||||
by existing tests. Index equality re-checked at the query level
|
||||
(`defines`, `member`, `references_to`, `members_of_chain`,
|
||||
`hierarchical_declarations`) over a macro-table + re-export fixture.
|
||||
`check/` no diff; `(K-reused)+E` formula sabotage-verified. 36-row and
|
||||
1 750-sentence parity, and the 34.3 % go arithmetic, re-derived from
|
||||
raw evidence, not just read. Three QA-chosen renames (wildcard
|
||||
import, bind-visible name, two-level hierarchical tail) run directly
|
||||
against the real opentitan tree: byte-identical outcomes across
|
||||
no-reuse/full-reuse/half-reuse. One out-of-scope observation flagged
|
||||
separately (a bind-file's own occurrence going unedited/unwarned,
|
||||
reproducible at HEAD, unrelated to the reuse door). Full log:
|
||||
`docs/features/perf5r-scope-reuse/README.md`'s QA log.
|
||||
|
||||
### 61.6 Closing
|
||||
|
||||
- [x] `docs/perf/README.md` entry; topo for every contract amended; the
|
||||
review's status line; release 0.52.0 with assets verified — entry,
|
||||
topo and status lines done 2026-09-09; **0.52.0** released
|
||||
(b12e0cc, v0.52.0): 8 assets, the darwin-arm64 vsix at 0.52.0 with
|
||||
both binaries, `hierarchySections.js`, `extract.js`, no `*_test.js`.
|
||||
|
||||
## 62. The 0.52.0 review (Codex, 2026-09-09) — F1/F2/F3 and the next lanes
|
||||
|
||||
`docs/performance_052_review.md` (findings F1–F3, next actions 3–5) and
|
||||
`docs/052_implementation_plan.md` (the other agent's plan; its Phase 1
|
||||
was implemented in the tree before the lead saw it) are the spec; the
|
||||
tracker's "Follow-up findings" and N1–N3 rows are the ledger; evidence in
|
||||
`docs/perf/review-052-20260909/`. Same protocol as §60/§61.
|
||||
|
||||
### 62.1 F1 — directory aliases in the split startup scan (correctness)
|
||||
|
||||
The neighbourhood walk and the rest walk had separate visited sets, so a
|
||||
directory reachable by two spellings (`a_alias -> z_real`) was indexed
|
||||
twice at startup: two definition targets, a false "declared in more than
|
||||
one file" rename refusal, healed only by a rescan. Fix (the other agent +
|
||||
the lead's finishing lane): one `DirectoryTracker` shared across both
|
||||
walks; a pre-check that falls back to the single canonical walk when an
|
||||
alias sorts before the open folder or an ancestor; the `HEAD_WALK_MAX`
|
||||
fallback discards the head instead of unioning it; an alias found only
|
||||
by the rest walk requests an ordinary rescan so path spellings converge;
|
||||
the open-buffer alias check stats only same-named files.
|
||||
- [x] tracker shared, pre-check, fallback, conflict → rescan; `stats` 0
|
||||
on opentitan again; discovery and the 100-buffer cell unchanged
|
||||
- [x] fixtures: alias before / after / multiple / ancestor / sibling
|
||||
(outside the chain) / cycle / ignore rules / unsaved buffer /
|
||||
genuine duplicate declarations (still refused) — startup, rescan
|
||||
and restart agree on index paths, definitions and prepareRename
|
||||
- [x] QA: the matrix re-attacked, stat counts, numbers re-taken
|
||||
|
||||
### 62.2 F2 + F3 — the load probe (harness)
|
||||
|
||||
- [x] F2: a warm `scanload` cell primes an empty store untimed; per-trial
|
||||
cache hits/misses in the row; a warm trial with 0 hits is an error
|
||||
- [x] F3: scan completion stamped from the scan's own end event, not the
|
||||
request window; responses partitioned by it; arrival stamps kept
|
||||
- [x] QA: a brand-new store, a window longer than the scan
|
||||
|
||||
### 62.3 N1–N3 — deferred to loop 3 unless the owner asks
|
||||
|
||||
N1 the dirty-buffer parse (114 ms first-after-edit), N2 the retained-
|
||||
analysis parse work and the 31 ms facts decode, N3 the whole-index merge
|
||||
per publication. Filed with the review's baselines; not started.
|
||||
|
||||
### 62.4 Closing
|
||||
|
||||
- [x] `docs/perf/README.md` note; topo (the walk tracker); release 0.53.0
|
||||
with assets verified — done 2026-09-09: **0.53.0** (b4a0668,
|
||||
v0.53.0), 8 assets, the darwin-arm64 vsix at 0.53.0 with both
|
||||
binaries, `hierarchySections.js`, `extract.js`, no `*_test.js`.
|
||||
|
||||
## 63. Loop 3, round 1 (planned 2026-09-11) — the `bind` rename gap, then N1
|
||||
|
||||
Two lanes, serial, in the main tree (§36's protocol: one dev (Opus), then
|
||||
one QA (Sonnet), then the lead's review; dev and QA both through
|
||||
`tools/guard.sh`; no `sleep` over 60 s; no `pgrep -f`). Ships as 0.54.0.
|
||||
|
||||
### 63.1 A `bind` file's own occurrence of a renamed name (QA `task_834abda3`)
|
||||
|
||||
Found by §61.5's QA on the real opentitan tree, reproducible at HEAD and
|
||||
unrelated to facts reuse. Renaming `entropy_masking_req` (a net declared in
|
||||
`hw/ip/aes/rtl/aes.sv`) edits `aes.sv` but leaves `hw/ip/aes/dv/aes_bind.sv`'s
|
||||
`.entropy_masking_req(entropy_masking_req)` — the expression half of a
|
||||
connection inside `bind aes aes_reseed_if u_aes_reseed_if (…)`, which the
|
||||
binder resolves in the bind target's scope (`Target::BindScope { target:
|
||||
"aes" }`, `vlog_semantic/src/resolve.rs`) — neither edited nor warned about.
|
||||
Renaming `seed_en` (declared in `aes_prng_clearing.sv`) leaves the same file's
|
||||
two-level tail `u_aes_core.u_aes_prng_clearing.seed_en` neither edited nor
|
||||
warned about, while §49's hierarchical tail from an ordinary instantiating
|
||||
file (`u_entropy_src_main_sm.state_q` in `entropy_src_core.sv`) is edited.
|
||||
The whole-scope engine is the refusal authority, so a silent miss is a
|
||||
wrong answer: after the rename the design no longer elaborates.
|
||||
|
||||
The contract to reach: an occurrence in a `bind` directive's connection is
|
||||
**edited** when the engine resolves it to the renamed declaration — a bare
|
||||
name in the bind target's scope, or a hierarchical path whose root is the
|
||||
bind target (the target module, a `: u_x` instance list, or a hierarchical
|
||||
target path) — through the same rungs an instantiating file's occurrences
|
||||
use; **warned about** (file:line, the sentence shape `rename/warnings.rs`
|
||||
already uses) when the name occurs in a `bind` connection the engine cannot
|
||||
resolve; never silent. Source selection (`rename_sources_traced`'s rungs,
|
||||
`module_select::hierarchical_users`, `files_mentioning`) must bring the
|
||||
`bind` file in — find out which rung drops it before adding one. Refusal
|
||||
parity with `rename_preflight` stays one-directional (the preflight may
|
||||
refuse only what the engine refuses); `check/after.rs`'s rebinding check
|
||||
runs over the edited `bind` file like any other.
|
||||
|
||||
Feature README: `docs/features/rename-bind-occurrences/README.md`. Files:
|
||||
`crates/vlog_refactor/src/{rename/,references.rs,scope.rs,check/}`,
|
||||
`crates/vlog_semantic/src/{resolve.rs,workspace/}` only if a resolver rung is
|
||||
missing (a Handshake entry in the README either way),
|
||||
`crates/lucisv_server/src/{rename.rs,rename_trace.rs,module_select.rs,state/}`
|
||||
for selection, `tools/perf/` only to add a fixture row. Nothing else.
|
||||
|
||||
- [x] the reproduction pinned first: engine-level fixtures in
|
||||
`vlog_refactor` (a `bind` file beside the declaring file) for the
|
||||
bare-name connection, the positional connection, the two-level tail,
|
||||
a `: u_x` instance-list target, a hierarchical target path, a `bind`
|
||||
inside a generate block (`if (…) begin : gen … end`), and one the
|
||||
engine must *not* resolve (a bind whose target module is not in the
|
||||
workspace) — each asserting today's silent miss, then flipped
|
||||
- [x] the fix: occurrences resolved through `Target::BindScope` and tails
|
||||
rooted at the bind target edited; unresolvable ones warned about;
|
||||
the rung that dropped `aes_bind.sv` named in the README
|
||||
- [x] parity: `renamewarn`'s 1 750 sentences and the 36-row `paired`
|
||||
fingerprints re-taken against 0.53.0 — every difference is a `bind`
|
||||
file's new edit or warning and is listed in the README, nothing else
|
||||
moves; the eight rename shapes' timings within noise (the tail rename
|
||||
≤ 330 ms median)
|
||||
- [x] the three QA renames (`WidthPRDSBox`, `entropy_masking_req`,
|
||||
`seed_en`) run against the real opentitan tree through
|
||||
`rename_traced_with` under all three reuse modes: identical answers,
|
||||
and `aes_bind.sv` now edited
|
||||
- [x] QA: fixtures re-attacked (a `bind` whose connection names a
|
||||
*different* declaration of the same name; the new name colliding in
|
||||
the bind target's scope — refused; an escaped-name target; a
|
||||
`defparam`-only bind file), parity re-derived, opentitan sweep
|
||||
|
||||
### 63.2 N1 — the first request after an edit (the 0.52.0 review, item 3)
|
||||
|
||||
The review's cell: `pinmux_reg_top.sv` (40 267 lines), one-character
|
||||
`didChange`, then the all-family `codeAction` menu — **113.6 ms**, against
|
||||
0.23 ms for the unchanged repeat. The lint snapshot cannot help a fresh
|
||||
revision; what remains is the debounced `Document::new` the request wrapper
|
||||
performs before any handler runs (`tokenize`, `parse_tolerant` over a clone
|
||||
of the token stream, `collect_defines`, `analyze`, `resolve_external`,
|
||||
`LineIndex::new`), the diagnostics publish that lints the new revision, and
|
||||
the menu's own stages. `crate::lint_trace` already splits the request into
|
||||
flush / config / build / lint / fence / serialize under `--verbose`; the
|
||||
flush's inner stages are not yet split.
|
||||
|
||||
Target: ≥ 15 % off the first-after-edit cell (stretch < 95 ms) with the
|
||||
AST, the diagnostics and the menu byte-identical; the unchanged-repeat cell
|
||||
and every other `offeredit`/`offerkinds` row within noise; peak RSS not up.
|
||||
Measure before building: split the flush in `lint_trace` (lex / parse /
|
||||
defines / analyze / external / lines / publish-lint), take the numbers on
|
||||
0.53.0, and go after the largest stage. Candidates, in the order the review
|
||||
named them: the token-stream clone into `parse_tolerant` (borrow or hand
|
||||
over, keeping `Document::tokens`), allocation in `tokenize`/`parse_tolerant`
|
||||
for a 40 k-line generated file, `analyze`'s tables, `resolve_external`
|
||||
against a 3 975-file index, a second lint of the same revision anywhere on
|
||||
the path (the snapshot must serve both the publish and the menu — verify it
|
||||
does). A change in `vlog_parser`'s public signatures is a Handshake in the
|
||||
README and a topo row. No stopwatch assertions in tests.
|
||||
|
||||
Feature README: `docs/features/perf-first-after-edit/README.md`. Files:
|
||||
`crates/lucisv_server/src/{lint_trace.rs,state/mod.rs,server/,diagnostics.rs,
|
||||
code_action.rs}`, `crates/vlog_parser/src/{lexer.rs,parser/,lib.rs}`,
|
||||
`crates/vlog_semantic/src/{analyze*,bind/}` only for a measured stage,
|
||||
`tools/perf/` for the flush split rows. Nothing else.
|
||||
|
||||
- [x] the flush split in `lint_trace` and a harness row per stage; the
|
||||
0.53.0 numbers in the README before any change — `Rebuild`'s seven
|
||||
stages (`lex parse defines analyze external lines publish`) plus
|
||||
`documents`, printed as a **third sibling group** `rebuild{…}` on
|
||||
the `timing: codeaction` line, which `phases_r1.actionprofile`
|
||||
picks up as `trace_rebuild_*` with no harness code change
|
||||
(`phases_p2.parse_trace` flattens one level). **The 100 ms flush on
|
||||
0.53.0: lex 29.1, parse 25.6, publish 22.2 (lint 22.0), analyze
|
||||
10.1, external 4.8, lines 0.6, defines 0.5, ~7 dropping the old
|
||||
revision.** Two of the review's candidates were answered by the
|
||||
split: `action` reads `snapshot=hit`/`lint=0.00ms` (no second lint
|
||||
of the revision) and `lint::context` already lends `doc.semantics`
|
||||
(no second analysis)
|
||||
- [x] the fix, one stage at a time, each with its before/after cell;
|
||||
parser snapshot and idempotency suites green; corpus and opentitan
|
||||
byte-identity gates — three changes, all in `vlog_parser`: the
|
||||
lexer's two phases **fused** (the intermediate `Vec<RawTok>` gone;
|
||||
`tokenize` 27.8 → 24.7 ms), **`Parser::skip`** for the 178
|
||||
`bump()` sites that threw the token away (`parse_tolerant` 17.5 →
|
||||
16.0 ms), and a **first-byte test in front of the 44-entry
|
||||
operator table** (24.7 → **11.6 ms**, the largest single win).
|
||||
Parity: token stream + parse diagnostics + whole AST + symbol
|
||||
table digested per file over **4 807 files** (corpus + opentitan),
|
||||
0 differ; `format --stdout` byte-identical over corpus (860) and
|
||||
over opentitan (one tree digest, identical stderr); diagnostics
|
||||
and the all-family + seven-family menus identical on the pinmux,
|
||||
aes and tb buffers before and after an edit, including a revision
|
||||
edited to *have* lint findings. 4 403 → **4 406 tests**
|
||||
- [x] `offeredit`, `offerkinds`, `flush`, `diagnostics` phases paired
|
||||
against 0.53.0 with the order alternated; RSS cell — the cell
|
||||
**110.95 / 107.54 → 88.31 / 88.36 ms, −19.2 %**: the ≥ 15 % gate
|
||||
met and the < 95 ms stretch met. The unchanged-repeat cell
|
||||
(0.27/0.32 → 0.22/0.19) and every `offeredit`/`offerkinds`/
|
||||
`flush`/`diagnostics` row are inside their own version's a/b
|
||||
spread. RSS **not up**: warm flat (≈428 MiB both), cold scan
|
||||
~25 MiB *lower* (506 → 480 MiB) — the `Vec<RawTok>` that is no
|
||||
longer built; index store byte-identical at 45 468 KiB. Feature
|
||||
README `docs/features/perf-first-after-edit/`; evidence and
|
||||
runners in `~/.cache/lucisv-perf/63-2/`
|
||||
- [x] QA: the trace's arithmetic re-derived, the parity attacked (a buffer
|
||||
that fails to lex; a `` `define`` edit that changes the macro table;
|
||||
an edit that moves a fence), the numbers re-taken
|
||||
|
||||
### 63.3 Closing
|
||||
|
||||
- [x] `docs/perf/README.md` entry; topo rows for every contract amended;
|
||||
release 0.54.0 with assets verified — done 2026-09-12: **0.54.0**
|
||||
(da32237, v0.54.0), 8 assets, the darwin-arm64 vsix at 0.54.0 with
|
||||
both binaries, `hierarchySections.js`, `extract.js`, no `*_test.js`.
|
||||
|
||||
## 64. Loop 3, round 2 (planned 2026-09-12) — cross-file references for hierarchical-surface-only declarations
|
||||
|
||||
One lane. The dev half runs in the owner's spawned session
|
||||
(`task_d8afe80f`, its own worktree); QA (Sonnet) and the lead's review run
|
||||
on that result in the main tree after it lands. Same rules as §63: guard
|
||||
every suite and sweep, no `sleep` over 60 s, no `pgrep -f`, opentitan
|
||||
read-only. Ships as 0.55.0.
|
||||
|
||||
### 64.1 `references` stops at the connection surface (QA §63.1, `task_d8afe80f`)
|
||||
|
||||
`crates/lucisv_server/src/nav.rs`: `leaves_this_file` (~148) and
|
||||
`indexed_def_in_file` (~235; `indexed_def_for_symbol` is shared with
|
||||
`hover.rs`) decide whether a declaration can be referenced from another file
|
||||
by `WorkspaceIndex::member(unit, name)` — the **connection** surface, ports
|
||||
and parameters. A module's net, variable or instance lives on the
|
||||
**hierarchical** surface only (`workspace/hierarchy.rs`, since 2026-09-05), so
|
||||
both functions treat such a declaration as unable to leave its file. Two
|
||||
symptoms, pinned by
|
||||
`nav.rs::a_binds_connection_expression_is_reachable_by_definition_not_yet_by_references`:
|
||||
`references` from the *declaration* of a hierarchically reached net falls to
|
||||
the single-file fallback and never sees a cross-file use (a `bind`
|
||||
connection or an ordinary `u_x.sig` tail alike); `references` from a *use*
|
||||
that does resolve cross-file cannot re-identify the open buffer's own
|
||||
in-file use of the same declaration, because `indexed_def_in_file` maps the
|
||||
live symbol back the same wrong way. Not `bind`-specific; reproduced with a
|
||||
plain `assign w = u_leaf.sig;`.
|
||||
|
||||
The contract to reach: a declaration's cross-file reachability is judged on
|
||||
the surface a use can actually reach it by — `member_in(unit, name,
|
||||
Surface::Hierarchical)` in both call sites (the connection answer is a prefix
|
||||
of the hierarchical one, so package/class/struct members and ports keep
|
||||
their answers byte-for-byte). `references_are_ambiguous` and the
|
||||
single-record rule (`defs.len() != 1`) keep their meaning over the wider
|
||||
answer — a name declared both as a port and as an internal net of the same
|
||||
unit is ambiguous, not silently the port. Hover and definition, which share
|
||||
`indexed_def_for_symbol`, must not change what they say for anything they
|
||||
already answered. No new index field, so no `FACTS_FORMAT` bump; if one
|
||||
turns out to be needed, say why in the README.
|
||||
|
||||
Feature README: `docs/features/references-hierarchical-surface/README.md`.
|
||||
Files: `crates/lucisv_server/src/{nav.rs,hover.rs}` and the server's wire
|
||||
tests (`server/tests/`), `crates/vlog_semantic/src/workspace/hierarchy.rs`
|
||||
only if `member_in` needs a case it lacks (a Handshake entry either way).
|
||||
Nothing else.
|
||||
|
||||
- [x] the fixture sweep first, asserting today's answers, then flipped:
|
||||
`definition`, `references` (from the declaration and from each use,
|
||||
`includeDeclaration` both ways), `hover`, `documentHighlight` over
|
||||
(a) a `bind` connection's bare name, (b) a `u_x.sig` tail from an
|
||||
instantiating file, (c) a two-level tail, (d) a port of the same
|
||||
unit (unchanged answers), (e) a package member (unchanged), (f) a
|
||||
name that is both a port and an internal net of one unit (ambiguous
|
||||
— the single-file fallback, as today), (g) an unsaved buffer
|
||||
(`untitled:`), (h) the open buffer's own in-file use seen from a
|
||||
cross-file use
|
||||
- [x] the fix in both call sites; the §63.1 QA test renamed to say what it
|
||||
now asserts
|
||||
- [x] on the real opentitan tree (read-only): `references` on
|
||||
`entropy_masking_req` from `aes.sv` lists `aes_bind.sv`; on
|
||||
`state_q` from `entropy_src_main_sm.sv` lists `entropy_src_core.sv`;
|
||||
the `nav`/`navqueue` harness rows within noise (the hierarchical
|
||||
lookup is one more map probe)
|
||||
- [x] QA: fixtures re-attacked (a generate-scoped net; a net shadowed by a
|
||||
port of the same name in a *different* unit; a class member — must
|
||||
stay on the connection answer), opentitan census, gates. Verdict:
|
||||
rework needed — three findings in the closed-declaring-file repair's
|
||||
handling of a stale-on-disk file (one new to this lane, two
|
||||
pre-existing and general); see the feature README's QA log.
|
||||
- [x] rework (dev, per the lead's ruling on QA findings 1–3): one fresh read
|
||||
per closed file per request, threaded to the rendering step
|
||||
(`file_view`'s cache is no longer on this path); a re-analysed closed
|
||||
file's declaration reported at its live span; every index-time
|
||||
closed-file span guarded with `hover::spells_exactly` (now `pub(crate)`)
|
||||
and dropped rather than misrendered. `qa_finding_1/2/3` flipped to the
|
||||
fixed answers and renamed, plus one attack on the guard itself. QA's
|
||||
+25 % on a local-net request in a 40 000-line file accepted as-is, for
|
||||
§64.2 to note in `docs/perf/README.md`.
|
||||
- [x] QA re-check (same worktree): findings 1–3 re-derived by hand and
|
||||
confirmed fixed (a use-only shift, a deleted declaring file, a UTF-8
|
||||
boundary, two independent closed files, an escaped port and an
|
||||
escaped hierarchical net all attacked and held). **Finding 4, new**:
|
||||
the `include_declaration` fallback's index-time span is rendered with
|
||||
**no guard** when the file is *open* (only the closed path calls
|
||||
`spells_exactly`) — reproduced with a renamed live buffer, a stale
|
||||
3-byte span lands on the first three characters of the live token
|
||||
`sig2`. Verdict: rework needed again; see the feature README's QA log
|
||||
for the fix suggestion. Gates green (4453 passed), opentitan
|
||||
re-confirmed byte-identical, size 423 lines.
|
||||
- [x] rework 2 (dev, finding 4): the `include_declaration` chain lifted into
|
||||
`nav::declaration_site`; an open buffer's index-time fallback span is
|
||||
emitted only if `hover::spells_exactly` holds against the live text,
|
||||
else the declaration is omitted (the closed path keeps its single guard
|
||||
in `closed_locations`). QA's finding-4 test flipped and renamed, plus a
|
||||
control (an unsaved edit above the declaration still reports the live
|
||||
line). Gates green through `tools/guard.sh`.
|
||||
- [x] QA final (escalated, same worktree): the finding-4 test re-derived
|
||||
by hand (a real unsaved rename; honest omission, tails unchanged) and
|
||||
the control shown to come from the live path; the declaration-site
|
||||
ladder attacked rung by rung — five `qa_final_*` tests (a failed live
|
||||
lookup with the name still in place → emitted; a suffix of a longer
|
||||
live name → dropped; off a UTF-8 boundary → dropped, no panic;
|
||||
`includeDeclaration: false` on the closed rungs; one observation, a
|
||||
different exact `sig` at the old bytes is reported, for the lead).
|
||||
`nav.rs` 433 production lines, no unwrap/expect/panic,
|
||||
`indexed_references` 71 lines (reported). Gates green (4459 passed),
|
||||
opentitan rows re-confirmed read-only, checkout status identical.
|
||||
Verdict: **pass**.
|
||||
|
||||
### 64.2 Closing
|
||||
|
||||
- [x] `docs/perf/README.md` note if any harness number moved; topo row
|
||||
(`lucisv_server ──▶ vlog_semantic`: nav asks the hierarchical
|
||||
surface) — done 2026-09-12 (the perf entry records the +25 % on a
|
||||
local-net `references` and the closed-file parse; the
|
||||
`references-nav ──▶ workspace-index` row amended)
|
||||
- [ ] release 0.55.0 with assets verified — owner's call; not run from the
|
||||
`task_d8afe80f` session (a release chain never runs while a lane is
|
||||
in flight, and the lane merges first)
|
||||
+393
-19
@@ -2,7 +2,7 @@
|
||||
//! `.gitignore` subset documented in
|
||||
//! `docs/features/parallel-files/README.md`.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// File extensions lucisv formats when walking a directory.
|
||||
@@ -48,27 +48,134 @@ pub fn collect_files(
|
||||
gitignore: bool,
|
||||
files: &mut Vec<PathBuf>,
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String> {
|
||||
collect_files_with(input, exclude, gitignore, &mut |path, _| files.push(path), warn)
|
||||
}
|
||||
|
||||
/// [`collect_files`] with the size the walk already read handed on beside each
|
||||
/// path.
|
||||
///
|
||||
/// The same walk, the same order, the same warnings — the only difference is
|
||||
/// where a file goes when it is found. A directory walk already calls
|
||||
/// `metadata` on every entry to answer "directory?", so the length is a field
|
||||
/// of a struct it holds anyway; a caller that has to know how big a file is —
|
||||
/// the server's `lucisv.index.maxFileSize` cap — would otherwise ask the
|
||||
/// filesystem the same question a second time, once per file.
|
||||
/// `docs/features/perf5r-first-answer/README.md` measured that second `stat`
|
||||
/// at 6.9 ms of a 165 ms discovery over 3 976 files — small, because the walk
|
||||
/// has just warmed every one of those inodes, and 3 976 system calls that buy
|
||||
/// a number already in hand all the same.
|
||||
///
|
||||
/// **`None` means the walk did not look.** `input` naming a file rather than a
|
||||
/// directory is handed straight over, exactly as [`collect_files`] hands it
|
||||
/// over, with no `metadata` call added to a path that never needed one — so a
|
||||
/// caller that wants a size there asks for it itself. Every path a *directory
|
||||
/// walk* yields carries `Some`.
|
||||
pub fn collect_files_with(
|
||||
input: &str,
|
||||
exclude: &[String],
|
||||
gitignore: bool,
|
||||
found: &mut dyn FnMut(PathBuf, Option<u64>),
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String> {
|
||||
let mut tracker = DirectoryTracker::new();
|
||||
collect_files_tracked(input, exclude, gitignore, &mut tracker, found, warn)
|
||||
}
|
||||
|
||||
/// [`collect_files_with`] using an existing [`DirectoryTracker`].
|
||||
pub fn collect_files_tracked(
|
||||
input: &str,
|
||||
exclude: &[String],
|
||||
gitignore: bool,
|
||||
tracker: &mut DirectoryTracker,
|
||||
found: &mut dyn FnMut(PathBuf, Option<u64>),
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String> {
|
||||
let path = Path::new(input);
|
||||
if path.is_dir() {
|
||||
let mut walk = Walk {
|
||||
exclude,
|
||||
gitignore,
|
||||
ignores: Vec::new(),
|
||||
rel: Vec::new(),
|
||||
visited: HashSet::new(),
|
||||
files,
|
||||
warn,
|
||||
};
|
||||
let mut walk =
|
||||
Walk { exclude, gitignore, ignores: Vec::new(), rel: Vec::new(), tracker, found, warn };
|
||||
walk.dir(path);
|
||||
} else if path.is_file() {
|
||||
files.push(path.to_path_buf());
|
||||
found(path.to_path_buf(), None);
|
||||
} else {
|
||||
return Err(format!("{input}: no such file or directory"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// [`collect_files_with`] over `input`, which lies **under** `root`, finding
|
||||
/// exactly what a walk of `root` would have found there.
|
||||
///
|
||||
/// The difference from walking `input` directly is the `.gitignore` files
|
||||
/// between the two. A walk reads ignore rules from its own starting directory
|
||||
/// downwards, so `collect_files_with("<root>/hw/ip/aes")` never sees the rule
|
||||
/// `<root>/.gitignore` writes about `hw/ip/aes/gen/` — and a caller walking a
|
||||
/// subtree *of a scope whose rung is the root* would then index files that
|
||||
/// scope excludes. This one walks the ancestor chain first: it reads each
|
||||
/// ancestor's `.gitignore` onto the stack with the depth it belongs at, and it
|
||||
/// stops without yielding anything when one of those ancestors is itself
|
||||
/// ignored or excluded — because a walk of `root` would never have descended
|
||||
/// into it.
|
||||
///
|
||||
/// `input` not being under `root` is the caller's mistake and is answered the
|
||||
/// way a walk of an unknown path is: nothing found, and no error, since there
|
||||
/// is no ancestor chain to apply.
|
||||
///
|
||||
/// Everything else is [`collect_files_with`]: the same order, the same cycle
|
||||
/// guard, the same warnings, the same lengths.
|
||||
pub fn collect_files_below(
|
||||
root: &Path,
|
||||
input: &Path,
|
||||
exclude: &[String],
|
||||
gitignore: bool,
|
||||
found: &mut dyn FnMut(PathBuf, Option<u64>),
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String> {
|
||||
let mut tracker = DirectoryTracker::new();
|
||||
collect_files_below_tracked(root, input, exclude, gitignore, &mut tracker, found, warn)
|
||||
}
|
||||
|
||||
/// [`collect_files_below`] using an existing [`DirectoryTracker`].
|
||||
pub fn collect_files_below_tracked(
|
||||
root: &Path,
|
||||
input: &Path,
|
||||
exclude: &[String],
|
||||
gitignore: bool,
|
||||
tracker: &mut DirectoryTracker,
|
||||
found: &mut dyn FnMut(PathBuf, Option<u64>),
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String> {
|
||||
let Ok(below) = input.strip_prefix(root) else { return Ok(()) };
|
||||
if !input.is_dir() {
|
||||
return Err(format!("{}: no such file or directory", input.display()));
|
||||
}
|
||||
let mut walk =
|
||||
Walk { exclude, gitignore, ignores: Vec::new(), rel: Vec::new(), tracker, found, warn };
|
||||
// The root's own `.gitignore` sits at depth 0, exactly where a walk of the
|
||||
// root would have put it.
|
||||
walk.push_ignore(root);
|
||||
let mut here = root.to_path_buf();
|
||||
let names: Vec<String> = below.iter().map(|name| name.to_string_lossy().into_owned()).collect();
|
||||
for (at, name) in names.iter().enumerate() {
|
||||
here.push(name);
|
||||
if is_excluded(&here, exclude) {
|
||||
return Ok(());
|
||||
}
|
||||
walk.rel.push(name.clone());
|
||||
if is_ignored(&walk.ignores, &walk.rel, true) {
|
||||
return Ok(());
|
||||
}
|
||||
// Not `input`'s own — `Walk::dir` pushes that one itself, and pushing
|
||||
// it twice would apply its rules at two different depths.
|
||||
if at + 1 < names.len() {
|
||||
walk.push_ignore(&here);
|
||||
}
|
||||
}
|
||||
walk.dir(input);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// How a directory is recognised as one the walk has already entered. Two
|
||||
/// names for the same directory — a symlink and its target, or two symlinks
|
||||
/// pointing at one place — must map to the same identity, or a cycle has no
|
||||
@@ -76,24 +183,78 @@ pub fn collect_files(
|
||||
/// elsewhere it is the canonical path, which resolves symlinks the same way
|
||||
/// at the cost of a real path lookup.
|
||||
#[cfg(unix)]
|
||||
type DirId = (u64, u64);
|
||||
pub type DirId = (u64, u64);
|
||||
#[cfg(not(unix))]
|
||||
type DirId = PathBuf;
|
||||
pub type DirId = PathBuf;
|
||||
|
||||
/// The identity of the directory at `path`, or `None` when it cannot be
|
||||
/// read — a dangling symlink, or a directory that vanished mid-walk.
|
||||
#[cfg(unix)]
|
||||
fn dir_id(path: &Path) -> Option<DirId> {
|
||||
pub fn dir_id(path: &Path) -> Option<DirId> {
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
let meta = std::fs::metadata(path).ok()?;
|
||||
Some((meta.dev(), meta.ino()))
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn dir_id(path: &Path) -> Option<DirId> {
|
||||
pub fn dir_id(path: &Path) -> Option<DirId> {
|
||||
std::fs::canonicalize(path).ok()
|
||||
}
|
||||
|
||||
/// What happened when attempting to enter a directory with [`DirectoryTracker`].
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum DirStatus {
|
||||
/// Entered for the first time.
|
||||
EnteredFirstTime,
|
||||
/// Already visited under the same or an earlier path.
|
||||
AlreadyVisited,
|
||||
/// Previously entered under `recorded`, but `dir < recorded` indicating
|
||||
/// out-of-order traversal relative to a canonical root walk.
|
||||
PrecedenceConflict { recorded: PathBuf },
|
||||
}
|
||||
|
||||
/// Tracks visited directories across one or more walks to ensure cycle termination
|
||||
/// and detect order divergence.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct DirectoryTracker {
|
||||
visited: HashMap<DirId, PathBuf>,
|
||||
has_conflict: bool,
|
||||
}
|
||||
|
||||
impl DirectoryTracker {
|
||||
/// Creates an empty directory tracker.
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Records `dir` as entered and returns its [`DirStatus`].
|
||||
pub fn enter(&mut self, dir: &Path) -> DirStatus {
|
||||
let Some(id) = dir_id(dir) else {
|
||||
return DirStatus::AlreadyVisited;
|
||||
};
|
||||
match self.visited.entry(id) {
|
||||
std::collections::hash_map::Entry::Vacant(v) => {
|
||||
v.insert(dir.to_path_buf());
|
||||
DirStatus::EnteredFirstTime
|
||||
}
|
||||
std::collections::hash_map::Entry::Occupied(o) => {
|
||||
let recorded = o.get();
|
||||
if dir < recorded.as_path() {
|
||||
self.has_conflict = true;
|
||||
DirStatus::PrecedenceConflict { recorded: recorded.clone() }
|
||||
} else {
|
||||
DirStatus::AlreadyVisited
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether any precedence conflict was observed across walks.
|
||||
pub fn has_conflict(&self) -> bool {
|
||||
self.has_conflict
|
||||
}
|
||||
}
|
||||
|
||||
/// True when `path` names one of the source files lucisv formats.
|
||||
fn is_source(path: &Path) -> bool {
|
||||
path.extension().and_then(|e| e.to_str()).is_some_and(|ext| EXTENSIONS.contains(&ext))
|
||||
@@ -109,8 +270,10 @@ struct Walk<'a> {
|
||||
gitignore: bool,
|
||||
ignores: Vec<Ignore>,
|
||||
rel: Vec<String>,
|
||||
visited: HashSet<DirId>,
|
||||
files: &'a mut Vec<PathBuf>,
|
||||
tracker: &'a mut DirectoryTracker,
|
||||
/// Where a source file goes when the walk finds one, with the length the
|
||||
/// walk's own `metadata` call already read.
|
||||
found: &'a mut dyn FnMut(PathBuf, Option<u64>),
|
||||
warn: &'a mut dyn FnMut(Warning),
|
||||
}
|
||||
|
||||
@@ -169,7 +332,10 @@ impl Walk<'_> {
|
||||
if meta.is_dir() {
|
||||
self.dir(&path);
|
||||
} else if meta.is_file() && is_source(&path) {
|
||||
self.files.push(path);
|
||||
// The length comes off the `metadata` above — the same
|
||||
// call that answered "directory?" — so a caller wanting it
|
||||
// costs the walk nothing at all.
|
||||
(self.found)(path, Some(meta.len()));
|
||||
}
|
||||
}
|
||||
self.rel.pop();
|
||||
@@ -192,7 +358,7 @@ impl Walk<'_> {
|
||||
///
|
||||
/// A directory whose identity cannot be read is not entered.
|
||||
fn enter(&mut self, dir: &Path) -> bool {
|
||||
dir_id(dir).is_some_and(|id| self.visited.insert(id))
|
||||
matches!(self.tracker.enter(dir), DirStatus::EnteredFirstTime)
|
||||
}
|
||||
|
||||
/// Reads `dir`'s `.gitignore`, if there is one, onto the rule stack.
|
||||
@@ -680,6 +846,181 @@ mod tests {
|
||||
assert_eq!(tree.walk(""), ["keep.sv"]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// The metadata hand-off — `docs/features/perf5r-first-answer/README.md`
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// Every path `collect_files_with` yields under `rel`, with its length.
|
||||
#[cfg(unix)]
|
||||
fn walked_with(tree: &TempTree, rel: &str) -> Vec<(String, Option<u64>)> {
|
||||
let start = if rel.is_empty() { tree.path.clone() } else { tree.path.join(rel) };
|
||||
let mut out = Vec::new();
|
||||
collect_files_with(
|
||||
start.to_str().expect("utf-8 temp path"),
|
||||
&[],
|
||||
true,
|
||||
&mut |path, len| out.push((tree.rel_of(&path), len)),
|
||||
&mut |_| {},
|
||||
)
|
||||
.expect("the walk finishes");
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn the_metadata_entry_yields_exactly_the_paths_the_plain_one_does() {
|
||||
// The claim the server's cap rests on: `collect_files` is
|
||||
// `collect_files_with` with the length thrown away, so the two cannot
|
||||
// disagree about which files exist — not about order, not about
|
||||
// `.gitignore`, not about a symlink cycle, not about a broken link.
|
||||
let tree = TempTree::new("handoffsame");
|
||||
tree.write(".gitignore", "build\n");
|
||||
tree.source("a.sv");
|
||||
tree.source("rtl/b.sv");
|
||||
tree.source("rtl/deep/c.svh");
|
||||
tree.source("build/hidden.sv");
|
||||
tree.write("rtl/notsource.txt", "x");
|
||||
tree.link("rtl/loop", "..");
|
||||
tree.link("rtl/dangling.sv", "nowhere.sv");
|
||||
|
||||
let mut plain = Vec::new();
|
||||
collect_files(tree.path.to_str().expect("utf-8"), &[], true, &mut plain, &mut |_| {})
|
||||
.expect("the walk finishes");
|
||||
let plain: Vec<String> = plain.iter().map(|p| tree.rel_of(p)).collect();
|
||||
let handed: Vec<String> =
|
||||
walked_with(&tree, "").into_iter().map(|(path, _)| path).collect();
|
||||
assert_eq!(plain, handed, "the same paths in the same order, byte for byte");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_walked_file_carries_the_length_the_walk_already_read() {
|
||||
let tree = TempTree::new("handofflen");
|
||||
tree.write("small.sv", "module m;\nendmodule\n");
|
||||
tree.write("big.sv", &"// pad\n".repeat(500));
|
||||
let found = walked_with(&tree, "");
|
||||
let sizes: Vec<(String, Option<u64>)> = found;
|
||||
assert_eq!(
|
||||
sizes,
|
||||
[("big.sv".to_string(), Some(3_500)), ("small.sv".to_string(), Some(20))],
|
||||
"the length is the file's own, not a guess"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_path_named_directly_is_handed_over_without_a_stat() {
|
||||
// `None` is the walk saying it did not look — the file was named, not
|
||||
// walked to, and adding a `metadata` call for it would be a cost
|
||||
// `collect_files` never paid.
|
||||
let tree = TempTree::new("handoffnamed");
|
||||
tree.source("one.sv");
|
||||
let found = walked_with(&tree, "one.sv");
|
||||
assert_eq!(found, [("one.sv".to_string(), None)]);
|
||||
}
|
||||
|
||||
/// What `collect_files_below(root, root/rel)` finds, relative to the tree.
|
||||
#[cfg(unix)]
|
||||
fn below(tree: &TempTree, rel: &str, exclude: &[&str]) -> Vec<String> {
|
||||
let patterns: Vec<String> = exclude.iter().map(|p| p.to_string()).collect();
|
||||
let mut out = Vec::new();
|
||||
collect_files_below(
|
||||
&tree.path,
|
||||
&tree.path.join(rel),
|
||||
&patterns,
|
||||
true,
|
||||
&mut |path, _| out.push(tree.rel_of(&path)),
|
||||
&mut |_| {},
|
||||
)
|
||||
.expect("the walk finishes");
|
||||
out.sort();
|
||||
out
|
||||
}
|
||||
|
||||
/// What a walk of the whole tree finds under `rel` — the answer `below`
|
||||
/// has to reproduce.
|
||||
#[cfg(unix)]
|
||||
fn whole_under(tree: &TempTree, rel: &str, exclude: &[&str]) -> Vec<String> {
|
||||
let patterns: Vec<String> = exclude.iter().map(|p| p.to_string()).collect();
|
||||
let mut out = Vec::new();
|
||||
collect_files(tree.path.to_str().expect("utf-8"), &patterns, true, &mut out, &mut |_| {})
|
||||
.expect("the walk finishes");
|
||||
let prefix = format!("{rel}/");
|
||||
let mut under: Vec<String> =
|
||||
out.iter().map(|p| tree.rel_of(p)).filter(|p| p.starts_with(&prefix)).collect();
|
||||
under.sort();
|
||||
under
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_walk_that_starts_below_a_root_still_obeys_that_roots_gitignore() {
|
||||
// The whole reason `collect_files_below` exists. Starting the walk at
|
||||
// `hw/ip/aes` loses every rule written above it, and a scope whose
|
||||
// rung *is* the root would then index files that scope excludes.
|
||||
let tree = TempTree::new("belowignore");
|
||||
tree.write(".gitignore", "gen/\n*_generated.sv\n");
|
||||
tree.write("hw/.gitignore", "vendor/\n");
|
||||
tree.source("hw/ip/aes/rtl/aes.sv");
|
||||
tree.source("hw/ip/aes/rtl/aes_generated.sv");
|
||||
tree.source("hw/ip/aes/gen/made.sv");
|
||||
tree.source("hw/ip/aes/vendor/third.sv");
|
||||
tree.source("hw/ip/aes/dv/tb.sv");
|
||||
|
||||
let seen = below(&tree, "hw/ip/aes", &[]);
|
||||
assert_eq!(seen, ["hw/ip/aes/dv/tb.sv", "hw/ip/aes/rtl/aes.sv"]);
|
||||
assert_eq!(seen, whole_under(&tree, "hw/ip/aes", &[]), "the root walk agrees");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_directory_the_root_walk_never_entered_yields_nothing_below_it() {
|
||||
// An ancestor the root's own rules ignore is an ancestor the root walk
|
||||
// never descended into, so nothing under it is in scope however
|
||||
// directly it is named.
|
||||
let tree = TempTree::new("belowblocked");
|
||||
tree.write(".gitignore", "hw/vendor/\n");
|
||||
tree.source("hw/vendor/ip/aes/aes.sv");
|
||||
tree.source("hw/ip/aes/aes.sv");
|
||||
assert!(below(&tree, "hw/vendor/ip/aes", &[]).is_empty());
|
||||
assert_eq!(below(&tree, "hw/ip/aes", &[]), ["hw/ip/aes/aes.sv"]);
|
||||
// An excluded ancestor is the same answer by the other filter.
|
||||
assert!(below(&tree, "hw/ip/aes", &["ip"]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_negation_below_the_root_still_wins_over_the_root_rule() {
|
||||
// The precedence a root walk gives — deeper file last, so its `!` line
|
||||
// re-includes — must survive the ancestor chain being pre-loaded.
|
||||
let tree = TempTree::new("belownegate");
|
||||
tree.write(".gitignore", "*.sv\n");
|
||||
tree.write("hw/ip/aes/.gitignore", "!keep.sv\n");
|
||||
tree.source("hw/ip/aes/keep.sv");
|
||||
tree.source("hw/ip/aes/drop.sv");
|
||||
let seen = below(&tree, "hw/ip/aes", &[]);
|
||||
assert_eq!(seen, ["hw/ip/aes/keep.sv"]);
|
||||
assert_eq!(seen, whole_under(&tree, "hw/ip/aes", &[]), "the root walk agrees");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_start_that_is_not_under_the_root_finds_nothing() {
|
||||
let tree = TempTree::new("belowoutside");
|
||||
tree.source("a/x.sv");
|
||||
let mut out = Vec::new();
|
||||
collect_files_below(
|
||||
&tree.path.join("a"),
|
||||
&tree.path,
|
||||
&[],
|
||||
true,
|
||||
&mut |path, _| out.push(path),
|
||||
&mut |_| {},
|
||||
)
|
||||
.expect("no error, nothing found");
|
||||
assert!(out.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_syntax_degrades_to_plain_globbing() {
|
||||
// `**` is just two stars inside one component; documented.
|
||||
@@ -689,4 +1030,37 @@ mod tests {
|
||||
assert!(ignored("x?.sv", "x?.sv"));
|
||||
assert!(!ignored("x?.sv", "xa.sv"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn tracker_detects_precedence_conflict_when_alias_sorts_before() {
|
||||
let tree = TempTree::new("trackconflict");
|
||||
tree.source("z_real/child.sv");
|
||||
tree.link("a_alias", "z_real");
|
||||
|
||||
let mut tracker = DirectoryTracker::new();
|
||||
assert_eq!(tracker.enter(&tree.path.join("z_real")), DirStatus::EnteredFirstTime);
|
||||
assert!(!tracker.has_conflict());
|
||||
|
||||
// Entering a_alias afterwards detects that a_alias sorts before z_real
|
||||
let status = tracker.enter(&tree.path.join("a_alias"));
|
||||
assert!(matches!(status, DirStatus::PrecedenceConflict { .. }));
|
||||
assert!(tracker.has_conflict());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn tracker_allows_alias_sorting_after_without_conflict() {
|
||||
let tree = TempTree::new("trackorder");
|
||||
tree.source("a_real/child.sv");
|
||||
tree.link("z_alias", "a_real");
|
||||
|
||||
let mut tracker = DirectoryTracker::new();
|
||||
assert_eq!(tracker.enter(&tree.path.join("a_real")), DirStatus::EnteredFirstTime);
|
||||
assert!(!tracker.has_conflict());
|
||||
|
||||
// Entering z_alias afterwards: already visited, no precedence conflict
|
||||
assert_eq!(tracker.enter(&tree.path.join("z_alias")), DirStatus::AlreadyVisited);
|
||||
assert!(!tracker.has_conflict());
|
||||
}
|
||||
}
|
||||
@@ -33,19 +33,36 @@ pub fn code_actions(
|
||||
doc: &Document,
|
||||
range: Range,
|
||||
only: Option<&[CodeActionKind]>,
|
||||
tab_width: usize,
|
||||
) -> Vec<CodeActionOrCommand> {
|
||||
let violations = crate::lint::fixable(run, doc);
|
||||
// Timed apart from the lint pass that found them: a menu that is slow
|
||||
// because it *renders* a thousand fixes is a different problem from one
|
||||
// that is slow because it found them (review round §R1b).
|
||||
let actions = crate::lint_trace::stage(crate::lint_trace::Stage::Serialize, || {
|
||||
offered(uri, doc, range, only, &violations)
|
||||
});
|
||||
crate::lint_trace::saw_actions(actions.len());
|
||||
actions
|
||||
}
|
||||
|
||||
/// The quick fixes and the fix-all action `only` asks for, built from
|
||||
/// violations already found.
|
||||
fn offered(
|
||||
uri: &Uri,
|
||||
doc: &Document,
|
||||
range: Range,
|
||||
only: Option<&[CodeActionKind]>,
|
||||
violations: &[Violation],
|
||||
) -> Vec<CodeActionOrCommand> {
|
||||
let positions = doc.positions();
|
||||
let violations = crate::lint::fixable(run, doc, tab_width);
|
||||
let mut actions = Vec::new();
|
||||
if wanted(only, &CodeActionKind::QUICKFIX) {
|
||||
let quick = violations.iter().filter_map(|v| quick_fix(uri, &positions, v, range));
|
||||
actions.extend(quick.map(CodeActionOrCommand::CodeAction));
|
||||
}
|
||||
if wanted(only, &CodeActionKind::new(FIX_ALL)) {
|
||||
actions.extend(
|
||||
fix_all(uri, doc, &positions, &violations).map(CodeActionOrCommand::CodeAction),
|
||||
);
|
||||
actions
|
||||
.extend(fix_all(uri, doc, &positions, violations).map(CodeActionOrCommand::CodeAction));
|
||||
}
|
||||
actions
|
||||
}
|
||||
@@ -184,7 +201,7 @@ mod tests {
|
||||
fn actions_of(ws: &Workspace) -> Vec<CodeAction> {
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
code_actions(&LintRun::default(), &uri(), doc, whole, None, 2)
|
||||
code_actions(&LintRun::default(), &uri(), doc, whole, None)
|
||||
.into_iter()
|
||||
.map(|a| match a {
|
||||
CodeActionOrCommand::CodeAction(action) => action,
|
||||
@@ -268,7 +285,6 @@ mod tests {
|
||||
doc,
|
||||
line1,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
2,
|
||||
);
|
||||
assert_eq!(actions.len(), 1, "the cursor's line only: {actions:#?}");
|
||||
}
|
||||
@@ -341,14 +357,8 @@ mod tests {
|
||||
start: Position { line: fenced_line, character: 0 },
|
||||
end: Position { line: fenced_line, character: 0 },
|
||||
};
|
||||
let actions = code_actions(
|
||||
&LintRun::default(),
|
||||
&uri(),
|
||||
doc,
|
||||
at,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
2,
|
||||
);
|
||||
let actions =
|
||||
code_actions(&LintRun::default(), &uri(), doc, at, Some(&[CodeActionKind::QUICKFIX]));
|
||||
assert!(actions.is_empty(), "no quick fix inside a fence: {actions:#?}");
|
||||
// The unfenced tab one line further down still has one.
|
||||
let at = Range {
|
||||
@@ -356,15 +366,8 @@ mod tests {
|
||||
end: Position { line: 4, character: 0 },
|
||||
};
|
||||
assert_eq!(
|
||||
code_actions(
|
||||
&LintRun::default(),
|
||||
&uri(),
|
||||
doc,
|
||||
at,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
2
|
||||
)
|
||||
.len(),
|
||||
code_actions(&LintRun::default(), &uri(), doc, at, Some(&[CodeActionKind::QUICKFIX]),)
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
}
|
||||
@@ -409,19 +412,14 @@ mod tests {
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
let fix_all_only = [CodeActionKind::new(FIX_ALL)];
|
||||
let actions = code_actions(&LintRun::default(), &uri(), doc, whole, Some(&fix_all_only), 2);
|
||||
let actions = code_actions(&LintRun::default(), &uri(), doc, whole, Some(&fix_all_only));
|
||||
assert_eq!(actions.len(), 1, "no quick fixes when only fixAll was asked for");
|
||||
// `source` is a prefix filter for `source.fixAll.lucisv`.
|
||||
let source = [CodeActionKind::SOURCE];
|
||||
assert_eq!(
|
||||
code_actions(&LintRun::default(), &uri(), doc, whole, Some(&source), 2).len(),
|
||||
1
|
||||
);
|
||||
assert_eq!(code_actions(&LintRun::default(), &uri(), doc, whole, Some(&source)).len(), 1);
|
||||
// And an unrelated filter selects nothing.
|
||||
let refactor = [CodeActionKind::REFACTOR];
|
||||
assert!(
|
||||
code_actions(&LintRun::default(), &uri(), doc, whole, Some(&refactor), 2).is_empty()
|
||||
);
|
||||
assert!(code_actions(&LintRun::default(), &uri(), doc, whole, Some(&refactor)).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -431,12 +429,11 @@ mod tests {
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
let actions = code_actions(
|
||||
&LintRun::default(),
|
||||
&LintRun::default().with_tab_width(4),
|
||||
&uri(),
|
||||
doc,
|
||||
whole,
|
||||
Some(&[CodeActionKind::QUICKFIX]),
|
||||
4,
|
||||
);
|
||||
let CodeActionOrCommand::CodeAction(fix) = &actions[0] else { panic!("an action") };
|
||||
assert_eq!(applied(text, fix), "module m;\n wire a;\nendmodule\n");
|
||||
@@ -467,18 +464,14 @@ mod tests {
|
||||
let ws = workspace(src);
|
||||
let doc = ws.document(&uri()).expect("open");
|
||||
let whole = doc.positions().whole_document();
|
||||
let (external, problems) = vlog_linter::ExternalWaivers::parse(
|
||||
std::path::Path::new("team.waiver"),
|
||||
"waive --rule=no-tabs\n",
|
||||
);
|
||||
assert!(problems.is_empty(), "{problems:?}");
|
||||
let waived = LintRun::default().with_external(external);
|
||||
let waived = LintRun::default()
|
||||
.with_waivers(std::path::Path::new("team.waiver"), "waive --rule=no-tabs\n");
|
||||
assert!(
|
||||
code_actions(&waived, &uri(), doc, whole, None, 2).is_empty(),
|
||||
code_actions(&waived, &uri(), doc, whole, None).is_empty(),
|
||||
"no quick fix and no fix-all for a waived finding"
|
||||
);
|
||||
assert!(
|
||||
!code_actions(&LintRun::default(), &uri(), doc, whole, None, 2).is_empty(),
|
||||
!code_actions(&LintRun::default(), &uri(), doc, whole, None).is_empty(),
|
||||
"the same buffer without the waiver is fixable"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -137,6 +137,16 @@ pub fn execute(
|
||||
true => Home::NewFile,
|
||||
false => Home::SameFile,
|
||||
};
|
||||
// No preflight here, and the take 5 review round (§61.1) is why: every
|
||||
// refusal one could take is already taken before a scope is built. The
|
||||
// `site_at` gate above **is** `extract_site_in`, which returns `None` on a
|
||||
// parse diagnostic and on every `Region::read` refusal, so neither can
|
||||
// reach the engine; and `extract_module` checks the new name and the
|
||||
// occupied target as its own first two statements, ahead of
|
||||
// `Extraction::plan`. The 805 ms at `aes_wrap.sv` is none of those — it is
|
||||
// `boundary::Crossing::read`, which needs the instantiated modules' port
|
||||
// directions and so needs the scope. See
|
||||
// `docs/features/perf5r-preflight/README.md`.
|
||||
let refactoring = vlog_refactor::extract_module(&files, &path, start, end, &name, home)?;
|
||||
Ok((workspace_edit(ws, &refactoring)?, refactoring.warnings))
|
||||
}
|
||||
@@ -381,4 +391,76 @@ endmodule
|
||||
assert!(crate::code_action::wanted(Some(&filter), &kind()));
|
||||
assert!(!crate::code_action::wanted(Some(&filter), &CodeActionKind::QUICKFIX));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Where the extract refusals are actually taken (take 5 review §3 item 5,
|
||||
// TODO §61.1). No preflight was added — every refusal below is already
|
||||
// reached before a scope exists, and these pin that it stays so.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
fn run(
|
||||
ws: &Workspace,
|
||||
uri: &Uri,
|
||||
range: Range,
|
||||
name: &str,
|
||||
create: bool,
|
||||
) -> Result<(), String> {
|
||||
let arguments = vec![
|
||||
serde_json::to_value(uri).expect("uri"),
|
||||
serde_json::to_value(range).expect("range"),
|
||||
Value::String(name.to_string()),
|
||||
];
|
||||
execute(ws, &arguments, create).map(|_| ())
|
||||
}
|
||||
|
||||
/// A bad new name is refused by `extract_module`'s own first statement,
|
||||
/// and a selection covering no whole item is refused by the `site_at` gate
|
||||
/// — neither reaches `Extraction::plan`, so neither builds a scope.
|
||||
#[test]
|
||||
fn the_cheap_refusals_reach_the_wire_in_the_engines_words() {
|
||||
let tree = Tree::new("preflightrefusals");
|
||||
let (ws, uri) = opened(&tree);
|
||||
|
||||
let bad = run(&ws, &uri, selection(), "1bad", true).expect_err("a bad name");
|
||||
assert!(bad.contains("plain SystemVerilog identifier"), "{bad}");
|
||||
|
||||
// Half of `assign s = a + b;`, which covers no whole item.
|
||||
let partial = Range {
|
||||
start: Position { line: 6, character: 6 },
|
||||
end: Position { line: 6, character: 19 },
|
||||
};
|
||||
assert_eq!(
|
||||
run(&ws, &uri, partial, "sum", true),
|
||||
Err(NOTHING.to_string()),
|
||||
"the `site_at` gate answers a partial selection before the engine is asked"
|
||||
);
|
||||
}
|
||||
|
||||
/// A file already sitting where the new module would go is refused before
|
||||
/// `Extraction::plan`, and the question is asked of the source set the
|
||||
/// engine was handed rather than of the disk behind its back.
|
||||
#[test]
|
||||
fn an_occupied_target_is_refused_with_the_engines_sentence() {
|
||||
let tree = Tree::new("preflightoccupied");
|
||||
tree.write("sum.sv", "module sum;\nendmodule\n");
|
||||
let (ws, uri) = opened(&tree);
|
||||
let refusal = run(&ws, &uri, selection(), "sum", true).expect_err("occupied");
|
||||
assert!(refusal.contains("there is already a"), "{refusal}");
|
||||
assert!(refusal.contains("sum.sv"), "and it names the file: {refusal}");
|
||||
|
||||
// Into the same file nothing is occupied, so the early check passes
|
||||
// and the engine refuses for its own, later reason: the workspace
|
||||
// already declares that name — an index question, answered by the
|
||||
// stage that owns the index.
|
||||
let deferred = run(&ws, &uri, selection(), "sum", false).expect_err("already declared");
|
||||
assert!(deferred.contains("the workspace already declares"), "{deferred}");
|
||||
}
|
||||
|
||||
/// The control: a whole, movable item still extracts.
|
||||
#[test]
|
||||
fn a_whole_movable_selection_still_extracts() {
|
||||
let tree = Tree::new("preflightok");
|
||||
let (ws, uri) = opened(&tree);
|
||||
assert!(run(&ws, &uri, selection(), "sum", true).is_ok());
|
||||
}
|
||||
}
|
||||
@@ -31,3 +31,10 @@ use crate::state::Document;
|
||||
pub fn of(doc: &Document) -> &[Region] {
|
||||
doc.fences.get_or_init(|| fence::protected_regions(&doc.text))
|
||||
}
|
||||
|
||||
/// Whether the answer is already in hand — asked *before* [`of`], so a
|
||||
/// `--verbose` trace can say whether this request paid the parse or read the
|
||||
/// memo (review round §R1b, `crate::lint_trace`). Decides nothing.
|
||||
pub fn held(doc: &Document) -> bool {
|
||||
doc.fences.get().is_some()
|
||||
}
|
||||
@@ -455,7 +455,7 @@ fn span_text(text: &str, span: TextRange) -> Option<&str> {
|
||||
/// to not continue an identifier turns that prefix/suffix match back into a
|
||||
/// miss, without needing anything more than the same "is this still a name
|
||||
/// character" question a lexer already answers for `$`, `_` and alnum.
|
||||
fn spells_exactly(text: &str, span: TextRange, name: &str) -> bool {
|
||||
pub(crate) fn spells_exactly(text: &str, span: TextRange, name: &str) -> bool {
|
||||
if span_text(text, span) != Some(name) {
|
||||
return false;
|
||||
}
|
||||
@@ -1313,6 +1313,45 @@ endmodule
|
||||
let _ = fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// TODO §64.1. The same live-span read for a declaration only a
|
||||
/// **hierarchical** path can reach — a module's internal net, named from
|
||||
/// another file as `u_leaf.sig`.
|
||||
///
|
||||
/// `declaration_snippet` reaches it through `live_symbol` →
|
||||
/// `nav::indexed_def_for_symbol`, which asked `WorkspaceIndex::member`
|
||||
/// (the *connection* surface) until §64.1 and so mapped no live symbol
|
||||
/// back to this `Def` at all: the card came out with its heading and no
|
||||
/// fence, on a file that was open and perfectly readable. It now shows the
|
||||
/// live line, which is the same guarantee the port above gets — and the
|
||||
/// guard is untouched, so a buffer whose live text no longer declares the
|
||||
/// name still prints nothing (asserted below).
|
||||
#[test]
|
||||
fn a_hierarchical_only_declaration_is_read_at_its_live_span_too() {
|
||||
let top =
|
||||
"module top;\n leaf u_leaf ();\n wire w;\n assign w = u_leaf.sig;\nendmodule\n";
|
||||
let saved = "module leaf;\n logic [7:0] sig;\nendmodule\n";
|
||||
let (dir, mut ws, uri) = included("livehier", &[("leaf.sv", saved), ("top.sv", top)]);
|
||||
let leaf_uri = path_to_uri(&dir.join("leaf.sv")).expect("uri");
|
||||
let edited =
|
||||
"// two lines\n// pushed it down\nmodule leaf;\n logic [15:0] sig;\nendmodule\n";
|
||||
ws.set_document(leaf_uri.clone(), edited.to_string());
|
||||
|
||||
let body = text_of(&hover(&ws, &uri, at(top, "u_leaf.sig") + 7).expect("hover"));
|
||||
assert!(
|
||||
body.contains("```systemverilog\n logic [15:0] sig;\n```"),
|
||||
"the live line, width and all: got {body}"
|
||||
);
|
||||
assert!(!body.contains("[7:0]"), "not the saved one: got {body}");
|
||||
|
||||
// The guard half, on the same shape: the net renamed away in the
|
||||
// buffer leaves the heading and no fence.
|
||||
ws.set_document(leaf_uri, "module leaf;\n logic [15:0] renamed;\nendmodule\n".to_string());
|
||||
let guarded = text_of(&hover(&ws, &uri, at(top, "u_leaf.sig") + 7).expect("hover"));
|
||||
assert!(guarded.contains("— declared in"), "today's card, intact: got {guarded}");
|
||||
assert!(!guarded.contains("```"), "and no snippet at all: got {guarded}");
|
||||
let _ = fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_stale_indexed_span_drops_the_snippet_rather_than_showing_the_wrong_line() {
|
||||
// The file changed on disk under a live index — a rescan the server has
|
||||
|
||||
@@ -215,6 +215,28 @@ impl IndexCache {
|
||||
self.dir.as_deref()
|
||||
}
|
||||
|
||||
/// The entry that asserts *exactly these bytes*, if there is one.
|
||||
///
|
||||
/// The one place the record and the key it is filed under are read
|
||||
/// together: an entry holds the FNV-1a of the bytes its facts were read
|
||||
/// off, and this is the only comparison anything in the server makes
|
||||
/// against it. Both readers below go through here, so "the store answers
|
||||
/// for this text" means one thing in a scan and in a refactoring alike.
|
||||
fn entry_for(&self, path: &Path, text: &str) -> Option<&Entry> {
|
||||
self.entries.get(path).filter(|entry| entry.content == content_hash(text.as_bytes()))
|
||||
}
|
||||
|
||||
/// [`IndexCache::facts_for`] asked by something that is **not** a scan.
|
||||
///
|
||||
/// The same question, the same entry, the same answer — but the work is
|
||||
/// not counted into [`IndexCache::work`], because that counter is what a
|
||||
/// scan's own trace subtracts to say what *it* did. A refactoring reading
|
||||
/// records between two scans would otherwise show up as decodes the next
|
||||
/// scan never made (review round §R3b, `crate::state::Workspace::known_facts`).
|
||||
pub fn facts_now(&self, path: &Path, text: &str) -> Option<FileFacts> {
|
||||
FileFacts::decode(&self.entry_for(path, text)?.facts)
|
||||
}
|
||||
|
||||
/// The facts a previous session read off this exact text, if it did.
|
||||
///
|
||||
/// The hash is of the text the server is about to index — an open buffer's
|
||||
@@ -226,8 +248,7 @@ impl IndexCache {
|
||||
/// gets here.
|
||||
pub fn facts_for(&self, path: &Path, text: &str) -> Option<FileFacts> {
|
||||
let looking = Instant::now();
|
||||
let found =
|
||||
self.entries.get(path).filter(|entry| entry.content == content_hash(text.as_bytes()));
|
||||
let found = self.entry_for(path, text);
|
||||
let mut work = self.work.get();
|
||||
work.lookup_ns += elapsed_ns(looking);
|
||||
let Some(entry) = found else {
|
||||
@@ -713,6 +734,42 @@ mod tests {
|
||||
assert!(reopened.facts_for(Path::new("/nowhere.sv"), M).is_none());
|
||||
}
|
||||
|
||||
/// **The R3b tie, both ways.** `facts_now` is the same content key
|
||||
/// `facts_for` is — a record answers for the bytes it was read off and for
|
||||
/// no others — and it leaves the scan's own work counters alone.
|
||||
///
|
||||
/// The stale case is the one that matters: a record written from one text
|
||||
/// must never be handed to a refactoring reading a different text, because
|
||||
/// the refactoring would index it as that file's facts and edit against an
|
||||
/// index describing bytes nobody has.
|
||||
#[test]
|
||||
fn a_request_local_read_answers_for_these_bytes_and_counts_as_no_scan_work() {
|
||||
let dir = TempDir::new("factsnow");
|
||||
let file = dir.file("m.sv", M);
|
||||
let mut cache = IndexCache::open(Some(dir.path.clone()));
|
||||
cache.record(&facts(&file, M), M);
|
||||
cache.compact();
|
||||
|
||||
let reopened = IndexCache::open(Some(dir.path.clone()));
|
||||
let before = reopened.work();
|
||||
assert_eq!(reopened.facts_now(&file, M), Some(facts(&file, M)), "these bytes");
|
||||
// Every way the bytes can differ, and the wrong path too.
|
||||
const EDITED: &str = "module m;\n sub u ();\n wire added;\nendmodule\n";
|
||||
assert!(reopened.facts_now(&file, EDITED).is_none(), "a stale record must not be served");
|
||||
assert!(reopened.facts_now(&file, "").is_none(), "nor an empty buffer's");
|
||||
assert!(reopened.facts_now(&file, &M[..M.len() - 1]).is_none(), "nor one byte short");
|
||||
assert!(reopened.facts_now(Path::new("/nowhere.sv"), M).is_none(), "nor another path's");
|
||||
let after = reopened.work();
|
||||
assert_eq!(
|
||||
(after.hits, after.misses, after.decode_ns, after.lookup_ns),
|
||||
(before.hits, before.misses, before.decode_ns, before.lookup_ns),
|
||||
"a refactoring's reads are not a scan's work"
|
||||
);
|
||||
// The counted reader, asked the same questions, answers the same way.
|
||||
assert_eq!(reopened.facts_for(&file, M), reopened.facts_now(&file, M));
|
||||
assert_eq!(reopened.facts_for(&file, EDITED), reopened.facts_now(&file, EDITED));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_record_survives_a_session_that_never_compacted() {
|
||||
// The crash case: records are written through as they are made, so a
|
||||
|
||||
@@ -23,6 +23,7 @@ pub use project::{ConfigProblems, ProblemLog, ProjectLint};
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use lsp_types::{Diagnostic, DiagnosticSeverity, NumberOrString};
|
||||
use lucisv_core::config::FileConfig;
|
||||
@@ -35,6 +36,8 @@ use vlog_semantic::{FileId, SymbolKind, WorkspaceIndex};
|
||||
|
||||
use crate::convert::Positions;
|
||||
use crate::diagnostics::SOURCE;
|
||||
use crate::lint_snapshot::{Key, Slot};
|
||||
use crate::lint_trace::{self, Fences, Reuse, Stage};
|
||||
use crate::settings::ClientSettings;
|
||||
use crate::state::{Document, Workspace};
|
||||
|
||||
@@ -53,10 +56,29 @@ pub struct LintRun<'a> {
|
||||
/// The width `line-length` holds this buffer to — the width the formatter
|
||||
/// would wrap it to, so the two halves of lucisv cannot disagree.
|
||||
line_length: usize,
|
||||
/// The width a `no-tabs` fix writes where a tab was — the same ladder
|
||||
/// `format::indent_width` walks, read off the `FileConfig` this pass
|
||||
/// already discovered.
|
||||
///
|
||||
/// On the run rather than passed to [`fixable`] since the review round's
|
||||
/// §R1a: the diagnostics pass and the quick-fix pass must build the *same*
|
||||
/// `LintContext` to share one snapshot. Nothing published moves — the
|
||||
/// width reaches only `no-tabs`' fix *text*, and the diagnostics path
|
||||
/// never reads a fix.
|
||||
tab_width: usize,
|
||||
/// The external waiver files in force for this buffer, from its
|
||||
/// `lucisv.toml` and from `lucisv.lint.waivers`. Empty unless one is
|
||||
/// configured, and then costing the pass nothing.
|
||||
external: ExternalWaivers,
|
||||
/// Those files' paths and contents, in the order they were read — the
|
||||
/// snapshot key's row 7. Empty when no waiver file is configured.
|
||||
///
|
||||
/// **Written in the same step as `external`**, by `waiver_files` and by
|
||||
/// `with_waivers` and by nothing else, so a run can never carry a waiver
|
||||
/// its key cannot see. A run whose key missed a waiver would offer a fix
|
||||
/// for a finding the waiver had silenced, which is the stale-fix failure
|
||||
/// this whole key exists to prevent.
|
||||
waiver_texts: Vec<(PathBuf, String)>,
|
||||
/// What the buffer's `lucisv.toml` asked for and did not get. Reported by
|
||||
/// whoever can talk to the client — [`ProblemLog`] keeps it to once per
|
||||
/// (config file, message) — and never fatal here: §42.2.
|
||||
@@ -70,7 +92,9 @@ impl Default for LintRun<'_> {
|
||||
oracle: None,
|
||||
options: RuleOptions::new(),
|
||||
line_length: DEFAULT_LINE_LENGTH,
|
||||
tab_width: DEFAULT_TAB_WIDTH,
|
||||
external: ExternalWaivers::default(),
|
||||
waiver_texts: Vec::new(),
|
||||
problems: ConfigProblems::default(),
|
||||
}
|
||||
}
|
||||
@@ -80,6 +104,11 @@ impl Default for LintRun<'_> {
|
||||
/// editor says otherwise — `vlog_formatter::Config`'s own default.
|
||||
const DEFAULT_LINE_LENGTH: usize = 100;
|
||||
|
||||
/// The indent width a buffer's fixes are written at when neither its
|
||||
/// `lucisv.toml` nor the editor says otherwise — `vlog_formatter::Config`'s
|
||||
/// own default, which is what `format::indent_width` falls back to.
|
||||
const DEFAULT_TAB_WIDTH: usize = 2;
|
||||
|
||||
impl<'a> LintRun<'a> {
|
||||
/// The pass this workspace's settings and index describe for one buffer.
|
||||
///
|
||||
@@ -90,25 +119,12 @@ impl<'a> LintRun<'a> {
|
||||
/// cross-file evidence behind them, which is the false-positive mode this
|
||||
/// whole round exists to close.
|
||||
pub fn for_document(ws: &'a Workspace, doc: &Document) -> LintRun<'a> {
|
||||
let index = ws.index();
|
||||
let own = doc.path.as_deref().and_then(|path| index.file_id(path));
|
||||
let workspace = index.files().len() > usize::from(own.is_some());
|
||||
let oracle = workspace.then_some(IndexMentions { index, own });
|
||||
// One discovery for the whole pass: the selection, the options, the
|
||||
// width and the waiver paths all read the same `FileConfig`, so
|
||||
// reading the project's rules costs no extra stat and no extra open.
|
||||
let (options, line_length, file, mut messages) = configured(ws.client_settings(), doc);
|
||||
let (from_file, bad_names) = ProjectLint::read(&file);
|
||||
messages.extend(bad_names);
|
||||
let rules = enabled_rules(ws.client_settings(), &from_file, workspace);
|
||||
let (mut external, bad_waivers) = external_waivers(&project_waivers(&file));
|
||||
messages.extend(bad_waivers);
|
||||
// The editor's own waiver files are read separately and their
|
||||
// problems dropped: `notification::apply_settings` already said them
|
||||
// once, where the setting arrived.
|
||||
external.absorb(external_waivers(&editor_waivers(ws.client_settings(), ws.roots())).0);
|
||||
let problems = ConfigProblems::new(&file, messages);
|
||||
LintRun { rules, oracle, options, line_length, external, problems }
|
||||
// Two stages, so `--verbose` can say which of them the request spent
|
||||
// its milliseconds in: everything read from disk, then everything
|
||||
// decided from what was read (review round §R1b, `crate::lint_trace`).
|
||||
let found = lint_trace::stage(Stage::Config, || Discovered::read(ws, doc));
|
||||
lint_trace::saw_config(found.file.source.is_some(), found.texts.len());
|
||||
lint_trace::stage(Stage::Build, || found.into_run(ws, doc))
|
||||
}
|
||||
|
||||
/// What this buffer's `lucisv.toml` asked for and did not get, for a
|
||||
@@ -117,17 +133,53 @@ impl<'a> LintRun<'a> {
|
||||
&self.problems
|
||||
}
|
||||
|
||||
/// A run carrying these external waivers — for the tests that pin what a
|
||||
/// waiver keeps out of the code actions.
|
||||
/// A run carrying this waiver file — for the tests that pin what a waiver
|
||||
/// keeps out of the code actions.
|
||||
///
|
||||
/// Takes the file's **text**, not a parsed `ExternalWaivers`, for the same
|
||||
/// reason `waiver_files` returns both: the waivers a run lints with and
|
||||
/// the texts its snapshot key holds must be written in one step, or a run
|
||||
/// could carry waivers its key cannot see. The bad-line messages are
|
||||
/// dropped here; the caller asserts about them itself where it cares.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_external(mut self, external: ExternalWaivers) -> Self {
|
||||
self.external = external;
|
||||
pub(crate) fn with_waivers(mut self, path: &Path, text: &str) -> Self {
|
||||
self.external.absorb(ExternalWaivers::parse(path, text).0);
|
||||
self.waiver_texts.push((path.to_path_buf(), text.to_string()));
|
||||
self
|
||||
}
|
||||
|
||||
/// A run whose fixes are written at this indent width — for the tests
|
||||
/// that pin what a `no-tabs` fix writes. The server itself reads the
|
||||
/// width off the buffer's own configuration in [`Discovered::read`].
|
||||
#[cfg(test)]
|
||||
pub(crate) fn with_tab_width(mut self, tab_width: usize) -> Self {
|
||||
self.tab_width = tab_width;
|
||||
self
|
||||
}
|
||||
|
||||
/// What this run would lint with, as the snapshot compares it.
|
||||
///
|
||||
/// Every field is an argument of the `lint_with` call it guards; the
|
||||
/// buffer itself and the workspace index are settled by identity and by
|
||||
/// `Document::refresh_overlay` instead. The feature README's table is the
|
||||
/// whole argument.
|
||||
fn key(&self) -> Key {
|
||||
Key {
|
||||
rules: self.rules.iter().map(|rule| rule.name()).collect(),
|
||||
options: self.options.clone(),
|
||||
line_length: self.line_length,
|
||||
tab_width: self.tab_width,
|
||||
has_oracle: self.oracle.is_some(),
|
||||
waivers: self.waiver_texts.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// This run's context over a buffer's own parse products.
|
||||
fn context<'d>(&'d self, doc: &'d Document) -> LintContext<'d> {
|
||||
let ctx = context(doc).with_options(&self.options).with_line_length(self.line_length);
|
||||
let ctx = context(doc)
|
||||
.with_options(&self.options)
|
||||
.with_line_length(self.line_length)
|
||||
.with_tab_width(self.tab_width);
|
||||
match &self.oracle {
|
||||
Some(oracle) => ctx.with_oracle(oracle),
|
||||
None => ctx,
|
||||
@@ -135,6 +187,76 @@ impl<'a> LintRun<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Everything one lint pass reads **from disk**: the `lucisv.toml` governing
|
||||
/// the buffer, what its `[lint]` table said, and the external waiver files in
|
||||
/// force.
|
||||
///
|
||||
/// Split out of [`LintRun::for_document`] so the I/O has a name and a stage of
|
||||
/// its own on the `--verbose` channel — "config read plus lint" was as far as
|
||||
/// take 5 §P1 could attribute the pinmux menu's 23 ms, and that is two
|
||||
/// answers. Nothing about *what* is read changed: the calls below are
|
||||
/// `for_document`'s own, in its own order, so the messages a config problem
|
||||
/// produces arrive in the order §42.2 fixed.
|
||||
struct Discovered {
|
||||
options: RuleOptions,
|
||||
line_length: usize,
|
||||
tab_width: usize,
|
||||
file: FileConfig,
|
||||
project: ProjectLint,
|
||||
external: ExternalWaivers,
|
||||
/// Each waiver file's path and the text it was parsed from — the
|
||||
/// snapshot key's only I/O-derived field.
|
||||
texts: Vec<(PathBuf, String)>,
|
||||
messages: Vec<String>,
|
||||
}
|
||||
|
||||
impl Discovered {
|
||||
/// One discovery for the whole pass: the selection, the options, the
|
||||
/// width, the indent and the waiver paths all read the same `FileConfig`,
|
||||
/// so reading the project's rules costs no extra stat and no extra open.
|
||||
fn read(ws: &Workspace, doc: &Document) -> Discovered {
|
||||
let (options, line_length, file, mut messages) = configured(ws.client_settings(), doc);
|
||||
let (project, bad_names) = ProjectLint::read(&file);
|
||||
messages.extend(bad_names);
|
||||
let (mut external, bad_waivers, mut texts) = waiver_files(&project_waivers(&file));
|
||||
messages.extend(bad_waivers);
|
||||
// The editor's own waiver files are read separately and their
|
||||
// problems dropped: `notification::apply_settings` already said them
|
||||
// once, where the setting arrived.
|
||||
let editor = waiver_files(&editor_waivers(ws.client_settings(), ws.roots()));
|
||||
external.absorb(editor.0);
|
||||
texts.extend(editor.2);
|
||||
// `format::indent_width` stays the one authority on the indent ladder
|
||||
// (`lucisv.toml` > `lucisv.indent` > the formatter's default): reading
|
||||
// it here rather than spelling the ladder a second time costs a second
|
||||
// `Discovery` walk, which the R1b trace measures at hundredths of a
|
||||
// millisecond against a 21 ms pass.
|
||||
let tab_width = crate::format::indent_width(doc.path.as_deref(), ws.client_settings());
|
||||
Discovered { options, line_length, tab_width, file, project, external, texts, messages }
|
||||
}
|
||||
|
||||
/// What this buffer's index and settings make of it: the census oracle and
|
||||
/// the rule ladder, neither of which touches the filesystem.
|
||||
fn into_run<'a>(self, ws: &'a Workspace, doc: &Document) -> LintRun<'a> {
|
||||
let index = ws.index();
|
||||
let own = doc.path.as_deref().and_then(|path| index.file_id(path));
|
||||
let workspace = index.files().len() > usize::from(own.is_some());
|
||||
let oracle = workspace.then_some(IndexMentions { index, own });
|
||||
let rules = enabled_rules(ws.client_settings(), &self.project, workspace);
|
||||
let problems = ConfigProblems::new(&self.file, self.messages);
|
||||
LintRun {
|
||||
rules,
|
||||
oracle,
|
||||
options: self.options,
|
||||
line_length: self.line_length,
|
||||
tab_width: self.tab_width,
|
||||
external: self.external,
|
||||
waiver_texts: self.texts,
|
||||
problems,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The per-rule options and the line width governing one buffer.
|
||||
///
|
||||
/// **Precedence for an option, highest first: the editor, then the buffer's
|
||||
@@ -237,18 +359,37 @@ fn editor_waivers(client: &ClientSettings, roots: &[PathBuf]) -> Vec<PathBuf> {
|
||||
/// pass, which runs on every keystroke, drops them silently rather than
|
||||
/// logging the same line a hundred times.
|
||||
pub fn external_waivers(paths: &[PathBuf]) -> (ExternalWaivers, Vec<String>) {
|
||||
let (waivers, problems, _) = waiver_files(paths);
|
||||
(waivers, problems)
|
||||
}
|
||||
|
||||
/// [`external_waivers`], keeping each file's **text** as well.
|
||||
///
|
||||
/// The text is what the lint snapshot's key holds (review round §R1a): a
|
||||
/// waiver file is not watched — `watch::SOURCE_GLOB` covers sources and the
|
||||
/// filelist alone — so comparing its contents is the only thing that ever
|
||||
/// notices one being rewritten under a running server.
|
||||
///
|
||||
/// One read, not two. `ExternalWaivers::read` is `read_to_string` followed by
|
||||
/// `ExternalWaivers::parse`, and both halves are public, so the bytes are
|
||||
/// taken once and handed to the parser; the sentence an unreadable file
|
||||
/// produces is `read`'s own, byte for byte.
|
||||
fn waiver_files(paths: &[PathBuf]) -> (ExternalWaivers, Vec<String>, Vec<(PathBuf, String)>) {
|
||||
let mut waivers = ExternalWaivers::default();
|
||||
let mut problems = Vec::new();
|
||||
let mut texts = Vec::new();
|
||||
for path in paths {
|
||||
match ExternalWaivers::read(path) {
|
||||
Ok((file, bad)) => {
|
||||
match std::fs::read_to_string(path) {
|
||||
Ok(text) => {
|
||||
let (file, bad) = ExternalWaivers::parse(path, &text);
|
||||
problems.extend(bad);
|
||||
waivers.absorb(file);
|
||||
texts.push((path.clone(), text));
|
||||
}
|
||||
Err(problem) => problems.push(problem),
|
||||
Err(problem) => problems.push(format!("{}: {problem}", path.display())),
|
||||
}
|
||||
}
|
||||
(waivers, problems)
|
||||
(waivers, problems, texts)
|
||||
}
|
||||
|
||||
/// Which rules a buffer is linted with, given what the editor's settings and
|
||||
@@ -419,16 +560,43 @@ fn context(doc: &Document) -> LintContext<'_> {
|
||||
/// waiver was dead, and a server never has one — it lints the buffers a user
|
||||
/// happens to have open. `lucisv check` is what reports an unused external
|
||||
/// waiver; see `docs/features/waiver-files/README.md`.
|
||||
pub fn violations_in(doc: &Document, run: &LintRun) -> Vec<Violation> {
|
||||
lint_with(&run.context(doc), &run.rules, &run.external).0
|
||||
pub fn violations_in(doc: &Document, run: &LintRun) -> Arc<[Violation]> {
|
||||
found(doc, run)
|
||||
}
|
||||
|
||||
/// The findings a code action may offer a fix for, with their fixes built for
|
||||
/// `tab_width`.
|
||||
/// The one place `vlog_linter::lint_with` is called for an open buffer.
|
||||
///
|
||||
/// The code-action path passes the indent width of the `lucisv.toml` governing
|
||||
/// the buffer, so a quick fix that replaces a tab writes exactly what `lucisv`
|
||||
/// would have written there.
|
||||
/// One place, so there is one snapshot to read (review round §R1a) and one
|
||||
/// site that says on the `--verbose` channel what a pass ran, what it found,
|
||||
/// and whether it ran at all. Both doors — the diagnostics publish and
|
||||
/// quick-fix discovery — arrive here with the *same* context, which is why the
|
||||
/// tab width lives on the [`LintRun`] rather than being handed to [`fixable`].
|
||||
fn found(doc: &Document, run: &LintRun) -> Arc<[Violation]> {
|
||||
let key = run.key();
|
||||
let (violations, hit) = lint_trace::stage(Stage::Lint, || {
|
||||
snapshot(doc).read_or(&key, || lint_with(&run.context(doc), &run.rules, &run.external).0)
|
||||
});
|
||||
let reuse = if hit { Reuse::Hit } else { Reuse::Miss };
|
||||
lint_trace::saw_lint(run.rules.len(), violations.len(), reuse);
|
||||
violations
|
||||
}
|
||||
|
||||
/// The slot this buffer's findings are kept in.
|
||||
///
|
||||
/// A field on the `Document`, so it is dropped with the buffer and cannot
|
||||
/// outlive the text it was computed from: `Workspace::set_document` builds a
|
||||
/// new `Document` for every flushed change. One per open document and nothing
|
||||
/// else — no map, no eviction, no second analysis cache.
|
||||
fn snapshot(doc: &Document) -> &Slot {
|
||||
&doc.lint
|
||||
}
|
||||
|
||||
/// The findings a code action may offer a fix for.
|
||||
///
|
||||
/// The fixes are written at the run's own indent width — the `lucisv.toml`
|
||||
/// governing the buffer, else `lucisv.indent`, else the formatter's default —
|
||||
/// so a quick fix that replaces a tab writes exactly what `lucisv` would have
|
||||
/// written there.
|
||||
///
|
||||
/// A finding whose fix would edit bytes inside a `// verilog_format: off`
|
||||
/// region is dropped here, so the editor keeps the same promise `lucisv check
|
||||
@@ -437,14 +605,13 @@ pub fn violations_in(doc: &Document, run: &LintRun) -> Vec<Violation> {
|
||||
/// just has no lightbulb. Which bytes count as fenced is
|
||||
/// [`fence::protected_regions`]' answer, the one the CLI asks too; see
|
||||
/// `docs/features/shared-fence-filter/README.md`.
|
||||
pub fn fixable(run: &LintRun, doc: &Document, tab_width: usize) -> Vec<Violation> {
|
||||
pub fn fixable(run: &LintRun, doc: &Document) -> Arc<[Violation]> {
|
||||
// The buffer's own run: its enabled rules and its external waiver files,
|
||||
// so a fix is never offered — nor applied by fix-on-save — for a finding
|
||||
// the diagnostics pass would not have shown. Found by §39's QA: with
|
||||
// `default_rules()` and no waivers here, `source.fixAll.lucisv` rewrote a
|
||||
// line a checked-in waiver file had waived.
|
||||
let ctx = run.context(doc).with_tab_width(tab_width);
|
||||
let found = lint_with(&ctx, &run.rules, &run.external).0;
|
||||
let violations = found(doc, run);
|
||||
// The fence answer is a whole second tolerant parse of the buffer:
|
||||
// `protected_regions` takes text and parses internally, on purpose — one
|
||||
// fence answer for every front end, none of which can feed it a stale tree
|
||||
@@ -453,15 +620,24 @@ pub fn fixable(run: &LintRun, doc: &Document, tab_width: usize) -> Vec<Violation
|
||||
// and nothing to ask: the filter below would be the identity. Skipping it
|
||||
// there is take 5 §P1a. The per-keystroke diagnostics path pays nothing
|
||||
// either, because it never reads a fix.
|
||||
if !found.iter().any(|violation| violation.fix.is_some()) {
|
||||
return found;
|
||||
if !violations.iter().any(|violation| violation.fix.is_some()) {
|
||||
lint_trace::saw_fences(Fences::Skipped);
|
||||
return violations;
|
||||
}
|
||||
// Asked once per document revision rather than once per request: the text
|
||||
// a `Document` holds cannot change without a new `Document` (§P1b,
|
||||
// `crate::fences`). The question itself is unchanged — still
|
||||
// `protected_regions` over this buffer's text.
|
||||
let regions = crate::fences::of(doc);
|
||||
found.into_iter().filter(|violation| !fix_touches_fence(violation, regions)).collect()
|
||||
let held = crate::fences::held(doc);
|
||||
let regions = lint_trace::stage(Stage::Fence, || crate::fences::of(doc));
|
||||
lint_trace::saw_fences(if held { Fences::Memo } else { Fences::Computed });
|
||||
// The snapshot's own findings when the fence drops nothing, which is every
|
||||
// buffer with no `// lucisv: off` region in it: the filter would be the
|
||||
// identity, and copying the findings to prove it would undo the reuse.
|
||||
if !violations.iter().any(|violation| fix_touches_fence(violation, regions)) {
|
||||
return violations;
|
||||
}
|
||||
violations.iter().filter(|v| !fix_touches_fence(v, regions)).cloned().collect()
|
||||
}
|
||||
|
||||
/// True when a violation carries a fix any edit of which lands in a fenced
|
||||
@@ -645,7 +821,7 @@ mod tests {
|
||||
let doc = ws.document(&uri).expect("open");
|
||||
let diags = diagnostics(doc);
|
||||
assert_eq!(diags.len(), 2, "both tabs are reported: {diags:#?}");
|
||||
let offered = fixable(&LintRun::default(), doc, 2);
|
||||
let offered = fixable(&LintRun::default(), doc);
|
||||
assert_eq!(offered.len(), 1, "only the unfenced one may be fixed: {offered:#?}");
|
||||
let free = text.find("\twire b").expect("the unfenced tab") as u32;
|
||||
assert_eq!(offered[0].span.start, free);
|
||||
@@ -665,7 +841,7 @@ mod tests {
|
||||
.any(|d| d.code == Some(NumberOrString::String("no-tabs".into()))),
|
||||
"still reported"
|
||||
);
|
||||
assert!(fixable(&LintRun::default(), doc, 2).is_empty(), "and still not fixable");
|
||||
assert!(fixable(&LintRun::default(), doc).is_empty(), "and still not fixable");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -913,7 +1089,7 @@ mod tests {
|
||||
#[test]
|
||||
fn an_unfenced_file_offers_every_fix() {
|
||||
let (ws, uri) = doc_of("module m;\n// just a note\n\twire a;\nendmodule\n");
|
||||
assert_eq!(fixable(&LintRun::default(), ws.document(&uri).expect("open"), 2).len(), 1);
|
||||
assert_eq!(fixable(&LintRun::default(), ws.document(&uri).expect("open")).len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -921,7 +1097,7 @@ mod tests {
|
||||
let (ws, uri) = doc_of("module m;\n\twire a;\nendmodule\n");
|
||||
let doc = ws.document(&uri).expect("open");
|
||||
for width in [2usize, 4] {
|
||||
let found = fixable(&LintRun::default(), doc, width);
|
||||
let found = fixable(&LintRun::default().with_tab_width(width), doc);
|
||||
let fix = found[0].fix.as_ref().expect("no-tabs offers a fix");
|
||||
assert_eq!(fix.edits[0].1, " ".repeat(width));
|
||||
}
|
||||
@@ -958,6 +1134,79 @@ mod tests {
|
||||
assert!(waiver_paths(&ClientSettings::default(), &roots, &FileConfig::default()).is_empty());
|
||||
}
|
||||
|
||||
/// The run's indent width is the formatter's own ladder, read through
|
||||
/// `format::indent_width` rather than spelled a second time — pinned at
|
||||
/// each rung, because the width is a fix's bytes and this lane moved
|
||||
/// where it is read (review round §R1a).
|
||||
#[test]
|
||||
fn the_runs_tab_width_is_the_formatters_own_ladder() {
|
||||
let dir = std::env::temp_dir().join(format!("lucisv_lint_{}_indent", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).expect("temp dir");
|
||||
std::fs::write(dir.join("m.sv"), "module m;\n\twire a;\nendmodule\n").expect("write");
|
||||
let path = dir.join("m.sv");
|
||||
let uri = Uri::from_str(&format!("file://{}", path.display())).expect("uri");
|
||||
|
||||
// Rung by rung: the built-in default, the editor's setting, and a
|
||||
// `lucisv.toml` that outranks it.
|
||||
let rungs: Vec<(Option<&str>, Option<usize>, usize)> = vec![
|
||||
(None, None, 2),
|
||||
(None, Some(8), 8),
|
||||
(Some("indent = 4\n"), Some(8), 4),
|
||||
(Some("indent = 3\n"), None, 3),
|
||||
];
|
||||
for (toml, editor, want) in rungs {
|
||||
match toml {
|
||||
Some(text) => std::fs::write(dir.join("lucisv.toml"), text).expect("write"),
|
||||
None => {
|
||||
let _ = std::fs::remove_file(dir.join("lucisv.toml"));
|
||||
}
|
||||
}
|
||||
let mut ws = Workspace::default();
|
||||
ws.set_client_settings(ClientSettings { indent: editor, ..Default::default() });
|
||||
ws.set_document(uri.clone(), "module m;\n\twire a;\nendmodule\n".to_string());
|
||||
let doc = ws.document(&uri).expect("open");
|
||||
let run = LintRun::for_document(&ws, doc);
|
||||
assert_eq!(run.tab_width, want, "toml={toml:?} editor={editor:?}");
|
||||
assert_eq!(
|
||||
run.tab_width,
|
||||
crate::format::indent_width(Some(&path), ws.client_settings()),
|
||||
"the two readings of the ladder agree"
|
||||
);
|
||||
assert_eq!(
|
||||
fixable(&run, doc)[0].fix.as_ref().expect("a fix").edits[0].1,
|
||||
" ".repeat(want)
|
||||
);
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// The snapshot is a memo and not a second implementation: what it hands
|
||||
/// back is what a pass computed from scratch would have, violation for
|
||||
/// violation, and both doors get the same object.
|
||||
#[test]
|
||||
fn a_reused_snapshot_is_what_a_fresh_pass_would_have_found() {
|
||||
let (ws, uri) = doc_of("module m;\n\twire a; \nendmodule\n");
|
||||
let doc = ws.document(&uri).expect("open");
|
||||
let run = LintRun::default();
|
||||
let fresh: Vec<Violation> = lint_with(&run.context(doc), &run.rules, &run.external).0;
|
||||
let first = violations_in(doc, &run);
|
||||
let second = fixable(&run, doc);
|
||||
assert!(Arc::ptr_eq(&first, &second), "the diagnostics and the fixes are one pass");
|
||||
assert_eq!(first.len(), fresh.len(), "{fresh:#?}");
|
||||
for (held, made) in first.iter().zip(&fresh) {
|
||||
assert_eq!(
|
||||
(held.rule, held.span, &held.message),
|
||||
(made.rule, made.span, &made.message)
|
||||
);
|
||||
assert_eq!(
|
||||
held.fix.as_ref().map(|fix| &fix.edits),
|
||||
made.fix.as_ref().map(|fix| &fix.edits),
|
||||
"the fix bytes are the fresh pass's too"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A waiver file that is missing, and one with a bad line, are both
|
||||
/// described rather than fatal — and the good directives of the second
|
||||
/// still apply. TODO §39.
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
//! One lint pass's findings, kept for as long as they are still the answer.
|
||||
//!
|
||||
//! Take 5 **review** round §R1a (`docs/features/perf5r-lint-snapshot/README.md`,
|
||||
//! `docs/performance_take5_review.md` §1). A `textDocument/codeAction` on
|
||||
//! `pinmux_reg_top.sv` spends **21 of its 22 ms in `lint_with`**, and the first
|
||||
//! request after an edit runs that pass **twice** on one revision — once to
|
||||
//! publish diagnostics, once to discover quick fixes. This module is what lets
|
||||
//! the second one read the first one's answer.
|
||||
//!
|
||||
//! **The whole design is in [`Key`].** A snapshot is legitimate only while
|
||||
//! every input of `lint_with(ctx, rules, external)` is what it was, and the
|
||||
//! key is those inputs *by value* — no hash, no mtime, no generation number,
|
||||
//! so "could this offer a stale fix?" is a question about `PartialEq` and not
|
||||
//! about collision probability. What the key deliberately does **not** carry
|
||||
//! is the two things identity already settles:
|
||||
//!
|
||||
//! * the **buffer** — a [`Slot`] is a field on the `Document`, and
|
||||
//! `Workspace::set_document` builds a new `Document` for every flushed
|
||||
//! change, so a slot cannot outlive the text it was computed from (the
|
||||
//! argument `crate::fences` already rests on);
|
||||
//! * the **workspace index** the census oracle reads — every index mutation in
|
||||
//! `state/mod.rs` ends by calling `Document::refresh_overlay` on every open
|
||||
//! buffer, and that is where the slot is cleared.
|
||||
//!
|
||||
//! The invalidation table in the feature README has one row per input, the
|
||||
//! mechanism for each, and the test that flips it.
|
||||
//!
|
||||
//! **Bounded by construction:** one slot per open document, holding that
|
||||
//! document's own violations, dropped with the `Document` on `didClose`. There
|
||||
//! is no map, no eviction policy and no second unbounded analysis cache.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use vlog_linter::{RuleOptions, Violation};
|
||||
|
||||
/// Everything a lint result depends on that is **not** settled by the
|
||||
/// `Document`'s own identity.
|
||||
///
|
||||
/// Compared by value, field by field. Every field is an argument of the
|
||||
/// `lint_with` call it guards, which is what makes the list complete: see the
|
||||
/// feature README's table, which derives it from that call's signature.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Key {
|
||||
/// The enabled rules' names, in registry order — the whole of what the
|
||||
/// `lucisv.lint.*` ladder and the project's `[lint]` table decided.
|
||||
pub rules: Vec<&'static str>,
|
||||
/// The merged per-rule options: the buffer's `lucisv.toml` overlaid with
|
||||
/// the editor's `lucisv.lint.options`.
|
||||
pub options: RuleOptions,
|
||||
/// The width `line-length` holds this buffer to.
|
||||
pub line_length: usize,
|
||||
/// The width a `no-tabs` fix writes. It changes a fix's *text* and
|
||||
/// nothing else, but a fix's text is what a user applies.
|
||||
pub tab_width: usize,
|
||||
/// Whether the pass had a census to ask. The oracle's *answers* are
|
||||
/// covered by `refresh_overlay`; whether there is one at all is decided
|
||||
/// from the index's file count, which can move without any one file's
|
||||
/// facts moving.
|
||||
pub has_oracle: bool,
|
||||
/// Every external waiver file in force, path and **contents**, in the
|
||||
/// order they were read.
|
||||
///
|
||||
/// The contents, not a digest and not an mtime: a waiver file is not
|
||||
/// watched (`watch::SOURCE_GLOB` covers sources and the filelist alone),
|
||||
/// so the only thing that ever notices a rewritten one is this
|
||||
/// comparison. The text is already in hand — the pass read it to parse
|
||||
/// it — so keeping it costs a copy per open document and no I/O.
|
||||
pub waivers: Vec<(PathBuf, String)>,
|
||||
}
|
||||
|
||||
/// One document's lint snapshot: the key it was computed under, and what it
|
||||
/// found.
|
||||
struct Held {
|
||||
key: Key,
|
||||
violations: Arc<[Violation]>,
|
||||
}
|
||||
|
||||
/// The snapshot slot a `Document` carries.
|
||||
///
|
||||
/// A `Mutex` rather than a `RefCell` so a `Document` stays `Sync` exactly as
|
||||
/// its `OnceLock` fence memo leaves it; the lock is uncontended (one message
|
||||
/// loop) and is never held across the pass itself.
|
||||
#[derive(Default)]
|
||||
pub struct Slot(Mutex<Option<Held>>);
|
||||
|
||||
impl Slot {
|
||||
/// An empty slot — what every `Document` is built with.
|
||||
pub fn new() -> Slot {
|
||||
Slot(Mutex::new(None))
|
||||
}
|
||||
|
||||
/// Forget whatever is held.
|
||||
///
|
||||
/// Called from `Document::refresh_overlay`, which is the one place a
|
||||
/// `Document` is told the workspace index moved. Dropping here rather
|
||||
/// than keying on an index generation is deliberate: the four call sites
|
||||
/// that mutate the index all end in that loop, so there is no way for the
|
||||
/// index to move without this running, and no counter to keep in step.
|
||||
pub fn clear(&mut self) {
|
||||
if let Ok(mut held) = self.0.lock() {
|
||||
*held = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// The violations for `key`, computing them when what is held is for
|
||||
/// anything else.
|
||||
///
|
||||
/// Returns `(violations, answered_from_the_snapshot)`. A poisoned lock —
|
||||
/// which this server has no way to produce, having one message loop and no
|
||||
/// panicking library code — degrades to computing every time rather than
|
||||
/// to an error a user would see.
|
||||
pub fn read_or(
|
||||
&self,
|
||||
key: &Key,
|
||||
compute: impl FnOnce() -> Vec<Violation>,
|
||||
) -> (Arc<[Violation]>, bool) {
|
||||
if let Ok(held) = self.0.lock() {
|
||||
if let Some(held) = held.as_ref().filter(|held| held.key == *key) {
|
||||
return (Arc::clone(&held.violations), true);
|
||||
}
|
||||
}
|
||||
// Computed with the lock released: `lint_with` is the expensive part
|
||||
// and it reads nothing this slot owns.
|
||||
let violations: Arc<[Violation]> = compute().into();
|
||||
if let Ok(mut held) = self.0.lock() {
|
||||
*held = Some(Held { key: key.clone(), violations: Arc::clone(&violations) });
|
||||
}
|
||||
(violations, false)
|
||||
}
|
||||
|
||||
/// Whether anything is held at all — for the tests that assert a slot was
|
||||
/// filled, or was not.
|
||||
#[cfg(test)]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.lock().map_or(true, |held| held.is_none())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Slot {
|
||||
/// Says whether a snapshot is held and nothing about it: a `Document`'s
|
||||
/// `Debug` must not print a thousand violations.
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let held = self.0.lock().map(|held| held.is_some()).unwrap_or(false);
|
||||
f.debug_tuple("Slot").field(&held).finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use vlog_parser::TextRange;
|
||||
|
||||
fn key() -> Key {
|
||||
Key {
|
||||
rules: vec!["no-tabs"],
|
||||
options: RuleOptions::new(),
|
||||
line_length: 100,
|
||||
tab_width: 2,
|
||||
has_oracle: false,
|
||||
waivers: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn violation(message: &str) -> Violation {
|
||||
Violation::new("no-tabs", message, TextRange::new(0, 1))
|
||||
}
|
||||
|
||||
/// The second ask for the same key does not compute, and answers with the
|
||||
/// same findings.
|
||||
#[test]
|
||||
fn a_matching_key_answers_without_computing() {
|
||||
let slot = Slot::new();
|
||||
let (first, hit) = slot.read_or(&key(), || vec![violation("one")]);
|
||||
assert!(!hit, "an empty slot cannot hit");
|
||||
let (again, hit) = slot.read_or(&key(), || panic!("must not recompute"));
|
||||
assert!(hit);
|
||||
assert_eq!(again.len(), 1);
|
||||
assert_eq!(again[0].message, first[0].message);
|
||||
}
|
||||
|
||||
/// Every field of the key is load-bearing: change any one and the pass
|
||||
/// runs again. This is the table's row set in miniature — the per-input
|
||||
/// server tests assert the same thing through the real doors.
|
||||
#[test]
|
||||
fn every_field_of_the_key_forces_a_recompute() {
|
||||
let mut options = RuleOptions::new();
|
||||
options.set_raw("line-length", "length", "80").expect("a real option");
|
||||
let changes: Vec<(&str, Key)> = vec![
|
||||
("rules", Key { rules: vec!["no-tabs", "posix-eof"], ..key() }),
|
||||
("options", Key { options, ..key() }),
|
||||
("line_length", Key { line_length: 120, ..key() }),
|
||||
("tab_width", Key { tab_width: 4, ..key() }),
|
||||
("has_oracle", Key { has_oracle: true, ..key() }),
|
||||
(
|
||||
"waivers",
|
||||
Key {
|
||||
waivers: vec![(PathBuf::from("/w.waiver"), "waive --rule=no-tabs\n".into())],
|
||||
..key()
|
||||
},
|
||||
),
|
||||
];
|
||||
for (what, moved) in changes {
|
||||
let slot = Slot::new();
|
||||
slot.read_or(&key(), || vec![violation("old")]);
|
||||
let (found, hit) = slot.read_or(&moved, || vec![violation("new")]);
|
||||
assert!(!hit, "{what} did not invalidate the snapshot");
|
||||
assert_eq!(found[0].message, "new", "{what} answered stale");
|
||||
// ... and the new answer is what is held afterwards, so the stale
|
||||
// one cannot come back on the next request.
|
||||
let (again, hit) = slot.read_or(&moved, || panic!("must not recompute"));
|
||||
assert!(hit);
|
||||
assert_eq!(again[0].message, "new", "{what} left the old answer held");
|
||||
}
|
||||
}
|
||||
|
||||
/// A waiver file rewritten to the same length with different bytes is a
|
||||
/// different key: the contents are compared, not a size or a time.
|
||||
#[test]
|
||||
fn a_waiver_rewritten_in_place_is_a_different_key() {
|
||||
let one = |text: &str| Key {
|
||||
waivers: vec![(PathBuf::from("/w.waiver"), text.to_string())],
|
||||
..key()
|
||||
};
|
||||
let slot = Slot::new();
|
||||
slot.read_or(&one("waive --rule=no-tabs\n"), || vec![violation("old")]);
|
||||
let (found, hit) =
|
||||
slot.read_or(&one("waive --rule=posix-eof\n"), || vec![violation("new")]);
|
||||
assert!(!hit, "same length, different bytes");
|
||||
assert_eq!(found[0].message, "new");
|
||||
}
|
||||
|
||||
/// Clearing is what `refresh_overlay` does when the index moves.
|
||||
#[test]
|
||||
fn clearing_forces_the_next_pass_to_compute() {
|
||||
let mut slot = Slot::new();
|
||||
slot.read_or(&key(), || vec![violation("old")]);
|
||||
assert!(!slot.is_empty());
|
||||
slot.clear();
|
||||
assert!(slot.is_empty());
|
||||
let (found, hit) = slot.read_or(&key(), || vec![violation("new")]);
|
||||
assert!(!hit, "a cleared slot cannot hit");
|
||||
assert_eq!(found[0].message, "new");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,607 @@
|
||||
//! Where a lint-answering request's milliseconds went.
|
||||
//!
|
||||
//! Take 5 **review** round §R1b (`docs/performance_take5_review.md` §1,
|
||||
//! `docs/features/perf5r-lint-snapshot/README.md`). The review's own note is
|
||||
//! that the pinmux code-action menu costs **25 ms of which 23 is quickfix**,
|
||||
//! and that the first request after a one-character edit costs **136 ms** —
|
||||
//! but "config read plus lint" was as far as the previous lane could
|
||||
//! attribute it, and *config read plus lint* is two answers, not one. This
|
||||
//! module splits the request into the five stages a reader can act on:
|
||||
//!
|
||||
//! | stage | what it is |
|
||||
//! |---|---|
|
||||
//! | `config` | `Discovery::for_file`, `ProjectLint::read` and every waiver file read |
|
||||
//! | `build` | the rest of [`crate::lint::LintRun::for_document`] — the oracle, the rule ladder |
|
||||
//! | `lint` | `vlog_linter::lint_with`, and how many times it ran |
|
||||
//! | `fence` | `crate::fences::of` — computed, taken from the memo, or skipped |
|
||||
//! | `serialize` | turning violations into `CodeAction`s |
|
||||
//!
|
||||
//! and reports the **flush** — the debounced `Document` rebuild `answer_request`
|
||||
//! performs before any handler runs — as its own group, with the diagnostics
|
||||
//! pass that publishes inside it split the same five ways. That separation is
|
||||
//! the review's item 4: if the dirty-buffer stage dominates the 136 ms, a lint
|
||||
//! cache alone cannot fix it, and only a number can say.
|
||||
//!
|
||||
//! **Nothing here decides anything.** A trace is armed by
|
||||
//! [`crate::server`]'s request wrapper when `--verbose` asked for one, written
|
||||
//! as the request runs, logged once and dropped.
|
||||
//!
|
||||
//! Off is the shipped state and costs **one thread-local `Cell<bool>` read**
|
||||
//! per traced site — no clock read, no allocation, no line — which is the same
|
||||
//! bargain `Server::timer` makes for the rest of `docs/features/verbose-timing/`.
|
||||
//!
|
||||
//! Per thread, deliberately, for `vlog_parser::stats`' reason: a request is
|
||||
//! answered on one thread, so a thread-local accumulator is that request's
|
||||
//! number exactly, and `cargo test`'s parallel binaries cannot add to each
|
||||
//! other's.
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// One stage of a lint-answering request.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Stage {
|
||||
/// Reading the project's configuration: the `lucisv.toml` discovery walk,
|
||||
/// its `[lint]` table, and the external waiver files.
|
||||
Config,
|
||||
/// The rest of the `LintRun`: the census oracle and the rule ladder.
|
||||
Build,
|
||||
/// `vlog_linter::lint_with` itself.
|
||||
Lint,
|
||||
/// The formatter's fenced-region answer.
|
||||
Fence,
|
||||
/// Turning violations into what goes on the wire.
|
||||
Serialize,
|
||||
}
|
||||
|
||||
impl Stage {
|
||||
/// The name this stage is counted under in the `timing:` line.
|
||||
fn label(self) -> &'static str {
|
||||
match self {
|
||||
Stage::Config => "config",
|
||||
Stage::Build => "build",
|
||||
Stage::Lint => "lint",
|
||||
Stage::Fence => "fence",
|
||||
Stage::Serialize => "serialize",
|
||||
}
|
||||
}
|
||||
|
||||
/// Every stage, in the order a request passes through them — so a line
|
||||
/// always carries the same fields whether or not a stage ran.
|
||||
const ALL: [Stage; 5] =
|
||||
[Stage::Config, Stage::Build, Stage::Lint, Stage::Fence, Stage::Serialize];
|
||||
}
|
||||
|
||||
/// One stage of the debounced `Document` rebuild the flush performs, plus the
|
||||
/// diagnostics publish that follows it.
|
||||
///
|
||||
/// TODO §63.2: `flush{wall=…}` said the rebuild cost 100 ms and nothing about
|
||||
/// *which* of the six derivations that was, so the first thing this round does
|
||||
/// is name them. The six are [`crate::state::Document::new`]'s own steps in
|
||||
/// the order it runs them; `Publish` is what `flush_dirty` does with the
|
||||
/// rebuilt buffer, and the flush group's `config`/`build`/`lint`/`fence`
|
||||
/// stages are inside it.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Rebuild {
|
||||
/// `tokenize` over the buffer's text.
|
||||
Lex,
|
||||
/// `parse_tolerant` over those tokens (or `parse_source_tolerant` when the
|
||||
/// buffer does not lex).
|
||||
Parse,
|
||||
/// `collect_defines` over the tokens.
|
||||
Defines,
|
||||
/// `analyze` over the tree.
|
||||
Analyze,
|
||||
/// `resolve_external` against the workspace index.
|
||||
External,
|
||||
/// `LineIndex::new` over the text.
|
||||
Lines,
|
||||
/// The diagnostics publish for the rebuilt buffer.
|
||||
Publish,
|
||||
}
|
||||
|
||||
impl Rebuild {
|
||||
/// The name this stage is counted under in the `timing:` line.
|
||||
fn label(self) -> &'static str {
|
||||
match self {
|
||||
Rebuild::Lex => "lex",
|
||||
Rebuild::Parse => "parse",
|
||||
Rebuild::Defines => "defines",
|
||||
Rebuild::Analyze => "analyze",
|
||||
Rebuild::External => "external",
|
||||
Rebuild::Lines => "lines",
|
||||
Rebuild::Publish => "publish",
|
||||
}
|
||||
}
|
||||
|
||||
/// Every stage, in the order the flush passes through them.
|
||||
const ALL: [Rebuild; 7] = [
|
||||
Rebuild::Lex,
|
||||
Rebuild::Parse,
|
||||
Rebuild::Defines,
|
||||
Rebuild::Analyze,
|
||||
Rebuild::External,
|
||||
Rebuild::Lines,
|
||||
Rebuild::Publish,
|
||||
];
|
||||
}
|
||||
|
||||
/// The flush's inner stages: what rebuilding the dirty buffers cost, split.
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
pub struct Rebuilt {
|
||||
ms: [f64; Rebuild::ALL.len()],
|
||||
/// How many `Document`s were built from scratch.
|
||||
documents: usize,
|
||||
}
|
||||
|
||||
impl Rebuilt {
|
||||
/// The `const` form `thread_local!`'s initializer needs.
|
||||
const EMPTY: Rebuilt = Rebuilt { ms: [0.0; Rebuild::ALL.len()], documents: 0 };
|
||||
|
||||
fn add(&mut self, stage: Rebuild, took: Duration) {
|
||||
self.ms[stage as usize] += took.as_secs_f64() * 1_000.0;
|
||||
}
|
||||
|
||||
/// This group's fields, in the `key=value` shape `tools/perf` parses.
|
||||
fn fields(&self) -> String {
|
||||
let stages: Vec<String> = Rebuild::ALL
|
||||
.iter()
|
||||
.map(|stage| format!("{}={:.2}ms", stage.label(), self.ms[*stage as usize]))
|
||||
.collect();
|
||||
format!("{} documents={}", stages.join(" "), self.documents)
|
||||
}
|
||||
}
|
||||
|
||||
/// What the fence filter did, when a pass reached it at all.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
pub enum Fences {
|
||||
/// No finding carried a fix, so the filter would have been the identity
|
||||
/// and was not asked (take 5 §P1a).
|
||||
#[default]
|
||||
Skipped,
|
||||
/// `protected_regions` parsed the buffer for this `Document`.
|
||||
Computed,
|
||||
/// The `Document`'s memo answered (take 5 §P1b).
|
||||
Memo,
|
||||
}
|
||||
|
||||
impl Fences {
|
||||
fn label(self) -> &'static str {
|
||||
match self {
|
||||
Fences::Skipped => "skipped",
|
||||
Fences::Computed => "computed",
|
||||
Fences::Memo => "memo",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a lint pass was answered from the snapshot (review round §R1a).
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||
pub enum Reuse {
|
||||
/// No pass ran.
|
||||
#[default]
|
||||
None,
|
||||
/// The `Document` held no snapshot, or held one for other inputs.
|
||||
Miss,
|
||||
/// The snapshot matched and `lint_with` did not run.
|
||||
Hit,
|
||||
}
|
||||
|
||||
impl Reuse {
|
||||
fn label(self) -> &'static str {
|
||||
match self {
|
||||
Reuse::None => "none",
|
||||
Reuse::Miss => "miss",
|
||||
Reuse::Hit => "hit",
|
||||
}
|
||||
}
|
||||
|
||||
/// A hit only survives while every pass hit: one recompute in a request
|
||||
/// is a miss for that request, which is what a reader wants to know.
|
||||
fn saw(self, other: Reuse) -> Reuse {
|
||||
match (self, other) {
|
||||
(Reuse::Miss, _) | (_, Reuse::Miss) => Reuse::Miss,
|
||||
(Reuse::Hit, _) | (_, Reuse::Hit) => Reuse::Hit,
|
||||
_ => Reuse::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One group of stages: the flush's, or the handler's own.
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
pub struct Group {
|
||||
ms: [f64; Stage::ALL.len()],
|
||||
/// How many times `lint_with` ran in this group.
|
||||
passes: u32,
|
||||
/// How many violations the last pass found.
|
||||
violations: usize,
|
||||
/// How many rules that pass ran.
|
||||
rules: usize,
|
||||
/// How many actions were serialized.
|
||||
actions: usize,
|
||||
/// How many waiver files were read from disk.
|
||||
waivers: usize,
|
||||
/// Whether a `lucisv.toml` was found and read.
|
||||
toml: bool,
|
||||
fences: Fences,
|
||||
reuse: Reuse,
|
||||
}
|
||||
|
||||
impl Group {
|
||||
/// The `const` form `thread_local!`'s initializer needs; `Default` is not
|
||||
/// callable there.
|
||||
const EMPTY: Group = Group {
|
||||
ms: [0.0; Stage::ALL.len()],
|
||||
passes: 0,
|
||||
violations: 0,
|
||||
rules: 0,
|
||||
actions: 0,
|
||||
waivers: 0,
|
||||
toml: false,
|
||||
fences: Fences::Skipped,
|
||||
reuse: Reuse::None,
|
||||
};
|
||||
|
||||
fn add(&mut self, stage: Stage, took: Duration) {
|
||||
self.ms[stage as usize] += took.as_secs_f64() * 1_000.0;
|
||||
}
|
||||
|
||||
/// This group's fields, in the `key=value` shape `tools/perf` parses.
|
||||
fn fields(&self) -> String {
|
||||
let stages: Vec<String> = Stage::ALL
|
||||
.iter()
|
||||
.map(|stage| format!("{}={:.2}ms", stage.label(), self.ms[*stage as usize]))
|
||||
.collect();
|
||||
format!(
|
||||
"{} passes={} rules={} violations={} actions={} waivers={} toml={} fences={} \
|
||||
snapshot={}",
|
||||
stages.join(" "),
|
||||
self.passes,
|
||||
self.rules,
|
||||
self.violations,
|
||||
self.actions,
|
||||
self.waivers,
|
||||
self.toml,
|
||||
self.fences.label(),
|
||||
self.reuse.label(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// One request's trace: what the flush cost, and what the handler cost.
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
pub struct Trace {
|
||||
/// The stages the debounced `Document` rebuild and its diagnostics
|
||||
/// publish passed through, closed by [`close_flush`].
|
||||
pub flush: Group,
|
||||
/// How long the whole flush took, publish included.
|
||||
pub flush_ms: f64,
|
||||
/// Buffers the flush rebuilt.
|
||||
pub flush_buffers: usize,
|
||||
/// Whole-file parses the flush performed (`vlog_parser::stats`).
|
||||
pub flush_parses: u64,
|
||||
/// What the flush's `Document` rebuild and publish cost, stage by stage.
|
||||
pub rebuild: Rebuilt,
|
||||
/// The handler's own stages.
|
||||
pub action: Group,
|
||||
}
|
||||
|
||||
impl Trace {
|
||||
/// Whether this request touched the lint path at all. A trace that did
|
||||
/// not is not worth a line.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.flush == Group::default()
|
||||
&& self.action == Group::default()
|
||||
&& self.flush_buffers == 0
|
||||
&& self.rebuild == Rebuilt::default()
|
||||
}
|
||||
|
||||
/// The whole trace as one `timing:`-style fragment.
|
||||
///
|
||||
/// The three groups are siblings, never nested: `tools/perf`'s group
|
||||
/// regex flattens `name{…}` one level and would not survive a brace
|
||||
/// inside a brace.
|
||||
pub fn line(&self) -> String {
|
||||
format!(
|
||||
"flush{{wall={:.2}ms buffers={} parses={} {}}} rebuild{{{}}} action{{{}}}",
|
||||
self.flush_ms,
|
||||
self.flush_buffers,
|
||||
self.flush_parses,
|
||||
self.flush.fields(),
|
||||
self.rebuild.fields(),
|
||||
self.action.fields(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
/// One branch is the whole of what verbose-off costs at a traced site.
|
||||
static ARMED: Cell<bool> = const { Cell::new(false) };
|
||||
static TRACE: RefCell<Trace> = const { RefCell::new(Trace {
|
||||
flush: Group::EMPTY,
|
||||
flush_ms: 0.0,
|
||||
flush_buffers: 0,
|
||||
flush_parses: 0,
|
||||
rebuild: Rebuilt::EMPTY,
|
||||
action: Group::EMPTY,
|
||||
}) };
|
||||
/// Which group the stages recorded right now belong to.
|
||||
static IN_FLUSH: Cell<bool> = const { Cell::new(true) };
|
||||
}
|
||||
|
||||
/// Start a fresh trace for one request. Called by the request wrapper when
|
||||
/// `--verbose` asked for timing, and by nothing else.
|
||||
pub fn arm() {
|
||||
ARMED.set(true);
|
||||
IN_FLUSH.set(true);
|
||||
TRACE.with_borrow_mut(|trace| *trace = Trace::default());
|
||||
}
|
||||
|
||||
/// Whether a trace is being written — the one branch a caller checks before
|
||||
/// reading a clock of its own.
|
||||
pub fn armed() -> bool {
|
||||
ARMED.get()
|
||||
}
|
||||
|
||||
/// Stop tracing and return what was written, or `None` when nothing armed it.
|
||||
pub fn disarm() -> Option<Trace> {
|
||||
if !ARMED.replace(false) {
|
||||
return None;
|
||||
}
|
||||
Some(TRACE.with_borrow(Clone::clone))
|
||||
}
|
||||
|
||||
/// Close the flush group: everything recorded from here on is the handler's.
|
||||
///
|
||||
/// `parses` is the `vlog_parser::stats::parses()` delta across the flush and
|
||||
/// `buffers` is how many dirty buffers it rebuilt, so the `Document` rebuild
|
||||
/// is readable beside the diagnostics pass that follows it.
|
||||
pub fn close_flush(took: Duration, buffers: usize, parses: u64) {
|
||||
if !ARMED.get() {
|
||||
return;
|
||||
}
|
||||
TRACE.with_borrow_mut(|trace| {
|
||||
trace.flush_ms = took.as_secs_f64() * 1_000.0;
|
||||
trace.flush_buffers = buffers;
|
||||
trace.flush_parses = parses;
|
||||
});
|
||||
IN_FLUSH.set(false);
|
||||
}
|
||||
|
||||
/// Run `work`, counting what it took against `stage`.
|
||||
///
|
||||
/// Untimed and unallocated when nothing armed a trace, which is every session
|
||||
/// but a `--verbose` one.
|
||||
pub fn stage<T>(stage: Stage, work: impl FnOnce() -> T) -> T {
|
||||
if !ARMED.get() {
|
||||
return work();
|
||||
}
|
||||
let started = Instant::now();
|
||||
let out = work();
|
||||
let took = started.elapsed();
|
||||
group(|held| held.add(stage, took));
|
||||
out
|
||||
}
|
||||
|
||||
/// Run `work`, counting what it took against one of the flush's inner stages.
|
||||
///
|
||||
/// Off costs the same one thread-local read [`stage`] costs. The flush group
|
||||
/// is not consulted: a rebuild belongs to the rebuild it is part of whichever
|
||||
/// half of the request it happens in, and outside a flush there is none.
|
||||
pub fn rebuild<T>(stage: Rebuild, work: impl FnOnce() -> T) -> T {
|
||||
if !ARMED.get() {
|
||||
return work();
|
||||
}
|
||||
let started = Instant::now();
|
||||
let out = work();
|
||||
let took = started.elapsed();
|
||||
TRACE.with_borrow_mut(|trace| trace.rebuild.add(stage, took));
|
||||
out
|
||||
}
|
||||
|
||||
/// Record that one `Document` was built from scratch.
|
||||
pub fn saw_document() {
|
||||
if !ARMED.get() {
|
||||
return;
|
||||
}
|
||||
TRACE.with_borrow_mut(|trace| trace.rebuild.documents += 1);
|
||||
}
|
||||
|
||||
/// Record what a lint pass ran and found.
|
||||
pub fn saw_lint(rules: usize, violations: usize, reuse: Reuse) {
|
||||
group(|held| {
|
||||
held.passes += 1;
|
||||
held.rules = rules;
|
||||
held.violations = violations;
|
||||
held.reuse = held.reuse.saw(reuse);
|
||||
});
|
||||
}
|
||||
|
||||
/// Record what the configuration read found: a `lucisv.toml`, and how many
|
||||
/// waiver files it and the editor's settings between them named.
|
||||
pub fn saw_config(toml: bool, waivers: usize) {
|
||||
group(|held| {
|
||||
held.toml |= toml;
|
||||
held.waivers += waivers;
|
||||
});
|
||||
}
|
||||
|
||||
/// Record what the fence filter did.
|
||||
pub fn saw_fences(fences: Fences) {
|
||||
group(|held| held.fences = fences);
|
||||
}
|
||||
|
||||
/// Record how many actions were put on the wire.
|
||||
pub fn saw_actions(actions: usize) {
|
||||
group(|held| held.actions += actions);
|
||||
}
|
||||
|
||||
/// Apply `write` to whichever group is being filled, or to nothing at all.
|
||||
fn group(write: impl FnOnce(&mut Group)) {
|
||||
if !ARMED.get() {
|
||||
return;
|
||||
}
|
||||
let flushing = IN_FLUSH.get();
|
||||
TRACE.with_borrow_mut(|trace| {
|
||||
write(if flushing { &mut trace.flush } else { &mut trace.action })
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Nothing is written when nothing armed a trace — the shipped state.
|
||||
#[test]
|
||||
fn an_unarmed_trace_records_nothing_and_returns_the_work() {
|
||||
assert_eq!(disarm(), None);
|
||||
assert_eq!(stage(Stage::Lint, || 7), 7);
|
||||
saw_lint(3, 4, Reuse::Miss);
|
||||
assert_eq!(disarm(), None, "still nothing to say");
|
||||
}
|
||||
|
||||
/// The two groups are kept apart, and `close_flush` is what separates
|
||||
/// them: a stage before it is the flush's, one after it the handler's.
|
||||
#[test]
|
||||
fn close_flush_divides_the_request_into_its_two_halves() {
|
||||
arm();
|
||||
saw_lint(9, 100, Reuse::Miss);
|
||||
close_flush(Duration::from_millis(110), 1, 1);
|
||||
saw_lint(9, 100, Reuse::Hit);
|
||||
saw_actions(2);
|
||||
saw_fences(Fences::Memo);
|
||||
let trace = disarm().expect("armed");
|
||||
assert_eq!(trace.flush.passes, 1);
|
||||
assert_eq!(trace.flush.violations, 100);
|
||||
assert_eq!(trace.flush.actions, 0, "the flush serializes nothing");
|
||||
assert_eq!(trace.flush_buffers, 1);
|
||||
assert_eq!(trace.flush_parses, 1);
|
||||
assert!((trace.flush_ms - 110.0).abs() < 5.0, "{}", trace.flush_ms);
|
||||
assert_eq!(trace.action.passes, 1);
|
||||
assert_eq!(trace.action.actions, 2);
|
||||
assert_eq!(trace.action.fences, Fences::Memo);
|
||||
assert_eq!(trace.action.reuse, Reuse::Hit);
|
||||
assert_eq!(disarm(), None, "disarming twice says nothing twice");
|
||||
}
|
||||
|
||||
/// One recompute in a request is a miss for that request: a reader asking
|
||||
/// "did this menu re-lint?" must not be told "hit" because the second
|
||||
/// pass reused what the first one had just computed.
|
||||
#[test]
|
||||
fn a_single_recompute_makes_the_whole_request_a_miss() {
|
||||
arm();
|
||||
close_flush(Duration::ZERO, 0, 0);
|
||||
saw_lint(9, 100, Reuse::Hit);
|
||||
saw_lint(9, 100, Reuse::Miss);
|
||||
assert_eq!(disarm().expect("armed").action.reuse, Reuse::Miss);
|
||||
}
|
||||
|
||||
/// Every stage is named in the line whether or not it ran, so a reader
|
||||
/// (and `tools/perf/phases_r1.py`) always parses the same fields.
|
||||
#[test]
|
||||
fn the_line_names_every_stage_in_both_groups() {
|
||||
arm();
|
||||
stage(Stage::Config, || {});
|
||||
close_flush(Duration::from_millis(1), 1, 1);
|
||||
stage(Stage::Lint, || {});
|
||||
let line = disarm().expect("armed").line();
|
||||
for stage in Stage::ALL {
|
||||
assert_eq!(line.matches(&format!("{}=", stage.label())).count(), 2, "{line}");
|
||||
}
|
||||
assert!(line.contains("buffers=1"), "{line}");
|
||||
assert!(line.contains("snapshot=none"), "{line}");
|
||||
assert!(!line.contains(" "), "no empty field: {line}");
|
||||
}
|
||||
|
||||
/// The flush's inner stages are their own sibling group, named whether or
|
||||
/// not they ran, and never nested inside `flush{…}` — `tools/perf`'s
|
||||
/// group regex flattens one level only (TODO §63.2).
|
||||
#[test]
|
||||
fn the_rebuild_group_names_every_stage_beside_the_other_two() {
|
||||
arm();
|
||||
rebuild(Rebuild::Lex, || {});
|
||||
saw_document();
|
||||
close_flush(Duration::from_millis(1), 1, 1);
|
||||
let line = disarm().expect("armed").line();
|
||||
let rebuilt = line.split("rebuild{").nth(1).expect("a rebuild group").split('}').next();
|
||||
let rebuilt = rebuilt.expect("a closed rebuild group");
|
||||
for stage in Rebuild::ALL {
|
||||
assert!(rebuilt.contains(&format!("{}=", stage.label())), "{line}");
|
||||
}
|
||||
assert!(rebuilt.contains("documents=1"), "{line}");
|
||||
assert!(!rebuilt.contains('{'), "no nested group: {line}");
|
||||
}
|
||||
|
||||
/// TODO §63.2 QA: the sibling-group contract, attacked directly against
|
||||
/// the parser it is a contract *with*.
|
||||
///
|
||||
/// `tools/perf/phases_p2.py`'s `GROUP` regex is `([a-z_]+)\{([^{}]*)\}` —
|
||||
/// a group's body may not contain another `{`. Sabotaging `line()` to
|
||||
/// nest `rebuild{…}` inside `flush{…}` (tried by hand while attacking
|
||||
/// this pin) does **not** fail the test above: splitting on `"rebuild{"`
|
||||
/// still finds a clean `rebuild` body, because the extra brace the
|
||||
/// nesting adds sits *outside* the slice that test inspects. Run through
|
||||
/// the actual regex, though, nesting is fatal: `[^{}]*` cannot cross the
|
||||
/// inner `{`, so the whole `flush{...}` match fails and `flush_wall`,
|
||||
/// `flush_buffers`, `flush_parses` and every `flush.fields()` entry
|
||||
/// silently vanish from every `tools/perf` row — confirmed with
|
||||
/// `GROUP.findall` in a scratch interpreter against the sabotaged line,
|
||||
/// which matched only `rebuild` and `action`, never `flush`. This test
|
||||
/// reads the line the way the regex does (each group's body must reach
|
||||
/// its own `}` before another `{` opens) so a future nesting regression
|
||||
/// fails here instead of only downstream in Python.
|
||||
#[test]
|
||||
fn the_three_top_level_groups_are_flat_never_nested() {
|
||||
arm();
|
||||
rebuild(Rebuild::Lex, || {});
|
||||
saw_document();
|
||||
close_flush(Duration::from_millis(1), 1, 1);
|
||||
let line = disarm().expect("armed").line();
|
||||
for name in ["flush", "rebuild", "action"] {
|
||||
let open =
|
||||
line.find(&format!("{name}{{")).unwrap_or_else(|| panic!("no {name}{{ in {line}"));
|
||||
let body = &line[open + name.len() + 1..];
|
||||
let close =
|
||||
body.find('}').unwrap_or_else(|| panic!("no closing brace for {name}: {line}"));
|
||||
let next_open = body.find('{');
|
||||
assert!(
|
||||
next_open.is_none_or(|o| o > close),
|
||||
"{name}{{...}} is not flat — a nested group vanishes from every \
|
||||
tools/perf row parsed by phases_p2.GROUP instead of failing loudly: {line}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A rebuild is recorded in either half of the request, and an unarmed
|
||||
/// one records nothing at all.
|
||||
#[test]
|
||||
fn a_rebuild_is_counted_whichever_half_of_the_request_runs_it() {
|
||||
assert_eq!(rebuild(Rebuild::Parse, || 4), 4);
|
||||
assert_eq!(disarm(), None);
|
||||
arm();
|
||||
rebuild(Rebuild::Parse, || {});
|
||||
close_flush(Duration::ZERO, 1, 1);
|
||||
rebuild(Rebuild::Parse, || {});
|
||||
saw_document();
|
||||
saw_document();
|
||||
let trace = disarm().expect("armed");
|
||||
assert_eq!(trace.rebuild.documents, 2);
|
||||
assert_eq!(trace.flush.passes, 0, "a rebuild is not a lint pass");
|
||||
assert_eq!(trace.action.passes, 0);
|
||||
}
|
||||
|
||||
/// A request that only rebuilt a buffer still has something to say: the
|
||||
/// trace must not be discarded as empty before the line is logged.
|
||||
///
|
||||
/// The rebuilt *count*, not a stage's milliseconds, is what says a
|
||||
/// rebuild happened — a stage whose work takes less than the clock's
|
||||
/// resolution adds 0.00 ms, which is why `Document::new` reports itself
|
||||
/// with [`saw_document`] rather than leaving the evidence to a duration.
|
||||
#[test]
|
||||
fn a_trace_holding_only_a_rebuild_is_not_empty() {
|
||||
arm();
|
||||
rebuild(Rebuild::Analyze, || {});
|
||||
saw_document();
|
||||
assert!(!disarm().expect("armed").is_empty());
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ mod large;
|
||||
mod lens;
|
||||
mod linked;
|
||||
mod lint;
|
||||
mod lint_snapshot;
|
||||
mod lint_trace;
|
||||
mod locate;
|
||||
mod module_select;
|
||||
mod nav;
|
||||
|
||||
+1756
-54
File diff suppressed because it is too large.
Load diff
@@ -17,6 +17,7 @@ use std::path::PathBuf;
|
||||
|
||||
use lsp_types::{PrepareRenameResponse, TextEdit, Uri, WorkspaceEdit};
|
||||
use vlog_parser::LineIndex;
|
||||
use vlog_semantic::FileFacts;
|
||||
|
||||
use crate::convert::Positions;
|
||||
use crate::locate::display_name;
|
||||
@@ -65,6 +66,26 @@ pub fn rename_traced(
|
||||
) -> Result<(WorkspaceEdit, Vec<String>), String> {
|
||||
let doc = ws.document(uri).ok_or_else(|| UNSAVED.to_string())?;
|
||||
let path = doc.path.clone().ok_or_else(|| UNSAVED.to_string())?;
|
||||
// The engine's own first look at the request, over the buffer it is about
|
||||
// to be handed anyway. It refuses only what `vlog_refactor::rename` is
|
||||
// certain to refuse in the same words — so this is still one voice
|
||||
// deciding, just asked before the workspace is materialized for it. A
|
||||
// cursor on nothing used to read, parse and index all 3 976 files before
|
||||
// saying so (take 5 review §3 item 6); now it reads none.
|
||||
//
|
||||
// Sound because both selectors below hand the engine this very buffer, so
|
||||
// the out-of-scope refusal that outranks a cursor refusal cannot fire.
|
||||
//
|
||||
// A refusal here still writes a trace, because "where did the time go" is
|
||||
// a question about the fast refusals too — and the answer, nowhere, is
|
||||
// only believable if the line says `selected=0` and `parses=0` in the same
|
||||
// fields the slow road fills.
|
||||
if let Err(refusal) = vlog_refactor::rename_preflight(&doc.semantics, offset, new_name) {
|
||||
let (selection, engine) =
|
||||
(SelectionTrace::default(), vlog_refactor::RenameTrace::default());
|
||||
*trace = Some(format!("{} {} preflight=true", selection.line(), engine.line()));
|
||||
return Err(refusal);
|
||||
}
|
||||
// The name the cursor sits on, read off the buffer, is what the index is
|
||||
// asked for the fan-out. No refusal is taken here: `vlog_refactor::rename`
|
||||
// is the one voice that decides, and it decides over the files below. A
|
||||
@@ -80,7 +101,9 @@ pub fn rename_traced(
|
||||
}
|
||||
};
|
||||
let mut engine = vlog_refactor::RenameTrace::default();
|
||||
let outcome = vlog_refactor::rename_traced(&sources, &path, offset, new_name, &mut engine);
|
||||
let known = Known(ws);
|
||||
let outcome =
|
||||
vlog_refactor::rename_traced_with(&sources, &path, offset, new_name, &known, &mut engine);
|
||||
*trace = Some(format!("{} {}", selection.line(), engine.line()));
|
||||
let refactoring = outcome?;
|
||||
|
||||
@@ -116,6 +139,23 @@ pub fn rename_traced(
|
||||
Ok((WorkspaceEdit::new(changes), warnings))
|
||||
}
|
||||
|
||||
/// The workspace answering the engine's `KnownFacts` question, and nothing
|
||||
/// else: one call, to the one query that ties a record to the bytes it was
|
||||
/// read off ([`Workspace::known_facts`]).
|
||||
///
|
||||
/// A newtype rather than an `impl` on `Workspace` so that the promise this
|
||||
/// makes to `vlog_refactor` is written where a reader of the rename can see
|
||||
/// it, and so that no other handler can acquire it by accident — the facts a
|
||||
/// refactoring may reuse are the facts of the very texts it was handed, which
|
||||
/// is a property of *this* call site.
|
||||
struct Known<'a>(&'a Workspace);
|
||||
|
||||
impl vlog_refactor::KnownFacts for Known<'_> {
|
||||
fn facts_for(&self, path: &std::path::Path, text: &str) -> Option<FileFacts> {
|
||||
self.0.known_facts(path, text)
|
||||
}
|
||||
}
|
||||
|
||||
/// One sentence per file that writes the old name inside a macro invocation,
|
||||
/// a directive line or an attribute and was **not** among the files the engine
|
||||
/// was handed.
|
||||
@@ -213,6 +253,118 @@ mod tests {
|
||||
(ws, uri)
|
||||
}
|
||||
|
||||
/// A third file that spells nothing this rename is about, kept open so
|
||||
/// the open-buffer rung selects it: the "container" class in miniature —
|
||||
/// a file the engine must index and never analyses.
|
||||
const BYSTANDER: &str = "module bystander;\n logic unrelated;\nendmodule\n";
|
||||
|
||||
/// `sub.sv`, `top.sv` and `quiet.sv`, with the last two open and a
|
||||
/// persistent index store behind the workspace — so a rename is handed
|
||||
/// records keyed on the very bytes it reads.
|
||||
fn three_with_store(tree: &Tree, store: Option<&Tree>) -> (Workspace, Uri) {
|
||||
tree.write("sub.sv", SUB);
|
||||
let top = tree.write("top.sv", TOP);
|
||||
let quiet = tree.write("bystander.sv", BYSTANDER);
|
||||
let mut ws = Workspace::default();
|
||||
ws.set_client_settings(crate::settings::ClientSettings {
|
||||
index_cache_path: store.map(|s| s.path.to_string_lossy().into_owned()),
|
||||
index_scope: crate::settings::IndexScope::Workspace,
|
||||
..Default::default()
|
||||
});
|
||||
ws.open_whole_workspace(vec![tree.path.clone()]);
|
||||
let uri = path_to_uri(&top).expect("uri");
|
||||
ws.set_document(uri.clone(), TOP.to_string());
|
||||
ws.set_document(path_to_uri(&quiet).expect("uri"), BYSTANDER.to_string());
|
||||
(ws, uri)
|
||||
}
|
||||
|
||||
/// Every edit and every warning one rename produced, with the workspace's
|
||||
/// own scratch path taken out — the fingerprint the parity proof compares.
|
||||
fn print(result: &(WorkspaceEdit, Vec<String>), root: &Path) -> String {
|
||||
let (edit, warnings) = result;
|
||||
let mut lines: Vec<String> = Vec::new();
|
||||
for (uri, edits) in edit.changes.iter().flatten() {
|
||||
for one in edits {
|
||||
lines.push(format!(
|
||||
"{} {:?}..{:?} -> {}",
|
||||
uri.as_str(),
|
||||
one.range.start,
|
||||
one.range.end,
|
||||
one.new_text
|
||||
));
|
||||
}
|
||||
}
|
||||
lines.sort();
|
||||
lines.extend(warnings.iter().map(|w| format!("warn {w}")));
|
||||
lines.join("\n").replace(root.to_str().expect("utf-8"), "")
|
||||
}
|
||||
|
||||
/// **§R3b's server-side proof.** The same rename over the same files, once
|
||||
/// with a warm index store behind it — where the engine is handed every
|
||||
/// file's record and stops parsing the ones nothing analyses — and once
|
||||
/// with no store at all, where it parses them all: byte-identical edits,
|
||||
/// byte-identical warnings.
|
||||
///
|
||||
/// The reuse is asserted to have happened *and* to have removed a parse,
|
||||
/// so a store that silently stopped answering would fail this rather than
|
||||
/// pass it for the wrong reason.
|
||||
#[test]
|
||||
fn a_rename_over_a_warm_store_says_exactly_what_one_with_no_store_says() {
|
||||
let tree = Tree::new("reuse_store");
|
||||
let store = Tree::new("reuse_store_cache");
|
||||
let (warm, uri) = three_with_store(&tree, Some(&store));
|
||||
let mut line = None;
|
||||
let with_store = rename_traced(&warm, &uri, at(TOP, "clk"), "clk_x", &mut line)
|
||||
.expect("the rename succeeds");
|
||||
let trace = line.expect("a trace is always written");
|
||||
assert!(trace.contains("selected=3"), "all three files are selected: {trace}");
|
||||
assert!(trace.contains("reused_files=3"), "and every record came from the store: {trace}");
|
||||
assert!(trace.contains("other_files=1"), "bystander.sv is the unread one: {trace}");
|
||||
assert!(trace.contains("parses{index=2"), "so only the two analysed files: {trace}");
|
||||
|
||||
let bare = Tree::new("reuse_none");
|
||||
let (plain, plain_uri) = three_with_store(&bare, None);
|
||||
let mut plain_line = None;
|
||||
let no_store = rename_traced(&plain, &plain_uri, at(TOP, "clk"), "clk_x", &mut plain_line)
|
||||
.expect("the rename succeeds");
|
||||
let plain_trace = plain_line.expect("a trace is always written");
|
||||
assert!(plain_trace.contains("reused_files=0"), "premise: no store, no reuse");
|
||||
assert!(plain_trace.contains("parses{index=3"), "premise: all three parsed");
|
||||
|
||||
assert_eq!(
|
||||
print(&with_store, &tree.path),
|
||||
print(&no_store, &bare.path),
|
||||
"the reuse changed an edit or a warning"
|
||||
);
|
||||
}
|
||||
|
||||
/// **Unsaved-buffer precedence, for free.** A buffer whose text disagrees
|
||||
/// with the file on disk is not the bytes any record was written from, so
|
||||
/// the store answers nothing for it and it is parsed — and the rename acts
|
||||
/// on the buffer's text, which is the precedence it always had.
|
||||
///
|
||||
/// Nothing in the reuse arranges this: the key is the content, so unsaved
|
||||
/// text misses the same way changed text does.
|
||||
#[test]
|
||||
fn an_unsaved_buffer_is_parsed_and_renamed_from_its_own_text() {
|
||||
let tree = Tree::new("reuse_unsaved");
|
||||
let store = Tree::new("reuse_unsaved_cache");
|
||||
let (mut ws, uri) = three_with_store(&tree, Some(&store));
|
||||
// A signal that exists only in the buffer. Its record cannot be in a
|
||||
// store keyed on what is on disk.
|
||||
let edited = "module top;\n logic only_here;\n sub u_sub (.clk(only_here));\nendmodule\n";
|
||||
ws.set_document(uri.clone(), edited.to_string());
|
||||
|
||||
let mut line = None;
|
||||
let (edit, _) = rename_traced(&ws, &uri, at(edited, "only_here"), "renamed", &mut line)
|
||||
.expect("the buffer's own declaration renames");
|
||||
let trace = line.expect("a trace is always written");
|
||||
assert!(trace.contains("reused_files=1"), "only the untouched buffer's record: {trace}");
|
||||
assert!(trace.contains("lead=0.0ms") || trace.contains("parses{index=1"), "{trace}");
|
||||
let edits = edit.changes.as_ref().expect("changes").values().flatten().count();
|
||||
assert_eq!(edits, 2, "the declaration and its one use, both in the buffer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prepare_offers_the_identifier_and_its_placeholder() {
|
||||
let tree = Tree::new("prepare");
|
||||
@@ -1030,4 +1182,106 @@ mod tests {
|
||||
"and it is the engine's sentence, not the census's: {warning}"
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// The engine-owned preflight (take 5 review §3 item 6, TODO §61.1)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// A cursor on nothing used to select every in-scope file, parse all of
|
||||
/// them and index them before the engine's 0.1 ms refusal. The preflight
|
||||
/// is only worth having if that is now literally no parses at all — not
|
||||
/// fewer, none — so the gate is asserted, not measured.
|
||||
#[test]
|
||||
fn a_rename_on_a_cursor_with_no_symbol_parses_nothing() {
|
||||
let tree = Tree::new("nosymbolparses");
|
||||
let (ws, uri) = opened(&tree);
|
||||
let at_comment = TOP.len() as u32 - 1; // the newline after `endmodule`
|
||||
|
||||
let before = vlog_parser::stats::parses();
|
||||
let mut trace = None;
|
||||
let refusal =
|
||||
rename_traced(&ws, &uri, at_comment, "probe", &mut trace).expect_err("no symbol there");
|
||||
let parses = vlog_parser::stats::parses() - before;
|
||||
|
||||
assert_eq!(parses, 0, "the refusal parsed {parses} whole files");
|
||||
assert_eq!(refusal, "there is no symbol to rename at this position.");
|
||||
|
||||
// And the `--verbose` channel says so in its own fields, so the phase
|
||||
// that measures this row reads the parse count instead of trusting it.
|
||||
let trace = trace.expect("a refusal traces too");
|
||||
assert!(trace.contains("selected=0"), "{trace}");
|
||||
assert!(trace.contains("parses=0"), "{trace}");
|
||||
assert!(trace.contains("preflight=true"), "{trace}");
|
||||
}
|
||||
|
||||
/// …and it is the same sentence the whole workspace produced, taken from
|
||||
/// the engine over every in-scope file rather than from this module.
|
||||
#[test]
|
||||
fn the_preflights_refusal_is_the_whole_workspaces_refusal() {
|
||||
let tree = Tree::new("preflightparity");
|
||||
let (ws, uri) = opened(&tree);
|
||||
let path = tree.path.join("top.sv");
|
||||
for (case, offset) in [
|
||||
("past the last item", TOP.len() as u32 - 1),
|
||||
("on the `module` keyword", at(TOP, "module")),
|
||||
("on a literal", at(TOP, "1'b0")),
|
||||
] {
|
||||
let fast = rename(&ws, &uri, offset, "probe").expect_err(case);
|
||||
let slow = vlog_refactor::rename(&ws.sources(), &path, offset, "probe")
|
||||
.expect_err("the whole workspace refuses too");
|
||||
assert_eq!(fast, slow, "{case}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Precedence, in the two places the preflight could have disturbed it: an
|
||||
/// unusable buffer is refused by this module before the engine is asked
|
||||
/// anything, and an invalid new name outranks whatever the cursor is on.
|
||||
#[test]
|
||||
fn the_preflight_does_not_disturb_the_refusal_order() {
|
||||
let tree = Tree::new("preflightorder");
|
||||
let (ws, uri) = opened(&tree);
|
||||
|
||||
let untitled = Uri::from_str("untitled:Untitled-1").expect("uri");
|
||||
let mut with_untitled = Workspace::default();
|
||||
with_untitled.set_document(untitled.clone(), TOP.to_string());
|
||||
assert_eq!(
|
||||
rename(&with_untitled, &untitled, at(TOP, "u_sub"), "probe").expect_err("unsaved"),
|
||||
UNSAVED,
|
||||
"an untitled buffer is refused before the engine sees the cursor"
|
||||
);
|
||||
|
||||
// A cursor on nothing *and* a keyword for a new name: the name's
|
||||
// sentence, which is the one `renaming` reaches first.
|
||||
let refusal = rename(&ws, &uri, TOP.len() as u32 - 1, "module").expect_err("a keyword");
|
||||
assert_eq!(refusal, "`module` is a Verilog keyword.");
|
||||
}
|
||||
|
||||
/// The one buffer the preflight must never judge: on the large-file fast
|
||||
/// path every field but the text is the analysis of the *empty* file, so a
|
||||
/// preflight over it would refuse every cursor as symbolless. The
|
||||
/// large-buffer gate refuses the whole request first, and this pins that
|
||||
/// it still does.
|
||||
#[test]
|
||||
fn a_large_buffer_is_refused_before_the_preflight_could_see_it() {
|
||||
let tree = Tree::new("preflightlarge");
|
||||
tree.write("sub.sv", SUB);
|
||||
let top = tree.write("top.sv", TOP);
|
||||
let mut ws = Workspace::default();
|
||||
ws.set_client_settings(crate::settings::ClientSettings {
|
||||
index_scope: crate::settings::IndexScope::Workspace,
|
||||
large_file_threshold: 1,
|
||||
..Default::default()
|
||||
});
|
||||
ws.open_whole_workspace(vec![tree.path.clone()]);
|
||||
let uri = path_to_uri(&top).expect("uri");
|
||||
ws.set_document(uri.clone(), TOP.to_string());
|
||||
|
||||
let doc = ws.document(&uri).expect("open");
|
||||
assert!(doc.large, "premise: the buffer took the fast path");
|
||||
assert!(
|
||||
vlog_refactor::rename_preflight(&doc.semantics, at(TOP, "u_sub"), "probe").is_err(),
|
||||
"premise: the empty analysis would refuse a real cursor, which is why \
|
||||
`server/large_file.rs` must answer this method before we are reached"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -167,6 +167,46 @@ pub struct ScanTrace {
|
||||
/// 2026-09-08 that happens at the step that indexes each one, and is
|
||||
/// `read_ms` below (`docs/features/perf5-p4/README.md` §P4b3).
|
||||
pub discovery_ms: f64,
|
||||
|
||||
// -- discovery, split (TODO §61.3) ----------------------------------
|
||||
//
|
||||
// Five disjoint parts of `discovery_ms` and one counter. They are a split
|
||||
// *of* that stage, not stages beside it, so nothing that adds the scan up
|
||||
// may add these as well
|
||||
// (`docs/features/perf5r-first-answer/README.md`).
|
||||
/// Reading each walk root's `lucisv.toml` for its `exclude` patterns —
|
||||
/// `Discovery::for_dir`, cached per instance, so a second root under the
|
||||
/// same config costs a map lookup.
|
||||
pub config_ms: f64,
|
||||
/// The directory walks themselves: `read_dir`, `.gitignore` parsing, the
|
||||
/// cycle guard, and the one `metadata` per entry the walk has always made.
|
||||
pub walk_ms: f64,
|
||||
/// How many roots were walked — one per scope directory, so a folder scope
|
||||
/// over three open buffers' folders is three.
|
||||
pub walk_dirs: usize,
|
||||
/// Reading a filelist, when rung 1 is the one in force.
|
||||
pub filelist_ms: f64,
|
||||
/// Sorting the walk's output into path order and dropping the paths two
|
||||
/// overlapping walks both found.
|
||||
pub sort_ms: f64,
|
||||
/// Applying `lucisv.index.maxFileSize` to every walked file.
|
||||
pub cap_ms: f64,
|
||||
/// `metadata` calls the cap made *itself* — the ones the walk's hand-off
|
||||
/// did not already answer. Zero for a walked scope since 2026-09-08;
|
||||
/// a filelist's entries are not walked and still cost one each.
|
||||
pub stats: usize,
|
||||
/// Taking every open buffer's text and its finished analysis, and letting
|
||||
/// it override the disk copy of its own path.
|
||||
pub buffers_ms: f64,
|
||||
/// Directories the remaining walk met under a spelling the root walk
|
||||
/// would have preferred — a directory alias outside the open folder's own
|
||||
/// chain ([`crate::state::Scan::wants_rescan`]). 0 in every ordinary
|
||||
/// session; 1 says this scan's paths are the head's spelling.
|
||||
pub conflict: usize,
|
||||
/// Whole rescans this scan asked for on its way out. One per `conflict`,
|
||||
/// and nothing else sets it.
|
||||
pub rescan_requested: usize,
|
||||
|
||||
/// Sorting into index order and putting the user's own neighbourhood at
|
||||
/// the front ([`crate::scan_order`]).
|
||||
pub order_ms: f64,
|
||||
@@ -365,7 +405,8 @@ impl ScanTrace {
|
||||
pub fn stage_line(&self) -> String {
|
||||
let c = &self.cache;
|
||||
format!(
|
||||
"scan {} stages ({}, {} files): discovery={:.2} order={:.2} cache_open={:.2} \
|
||||
"scan {} stages ({}, {} files): discovery={:.2} config={:.2} walk={:.2} \
|
||||
filelist={:.2} sort={:.2} cap={:.2} buffers={:.2} order={:.2} cache_open={:.2} \
|
||||
read={:.2} lookup={:.2} decode={:.2} parse={:.2} encode={:.2} store_write={:.2} \
|
||||
publish_absorb={:.2} publish_candidates={:.2} publish_includes={:.2} \
|
||||
publish_overlay={:.2} gone={:.2} absorb={:.2} compact={:.2} candidates={:.2} \
|
||||
@@ -374,6 +415,12 @@ impl ScanTrace {
|
||||
self.kind,
|
||||
self.read,
|
||||
self.discovery_ms,
|
||||
self.config_ms,
|
||||
self.walk_ms,
|
||||
self.filelist_ms,
|
||||
self.sort_ms,
|
||||
self.cap_ms,
|
||||
self.buffers_ms,
|
||||
self.order_ms,
|
||||
self.cache_open_ms,
|
||||
self.read_ms,
|
||||
@@ -402,13 +449,17 @@ impl ScanTrace {
|
||||
pub fn count_line(&self) -> String {
|
||||
let c = &self.cache;
|
||||
format!(
|
||||
"scan {} counts ({}): read={} read_kib={} skipped={} hits={} misses={} buffers={} \
|
||||
"scan {} counts ({}): read={} read_kib={} walk_dirs={} stats={} skipped={} \
|
||||
hits={} misses={} buffers={} \
|
||||
records={} repeats={} decoded_kib={} written_kib={} opens={} compactions={} \
|
||||
publishes={} published={} first_publish={:.2} overlays={}",
|
||||
publishes={} published={} first_publish={:.2} overlays={} \
|
||||
conflict={} rescan_requested={}",
|
||||
self.number,
|
||||
self.kind,
|
||||
self.read,
|
||||
kib(self.read_bytes),
|
||||
self.walk_dirs,
|
||||
self.stats,
|
||||
self.skipped,
|
||||
c.hits,
|
||||
c.misses,
|
||||
@@ -423,6 +474,8 @@ impl ScanTrace {
|
||||
self.published,
|
||||
self.first_publish_ms,
|
||||
self.overlays,
|
||||
self.conflict,
|
||||
self.rescan_requested,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ pub(super) fn cancelled_in(batch: &[Message]) -> HashSet<RequestId> {
|
||||
/// The request id a `$/cancelRequest` names, or `None` for any other message.
|
||||
/// Both id forms the protocol allows are read; a cancel whose params do not
|
||||
/// parse is dropped, because there is no id to act on.
|
||||
fn cancelled_id(message: &Message) -> Option<RequestId> {
|
||||
pub(super) fn cancelled_id(message: &Message) -> Option<RequestId> {
|
||||
let Message::Notification(notification) = message else { return None };
|
||||
if notification.method != Cancel::METHOD {
|
||||
return None;
|
||||
|
||||
@@ -53,7 +53,7 @@ impl Server {
|
||||
let buffers = self.dirty.len();
|
||||
for (uri, text) in std::mem::take(&mut self.dirty) {
|
||||
self.set_document(uri.clone(), text);
|
||||
self.publish(&uri);
|
||||
crate::lint_trace::rebuild(crate::lint_trace::Rebuild::Publish, || self.publish(&uri));
|
||||
}
|
||||
self.timed(started, |took| {
|
||||
format!("flush of {buffers} dirty buffer{} took {took}", plural(buffers))
|
||||
|
||||
@@ -45,10 +45,29 @@ use super::client::ms;
|
||||
use super::Server;
|
||||
use crate::{
|
||||
code_action, completion, design_hierarchy, extract, file_ops, folding, format, hierarchy,
|
||||
hover, imports, includes, inlay, inline, inline_module, lens, linked, lint, nav, pairs, ports,
|
||||
rename, selection, signature, symbols, tokens, type_def, type_hierarchy,
|
||||
hover, imports, includes, inlay, inline, inline_module, lens, linked, lint, lint_trace, nav,
|
||||
pairs, ports, rename, selection, signature, symbols, tokens, type_def, type_hierarchy,
|
||||
};
|
||||
|
||||
/// The requests whose empty answer may mean "this scan has not reached the
|
||||
/// file yet" rather than "there is nowhere to go".
|
||||
///
|
||||
/// All three answer with a **list of places** and with an empty list when they
|
||||
/// find none, so `[]` is exactly the shape that carries no information. Every
|
||||
/// other request is left alone: a hover's `null`, a completion's empty list and
|
||||
/// a code-action menu with no offers all mean what they say whatever the scan
|
||||
/// has reached, and deferring one would be withholding an answer rather than
|
||||
/// waiting for a better one. `textDocument/implementation` would belong here;
|
||||
/// this server does not answer it, so it is not written down as if it did.
|
||||
const NAVIGATION: [&str; 3] =
|
||||
[GotoDefinition::METHOD, GotoTypeDefinition::METHOD, References::METHOD];
|
||||
|
||||
/// Whether a response says **nowhere**: an answer, not a failure, and an empty
|
||||
/// list of places. See [`NAVIGATION`].
|
||||
pub(super) fn names_nowhere(response: &Response) -> bool {
|
||||
matches!(&response.response_result, Ok(Value::Array(found)) if found.is_empty())
|
||||
}
|
||||
|
||||
impl Server {
|
||||
/// Answer one request, timing it when `--verbose` asked.
|
||||
///
|
||||
@@ -61,18 +80,92 @@ impl Server {
|
||||
pub(super) fn request(&mut self, request: Request) -> Response {
|
||||
let Some(started) = self.timer() else { return self.answer_request(request) };
|
||||
let method = request.method.clone();
|
||||
// One trace per request, armed here so the flush this request triggers
|
||||
// is inside it: the diagnostics pass that publishes during the flush is
|
||||
// the *other* consumer of a lint result, and the two are only readable
|
||||
// against each other when one line carries both (review round §R1b).
|
||||
lint_trace::arm();
|
||||
let response = self.answer_request(request);
|
||||
self.timing(format!("{method} answered in {}", ms(started)));
|
||||
// Silent for every request that never linted anything, which is all of
|
||||
// them but the code actions and the flushes that publish diagnostics.
|
||||
if let Some(trace) = lint_trace::disarm().filter(|trace| !trace.is_empty()) {
|
||||
self.timing(format!(
|
||||
"codeaction method={method} total={} {}",
|
||||
ms(started),
|
||||
trace.line()
|
||||
));
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
/// A copy of `request` to ask again at the scan's next publish, when an
|
||||
/// empty answer to it right now would mean "not scanned yet" rather than
|
||||
/// "nowhere".
|
||||
///
|
||||
/// **The lead's ruling from §61.3, as a rule in the drain.** A held
|
||||
/// startup request is answered the moment the user's own folder is
|
||||
/// published, and a definition whose target lives in another folder was
|
||||
/// answered `[]` there — coherent, and wrong by the time the scan ended.
|
||||
/// Rather than teach the drain to work out whether the published prefix
|
||||
/// resolves *this* request's target, the answer is computed through the
|
||||
/// ordinary handler and, when it names nowhere and the index is still
|
||||
/// growing, put back ([`Server::deferred`]).
|
||||
///
|
||||
/// **Only while a scan is running**, so a settled server answers empty
|
||||
/// exactly as it always did — including the last try, after the scan ends.
|
||||
/// **Only the three navigation methods that answer with a list of places**
|
||||
/// ([`NAVIGATION`]): a hover, a completion, a code action or a rename is
|
||||
/// unaffected, and so is every request whose empty answer means something
|
||||
/// else. `textDocument/implementation` is not on the list because this
|
||||
/// server does not answer it.
|
||||
pub(super) fn ask_again_if_empty(&self, request: &Request) -> Option<Request> {
|
||||
if !self.scanning || !NAVIGATION.contains(&request.method.as_str()) {
|
||||
return None;
|
||||
}
|
||||
Some(Request::new(request.id.clone(), request.method.clone(), request.params.clone()))
|
||||
}
|
||||
|
||||
/// `--verbose`: that a navigation answer was set aside for the next
|
||||
/// publish rather than sent, and how many are waiting with it.
|
||||
pub(super) fn say_deferred(&self, request: &Request) {
|
||||
if !self.verbose {
|
||||
return;
|
||||
}
|
||||
self.timing(format!(
|
||||
"{} DEFERRED to the next publish (empty mid-scan, already deferred={})",
|
||||
request.method,
|
||||
self.deferred.len()
|
||||
));
|
||||
}
|
||||
|
||||
/// [`Server::flush_dirty`], with the dirty-buffer stage measured apart
|
||||
/// from the handler that follows it.
|
||||
///
|
||||
/// The review's item 4: *if the dirty-buffer stage dominates the 136 ms, a
|
||||
/// lint cache alone cannot fix it*. The flush rebuilds each dirty
|
||||
/// `Document` (parse and analysis, counted as whole-file parses) and then
|
||||
/// publishes its diagnostics, which lints; the handler lints again. One
|
||||
/// line carrying both is what makes the two comparable.
|
||||
fn flush_dirty_traced(&mut self) {
|
||||
if !lint_trace::armed() {
|
||||
return self.flush_dirty();
|
||||
}
|
||||
let buffers = self.dirty.len();
|
||||
let before = vlog_parser::stats::parses();
|
||||
let started = std::time::Instant::now();
|
||||
self.flush_dirty();
|
||||
let parses = vlog_parser::stats::parses().saturating_sub(before);
|
||||
lint_trace::close_flush(started.elapsed(), buffers, parses);
|
||||
}
|
||||
|
||||
fn answer_request(&mut self, request: Request) -> Response {
|
||||
// A request answers from a buffer's analysis, so any change the client
|
||||
// has already sent is in effect before it is answered — the order
|
||||
// contract the loop has always promised. Here is also where a typing
|
||||
// burst is coalesced: the changes before this request all become one
|
||||
// `set_document` in `flush_dirty`.
|
||||
self.flush_dirty();
|
||||
self.flush_dirty_traced();
|
||||
let id = request.id.clone();
|
||||
let method = request.method.clone();
|
||||
// The large-file fast path answers first, and for most methods it
|
||||
@@ -262,9 +355,9 @@ impl Server {
|
||||
if code_action::wants_fixes(only.as_deref()) {
|
||||
// A code-action request carries no `tabSize`, so the width a
|
||||
// `no-tabs` fix writes comes from the buffer's own `lucisv.toml`
|
||||
// or from the built-in default.
|
||||
let tab_width =
|
||||
format::indent_width(doc.path.as_deref(), self.workspace.client_settings());
|
||||
// or from the built-in default — read by the run itself, off
|
||||
// the `FileConfig` it discovers anyway, so this path no longer
|
||||
// walks for a config file twice (review round §R1a).
|
||||
let run = lint::LintRun::for_document(&self.workspace, doc);
|
||||
actions.extend(code_action::code_actions(
|
||||
&run,
|
||||
@@ -272,7 +365,6 @@ impl Server {
|
||||
doc,
|
||||
p.range,
|
||||
only.as_deref(),
|
||||
tab_width,
|
||||
));
|
||||
}
|
||||
// The port refactorings answer for the cursor, not for a range:
|
||||
|
||||
@@ -221,9 +221,29 @@ impl Server {
|
||||
self.scanning = false;
|
||||
// A neighbourhood can only be owed by a scan, and there is none now.
|
||||
self.head_owed = false;
|
||||
self.answer_what_was_deferred();
|
||||
warnings
|
||||
}
|
||||
|
||||
/// Answer whatever the empty-answer rule set aside, now that the index has
|
||||
/// stopped growing.
|
||||
///
|
||||
/// **The other half of that rule, and the reason it can never strand a
|
||||
/// request.** A navigation answer was deferred because `[]` might have
|
||||
/// meant "not scanned yet"; here it cannot mean that any more, so an empty
|
||||
/// answer is the honest one and goes out. The scan is over, so
|
||||
/// [`Server::ask_again_if_empty`] defers nothing this time round — and a
|
||||
/// request the order contract still holds, one behind something already
|
||||
/// `held`, is put back by `process_batch`'s own rule exactly as any other
|
||||
/// message would be.
|
||||
pub(super) fn answer_what_was_deferred(&mut self) {
|
||||
let deferred = std::mem::take(&mut self.deferred);
|
||||
if deferred.is_empty() || self.stopped {
|
||||
return;
|
||||
}
|
||||
self.stopped = !matches!(self.process_batch(deferred), Ok(false));
|
||||
}
|
||||
|
||||
/// One whole scan: the bar up, every file indexed with the client's
|
||||
/// messages answered between two of them, the bar down.
|
||||
///
|
||||
@@ -241,24 +261,54 @@ impl Server {
|
||||
let verbose = started.is_some();
|
||||
let bar = self.begin_indexing();
|
||||
let mut scan = self.watching(bar.as_ref(), |ws, watch| ws.begin_scan(watch, verbose));
|
||||
let interleave = scan.total() > INTERLEAVE_ABOVE;
|
||||
// A scan that has walked the user's own folders and owes itself the
|
||||
// rest of the workspace **always** interleaves, whatever its work list
|
||||
// says today: the whole point of leading with that neighbourhood is
|
||||
// that the request waiting for it is answered the moment it is in
|
||||
// (`docs/features/perf5r-first-answer/README.md`).
|
||||
let interleave = scan.total() > INTERLEAVE_ABOVE || scan.discovery_pending();
|
||||
let total = scan.total();
|
||||
if started.is_some() {
|
||||
// Whether it interleaves is said here because it is decided here,
|
||||
// and because it is the answer to "why did my hover wait?" — a
|
||||
// scan that does not interleave answers nothing until it is done.
|
||||
let interleaving = if interleave { ", interleaved" } else { "" };
|
||||
self.timing(format!("scan started: {total} file{}{interleaving}", plural(total)));
|
||||
let staged = if scan.discovery_pending() { " (the folder first)" } else { "" };
|
||||
self.timing(format!(
|
||||
"scan started: {total} file{}{staged}{interleaving}",
|
||||
plural(total)
|
||||
));
|
||||
}
|
||||
while self.watching(bar.as_ref(), |workspace, watch| workspace.scan_step(&mut scan, watch))
|
||||
{
|
||||
loop {
|
||||
// **No bar while the denominator can still grow.** The work list
|
||||
// is the neighbourhood so far, and a percentage against it would
|
||||
// fall to a twentieth of itself the moment the rest of the
|
||||
// workspace lands. The per-file log still runs — it names files,
|
||||
// not fractions — and the first percentage the client sees is the
|
||||
// first measured one (`docs/features/indexing-ux/README.md`).
|
||||
let showing = if scan.discovery_pending() { None } else { bar.as_ref() };
|
||||
let stepped =
|
||||
self.watching(showing, |workspace, watch| workspace.scan_step(&mut scan, watch));
|
||||
if !stepped {
|
||||
break;
|
||||
}
|
||||
if interleave && self.answer_what_is_waiting(&mut scan) {
|
||||
// Nothing after this may speak to a client that has gone, the
|
||||
// timing line included.
|
||||
return Vec::new();
|
||||
}
|
||||
}
|
||||
let total = scan.total();
|
||||
let (skipped, cached) = (scan.skipped(), scan.cached());
|
||||
// A split discovery whose two halves reached one directory by two
|
||||
// spellings: nothing was indexed twice, and every answer this scan
|
||||
// gives is the right one, but the paths are the head's and a plain
|
||||
// walk of the same tree spells them the other way
|
||||
// ([`Scan::wants_rescan`]). One ordinary rescan *is* that plain walk,
|
||||
// so it converges them — asked for with the same flag a save or a
|
||||
// settings change sets, and therefore run when this scan ends, with
|
||||
// every request held for the whole of it.
|
||||
self.rescan_wanted |= scan.wants_rescan();
|
||||
let warnings = self.workspace.finish_scan(scan);
|
||||
self.end_indexing(bar, skipped, cached);
|
||||
self.timed(started, |took| {
|
||||
@@ -313,13 +363,22 @@ impl Server {
|
||||
/// **This is the round's whole point, and its whole cost.** Polling costs
|
||||
/// one `try_recv` per file and finds nothing in a scan nobody is waiting
|
||||
/// on, so a quiet scan pays nothing at all; a scan somebody *is* waiting
|
||||
/// on pays one merge per burst to make the records it has taken since the
|
||||
/// last one answerable ([`Workspace::publish_scan`]). The messages then go
|
||||
/// on pays a merge to make the records it has taken since the last one
|
||||
/// answerable ([`Workspace::publish_scan`]). The messages then go
|
||||
/// through the same `process_batch` the loop uses, so a `didChange` queued
|
||||
/// ahead of a hover is applied before that hover is answered and a cancel
|
||||
/// beside its request still answers it `RequestCancelled` — the order
|
||||
/// contract is the loop's, unchanged, because it is the loop's code.
|
||||
///
|
||||
/// **A merge per burst was the cost; a merge per 512 files is what it is
|
||||
/// now.** [`Scan::publish_is_due`] is the cadence, and the one drain
|
||||
/// exempt from it is the one with something *waiting* — the startup's held
|
||||
/// requests, drained the moment the neighbourhood is in, which is the
|
||||
/// session's first useful answer and must not be a file later than it was
|
||||
/// (`docs/features/perf5r-first-answer/README.md`). Everything else reads
|
||||
/// a coherent prefix that is at most a cadence older, which is the trade
|
||||
/// `docs/features/perf5r-publication/README.md` measures.
|
||||
///
|
||||
/// An error here is a client that has gone: there is nobody to report it
|
||||
/// to and no reason to go on scanning, so it stops the scan the same way a
|
||||
/// `shutdown` does.
|
||||
@@ -329,9 +388,24 @@ impl Server {
|
||||
// would be `[]` (`docs/features/perf5-p4/README.md` §P4b3).
|
||||
self.head_owed = !scan.neighbourhood_indexed();
|
||||
let mut batch = self.waiting_for_this_scan();
|
||||
let owed = !batch.is_empty();
|
||||
let mut arrived = Vec::new();
|
||||
while let Ok(message) = self.queue.try_recv() {
|
||||
batch.push(message);
|
||||
arrived.push(message);
|
||||
}
|
||||
// A quiet scan pays nothing at all, and that is a promise: the cadence
|
||||
// is asked only when there is something for a publish to be *for*.
|
||||
if !owed && arrived.is_empty() && self.deferred.is_empty() {
|
||||
return false;
|
||||
}
|
||||
if owed || scan.publish_is_due() {
|
||||
self.workspace.publish_scan(scan);
|
||||
// A navigation answer this scan could not give yet is asked again
|
||||
// off the prefix that has just grown — behind whatever was already
|
||||
// waiting, ahead of everything newer ([`Server::deferred`]).
|
||||
batch.append(&mut self.deferred);
|
||||
}
|
||||
batch.append(&mut arrived);
|
||||
if batch.is_empty() {
|
||||
return false;
|
||||
}
|
||||
@@ -343,14 +417,13 @@ impl Server {
|
||||
// recomputed below once the new head segment is known.
|
||||
let opened = !opened_in(&batch).is_empty();
|
||||
self.head_owed |= opened;
|
||||
self.workspace.publish_scan(scan);
|
||||
self.stopped = !matches!(self.process_batch(batch), Ok(false));
|
||||
// The files the user has just opened, and the folders around them, are
|
||||
// what they are looking at, so they are indexed next rather than when
|
||||
// the alphabet reaches them — the open-first rule, for buffers opened
|
||||
// after the work list was taken.
|
||||
if opened {
|
||||
self.workspace.open_next(scan);
|
||||
self.watching(None, |workspace, watch| workspace.open_next(scan, watch));
|
||||
self.head_owed = !scan.neighbourhood_indexed();
|
||||
}
|
||||
self.stopped
|
||||
|
||||
@@ -46,7 +46,8 @@ use lsp_types::{SemanticToken, Uri};
|
||||
|
||||
use crate::state::Workspace;
|
||||
|
||||
use batch::{burst, cancelled_in, cancelled_response};
|
||||
use batch::{burst, cancelled_id, cancelled_in, cancelled_response};
|
||||
use dispatch::names_nowhere;
|
||||
|
||||
mod batch;
|
||||
mod client;
|
||||
@@ -227,6 +228,23 @@ pub struct Server {
|
||||
/// [`Server::must_wait`] — this is the order contract, not a queue of its
|
||||
/// own.
|
||||
held: Vec<Message>,
|
||||
/// Navigation requests a scan answered **empty** while it was still
|
||||
/// growing the index, to be asked again at its next publish.
|
||||
///
|
||||
/// **Not a second `held`, and deliberately not part of
|
||||
/// [`Server::must_wait`].** A held request is one the order contract says
|
||||
/// nothing newer may overtake; this is one whose answer was computed,
|
||||
/// found to name nowhere, and set aside because the reason it named
|
||||
/// nowhere may be that the file it wants has not been scanned yet
|
||||
/// (`docs/features/perf5r-publication/README.md`). Nothing else is owed
|
||||
/// anything by it — a hover, a completion or a code action behind one is
|
||||
/// answered exactly as before — and it is asked again at most once per
|
||||
/// publish, so the re-computation is bounded by the cadence and not by the
|
||||
/// scan's file count. A scan ending runs whatever is left through the
|
||||
/// dispatch one last time, with itself already over — so nothing is
|
||||
/// deferred that time round and an empty answer, which is now the honest
|
||||
/// one, goes out ([`Server::answer_what_was_deferred`]).
|
||||
deferred: Vec<Message>,
|
||||
/// `--verbose`: whether every operation says how long it took, in the
|
||||
/// client's log channel. Off is the shipped state and the whole of what it
|
||||
/// costs is the branch that reads this field — see
|
||||
@@ -393,7 +411,20 @@ impl Server {
|
||||
let response = if cancelled.remove(&request.id) {
|
||||
cancelled_response(request.id)
|
||||
} else {
|
||||
self.request(request)
|
||||
// A navigation request whose answer would be `[]` only
|
||||
// because the scan has not reached its target yet is
|
||||
// asked again at the next publish rather than answered
|
||||
// with nowhere ([`Server::deferred`]).
|
||||
let again = self.ask_again_if_empty(&request);
|
||||
let response = self.request(request);
|
||||
match again.filter(|_| names_nowhere(&response)) {
|
||||
Some(request) => {
|
||||
self.say_deferred(&request);
|
||||
self.deferred.push(Message::Request(request));
|
||||
continue;
|
||||
}
|
||||
None => response,
|
||||
}
|
||||
};
|
||||
self.connection.sender.send(Message::Response(response))?;
|
||||
}
|
||||
@@ -402,7 +433,14 @@ impl Server {
|
||||
// already been done above. Kept only so that a request behind
|
||||
// one that has to wait takes its cancel with it.
|
||||
Message::Notification(notification) if notification.method == Cancel::METHOD => {
|
||||
consumed_cancels.push(Message::Notification(notification));
|
||||
let cancel = Message::Notification(notification);
|
||||
// A request the empty-answer rule set aside is not in this
|
||||
// burst, so `cancelled_in` cannot see it — but it is still
|
||||
// a request the client is waiting on, and a cancel for it
|
||||
// is honoured where it lands: answered `RequestCancelled`
|
||||
// now, and never asked again (QA, perf5r-publication).
|
||||
self.cancel_deferred(&cancel)?;
|
||||
consumed_cancels.push(cancel);
|
||||
}
|
||||
Message::Notification(notification) => self.notification(notification),
|
||||
Message::Response(response) => self.response(response),
|
||||
@@ -411,6 +449,22 @@ impl Server {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
/// Honour a `$/cancelRequest` naming a request in [`Server::deferred`]:
|
||||
/// take it out and answer it cancelled. A cancel naming anything else is
|
||||
/// left to the batch's own rule.
|
||||
fn cancel_deferred(&mut self, cancel: &Message) -> Result<(), Box<dyn Error + Sync + Send>> {
|
||||
let Some(id) = cancelled_id(cancel) else { return Ok(()) };
|
||||
let found = self
|
||||
.deferred
|
||||
.iter()
|
||||
.position(|message| matches!(message, Message::Request(request) if request.id == id));
|
||||
if let Some(at) = found {
|
||||
self.deferred.remove(at);
|
||||
self.connection.sender.send(Message::Response(cancelled_response(id)))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Whether a request reaching the dispatch right now must wait instead of
|
||||
/// being answered.
|
||||
///
|
||||
|
||||
@@ -45,6 +45,26 @@ use crate::state::Workspace;
|
||||
/// nothing does not leave a workspace unindexed.
|
||||
pub(super) const CONFIGURATION_WAIT: Duration = Duration::from_secs(2);
|
||||
|
||||
/// How long a startup waits, *after* the settings answer, for the editor to
|
||||
/// say which file it has open.
|
||||
///
|
||||
/// **Only when that name changes what the scan does.** A workspace-scoped scan
|
||||
/// with a buffer open walks that buffer's folder first, indexes it, and
|
||||
/// answers the request waiting for it in ~115 ms; without the name it walks
|
||||
/// all 3 976 files first and answers in ~290
|
||||
/// (`docs/features/perf5r-first-answer/README.md`). The two messages are
|
||||
/// written by the client at the same moment — the settings answer by whatever
|
||||
/// handles server-initiated requests, the `didOpen` by the editor — so which
|
||||
/// arrives first is a coin toss, and losing it costs 175 ms of the thing this
|
||||
/// round is about. This is that coin toss removed.
|
||||
///
|
||||
/// It is spent **only** by a session that is going to walk a whole workspace
|
||||
/// and has no buffer at all yet: a folder-scoped session has nothing to lead
|
||||
/// with, and a session whose buffer is already in hand stops waiting the
|
||||
/// moment it applies one. So the session that pays the full bound is the one
|
||||
/// with an empty editor, where nothing is waiting on the scan.
|
||||
pub(super) const OPENING_FILE_WAIT: Duration = Duration::from_millis(25);
|
||||
|
||||
/// Everything a session starts with that is not the connection or the roots.
|
||||
///
|
||||
/// One struct rather than six more parameters: `started` is the seam every
|
||||
@@ -147,6 +167,7 @@ impl Server {
|
||||
answering_a_rescan: false,
|
||||
stopped: false,
|
||||
held: Vec::new(),
|
||||
deferred: Vec::new(),
|
||||
verbose,
|
||||
born: Instant::now(),
|
||||
}
|
||||
@@ -233,10 +254,45 @@ impl Server {
|
||||
self.staging = true;
|
||||
self.request_configuration();
|
||||
self.await_configuration(wait);
|
||||
// Inside the staging window, because it is the same window: every
|
||||
// request is still held, and the scan has still not begun.
|
||||
if !wait.is_zero() && !self.stopped {
|
||||
self.await_opening_file(OPENING_FILE_WAIT);
|
||||
}
|
||||
self.staging = false;
|
||||
self.rescan_wanted = false;
|
||||
}
|
||||
|
||||
/// Wait a bounded moment for the editor's first `didOpen`, when knowing
|
||||
/// which folder the user is in is what decides the shape of the scan
|
||||
/// about to run ([`OPENING_FILE_WAIT`]).
|
||||
///
|
||||
/// Silent for every session that would not spend the knowledge: only a
|
||||
/// workspace-scoped scan leads with a folder, and only one with nothing
|
||||
/// open has a folder still to learn. The loop stops on the first buffer
|
||||
/// rather than draining the bound, so the ordinary session pays what the
|
||||
/// message took to arrive and nothing more.
|
||||
///
|
||||
/// **Not a scope decision.** Which files the scan indexes is settled by
|
||||
/// the settings that have just landed; this decides only which of them it
|
||||
/// indexes *first*, which `vlog_semantic::IndexBuilder` cannot see
|
||||
/// (`crate::scan_order`).
|
||||
fn await_opening_file(&mut self, wait: Duration) {
|
||||
if !self.workspace.leads_with_a_folder() {
|
||||
return;
|
||||
}
|
||||
let asked = Instant::now();
|
||||
while self.workspace.open_uris().is_empty() {
|
||||
let Some(left) = wait.checked_sub(asked.elapsed()) else { return };
|
||||
let Ok(message) = self.queue.recv_timeout(left) else { return };
|
||||
let batch = burst(&self.queue, message);
|
||||
self.stopped = !matches!(self.process_batch(batch), Ok(false));
|
||||
if self.stopped {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Read the client's messages until it answers the settings pull, the
|
||||
/// bound runs out, or it goes away.
|
||||
///
|
||||
|
||||
@@ -386,3 +386,35 @@ fn a_cancel_naming_a_server_initiated_id_does_not_touch_response_routing() {
|
||||
// cancel did not intercept it.
|
||||
session.answer(server_id, Value::Null);
|
||||
}
|
||||
|
||||
/// A request the empty-answer rule set aside (`Server::deferred`,
|
||||
/// perf5r-publication) is not in any burst, so the burst's own cancel rule
|
||||
/// cannot see it. A cancel for it must still be honoured where it lands:
|
||||
/// answered `RequestCancelled` at once, taken out of the deferred set, and
|
||||
/// never asked again when the scan ends. Found by QA on §61.4; the request is
|
||||
/// planted directly because a real deferral lives only inside a running scan.
|
||||
#[test]
|
||||
fn a_cancel_for_a_deferred_request_answers_it_cancelled_and_forgets_it() {
|
||||
let (_tree, mut session, uri) = cancelling_session("cancel-deferred", ONE_MODULE);
|
||||
let parked = Request::new(
|
||||
RequestId::from(41),
|
||||
GotoDefinition::METHOD.to_string(),
|
||||
serde_json::json!({
|
||||
"textDocument": { "uri": uri },
|
||||
"position": { "line": 0, "character": 7 }
|
||||
}),
|
||||
);
|
||||
session.server.deferred.push(Message::Request(parked));
|
||||
|
||||
session.server.process_batch(vec![cancel(serde_json::json!(41))]).expect("a burst");
|
||||
assert_eq!(outcomes(&session), vec![(RequestId::from(41), Some(CANCELLED))]);
|
||||
assert!(session.server.deferred.is_empty(), "the cancelled request is not asked again");
|
||||
|
||||
// And the scan's end finds nothing left to answer: exactly one response.
|
||||
session.server.answer_what_was_deferred();
|
||||
assert!(outcomes(&session).is_empty(), "a cancelled request is answered once");
|
||||
|
||||
// A cancel naming a request that is *not* deferred changes nothing.
|
||||
session.server.process_batch(vec![cancel(serde_json::json!(42))]).expect("a burst");
|
||||
assert!(outcomes(&session).is_empty());
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
//! One test per row of the lint snapshot's invalidation table.
|
||||
//!
|
||||
//! Take 5 **review** round §R1a
|
||||
//! (`docs/features/perf5r-lint-snapshot/README.md`). A `Document` keeps the
|
||||
//! findings of one `lint_with` pass so that the diagnostics publish and
|
||||
//! quick-fix discovery do not run the same 21 ms twice on one revision. What
|
||||
//! makes that legitimate is that **every input which can change the answer
|
||||
//! either builds a new `Document`, or is in the key, or clears the slot** —
|
||||
//! and the README's table has one row per input.
|
||||
//!
|
||||
//! This file walks that table through the real doors: a `didChange`, a
|
||||
//! `didChangeConfiguration`, a `lucisv.toml` rewritten on disk, a waiver file
|
||||
//! rewritten in place, a watched file in **another** buffer, a close and
|
||||
//! reopen, a UTF-16 range, a large buffer — and one attack, a fix offered for
|
||||
//! a span the buffer no longer has.
|
||||
//!
|
||||
//! Reuse is observed by pointer, not by a stopwatch: two passes that share a
|
||||
//! snapshot answer with the same `Arc`, and one that recomputed cannot. A
|
||||
//! timing assertion on a lint pass would be a flake; `Arc::ptr_eq` is not.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use vlog_linter::Violation;
|
||||
|
||||
use super::*;
|
||||
use crate::lint::{fixable, violations_in, LintRun};
|
||||
|
||||
/// A module with one tab in it: one `no-tabs` finding, carrying a Safe fix
|
||||
/// whose text is the indent width. Line 1 is the tab.
|
||||
const TABBED: &str = "module m;\n\twire a;\nendmodule\n";
|
||||
|
||||
/// A session over `tree` with `m.sv` open, its diagnostics already published.
|
||||
fn opened(tree: &Tree, text: &str) -> (Session, Uri) {
|
||||
let mut session = Session::wide(vec![tree.path.clone()], true);
|
||||
let uri = session.open(&tree.path.join("m.sv"), text);
|
||||
let _ = session.drain();
|
||||
(session, uri)
|
||||
}
|
||||
|
||||
/// The findings quick-fix discovery would offer for `uri` right now, taken
|
||||
/// through the same two calls the dispatcher makes.
|
||||
fn offered(session: &Session, uri: &Uri) -> Arc<[Violation]> {
|
||||
let doc = session.server.workspace.document(uri).expect("an open buffer");
|
||||
let run = LintRun::for_document(&session.server.workspace, doc);
|
||||
fixable(&run, doc)
|
||||
}
|
||||
|
||||
/// The rules that fired, by name, in the order they fired.
|
||||
fn rules(found: &[Violation]) -> Vec<&'static str> {
|
||||
found.iter().map(|violation| violation.rule).collect()
|
||||
}
|
||||
|
||||
/// The replacement text of the first fix, for the rows about fix bytes.
|
||||
fn fix_text(found: &[Violation]) -> String {
|
||||
let fix = found.first().and_then(|v| v.fix.as_ref()).expect("a fix");
|
||||
fix.edits.first().map(|(_, text)| text.clone()).expect("an edit")
|
||||
}
|
||||
|
||||
/// Push one `lucisv.lint.*` section and let the republish it triggers settle.
|
||||
fn push_lint_settings(session: &mut Session, lint: Value) {
|
||||
session.notify(
|
||||
DidChangeConfiguration::METHOD,
|
||||
serde_json::json!({ "settings": { "lucisv": { "lint": lint } } }),
|
||||
);
|
||||
let _ = session.drain();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// the headline: one pass, two consumers
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// The whole point of the round. A `didOpen` publishes diagnostics, which
|
||||
/// lints; the code action that follows reads **that** answer rather than
|
||||
/// running the rules again, and the two are the same object.
|
||||
#[test]
|
||||
fn the_diagnostics_publish_and_the_quick_fix_pass_share_one_lint() {
|
||||
let tree = Tree::new("lsshare");
|
||||
let (session, uri) = opened(&tree, TABBED);
|
||||
let doc = session.server.workspace.document(&uri).expect("open");
|
||||
assert!(
|
||||
!doc.lint.is_empty(),
|
||||
"the publish that answered the didOpen left its findings on the document"
|
||||
);
|
||||
let run = LintRun::for_document(&session.server.workspace, doc);
|
||||
let published = violations_in(doc, &run);
|
||||
let fixes = fixable(&run, doc);
|
||||
assert!(Arc::ptr_eq(&published, &fixes), "one pass answers both doors");
|
||||
assert_eq!(rules(&published), vec!["no-tabs"]);
|
||||
// ... and asking twice more does not compute twice more.
|
||||
assert!(Arc::ptr_eq(&fixes, &fixable(&run, doc)));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// row 1 — the buffer's own text
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn an_edited_buffer_is_relinted() {
|
||||
let tree = Tree::new("lsedit");
|
||||
let (mut session, uri) = opened(&tree, TABBED);
|
||||
assert_eq!(rules(&offered(&session, &uri)), vec!["no-tabs"], "premise");
|
||||
|
||||
change(
|
||||
&mut session,
|
||||
&uri,
|
||||
2,
|
||||
serde_json::json!([{ "text": "module m;\n wire a;\nendmodule\n" }]),
|
||||
);
|
||||
assert!(
|
||||
offered(&session, &uri).is_empty(),
|
||||
"the tab is gone, so the finding and its fix are gone"
|
||||
);
|
||||
|
||||
change(&mut session, &uri, 3, serde_json::json!([{ "text": TABBED }]));
|
||||
assert_eq!(rules(&offered(&session, &uri)), vec!["no-tabs"], "and back again");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// row 2 — the large-file fast path
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_large_buffer_lints_nothing_and_stores_nothing() {
|
||||
let tree = Tree::new("lslarge");
|
||||
let mut session = Session::wide(vec![tree.path.clone()], true);
|
||||
session.notify(
|
||||
DidChangeConfiguration::METHOD,
|
||||
serde_json::json!({ "settings": { "lucisv": { "largeFile": { "threshold": 16 } } } }),
|
||||
);
|
||||
let uri = session.open(&tree.path.join("m.sv"), TABBED);
|
||||
let _ = session.drain();
|
||||
let doc = session.server.workspace.document(&uri).expect("open");
|
||||
assert!(doc.large, "premise: over the threshold");
|
||||
assert!(doc.lint.is_empty(), "a large buffer's publish lints nothing to keep");
|
||||
let menu = session.result(
|
||||
CodeActionRequest::METHOD,
|
||||
serde_json::json!({
|
||||
"textDocument": { "uri": uri },
|
||||
"range": { "start": { "line": 1, "character": 1 },
|
||||
"end": { "line": 1, "character": 1 } },
|
||||
"context": { "diagnostics": [] },
|
||||
}),
|
||||
);
|
||||
assert_eq!(menu, serde_json::json!([]), "and offers nothing");
|
||||
let doc = session.server.workspace.document(&uri).expect("open");
|
||||
assert!(doc.lint.is_empty(), "the request left no snapshot behind either");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// rows 3 and 11 — the rule selection, pushed by the editor
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_pushed_rule_selection_is_relinted() {
|
||||
let tree = Tree::new("lsselect");
|
||||
let (mut session, uri) = opened(&tree, TABBED);
|
||||
assert_eq!(rules(&offered(&session, &uri)), vec!["no-tabs"], "premise");
|
||||
|
||||
push_lint_settings(&mut session, serde_json::json!({ "ignore": ["no-tabs"] }));
|
||||
assert!(offered(&session, &uri).is_empty(), "the setting silenced the rule and its fix");
|
||||
|
||||
push_lint_settings(&mut session, serde_json::json!({ "ignore": [] }));
|
||||
assert_eq!(rules(&offered(&session, &uri)), vec!["no-tabs"], "and un-silenced it");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// rows 4, 5, 8 and 12 — the `lucisv.toml`, rewritten under a running server
|
||||
// with no watcher event of any kind
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_rewritten_toml_is_relinted() {
|
||||
let tree = Tree::new("lstoml");
|
||||
tree.write("lucisv.toml", "[lint]\nignore = [\"no-tabs\"]\n");
|
||||
let (session, uri) = opened(&tree, TABBED);
|
||||
assert!(offered(&session, &uri).is_empty(), "premise: the project ignores the rule");
|
||||
|
||||
// Rewritten behind the server's back. `watch::SOURCE_GLOB` covers
|
||||
// `**/*.{v,vh,sv,svh}` and the filelist, so **no event is sent** — the
|
||||
// only thing that can notice is the per-request read and the key.
|
||||
tree.write("lucisv.toml", "[lint]\nignore = [\"posix-eof\"]\n");
|
||||
assert_eq!(
|
||||
rules(&offered(&session, &uri)),
|
||||
vec!["no-tabs"],
|
||||
"the next request read the new file"
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// row 6 — the indent width, which is a fix's bytes
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_tab_width_change_rewrites_the_fix() {
|
||||
let tree = Tree::new("lsindent");
|
||||
let (session, uri) = opened(&tree, TABBED);
|
||||
assert_eq!(fix_text(&offered(&session, &uri)), " ", "premise: the default indent");
|
||||
|
||||
tree.write("lucisv.toml", "indent = 4\n");
|
||||
assert_eq!(
|
||||
fix_text(&offered(&session, &uri)),
|
||||
" ",
|
||||
"the same finding, a different fix — and the snapshot must not hand back the old one"
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// row 7 — an external waiver file, rewritten in place
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_rewritten_waiver_file_is_relinted() {
|
||||
let tree = Tree::new("lswaiver");
|
||||
tree.write("lucisv.toml", "[lint]\nwaivers = [\"team.waiver\"]\n");
|
||||
tree.write("team.waiver", "waive --rule=no-tabs\n");
|
||||
let (session, uri) = opened(&tree, TABBED);
|
||||
assert!(offered(&session, &uri).is_empty(), "premise: the waiver silences it");
|
||||
|
||||
// Rewritten to name a different rule. The two texts are different
|
||||
// lengths, so this row alone would pass on a length check too — the
|
||||
// same-length case is `lint_snapshot::tests`'
|
||||
// `a_waiver_rewritten_in_place_is_a_different_key`.
|
||||
tree.write("team.waiver", "waive --rule=posix-eof\n");
|
||||
assert_eq!(rules(&offered(&session, &uri)), vec!["no-tabs"], "the waiver moved");
|
||||
|
||||
tree.write("team.waiver", "waive --rule=no-tabs\n");
|
||||
assert!(offered(&session, &uri).is_empty(), "and moved back");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// rows 9 and 10 — the workspace index the census oracle reads
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// A change in **another** file, which is the row a document-revision key
|
||||
/// could not have covered: this buffer's bytes never move, and what the
|
||||
/// semantic rules say about it does.
|
||||
#[test]
|
||||
fn a_change_in_another_file_relints_this_one() {
|
||||
let tree = Tree::new("lsoracle");
|
||||
let dut = "module dut;\n logic dbg_probe;\nendmodule\n";
|
||||
tree.write("dut.sv", dut);
|
||||
tree.write(
|
||||
"tb.sv",
|
||||
"module tb;\n dut d ();\n initial $display(\"%b\", d.dbg_probe);\nendmodule\n",
|
||||
);
|
||||
let mut session = Session::wide(vec![tree.path.clone()], true);
|
||||
let uri = session.open(&tree.path.join("dut.sv"), dut);
|
||||
let _ = session.drain();
|
||||
assert!(
|
||||
offered(&session, &uri).is_empty(),
|
||||
"premise: another file reads the signal, so it is not unused"
|
||||
);
|
||||
|
||||
// The other file stops mentioning it, and the watcher says so.
|
||||
tree.write("tb.sv", "module tb;\n dut d ();\nendmodule\n");
|
||||
session.watched(&[tree.path.join("tb.sv")]);
|
||||
let _ = session.drain();
|
||||
assert_eq!(
|
||||
rules(&offered(&session, &uri)),
|
||||
vec!["unused-signal"],
|
||||
"the index moved, so the snapshot had to go"
|
||||
);
|
||||
|
||||
tree.write(
|
||||
"tb.sv",
|
||||
"module tb;\n dut d ();\n initial $display(\"%b\", d.dbg_probe);\nendmodule\n",
|
||||
);
|
||||
session.watched(&[tree.path.join("tb.sv")]);
|
||||
let _ = session.drain();
|
||||
assert!(offered(&session, &uri).is_empty(), "and back");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// row 13 — close and reopen
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_closed_and_reopened_buffer_is_relinted() {
|
||||
let tree = Tree::new("lsreopen");
|
||||
let (mut session, uri) = opened(&tree, TABBED);
|
||||
assert_eq!(rules(&offered(&session, &uri)), vec!["no-tabs"], "premise");
|
||||
|
||||
session.notify(
|
||||
DidCloseTextDocument::METHOD,
|
||||
serde_json::json!({ "textDocument": { "uri": uri } }),
|
||||
);
|
||||
let _ = session.drain();
|
||||
assert!(session.server.workspace.document(&uri).is_none(), "the snapshot went with it");
|
||||
|
||||
let uri = session.open(&tree.path.join("m.sv"), "module m;\n wire a;\nendmodule\n");
|
||||
let _ = session.drain();
|
||||
assert!(offered(&session, &uri).is_empty(), "reopened with different text, relinted");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// row 14 — a fix's range, in UTF-16 units, off a reused snapshot
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// The snapshot holds byte spans; the range on the wire is built per request
|
||||
/// from the buffer's text. A reused snapshot must therefore still produce
|
||||
/// UTF-16 columns, which is the one place a cached *position* would have gone
|
||||
/// wrong.
|
||||
#[test]
|
||||
fn a_snapshot_fix_keeps_its_utf16_range() {
|
||||
let tree = Tree::new("lsutf16");
|
||||
// The `é` is two bytes and one UTF-16 unit; `🎉` is four bytes and two.
|
||||
let text = "module m;\n // é 🎉\twire a;\nendmodule\n";
|
||||
let (mut session, uri) = opened(&tree, text);
|
||||
let ask = serde_json::json!({
|
||||
"textDocument": { "uri": uri },
|
||||
"range": { "start": { "line": 1, "character": 9 },
|
||||
"end": { "line": 1, "character": 9 } },
|
||||
"context": { "diagnostics": [] },
|
||||
});
|
||||
// Twice: the first request may compute, the second is the reuse — and
|
||||
// both must name the same UTF-16 column.
|
||||
let first = session.result(CodeActionRequest::METHOD, ask.clone());
|
||||
let again = session.result(CodeActionRequest::METHOD, ask);
|
||||
assert_eq!(first, again, "the reused answer is the computed one");
|
||||
let edit = &first[0]["edit"]["changes"][uri.as_str()][0];
|
||||
assert_eq!(edit["range"]["start"]["character"], 9, "in UTF-16 units, not bytes");
|
||||
assert_eq!(edit["range"]["start"]["line"], 1);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// the attack
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// The failure the previous lane deferred this memo over: a **stale fix
|
||||
/// offer**. The buffer is edited so the bytes a previously offered fix named
|
||||
/// no longer exist; the next menu must not offer that fix, and must not offer
|
||||
/// an edit whose range runs past the end of the buffer.
|
||||
#[test]
|
||||
fn a_fix_is_never_offered_for_a_span_the_buffer_no_longer_has() {
|
||||
let tree = Tree::new("lsattack");
|
||||
// Two tabs, far apart, so the second fix's span is deep into the buffer.
|
||||
let long = format!("module m;\n\twire a;\n{}\twire z;\nendmodule\n", " // pad\n".repeat(40));
|
||||
let (mut session, uri) = opened(&tree, &long);
|
||||
let before = offered(&session, &uri);
|
||||
assert_eq!(before.len(), 2, "two tabs, two fixes: {:?}", rules(&before));
|
||||
let deepest = before.iter().map(|v| v.span.end).max().expect("a span");
|
||||
assert!(deepest as usize > 40, "premise: the fix is deep in the buffer");
|
||||
|
||||
// Now the buffer becomes three lines long. Every byte the second fix
|
||||
// named is gone.
|
||||
let after_text = "module m;\n wire a;\nendmodule\n";
|
||||
change(&mut session, &uri, 2, serde_json::json!([{ "text": after_text }]));
|
||||
let after = offered(&session, &uri);
|
||||
assert!(after.is_empty(), "no fix survives the text that justified it: {:?}", rules(&after));
|
||||
|
||||
// ... and through the wire, where a stale span would be a range past the
|
||||
// end of a three-line document.
|
||||
let menu = session.result(
|
||||
CodeActionRequest::METHOD,
|
||||
serde_json::json!({
|
||||
"textDocument": { "uri": uri },
|
||||
"range": { "start": { "line": 0, "character": 0 },
|
||||
"end": { "line": 2, "character": 9 } },
|
||||
// The fix families alone: an extraction is offered for any whole
|
||||
// selection and is not what this row is about.
|
||||
"context": { "diagnostics": [], "only": ["quickfix", "source.fixAll.lucisv"] },
|
||||
}),
|
||||
);
|
||||
assert_eq!(menu, serde_json::json!([]), "and nothing is offered: {menu:#?}");
|
||||
assert_eq!(
|
||||
session.server.workspace.document(&uri).expect("open").text,
|
||||
after_text,
|
||||
"the buffer the answer describes is the buffer the client has"
|
||||
);
|
||||
}
|
||||
@@ -55,6 +55,7 @@ mod formatting;
|
||||
mod hierarchy_reach;
|
||||
mod index;
|
||||
mod large_file;
|
||||
mod lint_snapshot;
|
||||
mod progress;
|
||||
mod pull_diagnostics;
|
||||
mod requests;
|
||||
@@ -98,6 +99,15 @@ impl Tree {
|
||||
}
|
||||
std::fs::write(&path, text).expect("write");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn link(&self, rel: &str, target: &str) {
|
||||
let path = self.path.join(rel);
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent).expect("parent");
|
||||
}
|
||||
std::os::unix::fs::symlink(target, &path).expect("symlink");
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Tree {
|
||||
|
||||
@@ -286,3 +286,39 @@ fn a_startup_scan_with_no_files_opens_no_store_and_a_warm_rescan_rewrites_none()
|
||||
);
|
||||
let _ = std::fs::remove_dir_all(&storage);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_discovery_split_is_a_split_of_discovery_and_not_stages_beside_it() {
|
||||
// §61.3. `config`, `walk`, `filelist`, `sort`, `cap` and `buffers` are
|
||||
// disjoint parts of `discovery`, so they may never add up to more than it
|
||||
// — and anything that sums the scan (`the_stages_add_up_to_the_scan_they
|
||||
// _describe`) must not sum these as well, which is why they are absent
|
||||
// from that test's list. The slack is `collect_sources`'s own bookkeeping:
|
||||
// the `spoken_for` set, the `Vec` pushes, the `Scope` moves.
|
||||
let tree = trace_tree("tracediscovery", 30);
|
||||
let session = Session::verbose_wide(vec![tree.path.clone()], None);
|
||||
let lines = scan_lines(&session);
|
||||
let stages = line_of(&lines, "stages");
|
||||
let discovery = number(&stages, "discovery");
|
||||
let parts: f64 = ["config", "walk", "filelist", "sort", "cap", "buffers"]
|
||||
.iter()
|
||||
.map(|key| number(&stages, key))
|
||||
.sum();
|
||||
assert!(discovery > 0.0, "a walk of 30 files takes measurable time: {stages}");
|
||||
assert!(parts <= discovery * 1.02, "the parts cannot exceed the whole: {parts} of {discovery}");
|
||||
assert!(parts > 0.0, "and at least one of them was timed: {stages}");
|
||||
// Not asserted: that the parts account for *most* of discovery. On a
|
||||
// fixture this small the whole is well under a millisecond and the
|
||||
// bookkeeping slack — the `spoken_for` set, the `Vec` pushes — rivals the
|
||||
// walk, so a ratio bound is a stopwatch under the workspace suite's
|
||||
// parallel load (it tripped once at 50 % in the lead's gate run and
|
||||
// passed alone three times). On opentitan the walk is 95 % of discovery
|
||||
// (`docs/features/perf5r-first-answer/README.md`); that ratio is the
|
||||
// README's measurement, not this test's claim.
|
||||
assert_eq!(number(&stages, "filelist"), 0.0, "no filelist is in force: {stages}");
|
||||
// Nothing was walked twice: one root, and the cap read the walk's own
|
||||
// lengths rather than asking the filesystem again.
|
||||
let counts = line_of(&lines, "counts");
|
||||
assert_eq!(field(&counts, "walk_dirs"), "1", "one root, walked once: {counts}");
|
||||
assert_eq!(field(&counts, "stats"), "0", "the cap stats nothing the walk already read");
|
||||
}
|
||||
@@ -20,6 +20,8 @@ use std::time::Instant;
|
||||
use super::scan::{positions, symbol_request};
|
||||
use super::scan_trace::{field, is_trace_line, line_of, trace_tree};
|
||||
use super::*;
|
||||
use crate::server::startup::OPENING_FILE_WAIT;
|
||||
use crate::state::discover::HEAD_WALK_MAX;
|
||||
|
||||
/// A client that answers `workspace/configuration` and is told what a scan
|
||||
/// spent its time on.
|
||||
@@ -55,6 +57,16 @@ fn the_whole_workspace() -> Value {
|
||||
serde_json::json!({ "index": { "scope": "workspace", "logFiles": true } })
|
||||
}
|
||||
|
||||
/// [`the_whole_workspace`] with the folder scope's raise turned off, so the
|
||||
/// folder a split leads with is the open buffer's own directory — the
|
||||
/// settings `docs/performance_052_review.md` F1 reproduces with, and what
|
||||
/// every alias fixture below needs to reach the split at all.
|
||||
fn the_whole_workspace_flat() -> Value {
|
||||
serde_json::json!({
|
||||
"index": { "scope": "workspace", "scopeDepth": 0, "logFiles": true }
|
||||
})
|
||||
}
|
||||
|
||||
/// A `textDocument/didOpen` over the wire, as the client sends it.
|
||||
fn did_open(path: &Path, text: &str) -> Message {
|
||||
Message::Notification(Notification::new(
|
||||
@@ -527,3 +539,950 @@ fn an_answer_behind_a_held_request_is_not_stranded_for_the_whole_bound() {
|
||||
assert_eq!(positions(&said, 7).1, None, "a short scan answers nothing mid-way: {said:#?}");
|
||||
assert_eq!(session.server.held.len(), 1, "and the request is still owed an answer");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// §61.3 (R2b): the neighbourhood is walked, stepped and published before
|
||||
// the rest of the workspace is discovered at all.
|
||||
// `docs/features/perf5r-first-answer/README.md`
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// The `scan started:` line, which says whether the scan led with a folder
|
||||
/// and how many files it had when it began.
|
||||
fn scan_started(messages: &[Message]) -> String {
|
||||
log_lines(messages)
|
||||
.into_iter()
|
||||
.find(|line| line.starts_with("timing: scan started"))
|
||||
.expect("a verbose scan says it started")
|
||||
}
|
||||
|
||||
/// A `textDocument/definition` on `path` at `line`:`character`.
|
||||
fn definition_at(id: i32, path: &Path, line: u32, character: u32) -> Message {
|
||||
Message::Request(Request::new(
|
||||
RequestId::from(id),
|
||||
GotoDefinition::METHOD.to_string(),
|
||||
serde_json::json!({
|
||||
"textDocument": { "uri": path_to_uri(path).expect("uri") },
|
||||
"position": { "line": line, "character": character },
|
||||
}),
|
||||
))
|
||||
}
|
||||
|
||||
/// The result of the response to `id`, or `None` when it never came.
|
||||
fn result_of(messages: &[Message], id: i32) -> Option<Value> {
|
||||
messages.iter().find_map(|message| match message {
|
||||
Message::Response(response) if response.id == RequestId::from(id) => {
|
||||
response.response_result.clone().ok()
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_users_folder_is_walked_and_stepped_before_the_rest_of_the_workspace() {
|
||||
// **The whole of R2b.** Before it, a workspace-scoped session walked all
|
||||
// 3 976 opentitan files — 155 ms — before it could step the 124 in the
|
||||
// folder the user was looking at, and the request waiting for that folder
|
||||
// paid the whole walk. Now the folder is walked, stepped and published
|
||||
// first and the walk of the rest happens behind the answer.
|
||||
//
|
||||
// The claim is readable off two numbers on the wire: the scan *starts*
|
||||
// with the folder's file count and *finishes* over the whole workspace.
|
||||
let tree = a_block_and_a_crowd("splitfolderfirst", INTERLEAVE_ABOVE + 6);
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![
|
||||
configuration_answer(the_whole_workspace()),
|
||||
did_open(&opened, &text),
|
||||
definition_at(7, &opened, 1, 3),
|
||||
],
|
||||
);
|
||||
let said = session.drain();
|
||||
let started = scan_started(&said);
|
||||
assert!(
|
||||
started.contains("2 files (the folder first)"),
|
||||
"the scan begins with the block's two files, not the workspace's {}: {started}",
|
||||
INTERLEAVE_ABOVE + 8
|
||||
);
|
||||
|
||||
// One scan, and it lands over everything: the split bought the order,
|
||||
// never a smaller index.
|
||||
let lines = trace_lines(&said);
|
||||
assert_eq!(lines.len(), 3, "one scan, three trace lines: {lines:#?}");
|
||||
for line in &lines {
|
||||
assert!(line.starts_with("timing: scan 1 "), "no second scan ran: {line}");
|
||||
}
|
||||
assert_eq!(
|
||||
field(&line_of(&lines, "counts"), "read"),
|
||||
(INTERLEAVE_ABOVE + 8).to_string(),
|
||||
"and the work list ends as the whole workspace"
|
||||
);
|
||||
assert_eq!(session.server.workspace.index().files().len(), INTERLEAVE_ABOVE + 8);
|
||||
|
||||
// And the answer the folder bought is the right one, given inside the
|
||||
// scan.
|
||||
let (ended, answered) = positions(&said, 7);
|
||||
let answered = answered.expect("the definition is answered at all");
|
||||
assert!(answered < ended.expect("the bar comes down"), "inside the scan: {said:#?}");
|
||||
let found = result_of(&said, 7).expect("a result");
|
||||
assert_eq!(
|
||||
found[0]["uri"],
|
||||
serde_json::json!(path_to_uri(&tree.path.join("ip/aes/rtl/aes.sv")).expect("uri")),
|
||||
"the module in the folder next door: {found}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_split_head_obeys_a_gitignore_written_at_the_workspace_root() {
|
||||
// **The correctness the split could most easily have broken.** A walk
|
||||
// starting at `ip/aes` reads no `.gitignore` above itself, so the folder
|
||||
// half of the scan would have indexed files the rest of it excludes — two
|
||||
// answers to "which files exist" inside one scan. `collect_files_below`
|
||||
// carries the ancestor rules down, and this is the file that proves it.
|
||||
let tree = a_block_and_a_crowd("splitgitignore", 4);
|
||||
tree.write(".gitignore", "*_generated.sv\n");
|
||||
tree.write("ip/aes/rtl/aes_generated.sv", "module aes_generated;\nendmodule\n");
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace()), did_open(&opened, &text)],
|
||||
);
|
||||
let said = session.drain();
|
||||
assert!(scan_started(&said).contains("(the folder first)"), "{}", scan_started(&said));
|
||||
let indexed: Vec<String> = session
|
||||
.server
|
||||
.workspace
|
||||
.index()
|
||||
.files()
|
||||
.iter()
|
||||
.map(|path| path.display().to_string())
|
||||
.collect();
|
||||
assert!(
|
||||
!indexed.iter().any(|path| path.ends_with("aes_generated.sv")),
|
||||
"the root's rule reaches into the folder the head walked: {indexed:#?}"
|
||||
);
|
||||
// Six: two in the block, four in the crowd. The generated one is out.
|
||||
assert_eq!(indexed.len(), 6, "{indexed:#?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_buffer_opened_from_the_workspace_root_is_no_neighbourhood_to_lead_with() {
|
||||
// The bound. A file opened from the root raises to the root, so "its
|
||||
// folder" is the whole workspace — leading with it would be leading with
|
||||
// everything, and waiting for it would be waiting out the entire scan
|
||||
// before answering anything. `splits_discovery` refuses, the scan is
|
||||
// ordered exactly as it was before this round, and
|
||||
// `scan_order::worth_waiting` decides the drain as it always did.
|
||||
let tree = a_block_and_a_crowd("splitrootlevel", INTERLEAVE_ABOVE + 6);
|
||||
tree.write("top.sv", "module top;\n aes dut ();\nendmodule\n");
|
||||
let opened = tree.path.join("top.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![
|
||||
configuration_answer(the_whole_workspace()),
|
||||
did_open(&opened, &text),
|
||||
definition_at(7, &opened, 1, 3),
|
||||
],
|
||||
);
|
||||
let said = session.drain();
|
||||
let started = scan_started(&said);
|
||||
assert!(
|
||||
!started.contains("the folder first"),
|
||||
"the root is not a folder to lead with: {started}"
|
||||
);
|
||||
// No deadlock: the request is still answered, and with the right place.
|
||||
// **It used to be answered `[]` inside the scan** — the drain reached it
|
||||
// before the alphabet reached `ip/aes/rtl`, and `[]` was what the prefix
|
||||
// said. Since §61.4 an empty *navigation* answer computed while the index
|
||||
// is still growing is not an answer at all: the request is asked again at
|
||||
// the scan's next publish and, in a workspace this small, at the scan's
|
||||
// end — which is later, and right (`perf5r-publication`).
|
||||
let found = result_of(&said, 7).expect("the definition is answered at all");
|
||||
assert_eq!(
|
||||
found[0]["uri"],
|
||||
serde_json::json!(path_to_uri(&tree.path.join("ip/aes/rtl/aes.sv")).expect("uri")),
|
||||
"the module the buffer instantiates, not the empty prefix: {found}"
|
||||
);
|
||||
assert_eq!(session.server.workspace.index().files().len(), INTERLEAVE_ABOVE + 9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_buffers_in_two_folders_put_both_folders_in_the_head() {
|
||||
// The multiple-folder case. The head is the union of what each buffer
|
||||
// raises to, so a definition into *either* block is answered off it —
|
||||
// and every file is still stepped exactly once, which is what the
|
||||
// finished index's file count says.
|
||||
let tree = a_block_and_a_crowd("splittwofolders", INTERLEAVE_ABOVE + 6);
|
||||
tree.write("ip/kmac/rtl/kmac.sv", "module kmac;\n localparam W = 2;\nendmodule\n");
|
||||
tree.write("ip/kmac/dv/tb/ktb.sv", "module ktb;\n kmac dut ();\nendmodule\n");
|
||||
let aes_tb = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let kmac_tb = tree.path.join("ip/kmac/dv/tb/ktb.sv");
|
||||
let aes_text = std::fs::read_to_string(&aes_tb).expect("read");
|
||||
let kmac_text = std::fs::read_to_string(&kmac_tb).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![
|
||||
configuration_answer(the_whole_workspace()),
|
||||
did_open(&aes_tb, &aes_text),
|
||||
did_open(&kmac_tb, &kmac_text),
|
||||
definition_at(7, &kmac_tb, 1, 3),
|
||||
],
|
||||
);
|
||||
let said = session.drain();
|
||||
let started = scan_started(&said);
|
||||
assert!(started.contains("4 files (the folder first)"), "both blocks lead: {started}");
|
||||
let found = result_of(&said, 7).expect("a result");
|
||||
assert_eq!(
|
||||
found[0]["uri"],
|
||||
serde_json::json!(path_to_uri(&tree.path.join("ip/kmac/rtl/kmac.sv")).expect("uri")),
|
||||
"the second buffer's own block is in the head too: {found}"
|
||||
);
|
||||
assert_eq!(
|
||||
session.server.workspace.index().files().len(),
|
||||
INTERLEAVE_ABOVE + 10,
|
||||
"every file once, the head's included"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unsaved_buffer_leads_with_its_own_text_and_not_the_disk_copy() {
|
||||
// Unsaved-buffer precedence, at the head. The buffer names a module the
|
||||
// file on disk does not, and the definition sent behind it must resolve
|
||||
// — which it can only do if the head indexed the buffer's own text.
|
||||
let tree = a_block_and_a_crowd("splitunsaved", INTERLEAVE_ABOVE + 6);
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
// On disk the testbench instantiates nothing at all.
|
||||
tree.write("ip/aes/dv/tb/tb.sv", "module tb;\nendmodule\n");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![
|
||||
configuration_answer(the_whole_workspace()),
|
||||
did_open(&opened, "module tb;\n aes dut ();\nendmodule\n"),
|
||||
definition_at(7, &opened, 1, 3),
|
||||
],
|
||||
);
|
||||
let said = session.drain();
|
||||
assert!(scan_started(&said).contains("(the folder first)"), "{}", scan_started(&said));
|
||||
let found = result_of(&said, 7).expect("a result");
|
||||
assert_eq!(
|
||||
found[0]["uri"],
|
||||
serde_json::json!(path_to_uri(&tree.path.join("ip/aes/rtl/aes.sv")).expect("uri")),
|
||||
"the head indexed the buffer, not the file under it: {found}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The cross-folder fixture: the buffer's folder is `ip/aes`, and what it
|
||||
/// instantiates lives in `ip/kmac` — so the head the split publishes first
|
||||
/// cannot answer the definition in it.
|
||||
fn a_block_that_instantiates_the_block_next_door(tag: &str) -> Tree {
|
||||
let tree = a_block_and_a_crowd(tag, INTERLEAVE_ABOVE + 6);
|
||||
tree.write("ip/kmac/rtl/kmac.sv", "module kmac;\nendmodule\n");
|
||||
tree.write("ip/aes/dv/tb/tb.sv", "module tb;\n kmac dut ();\nendmodule\n");
|
||||
tree
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_target_outside_the_head_is_asked_again_rather_than_answered_nowhere() {
|
||||
// **§61.3's honest limit, closed by §61.4's rule.** A held request is
|
||||
// drained the moment the user's own folder is published, and a definition
|
||||
// whose target lives in *another* folder used to be answered `[]` there —
|
||||
// coherent, and wrong by the time the scan ended. The rule now says an
|
||||
// empty **navigation** answer computed while the index is still growing is
|
||||
// not an answer: the request is put back and asked again at the scan's
|
||||
// next publish, and at the latest when the scan ends
|
||||
// (`docs/features/perf5r-publication/README.md`).
|
||||
//
|
||||
// This fixture stages under `PUBLISH_EVERY` files, so there is exactly one
|
||||
// publish — the head's — and the request is answered where the second half
|
||||
// of the rule catches it: at the end of the scan, with the right location.
|
||||
let tree = a_block_that_instantiates_the_block_next_door("splitcrossfolder");
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![
|
||||
configuration_answer(the_whole_workspace()),
|
||||
did_open(&opened, &text),
|
||||
definition_at(7, &opened, 1, 3),
|
||||
],
|
||||
);
|
||||
let said = session.drain();
|
||||
let found = result_of(&said, 7).expect("a result, not a failure");
|
||||
assert_eq!(
|
||||
found[0]["uri"],
|
||||
serde_json::json!(path_to_uri(&tree.path.join("ip/kmac/rtl/kmac.sv")).expect("uri")),
|
||||
"the block next door, which is the settled answer: {found}"
|
||||
);
|
||||
|
||||
// Once, not twice: the deferral puts the request back, it does not answer
|
||||
// it and then answer it again.
|
||||
let answers = said
|
||||
.iter()
|
||||
.filter(|message| matches!(message, Message::Response(r) if r.id == RequestId::from(7)))
|
||||
.count();
|
||||
assert_eq!(answers, 1, "one response for one request: {said:#?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_navigation_answer_that_is_genuinely_empty_is_answered_when_the_scan_ends() {
|
||||
// **The rule defers; it never withholds.** A cursor on a name nothing in
|
||||
// the workspace declares is empty at every publish and empty at settle,
|
||||
// and the request is answered all the same — with `[]`, once the scan has
|
||||
// stopped being a reason to doubt it.
|
||||
let tree = a_block_and_a_crowd("crossfoldergenuinelyempty", INTERLEAVE_ABOVE + 6);
|
||||
tree.write("ip/aes/dv/tb/tb.sv", "module tb;\n nowhere dut ();\nendmodule\n");
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![
|
||||
configuration_answer(the_whole_workspace()),
|
||||
did_open(&opened, &text),
|
||||
definition_at(7, &opened, 1, 3),
|
||||
],
|
||||
);
|
||||
let said = session.drain();
|
||||
let found = result_of(&said, 7).expect("a result, not a failure");
|
||||
assert_eq!(
|
||||
found.as_array().map(Vec::len),
|
||||
Some(0),
|
||||
"nothing declares `nowhere`, and the answer says so: {found}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_type_definition_outside_the_head_is_asked_again_too() {
|
||||
// The rule is three methods wide and the definition test only walks one of
|
||||
// them. A `typeDefinition` on the instance name answers with the module it
|
||||
// instantiates, which lives in the block next door: empty off the head,
|
||||
// right once the scan has been all the way round.
|
||||
let tree = a_block_that_instantiates_the_block_next_door("splitcrossfoldertype");
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let ask = Message::Request(Request::new(
|
||||
RequestId::from(7),
|
||||
GotoTypeDefinition::METHOD.to_string(),
|
||||
serde_json::json!({
|
||||
"textDocument": { "uri": path_to_uri(&opened).expect("uri") },
|
||||
"position": { "line": 1, "character": 7 },
|
||||
}),
|
||||
));
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace()), did_open(&opened, &text), ask],
|
||||
);
|
||||
let found = result_of(&session.drain(), 7).expect("a result, not a failure");
|
||||
assert_eq!(
|
||||
found[0]["uri"],
|
||||
serde_json::json!(path_to_uri(&tree.path.join("ip/kmac/rtl/kmac.sv")).expect("uri")),
|
||||
"the instance's module, from the block next door: {found}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hover_is_never_deferred_however_empty_it_is() {
|
||||
// **The rule is three methods wide, and this is the wall.** A hover
|
||||
// answers `null` for a name the index has not reached, and `null` is what
|
||||
// a hover means by "nothing to say" whatever the scan has done — so it is
|
||||
// answered where every mid-scan request is answered, inside the scan and
|
||||
// before the bar comes down. Deferring it would be withholding an answer
|
||||
// rather than waiting for a better one.
|
||||
let tree = a_block_that_instantiates_the_block_next_door("crossfolderhover");
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let hover = Message::Request(Request::new(
|
||||
RequestId::from(7),
|
||||
HoverRequest::METHOD.to_string(),
|
||||
serde_json::json!({
|
||||
"textDocument": { "uri": path_to_uri(&opened).expect("uri") },
|
||||
"position": { "line": 1, "character": 3 },
|
||||
}),
|
||||
));
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace()), did_open(&opened, &text), hover],
|
||||
);
|
||||
let said = session.drain();
|
||||
let (ended, answered) = positions(&said, 7);
|
||||
let answered = answered.expect("the hover is answered at all");
|
||||
assert!(
|
||||
answered < ended.expect("the bar comes down"),
|
||||
"inside the scan, at the head publish, like every other mid-scan request: {said:#?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_folder_bigger_than_the_head_bound_is_scanned_exactly_as_it_always_was() {
|
||||
// **`HEAD_WALK_MAX`, pinned** — the bound QA found untested in §61.3. Past
|
||||
// 512 files the neighbourhood is not provably a minority of anything, so
|
||||
// the split is refused: the walk is finished there and then, the two lists
|
||||
// are merged in path order, and the scan is the one every scan before the
|
||||
// split was. The proof is in three parts — the scan does not say "the
|
||||
// folder first", every file is indexed once, and the index it lands is the
|
||||
// one a session with nothing open lands.
|
||||
let tree = a_block_and_a_crowd("headwalkmax", 4);
|
||||
for n in 0..=HEAD_WALK_MAX {
|
||||
tree.package(&format!("ip/aes/rtl/big{n:04}.sv"), &format!("big{n:04}"));
|
||||
}
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace()), did_open(&opened, &text)],
|
||||
);
|
||||
let started = scan_started(&session.drain());
|
||||
assert!(
|
||||
!started.contains("the folder first"),
|
||||
"a neighbourhood over the bound is walked with everything else: {started}"
|
||||
);
|
||||
|
||||
// Every file once: the whole tree is `crowd/` (4) + `ip/aes/rtl` (1 + the
|
||||
// padding) + `ip/aes/dv/tb` (1) + `ip/kmac` (none here).
|
||||
let files = session.server.workspace.index().files();
|
||||
let expected = 4 + 1 + (HEAD_WALK_MAX + 1) + 1;
|
||||
assert_eq!(files.len(), expected, "every file, and none of them twice");
|
||||
let mut sorted = files.to_vec();
|
||||
sorted.sort();
|
||||
sorted.dedup();
|
||||
assert_eq!(sorted.len(), files.len(), "no path is in the index twice");
|
||||
|
||||
// And the index is the one the bound's other side would have built.
|
||||
let quiet = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace())],
|
||||
);
|
||||
let _ = quiet.drain();
|
||||
assert_eq!(
|
||||
session.server.workspace.index().fingerprint(),
|
||||
quiet.server.workspace.index().fingerprint(),
|
||||
"the open buffer bought the order, never a different index"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bar_paints_no_percentage_until_the_denominator_is_final() {
|
||||
// `docs/features/indexing-ux/README.md`: the percentage only counts up,
|
||||
// and every one of them is measured. While the neighbourhood is being
|
||||
// stepped the denominator is the head — which is about to grow twentyfold
|
||||
// — so no report is sent at all, and the first one the client sees is
|
||||
// against the finished work list. The per-file log still names every
|
||||
// file, head included.
|
||||
let tree = a_block_and_a_crowd("splitbar", INTERLEAVE_ABOVE + 6);
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling_with_a_bar(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace()), did_open(&opened, &text)],
|
||||
);
|
||||
let said = session.drain();
|
||||
let percentages: Vec<u64> = said
|
||||
.iter()
|
||||
.filter_map(|message| match message {
|
||||
Message::Notification(n) if n.method == Progress::METHOD => {
|
||||
n.params["value"]["percentage"].as_u64()
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert!(!percentages.is_empty(), "the bar does report: {said:#?}");
|
||||
assert!(
|
||||
percentages.windows(2).all(|pair| pair[0] <= pair[1]),
|
||||
"a percentage never falls: {percentages:?}"
|
||||
);
|
||||
// The head is two files of `INTERLEAVE_ABOVE + 8`; a report against the
|
||||
// head alone would have opened at 50%.
|
||||
assert!(percentages[0] < 50, "the first report is measured, not invented: {percentages:?}");
|
||||
|
||||
// And the head's files are still named in the log.
|
||||
let logged: Vec<String> = log_lines(&said)
|
||||
.into_iter()
|
||||
.filter(|line| line.starts_with("indexing: ") || line.starts_with("analyzed: "))
|
||||
.collect();
|
||||
assert!(
|
||||
logged.iter().any(|line| line.ends_with("tb.sv")),
|
||||
"the buffer's own step is logged: {logged:#?}"
|
||||
);
|
||||
assert!(
|
||||
logged.iter().any(|line| line.ends_with("aes.sv")),
|
||||
"and so is the folder's: {logged:#?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_session_that_opens_nothing_waits_only_the_opening_bound_and_scans() {
|
||||
// The cost side of `OPENING_FILE_WAIT`, and its bound. A workspace-scoped
|
||||
// session whose editor has no file open waits the whole of it — nothing
|
||||
// is waiting on the scan, which is why it is affordable — and then scans
|
||||
// the workspace exactly as it did before.
|
||||
assert_eq!(
|
||||
OPENING_FILE_WAIT,
|
||||
Duration::from_millis(25),
|
||||
"the shipped bound, which no test may quietly move"
|
||||
);
|
||||
let tree = trace_tree("splitnoopen", 9);
|
||||
let began = Instant::now();
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace())],
|
||||
);
|
||||
let took = began.elapsed();
|
||||
assert!(took < Duration::from_secs(1), "bounded, and by the small bound: {took:?}");
|
||||
let said = session.drain();
|
||||
let lines = trace_lines(&said);
|
||||
assert_eq!(lines.len(), 3, "one scan: {lines:#?}");
|
||||
assert_eq!(field(&line_of(&lines, "counts"), "read"), "9", "the whole workspace");
|
||||
assert!(!scan_started(&said).contains("the folder first"), "nothing to lead with");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rescan_does_not_lead_with_a_folder_because_nothing_may_be_answered_inside_it() {
|
||||
// The other half of the bound. A whole rescan is one a message asked for,
|
||||
// and `must_wait`'s `answering_a_rescan` holds every request for the whole
|
||||
// of it — so leading with the user's folder buys no answer any sooner and
|
||||
// costs the neighbourhood one extra directory traversal. Only the startup
|
||||
// scan, which nothing is queued ahead of, takes the split.
|
||||
let tree = a_block_and_a_crowd("splitrescan", INTERLEAVE_ABOVE + 6);
|
||||
let opened = tree.path.join("ip/aes/dv/tb/tb.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let mut session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace()), did_open(&opened, &text)],
|
||||
);
|
||||
assert!(scan_started(&session.drain()).contains("(the folder first)"), "premise");
|
||||
|
||||
// A changed `exclude` is a scope change, which is a whole rescan.
|
||||
session.notify(
|
||||
DidChangeConfiguration::METHOD,
|
||||
serde_json::json!({ "settings": { "lucisv": {
|
||||
"index": { "scope": "workspace", "logFiles": true },
|
||||
"exclude": ["**/p000.sv"],
|
||||
} } }),
|
||||
);
|
||||
let said = session.drain();
|
||||
let started: Vec<String> = log_lines(&said)
|
||||
.into_iter()
|
||||
.filter(|line| line.starts_with("timing: scan started"))
|
||||
.collect();
|
||||
assert_eq!(started.len(), 1, "one rescan: {started:#?}");
|
||||
assert!(
|
||||
!started[0].contains("the folder first"),
|
||||
"a rescan takes the plain order: {started:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
session.server.workspace.index().files().len(),
|
||||
INTERLEAVE_ABOVE + 7,
|
||||
"and the exclusion took one file out"
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Directory aliases across a split discovery (F1)
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// A symlinked directory gives every file under it a second path, and a walk
|
||||
// reports each file under the **first spelling that reaches it**
|
||||
// (`docs/features/walk-cycles/README.md`). The startup scan walks the user's
|
||||
// own folder before it walks the workspace, so the two halves must share that
|
||||
// rule or one module lands in the index twice and cannot be renamed — the
|
||||
// regression `docs/performance_052_review.md` F1 found and every fixture here
|
||||
// pins.
|
||||
//
|
||||
// Each one makes the same three asks of the same tree — after the startup
|
||||
// scan, after a whole rescan, and of a fresh session — and they must agree.
|
||||
|
||||
/// The testbench every fixture opens: it names `child`, which is what the
|
||||
/// definition and the rename below are asked about.
|
||||
#[cfg(unix)]
|
||||
const TB: &str = "module tb;\n child u();\nendmodule\n";
|
||||
|
||||
/// A `child` module and the testbench that instantiates it, in `dir`.
|
||||
#[cfg(unix)]
|
||||
fn alias_pair(tree: &Tree, dir: &str) {
|
||||
tree.write(&format!("{dir}/child.sv"), "module child;\nendmodule\n");
|
||||
tree.write(&format!("{dir}/tb.sv"), TB);
|
||||
}
|
||||
|
||||
/// Where `child` is named in [`TB`] — the cursor every claim below is made at.
|
||||
#[cfg(unix)]
|
||||
fn at_child(uri: &Uri) -> Value {
|
||||
serde_json::json!({
|
||||
"textDocument": { "uri": uri },
|
||||
"position": { "line": 1, "character": 3 },
|
||||
})
|
||||
}
|
||||
|
||||
/// What one session says about a fixture: which files the index holds, where
|
||||
/// the definition of `child` goes, whether that name may be renamed, and what
|
||||
/// the open buffer's diagnostics are.
|
||||
///
|
||||
/// The four together are the review's acceptance: a duplicate shows up as a
|
||||
/// second file, as a second target, and as a refusal to rename — and every
|
||||
/// answer the index feeds moves with it, which is what the diagnostics are
|
||||
/// here to catch.
|
||||
#[cfg(unix)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct Says {
|
||||
files: Vec<String>,
|
||||
defs: Vec<Value>,
|
||||
renamable: bool,
|
||||
diagnostics: Vec<Value>,
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn says(session: &mut Session, uri: &Uri) -> Says {
|
||||
let answer = session.result(GotoDefinition::METHOD, at_child(uri));
|
||||
let defs: Vec<Value> = serde_json::from_value(answer).expect("definition targets");
|
||||
let prepared = session.request(PrepareRenameRequest::METHOD, at_child(uri));
|
||||
let files =
|
||||
session.server.workspace.index().files().iter().map(|p| p.display().to_string()).collect();
|
||||
// The `resultId` is a generation counter and moves with every rebuild, so
|
||||
// what is compared is what the user sees: each diagnostic's sentence and
|
||||
// where it points.
|
||||
let report = document_pull(session, uri, None);
|
||||
let items = report["items"].as_array().cloned().expect("a full diagnostic report");
|
||||
let diagnostics = items
|
||||
.into_iter()
|
||||
.map(|item| serde_json::json!({ "message": item["message"], "range": item["range"] }))
|
||||
.collect();
|
||||
Says { files, defs, renamable: prepared.response_result.is_ok(), diagnostics }
|
||||
}
|
||||
|
||||
/// Index `tree` with `opened` open, then ask a whole rescan and a fresh
|
||||
/// session the same four questions. Reports what all three said.
|
||||
///
|
||||
/// The rescan trigger is the review's own: a watched-file notification naming
|
||||
/// more than one in-scope file is the whole rebuild rather than the one-file
|
||||
/// incremental path (`server/notification.rs`). No source byte changes, so a
|
||||
/// disagreement is the scan disagreeing with itself.
|
||||
#[cfg(unix)]
|
||||
fn startup_rescan_and_restart_agree(tree: &Tree, opened: &Path, text: &str) -> Says {
|
||||
let uri = path_to_uri(opened).expect("uri");
|
||||
let fresh = || {
|
||||
let session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace_flat()), did_open(opened, text)],
|
||||
);
|
||||
session.drain();
|
||||
session
|
||||
};
|
||||
let mut session = fresh();
|
||||
let startup = says(&mut session, &uri);
|
||||
let changed: Vec<PathBuf> = startup.files.iter().map(PathBuf::from).collect();
|
||||
assert!(changed.len() > 1, "the whole-rebuild trigger names more than one file");
|
||||
session.watched(&changed);
|
||||
session.drain();
|
||||
let rescan = says(&mut session, &uri);
|
||||
let restart = says(&mut fresh(), &uri);
|
||||
assert_eq!(startup, rescan, "the startup scan and a whole rescan must agree");
|
||||
assert_eq!(startup, restart, "the startup scan and a fresh session must agree");
|
||||
startup
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_alias_sorting_before_its_target_is_indexed_once_under_the_root_walks_spelling() {
|
||||
// The review's own reproduction. A walk of the root reaches `a_alias`
|
||||
// first, so `a_alias/child.sv` is the canonical spelling and the head —
|
||||
// which would lead with `z_real` — must not be led with at all.
|
||||
let tree = Tree::new("aliasbefore");
|
||||
alias_pair(&tree, "z_real");
|
||||
tree.link("a_alias", "z_real");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &tree.path.join("z_real/tb.sv"), TB);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "a module declared once may be renamed");
|
||||
assert!(
|
||||
said.files.iter().any(|file| file.ends_with("a_alias/child.sv")),
|
||||
"the root walk's own spelling: {:#?}",
|
||||
said.files
|
||||
);
|
||||
assert!(said.diagnostics.is_empty(), "and nothing is wrong with it: {:#?}", said.diagnostics);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_alias_sorting_after_its_target_leaves_the_head_leading() {
|
||||
// Nothing precedes `a_real`, so this one keeps the split — and the
|
||||
// remaining walk must still recognise `z_alias` as the folder it has.
|
||||
let tree = Tree::new("aliasafter");
|
||||
alias_pair(&tree, "a_real");
|
||||
tree.link("z_alias", "a_real");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &tree.path.join("a_real/tb.sv"), TB);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "a module declared once may be renamed");
|
||||
assert!(
|
||||
said.files.iter().any(|file| file.ends_with("a_real/child.sv")),
|
||||
"the target's own spelling: {:#?}",
|
||||
said.files
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn several_aliases_of_one_directory_contribute_one_copy_between_them() {
|
||||
let tree = Tree::new("multialias");
|
||||
alias_pair(&tree, "real");
|
||||
tree.link("a1_alias", "real");
|
||||
tree.link("a2_alias", "real");
|
||||
tree.link("z_alias", "real");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &tree.path.join("real/tb.sv"), TB);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "three aliases are still one declaration");
|
||||
assert_eq!(said.files.len(), 2, "one child, one buffer: {:#?}", said.files);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_alias_of_an_ancestor_of_the_open_folder_falls_back_to_the_one_walk() {
|
||||
// The head would lead with `z_real/sub`, but the root walk reaches the
|
||||
// whole of `z_real` through `a_link` — so the folder's *ancestors* are
|
||||
// what the check has to look at, not the folder alone.
|
||||
let tree = Tree::new("aliasancestor");
|
||||
alias_pair(&tree, "z_real/sub");
|
||||
tree.link("a_link", "z_real");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &tree.path.join("z_real/sub/tb.sv"), TB);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "a module declared once may be renamed");
|
||||
assert!(
|
||||
said.files.iter().any(|file| file.ends_with("a_link/sub/child.sv")),
|
||||
"the root walk's own spelling: {:#?}",
|
||||
said.files
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_ancestor_cycle_inside_the_neighbourhood_ends_and_names_each_file_once() {
|
||||
// `sub/up -> ..` is a link out of the neighbourhood and back to the top,
|
||||
// so the head walk finds the root's own file under `sub/up/top.sv` while
|
||||
// a walk of the root spells it `top.sv`. One spelling reaches the index,
|
||||
// and the rescan the conflict asks for is what settles which.
|
||||
let tree = Tree::new("ancestorcycle");
|
||||
alias_pair(&tree, "sub");
|
||||
tree.write("top.sv", "module top;\nendmodule\n");
|
||||
tree.link("sub/up", "..");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &tree.path.join("sub/tb.sv"), TB);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "the cycle did not duplicate `child`");
|
||||
assert_eq!(said.files.len(), 3, "child, top and the buffer: {:#?}", said.files);
|
||||
assert!(
|
||||
said.files.iter().any(|file| file.ends_with("/top.sv") && !file.contains("/up/")),
|
||||
"the root's file under the root's own spelling: {:#?}",
|
||||
said.files
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_ignored_alias_is_excluded_by_both_halves_of_the_scan() {
|
||||
let tree = Tree::new("ignorealias");
|
||||
tree.write(".gitignore", "a_alias/\n");
|
||||
alias_pair(&tree, "z_real");
|
||||
tree.link("a_alias", "z_real");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &tree.path.join("z_real/tb.sv"), TB);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "a module declared once may be renamed");
|
||||
assert!(
|
||||
said.files.iter().all(|file| !file.contains("a_alias")),
|
||||
"the ignored alias is in nobody's scope: {:#?}",
|
||||
said.files
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_open_unsaved_buffer_is_not_indexed_again_under_an_alias() {
|
||||
// The buffer is `z_real/tb.sv` and the walk's own spelling of it is
|
||||
// `a_alias/tb.sv`: two paths, one file, and an index holding both would
|
||||
// hold `tb` twice while showing the user only one of them.
|
||||
let tree = Tree::new("unsavedalias");
|
||||
alias_pair(&tree, "z_real");
|
||||
tree.link("a_alias", "z_real");
|
||||
let unsaved = "module tb;\n child u();\n localparam UNSAVED = 1;\nendmodule\n";
|
||||
let opened = tree.path.join("z_real/tb.sv");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &opened, unsaved);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "`child` is declared once");
|
||||
assert_eq!(said.files.len(), 2, "one child, one buffer: {:#?}", said.files);
|
||||
|
||||
// And the buffer's own name, which is the one the alias would have
|
||||
// duplicated: renamable, and the unsaved text is what was indexed.
|
||||
let uri = path_to_uri(&opened).expect("uri");
|
||||
let mut session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace_flat()), did_open(&opened, unsaved)],
|
||||
);
|
||||
let _ = session.drain();
|
||||
let at_tb = serde_json::json!({
|
||||
"textDocument": { "uri": &uri },
|
||||
"position": { "line": 0, "character": 8 },
|
||||
});
|
||||
let prepared = session.request(PrepareRenameRequest::METHOD, at_tb);
|
||||
assert!(prepared.response_result.is_ok(), "one `tb`: {:?}", prepared.response_result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_genuine_duplicate_declaration_is_still_ambiguous_at_startup_and_after_a_rescan() {
|
||||
// The other side of the fix, and the reason deduplicating by *name* was
|
||||
// never an option: two physical files really do declare `dup`, and a
|
||||
// rename that picked one of them would be a wrong edit.
|
||||
let tree = Tree::new("legitdup");
|
||||
tree.write("dir1/dup.sv", "module dup;\nendmodule\n");
|
||||
tree.write("dir2/dup.sv", "module dup;\nendmodule\n");
|
||||
let opened = tree.path.join("dir1/dup.sv");
|
||||
let text = std::fs::read_to_string(&opened).expect("read");
|
||||
let uri = path_to_uri(&opened).expect("uri");
|
||||
let at_dup = serde_json::json!({
|
||||
"textDocument": { "uri": &uri },
|
||||
"position": { "line": 0, "character": 8 },
|
||||
});
|
||||
|
||||
let mut session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace()), did_open(&opened, &text)],
|
||||
);
|
||||
session.drain();
|
||||
let refused = session.request(PrepareRenameRequest::METHOD, at_dup.clone());
|
||||
let error = refused.response_result.expect_err("two declarations are ambiguous");
|
||||
assert!(error.message.contains("declared in more than one indexed file"), "{}", error.message);
|
||||
|
||||
session.watched(&[opened.clone(), tree.path.join("dir2/dup.sv")]);
|
||||
session.drain();
|
||||
let again = session.request(PrepareRenameRequest::METHOD, at_dup);
|
||||
let rescanned = again.response_result.expect_err("a rescan refuses it the same way");
|
||||
assert_eq!(rescanned.message, error.message, "the same sentence, word for word");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_alias_beside_the_open_folder_indexes_once_and_asks_for_one_rescan() {
|
||||
// The case no pre-check can see: `other/link` is nowhere on the open
|
||||
// folder's own chain, so the head leads with `z_real` and only the
|
||||
// remaining walk finds out that a walk of the root would have spelled
|
||||
// those files `other/link/…`. Nothing is indexed twice — and the scan
|
||||
// asks for the canonical walk once, which is where the spelling
|
||||
// converges.
|
||||
let tree = Tree::new("siblingalias");
|
||||
alias_pair(&tree, "z_real");
|
||||
tree.link("other/link", "../z_real");
|
||||
let opened = tree.path.join("z_real/tb.sv");
|
||||
let uri = path_to_uri(&opened).expect("uri");
|
||||
|
||||
let mut session = Session::staged(
|
||||
vec![tree.path.clone()],
|
||||
pulling(),
|
||||
true,
|
||||
CONFIGURATION_WAIT,
|
||||
vec![configuration_answer(the_whole_workspace_flat()), did_open(&opened, TB)],
|
||||
);
|
||||
let messages = session.drain();
|
||||
let traces = trace_lines(&messages);
|
||||
let counts: Vec<&String> = traces.iter().filter(|line| line.contains(" counts (")).collect();
|
||||
assert_eq!(counts.len(), 2, "the startup scan and the one rescan it asked for: {traces:#?}");
|
||||
assert_eq!(field(counts[0], "conflict"), "1", "{}", counts[0]);
|
||||
assert_eq!(field(counts[0], "rescan_requested"), "1", "{}", counts[0]);
|
||||
assert_eq!(field(counts[1], "conflict"), "0", "the rescan is one whole walk: {}", counts[1]);
|
||||
assert_eq!(
|
||||
field(counts[1], "rescan_requested"),
|
||||
"0",
|
||||
"and it cannot ask for another: {}",
|
||||
counts[1]
|
||||
);
|
||||
|
||||
// What the startup indexed, from the per-file log: the head's spelling,
|
||||
// one copy of `child`, and no `other/link` beside it.
|
||||
let indexed: Vec<String> =
|
||||
log_lines(&messages).into_iter().filter(|line| line.contains("child.sv")).collect();
|
||||
assert_eq!(indexed.len(), 2, "one `child` per scan, never two: {indexed:#?}");
|
||||
assert!(indexed[0].contains("z_real/child.sv"), "the startup's spelling: {}", indexed[0]);
|
||||
assert!(indexed[1].contains("other/link/child.sv"), "the rescan's: {}", indexed[1]);
|
||||
|
||||
// And what the rescan left: the spelling a plain walk of this tree gives,
|
||||
// which is what every later scan and every restart will produce.
|
||||
let said = says(&mut session, &uri);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "`child` is declared once");
|
||||
assert!(
|
||||
said.files.iter().any(|file| file.ends_with("other/link/child.sv")),
|
||||
"the canonical spelling won: {:#?}",
|
||||
said.files
|
||||
);
|
||||
let plain = startup_rescan_and_restart_agree(&tree, &opened, TB);
|
||||
assert_eq!(said, plain, "and it is stable under a rescan and a restart");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_same_named_file_symlink_outside_the_head_is_not_a_second_copy_of_the_buffer() {
|
||||
// QA's (f) on §62.1: the head walk asked `Aliased` about a same-named
|
||||
// file, the remaining walk did not, so a file symlink to the open buffer
|
||||
// living outside its folder was indexed a second time and `tb` was
|
||||
// falsely declared twice. Now both walks ask.
|
||||
let tree = Tree::new("filealias");
|
||||
alias_pair(&tree, "z_real");
|
||||
tree.link("alias_dir/tb.sv", "../z_real/tb.sv");
|
||||
let said = startup_rescan_and_restart_agree(&tree, &tree.path.join("z_real/tb.sv"), TB);
|
||||
assert_eq!(
|
||||
said.files.iter().filter(|file| file.ends_with("tb.sv")).count(),
|
||||
1,
|
||||
"one `tb.sv`, the buffer's: {:#?}",
|
||||
said.files
|
||||
);
|
||||
assert_eq!(said.defs.len(), 1, "one definition target: {:#?}", said.defs);
|
||||
assert!(said.renamable, "`tb` is declared once, whatever the disk spells");
|
||||
assert!(said.diagnostics.is_empty(), "{:#?}", said.diagnostics);
|
||||
}
|
||||
@@ -0,0 +1,794 @@
|
||||
//! Which files a scan will index, how they were found, and what the finding
|
||||
//! cost.
|
||||
//!
|
||||
//! The scope ladder ([`Workspace::source_files`]) and the overlay that lets an
|
||||
//! open buffer beat the disk ([`Workspace::collect_sources`]), lifted out of
|
||||
//! `state/mod.rs` on 2026-09-08 (TODO §61.3) when discovery grew a stage split
|
||||
//! and a second entry point. It answers one question — *which files exist as
|
||||
//! far as this server is concerned, and how big are they* — and every rung of
|
||||
//! the ladder is in this file.
|
||||
//!
|
||||
//! **The size a walked file reports is the walk's own.** `lucisv_core`'s walk
|
||||
//! calls `metadata` on every directory entry to answer "directory?", so the
|
||||
//! length is a field it already holds; asking the filesystem again, once per
|
||||
//! file, was 6.9 ms of a 165 ms discovery over 3 976 files — measured, not
|
||||
//! assumed, and smaller than it looks because the walk has just warmed every
|
||||
//! one of those inodes (`docs/features/perf5r-first-answer/README.md`). A path
|
||||
//! the walk did not stat — a filelist entry, an input named rather than walked
|
||||
//! — carries no length and is stat'd here, exactly as every path used to be.
|
||||
//!
|
||||
//! **And the walk is split in two when it pays to be.** A workspace-scoped
|
||||
//! session with a buffer open walks that buffer's own folders first, so the
|
||||
//! scan can index and publish them before it discovers the other 3 850 files
|
||||
//! ([`Workspace::first_scope`]). One scan, one work list, every file once.
|
||||
//!
|
||||
//! **"Every file once" is a claim about directory identity, not about paths.**
|
||||
//! A symlinked directory gives every file under it a second path, and a walk
|
||||
//! answers that by entering each directory identity once and reporting its
|
||||
//! files under the first spelling that reached it
|
||||
//! (`docs/features/walk-cycles/README.md`). Two walks with two visited sets do
|
||||
//! not have that rule *between* them, which is how the split came to index a
|
||||
//! module twice (`docs/performance_052_review.md` F1). So the two halves share
|
||||
//! one [`DirectoryTracker`]; the head is not led with at all when a walk of the
|
||||
//! root would reach the user's own folder by an earlier name
|
||||
//! ([`Workspace::has_preceding_alias`]); and where only the remaining walk can
|
||||
//! find that out, it says so and the scan asks for one canonical walk
|
||||
//! ([`Scan::wants_rescan`](super::Scan::wants_rescan)).
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use lucisv_core::config::Discovery;
|
||||
use lucisv_core::walk::{
|
||||
collect_files_below_tracked, collect_files_tracked, dir_id, DirectoryTracker, EXTENSIONS,
|
||||
};
|
||||
|
||||
use crate::scan_trace::ScanTrace;
|
||||
|
||||
use super::scan::{Analyzed, HeldAnalyses, IndexEvent, PendingDiscovery, Sources};
|
||||
use super::Workspace;
|
||||
|
||||
/// One in-scope file, and the length whoever found it already knew.
|
||||
///
|
||||
/// `len` is `None` for a path nothing stat'd on the way here — a filelist
|
||||
/// entry, or an input named rather than walked. It is not "unknown size": it
|
||||
/// is "nobody has looked yet", and [`oversize`] is what looks.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(super) struct Found {
|
||||
pub(super) path: PathBuf,
|
||||
pub(super) len: Option<u64>,
|
||||
}
|
||||
|
||||
impl Found {
|
||||
/// A path nothing has stat'd.
|
||||
fn unmeasured(path: PathBuf) -> Found {
|
||||
Found { path, len: None }
|
||||
}
|
||||
|
||||
/// One path on its own, for a caller asking the cap about a single file
|
||||
/// rather than about a walk ([`Workspace::current_text`]).
|
||||
pub(super) fn of(path: &Path) -> Found {
|
||||
Found::unmeasured(path.to_path_buf())
|
||||
}
|
||||
}
|
||||
|
||||
/// What the scope ladder decided: the files to index, the directories an
|
||||
/// `` `include`` in them is looked for in, and what to tell the user.
|
||||
#[derive(Default)]
|
||||
pub(super) struct Scope {
|
||||
pub(super) files: Vec<Found>,
|
||||
/// The filelist's `+incdir+`s, in filelist order. Empty for every rung
|
||||
/// but the filelist — nothing else names an include path.
|
||||
pub(super) incdirs: Vec<PathBuf>,
|
||||
pub(super) warnings: Vec<String>,
|
||||
}
|
||||
|
||||
/// The size of `found` when it is over `cap`, else `None` — the whole of the
|
||||
/// `lucisv.index.maxFileSize` test.
|
||||
///
|
||||
/// Metadata only: the point of the cap is that a 200 MB netlist is never read
|
||||
/// into memory, so knowing how big it is has to come first. A `cap` of 0 is
|
||||
/// the client asking for no cap, and a file whose metadata cannot be read is
|
||||
/// not skipped here — it simply fails the read later, as it always did.
|
||||
///
|
||||
/// `stats` counts the `metadata` calls this one really made, so a session can
|
||||
/// prove the walk's hand-off removed them rather than assert it.
|
||||
pub(super) fn oversize(found: &Found, cap: u64, stats: &mut usize) -> Option<u64> {
|
||||
if cap == 0 {
|
||||
return None;
|
||||
}
|
||||
let size = match found.len {
|
||||
Some(size) => size,
|
||||
None => {
|
||||
*stats += 1;
|
||||
fs::metadata(&found.path).ok()?.len()
|
||||
}
|
||||
};
|
||||
(size > cap).then_some(size)
|
||||
}
|
||||
|
||||
/// The open buffers' files by **identity**, so a walked path that is a second
|
||||
/// spelling of one of them can be recognised and left out.
|
||||
///
|
||||
/// A symlinked directory gives every file under it a second path. The walk
|
||||
/// reports each file under the first spelling that reaches it, which may not be
|
||||
/// the one the buffer was opened by — and an index holding `a_alias/tb.sv` from
|
||||
/// disk beside the open `z_real/tb.sv` holds one module twice and refuses to
|
||||
/// rename it (`docs/features/walk-cycles/README.md`).
|
||||
///
|
||||
/// **The name is the gate, and it is what keeps this free.** A directory alias
|
||||
/// cannot change a file's *name*, so a walked file whose name no open buffer
|
||||
/// shares cannot be one of them and is never stat'd: an ordinary workspace pays
|
||||
/// nothing at all, and one with same-named files pays one `metadata` per
|
||||
/// same-named candidate. A **file**-level symlink under a different name is out
|
||||
/// of scope — two names for one inode that no directory relates, which every
|
||||
/// other part of this server already treats as two files.
|
||||
struct Aliased {
|
||||
/// The names those buffers' files go by — the cheap half of the test.
|
||||
names: HashSet<std::ffi::OsString>,
|
||||
/// Their `(dev, ino)` identities, read once per open buffer rather than
|
||||
/// once per walked file.
|
||||
ids: HashSet<lucisv_core::walk::DirId>,
|
||||
}
|
||||
|
||||
impl Aliased {
|
||||
/// The identities of `paths`, with the names to gate on.
|
||||
fn of(paths: &HashSet<&Path>) -> Aliased {
|
||||
let names = paths.iter().filter_map(|p| p.file_name()).map(|n| n.to_os_string()).collect();
|
||||
let ids = paths.iter().filter_map(|p| dir_id(p)).collect();
|
||||
Aliased { names, ids }
|
||||
}
|
||||
|
||||
/// Whether `path` names a file an open buffer already speaks for, by a
|
||||
/// different spelling. `stats` counts the `metadata` calls it made.
|
||||
fn speaks_for(&self, path: &Path, stats: &mut usize) -> bool {
|
||||
if self.ids.is_empty() {
|
||||
return false;
|
||||
}
|
||||
let Some(name) = path.file_name() else { return false };
|
||||
if !self.names.contains(name) {
|
||||
return false;
|
||||
}
|
||||
*stats += 1;
|
||||
dir_id(path).is_some_and(|id| self.ids.contains(&id))
|
||||
}
|
||||
}
|
||||
|
||||
impl Workspace {
|
||||
/// Resolve the scope: which files are in it, with open buffers overriding
|
||||
/// disk, and those buffers' own text.
|
||||
///
|
||||
/// **Metadata only, plus what is already in memory.** Nothing on disk is
|
||||
/// read here — a file's text is read by whoever indexes or rewrites it,
|
||||
/// one file at a time ([`Workspace::scan_step`], [`Workspace::sources`]).
|
||||
///
|
||||
/// This is where `lucisv.index.maxFileSize` applies, and it applies to the
|
||||
/// **walked** files only: an open buffer is folded in below whatever its
|
||||
/// size, because the user opened it deliberately and an editor that
|
||||
/// refused to understand the file on screen would be absurd. The check is
|
||||
/// the size the walk read, so an oversized file is still never read at all
|
||||
/// — which is the whole saving, and it is still counted and reported here
|
||||
/// so that a scan's skip count is known before its first step.
|
||||
///
|
||||
/// A refactoring reads this same list through `sources()`, so a file the
|
||||
/// cap keeps out of the index is also a file a workspace rename will not
|
||||
/// rewrite. That is the consistent answer: the cap says which files exist
|
||||
/// as far as this server is concerned.
|
||||
pub(super) fn collect_sources(
|
||||
&self,
|
||||
watch: &mut dyn FnMut(IndexEvent),
|
||||
analyses: HeldAnalyses,
|
||||
trace: &mut ScanTrace,
|
||||
) -> Sources {
|
||||
let scope = self.source_files(trace);
|
||||
self.overlay_buffers(scope, watch, analyses, trace)
|
||||
}
|
||||
|
||||
/// [`Workspace::collect_sources`] over one already-resolved scope — the
|
||||
/// cap, then the open buffers over the top.
|
||||
///
|
||||
/// Split out because the two-phase startup resolves the scope twice (the
|
||||
/// user's own folders, then the rest of the workspace) and both halves owe
|
||||
/// the buffers the same precedence.
|
||||
pub(super) fn overlay_buffers(
|
||||
&self,
|
||||
scope: Scope,
|
||||
watch: &mut dyn FnMut(IndexEvent),
|
||||
analyses: HeldAnalyses,
|
||||
trace: &mut ScanTrace,
|
||||
) -> Sources {
|
||||
let cap = self.client.max_file_size;
|
||||
// Every path an open buffer speaks for. Reading such a file from disk
|
||||
// is work thrown away — the buffer's text replaces it below, whatever
|
||||
// the disk says — so the read is skipped rather than undone. The cap is
|
||||
// still consulted first, so an oversized file still reports itself
|
||||
// skipped exactly as it did before the buffer put its own text back.
|
||||
let spoken_for: HashSet<&Path> =
|
||||
self.docs.values().filter_map(|doc| doc.path.as_deref()).collect();
|
||||
// …and every *other* spelling of those same files, which a directory
|
||||
// alias makes and a path comparison cannot see ([`Aliased`]).
|
||||
let aliased = Aliased::of(&spoken_for);
|
||||
let capping = trace.now();
|
||||
let mut stats = 0usize;
|
||||
let mut files: Vec<PathBuf> = Vec::new();
|
||||
for found in scope.files {
|
||||
if let Some(size) = oversize(&found, cap, &mut stats) {
|
||||
watch(IndexEvent::Skipped { path: &found.path, size, cap });
|
||||
continue;
|
||||
}
|
||||
if spoken_for.contains(found.path.as_path()) {
|
||||
continue;
|
||||
}
|
||||
if aliased.speaks_for(&found.path, &mut stats) {
|
||||
continue;
|
||||
}
|
||||
files.push(found.path);
|
||||
}
|
||||
ScanTrace::add(&mut trace.cap_ms, capping);
|
||||
trace.stats += stats;
|
||||
// Open buffers override what is on disk, and contribute themselves
|
||||
// when they are not on disk at all.
|
||||
//
|
||||
// Except a buffer on the large-file fast path, which overrides disk
|
||||
// with *nothing*: indexing it means parsing the hundred megabytes the
|
||||
// fast path exists not to parse. Removing the path rather than leaving
|
||||
// the disk copy in is the honest half of that — the alternative would
|
||||
// be an index describing a file the user is looking at by bytes it no
|
||||
// longer has. See `docs/features/large-file-mode/README.md` for the
|
||||
// interaction with `lucisv.index.maxFileSize`, whose "an open buffer is
|
||||
// never capped" rule this is the one exception to.
|
||||
let buffering = trace.now();
|
||||
let mut analyzed = Analyzed::default();
|
||||
let mut buffered: HashMap<PathBuf, String> = HashMap::new();
|
||||
for doc in self.docs.values() {
|
||||
let Some(path) = doc.path.clone() else { continue };
|
||||
files.retain(|p| p != &path);
|
||||
if !doc.large {
|
||||
if analyses == HeldAnalyses::Wanted {
|
||||
analyzed.facts.insert(path.clone(), doc.facts(path.clone()));
|
||||
analyzed.words.insert(path.clone(), doc.words());
|
||||
}
|
||||
buffered.insert(path.clone(), doc.text.clone());
|
||||
files.push(path);
|
||||
}
|
||||
}
|
||||
ScanTrace::add(&mut trace.buffers_ms, buffering);
|
||||
Sources { files, buffered, analyzed, incdirs: scope.incdirs, warnings: scope.warnings }
|
||||
}
|
||||
|
||||
/// The files the index covers, and what the user should be told about how
|
||||
/// they were chosen. The scope ladder, highest first:
|
||||
///
|
||||
/// 1. **A filelist** — `lucisv.filelist`, else a `filelist` key in the
|
||||
/// config governing a workspace root. It names *exactly* the files to
|
||||
/// index; the project said so, and guessing past it would defeat the
|
||||
/// point of having one. This is the "project file", and it is the one
|
||||
/// rung that is whole-project by definition.
|
||||
/// 2. **The workspace-folder walk**, on `lucisv.index.scope:
|
||||
/// "workspace"` — what every session did before 2026-08-27, now opt-in.
|
||||
/// 3. **The folder scope**, the default: each opened buffer's own
|
||||
/// directory raised `lucisv.index.scopeDepth` levels, walked. See
|
||||
/// `docs/features/index-scope/README.md` for what that costs, which is
|
||||
/// that a definition in another folder does not resolve until the
|
||||
/// scope reaches that folder.
|
||||
///
|
||||
/// A configured filelist that cannot be read falls back to rung 2 (or 3)
|
||||
/// with a warning. An editor that shows no symbols because of a typo in a
|
||||
/// path is worse than one that quietly indexes what it can and says so.
|
||||
///
|
||||
/// Only rung 1 can carry `+incdir+` directories: a walked workspace names
|
||||
/// none, so an `` `include`` there resolves against the including file's
|
||||
/// own directory alone (`docs/features/include-nav/README.md`).
|
||||
pub(super) fn source_files(&self, trace: &mut ScanTrace) -> Scope {
|
||||
// The walk's own warnings join the scope's, so an unreadable directory
|
||||
// reaches the output channel by the road a filelist's problems already
|
||||
// travel — said once per scan and never per keystroke.
|
||||
let mut warnings: Vec<String> = Vec::new();
|
||||
let Some(path) = self.filelist_path() else {
|
||||
let files = self.default_files(&mut |w| warnings.push(w), trace);
|
||||
return Scope { files, warnings, ..Default::default() };
|
||||
};
|
||||
let reading = trace.now();
|
||||
let read = lucisv_core::filelist::read(&path);
|
||||
ScanTrace::add(&mut trace.filelist_ms, reading);
|
||||
match read {
|
||||
Ok(list) => Scope {
|
||||
files: list.files.into_iter().map(Found::unmeasured).collect(),
|
||||
incdirs: list.incdirs,
|
||||
warnings: list.warnings,
|
||||
},
|
||||
Err(problem) => {
|
||||
let files = self.default_files(&mut |w| warnings.push(w), trace);
|
||||
warnings.insert(0, format!("{problem} — indexing the workspace instead"));
|
||||
Scope { files, incdirs: Vec::new(), warnings }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The filelist governing this workspace, if any: the client's setting
|
||||
/// first (absolute, or relative to the first root), else the `filelist`
|
||||
/// key of the config governing a root, in root order.
|
||||
///
|
||||
/// Public because the file watchers must name it: a `.f` edited outside
|
||||
/// the editor changes the index's scope, and nothing else on disk would
|
||||
/// tell us (`docs/features/file-watching/README.md`).
|
||||
pub fn filelist_path(&self) -> Option<PathBuf> {
|
||||
if let Some(setting) = &self.client.filelist {
|
||||
let path = Path::new(setting);
|
||||
return Some(match self.roots.first() {
|
||||
Some(root) if path.is_relative() => root.join(path),
|
||||
_ => path.to_path_buf(),
|
||||
});
|
||||
}
|
||||
let mut discovery = Discovery::new(true);
|
||||
// A broken `lucisv.toml` names no filelist, exactly as it contributes no
|
||||
// excludes below: the user hears about it when they format.
|
||||
self.roots.iter().find_map(|root| discovery.for_dir(root).ok()?.filelist)
|
||||
}
|
||||
|
||||
/// Rungs 2 and 3 of the ladder: the whole-workspace walk when the client
|
||||
/// asked for it, else the folder scope.
|
||||
fn default_files(&self, warn: &mut dyn FnMut(String), trace: &mut ScanTrace) -> Vec<Found> {
|
||||
if self.walks_the_workspace() {
|
||||
return self.walked_files(&self.roots, warn, trace);
|
||||
}
|
||||
self.folder_files(warn, trace)
|
||||
}
|
||||
|
||||
/// Rung 3: the folder scope — [`Workspace::scope_dirs`], walked with every
|
||||
/// filter the workspace walk applies.
|
||||
///
|
||||
/// One exception, kept exactly as it was from before this rung became the
|
||||
/// default: **a rootless session at depth 0 reads its directories flat**,
|
||||
/// one level, no `.gitignore`. That is the "a file opened on its own"
|
||||
/// case, where descending a tree the user never named would be a surprise
|
||||
/// — and the moment the user raises `scopeDepth` they have named one, so
|
||||
/// the walk is what they asked for.
|
||||
fn folder_files(&self, warn: &mut dyn FnMut(String), trace: &mut ScanTrace) -> Vec<Found> {
|
||||
let dirs = self.scope_dirs();
|
||||
if self.roots.is_empty() && self.client.index_scope_depth == 0 {
|
||||
return sibling_files(&dirs, trace);
|
||||
}
|
||||
self.walked_files(&dirs, warn, trace)
|
||||
}
|
||||
|
||||
/// Every source file under `dirs`, found by the CLI's own walk: the same
|
||||
/// extensions, the same `.gitignore` handling, and the `exclude` patterns
|
||||
/// of the config governing each directory. What `lucisv` skips, the index
|
||||
/// skips.
|
||||
///
|
||||
/// `dirs` is the workspace roots for rung 2 and the scope directories for
|
||||
/// rung 3. The one honest difference between the two: `.gitignore` files
|
||||
/// are read from the walk's own starting directory downwards, so a rule
|
||||
/// written in a root's `.gitignore` does not apply to a rung-3 walk that
|
||||
/// starts below it. The `exclude` patterns are matched against whole
|
||||
/// paths and so behave identically either way.
|
||||
pub(super) fn walked_files(
|
||||
&self,
|
||||
dirs: &[PathBuf],
|
||||
warn: &mut dyn FnMut(String),
|
||||
trace: &mut ScanTrace,
|
||||
) -> Vec<Found> {
|
||||
let mut tracker = DirectoryTracker::new();
|
||||
self.walked_files_tracked(dirs, &mut tracker, warn, trace)
|
||||
}
|
||||
|
||||
/// [`Workspace::walked_files`] over an existing [`DirectoryTracker`], so
|
||||
/// two walks of one scan enter each directory identity once between them.
|
||||
pub(super) fn walked_files_tracked(
|
||||
&self,
|
||||
dirs: &[PathBuf],
|
||||
tracker: &mut DirectoryTracker,
|
||||
warn: &mut dyn FnMut(String),
|
||||
trace: &mut ScanTrace,
|
||||
) -> Vec<Found> {
|
||||
let mut discovery = Discovery::new(true);
|
||||
let mut out: Vec<Found> = Vec::new();
|
||||
for root in dirs {
|
||||
// The walk names its inputs as strings; every directory here came
|
||||
// from a `file:` URI, which cannot carry a non-UTF-8 path.
|
||||
let Some(input) = root.to_str() else { continue };
|
||||
// A broken `lucisv.toml` must not stop the server from indexing: an
|
||||
// index that excludes nothing is a far better failure than a
|
||||
// server that comes up empty. The error is reported when the user
|
||||
// formats a file in this tree (`format::settings_for`).
|
||||
let configuring = trace.now();
|
||||
let mut exclude =
|
||||
discovery.for_dir(root).unwrap_or_default().exclude.unwrap_or_default();
|
||||
// The client's `lucisv.exclude` is *appended*, never substituted —
|
||||
// the CLI appends a config's excludes to `--exclude` the same way,
|
||||
// and a setting that silently dropped a checked-in exclude would
|
||||
// put vendored code back in the index for one user only.
|
||||
exclude.extend(self.client.exclude.iter().cloned());
|
||||
ScanTrace::add(&mut trace.config_ms, configuring);
|
||||
// `.gitignore` is always honoured: it is the CLI's default, and an
|
||||
// editor has no `--no-gitignore` to type. An unreadable directory
|
||||
// is skipped and said — the warning rides out on the scope's own
|
||||
// warnings, which `server/notification.rs` logs once per scan.
|
||||
let walking = trace.now();
|
||||
let _ = collect_files_tracked(
|
||||
input,
|
||||
&exclude,
|
||||
true,
|
||||
tracker,
|
||||
&mut |path, len| out.push(Found { path, len }),
|
||||
&mut |w| warn(w.to_string()),
|
||||
);
|
||||
ScanTrace::add(&mut trace.walk_ms, walking);
|
||||
trace.walk_dirs += 1;
|
||||
}
|
||||
let sorting = trace.now();
|
||||
sort_found(&mut out);
|
||||
ScanTrace::add(&mut trace.sort_ms, sorting);
|
||||
out
|
||||
}
|
||||
|
||||
/// The files the directories a widen added bring into scope, by the same
|
||||
/// rules [`Workspace::folder_files`] applies to the whole scope — including
|
||||
/// the rootless-at-depth-0 flat read.
|
||||
pub(super) fn widened_files(
|
||||
&self,
|
||||
added: &[PathBuf],
|
||||
warn: &mut dyn FnMut(String),
|
||||
trace: &mut ScanTrace,
|
||||
) -> Vec<Found> {
|
||||
if self.roots.is_empty() && self.client.index_scope_depth == 0 {
|
||||
return sibling_files(added, trace);
|
||||
}
|
||||
self.walked_files(added, warn, trace)
|
||||
}
|
||||
}
|
||||
|
||||
/// The largest neighbourhood a startup will index before it finds out how big
|
||||
/// the workspace is.
|
||||
///
|
||||
/// The split's whole premise is that the user's own folder is a small part of
|
||||
/// the workspace, so stepping it first costs the rest of the scan nothing a
|
||||
/// user notices. Beyond this many files that premise is not proven — the
|
||||
/// count that would prove it is the walk this order exists to postpone — so
|
||||
/// the walk is finished first and the scan is ordered exactly as it was
|
||||
/// before, `scan_order::worth_waiting` and all.
|
||||
///
|
||||
/// 512 is a measured bound and not a round number: a warm step costs about
|
||||
/// 0.2 ms a file (124 files in 25 ms, `docs/features/perf5-p4/README.md`
|
||||
/// §P4b3), so a head of this size is ~100 ms of stepping and the whole first
|
||||
/// answer still fits inside the round's 200 ms gate.
|
||||
pub(crate) const HEAD_WALK_MAX: usize = 512;
|
||||
|
||||
impl Workspace {
|
||||
/// Whether this scan may walk the user's own folders first and the rest of
|
||||
/// the workspace afterwards.
|
||||
///
|
||||
/// Three conditions, and each of them names a case the split would
|
||||
/// otherwise make *worse*:
|
||||
///
|
||||
/// * **the workspace walk is the rung in force.** It is the only rung
|
||||
/// whose discovery is a walk of everything: a filelist names its files
|
||||
/// and reads in one go, and the folder rung's own scope *is* the
|
||||
/// neighbourhood, so splitting it would put the whole scan in the head.
|
||||
/// * **a buffer is open, in a folder below a workspace root.** With no
|
||||
/// buffer there is no neighbourhood to lead with; with one opened from
|
||||
/// the root itself, the folder it raises to *is* the workspace, which is
|
||||
/// the case `scan_order::worth_waiting` exists for and the case this
|
||||
/// returns `false` for so that rule still decides it.
|
||||
/// * **the walk finds a small enough neighbourhood** — checked by the
|
||||
/// caller once the folders are walked, against [`HEAD_WALK_MAX`].
|
||||
/// * **it is the session's first scan** — checked by the caller, which is
|
||||
/// the only one that knows the scan number.
|
||||
pub(super) fn splits_discovery(&self) -> bool {
|
||||
if !self.leads_with_a_folder() {
|
||||
return false;
|
||||
}
|
||||
let dirs = self.raised_dirs();
|
||||
!dirs.is_empty() && dirs.iter().all(|dir| self.below_a_root(dir))
|
||||
}
|
||||
|
||||
/// Whether a scan of this workspace would lead with the user's own folder
|
||||
/// if it knew one — the rung half of [`Workspace::splits_discovery`],
|
||||
/// asked on its own by the startup that waits a bounded moment to be told
|
||||
/// which folder that is (`server/startup.rs`).
|
||||
pub fn leads_with_a_folder(&self) -> bool {
|
||||
self.walks_the_workspace()
|
||||
}
|
||||
|
||||
/// Whether `dir` is a **strict** descendant of some workspace root.
|
||||
///
|
||||
/// A directory that *is* a root is the whole of that root's walk, so
|
||||
/// leading with it is leading with everything.
|
||||
fn below_a_root(&self, dir: &Path) -> bool {
|
||||
self.roots.iter().any(|root| dir.starts_with(root) && dir != root)
|
||||
}
|
||||
|
||||
/// What a whole scan starts from: its scope, and whatever of that scope is
|
||||
/// still to be walked.
|
||||
///
|
||||
/// `None` for the second half means what it has always meant — the scope
|
||||
/// was resolved entire before the first file was indexed, and the work
|
||||
/// list the caller gets is the whole of it. `Some` means the caller is
|
||||
/// holding the user's own folders and owes itself the rest of the
|
||||
/// workspace once it has published them ([`PendingDiscovery`]).
|
||||
pub(super) fn first_scope(
|
||||
&self,
|
||||
watch: &mut dyn FnMut(IndexEvent),
|
||||
trace: &mut ScanTrace,
|
||||
) -> (Sources, Option<PendingDiscovery>) {
|
||||
// **The session's first scan only.** Every later whole rescan is one a
|
||||
// message asked for, and `must_wait`'s `answering_a_rescan` holds every
|
||||
// request for the whole of it — so leading with a folder buys no answer
|
||||
// any sooner and costs the neighbourhood one extra directory
|
||||
// traversal. The startup scan is the one nothing is queued ahead of,
|
||||
// and it is the one this order is for
|
||||
// (`docs/features/perf5r-first-answer/README.md`).
|
||||
if trace.number > 1 || !self.splits_discovery() {
|
||||
return (self.collect_sources(watch, HeldAnalyses::Wanted, trace), None);
|
||||
}
|
||||
// A directory alias that a root walk would reach *before* the folder
|
||||
// the head would lead with: leading with it would spell those files a
|
||||
// way no other scan of this workspace ever does
|
||||
// ([`Workspace::has_preceding_alias`]). The whole scope, walked once,
|
||||
// is the answer — a millisecond on a fixture and ~155 ms on
|
||||
// opentitan, and only for a session whose own folder is aliased.
|
||||
for dir in self.raised_dirs() {
|
||||
if let Some(root) = self.deepest_root(&dir) {
|
||||
if self.has_preceding_alias(&root, &dir) {
|
||||
return (self.collect_sources(watch, HeldAnalyses::Wanted, trace), None);
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut warnings: Vec<String> = Vec::new();
|
||||
let mut tracker = DirectoryTracker::new();
|
||||
let head = self.neighbourhood_files(&mut tracker, &mut |w| warnings.push(w), trace);
|
||||
if head.len() > HEAD_WALK_MAX {
|
||||
// Too big to lead with unproven. The head is **discarded** and the
|
||||
// whole scope walked once, ordered the way every scan before this
|
||||
// one was: keeping it and walking the rest beside it would union
|
||||
// two walks that never agreed on a directory's spelling, which is
|
||||
// the very thing the tracker exists to prevent.
|
||||
return (self.collect_sources(watch, HeldAnalyses::Wanted, trace), None);
|
||||
}
|
||||
// Every path the neighbourhood walk named, before the cap has had a
|
||||
// say: what the remaining walk must not decide about a second time.
|
||||
let mut seen: HashSet<PathBuf> = head.iter().map(|found| found.path.clone()).collect();
|
||||
seen.extend(self.docs.values().filter_map(|doc| doc.path.clone()));
|
||||
let scope = Scope { files: head, incdirs: Vec::new(), warnings };
|
||||
let sources = self.overlay_buffers(scope, watch, HeldAnalyses::Wanted, trace);
|
||||
(sources, Some(PendingDiscovery { roots: self.roots.clone(), seen, tracker }))
|
||||
}
|
||||
|
||||
/// Whether some directory between `root` and `dir` holds a **second
|
||||
/// spelling** of `dir` or of one of its ancestors that a walk of `root`
|
||||
/// would reach *first*.
|
||||
///
|
||||
/// The one case the split cannot lead with. A walk of the root reports
|
||||
/// each directory under the first path that reaches it, in name order, so
|
||||
/// with `a_alias -> z_real` the whole of `z_real` is spelled `a_alias/…`;
|
||||
/// a head walk starting at `z_real` would spell it `z_real/…` and the two
|
||||
/// halves of one scan would disagree with each other and with every later
|
||||
/// rescan. Asked before the head is walked, so the answer is a *fallback*
|
||||
/// to the single canonical walk and never a repair afterwards.
|
||||
///
|
||||
/// **It reads directories and stats symlinks only.** The chain from a
|
||||
/// buffer's folder to the root is a handful of directories (four on
|
||||
/// opentitan, ~150 entries between them); `read_dir` already carries each
|
||||
/// entry's kind, so an ordinary tree costs no `metadata` at all.
|
||||
fn has_preceding_alias(&self, root: &Path, dir: &Path) -> bool {
|
||||
let targets = identities_to(root, dir);
|
||||
!targets.is_empty()
|
||||
&& ancestors_to(root, dir).into_iter().any(|up| precedes_a_target(up, &targets))
|
||||
}
|
||||
|
||||
/// The user's own neighbourhood, walked: every source file under the
|
||||
/// folders the open buffers raise to, **as the walk of the workspace root
|
||||
/// would have found them**.
|
||||
///
|
||||
/// `collect_files_below` rather than `collect_files_with` is the whole of
|
||||
/// that "as": a walk starting at `hw/ip/aes` reads no `.gitignore` above
|
||||
/// itself, and the rung in force here is the *root's*, so the folder half
|
||||
/// of one scope must obey the same rules the other half does. Without it
|
||||
/// the head would index files the rest of the scan excludes, and the two
|
||||
/// halves of one scan would disagree about which files exist.
|
||||
fn neighbourhood_files(
|
||||
&self,
|
||||
tracker: &mut DirectoryTracker,
|
||||
warn: &mut dyn FnMut(String),
|
||||
trace: &mut ScanTrace,
|
||||
) -> Vec<Found> {
|
||||
let mut discovery = Discovery::new(true);
|
||||
let mut out: Vec<Found> = Vec::new();
|
||||
for dir in self.raised_dirs() {
|
||||
// The root this folder was raised inside: the deepest one that
|
||||
// contains it, which is the one `Workspace::raised` clamped to.
|
||||
let Some(root) = self.deepest_root(&dir) else { continue };
|
||||
let configuring = trace.now();
|
||||
let mut exclude =
|
||||
discovery.for_dir(&root).unwrap_or_default().exclude.unwrap_or_default();
|
||||
exclude.extend(self.client.exclude.iter().cloned());
|
||||
ScanTrace::add(&mut trace.config_ms, configuring);
|
||||
let walking = trace.now();
|
||||
let _ = collect_files_below_tracked(
|
||||
&root,
|
||||
&dir,
|
||||
&exclude,
|
||||
true,
|
||||
tracker,
|
||||
&mut |path, len| out.push(Found { path, len }),
|
||||
&mut |w| warn(w.to_string()),
|
||||
);
|
||||
ScanTrace::add(&mut trace.walk_ms, walking);
|
||||
trace.walk_dirs += 1;
|
||||
}
|
||||
let sorting = trace.now();
|
||||
sort_found(&mut out);
|
||||
ScanTrace::add(&mut trace.sort_ms, sorting);
|
||||
out
|
||||
}
|
||||
|
||||
/// The deepest workspace root containing `dir` — the one
|
||||
/// [`Workspace::raised`] clamped the raise to, and so the one whose walk
|
||||
/// this folder is part of.
|
||||
fn deepest_root(&self, dir: &Path) -> Option<PathBuf> {
|
||||
self.roots
|
||||
.iter()
|
||||
.filter(|root| dir.starts_with(root))
|
||||
.max_by_key(|root| root.components().count())
|
||||
.cloned()
|
||||
}
|
||||
|
||||
/// The rest of the workspace: everything the roots hold that `seen` does
|
||||
/// not already name, capped and reported exactly as the neighbourhood was.
|
||||
///
|
||||
/// Returns the files to index, what the walk wants said, and how many the
|
||||
/// cap kept out. Open buffers are **not** folded in again — they were
|
||||
/// folded into the head, and a buffer's path is in `pending.seen`.
|
||||
///
|
||||
/// **It walks with the head's own directory identities.** The tracker is
|
||||
/// the one the neighbourhood filled, so a directory the head already
|
||||
/// entered is not entered again under an alias and no file is discovered
|
||||
/// twice. Where this walk reaches such a directory under a spelling the
|
||||
/// root walk would have *preferred*, the tracker says so
|
||||
/// ([`DirectoryTracker::has_conflict`]) and the caller asks for one
|
||||
/// ordinary rescan, which is that root walk.
|
||||
pub(super) fn rest_of_scope(
|
||||
&self,
|
||||
pending: &mut PendingDiscovery,
|
||||
watch: &mut dyn FnMut(IndexEvent),
|
||||
trace: &mut ScanTrace,
|
||||
) -> (Vec<PathBuf>, Vec<String>, usize) {
|
||||
let (roots, seen) = (&pending.roots, &pending.seen);
|
||||
let mut warnings: Vec<String> = Vec::new();
|
||||
let walked = self.walked_files_tracked(
|
||||
roots,
|
||||
&mut pending.tracker,
|
||||
&mut |w| warnings.push(w),
|
||||
trace,
|
||||
);
|
||||
// The same gate the neighbourhood applied: a file an open buffer
|
||||
// already speaks for, reached here by **another** spelling (a
|
||||
// same-named file symlink outside the head), must not be indexed a
|
||||
// second time. The buffer's own spelling is not an alias — a buffer
|
||||
// opened mid-scan is discovered here for the first time and must land
|
||||
// in the work list — so the gate is asked only about other paths.
|
||||
// Found by QA on §62.1, twice: the head walk had the gate and this walk
|
||||
// did not; then the gate matched a mid-scan buffer against itself.
|
||||
let spoken_for: HashSet<&Path> =
|
||||
self.docs.values().filter_map(|doc| doc.path.as_deref()).collect();
|
||||
let aliased = Aliased::of(&spoken_for);
|
||||
let cap = self.client.max_file_size;
|
||||
let capping = trace.now();
|
||||
let mut stats = 0usize;
|
||||
let mut skipped = 0usize;
|
||||
let mut files: Vec<PathBuf> = Vec::new();
|
||||
for found in walked {
|
||||
// Already decided about by the neighbourhood: indexed, capped out,
|
||||
// or spoken for by an open buffer. Deciding again would step a
|
||||
// file twice or report one skip as two.
|
||||
let another_spelling = !spoken_for.contains(found.path.as_path());
|
||||
if seen.contains(&found.path)
|
||||
|| (another_spelling && aliased.speaks_for(&found.path, &mut stats))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if let Some(size) = oversize(&found, cap, &mut stats) {
|
||||
watch(IndexEvent::Skipped { path: &found.path, size, cap });
|
||||
skipped += 1;
|
||||
continue;
|
||||
}
|
||||
files.push(found.path);
|
||||
}
|
||||
ScanTrace::add(&mut trace.cap_ms, capping);
|
||||
trace.stats += stats;
|
||||
(files, warnings, skipped)
|
||||
}
|
||||
}
|
||||
|
||||
/// The identity of `dir` and of every directory between it and `root` — what
|
||||
/// a second spelling would have to name to matter ([`Workspace::has_preceding_alias`]).
|
||||
///
|
||||
/// `root` itself is not among them: a walk of the root enters it before it
|
||||
/// reads anything, so nothing it holds can precede it.
|
||||
fn identities_to(root: &Path, dir: &Path) -> Vec<(lucisv_core::walk::DirId, PathBuf)> {
|
||||
let mut out = Vec::new();
|
||||
let mut at = dir;
|
||||
while at != root {
|
||||
if let Some(id) = dir_id(at) {
|
||||
out.push((id, at.to_path_buf()));
|
||||
}
|
||||
let Some(parent) = at.parent() else { break };
|
||||
at = parent;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The directories a walk of `root` reads on its way down to `dir`: its
|
||||
/// parent, that one's parent, and so on up to and including `root`.
|
||||
fn ancestors_to<'a>(root: &'a Path, dir: &'a Path) -> Vec<&'a Path> {
|
||||
let mut out = Vec::new();
|
||||
let mut at = dir.parent();
|
||||
while let Some(parent) = at {
|
||||
out.push(parent);
|
||||
if parent == root {
|
||||
break;
|
||||
}
|
||||
at = parent.parent();
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Whether `dir` holds a symlink to one of `targets` under a name that sorts
|
||||
/// before the target's own path — the entry a root walk would follow first.
|
||||
fn precedes_a_target(dir: &Path, targets: &[(lucisv_core::walk::DirId, PathBuf)]) -> bool {
|
||||
let Ok(entries) = fs::read_dir(dir) else { return false };
|
||||
entries.flatten().any(|entry| {
|
||||
// Only a symlink can be a second spelling of a directory, and the kind
|
||||
// is the one `read_dir` already read — so the stat below happens once
|
||||
// per link in the chain and never once per entry.
|
||||
if !entry.file_type().is_ok_and(|kind| kind.is_symlink()) {
|
||||
return false;
|
||||
}
|
||||
let path = entry.path();
|
||||
let Some(id) = dir_id(&path) else { return false };
|
||||
targets.iter().any(|(target, spelling)| id == *target && path < *spelling)
|
||||
})
|
||||
}
|
||||
|
||||
/// Path order, one entry per path — what the walk's callers have always done
|
||||
/// with the paths of several overlapping directory walks.
|
||||
///
|
||||
/// The first entry for a path wins, which matters only for the length beside
|
||||
/// it, and two walks that found the same file read the same `metadata` for it.
|
||||
pub(super) fn sort_found(found: &mut Vec<Found>) {
|
||||
found.sort_by(|a, b| a.path.cmp(&b.path));
|
||||
found.dedup_by(|a, b| a.path == b.path);
|
||||
}
|
||||
|
||||
/// The source files sitting in each of `dirs`, one directory deep. No walk, no
|
||||
/// `.gitignore`: this is the rootless default, where descending a tree the
|
||||
/// user never named would be a surprise.
|
||||
fn sibling_files(dirs: &[PathBuf], trace: &mut ScanTrace) -> Vec<Found> {
|
||||
let walking = trace.now();
|
||||
let mut out: Vec<Found> = Vec::new();
|
||||
for dir in dirs {
|
||||
let Ok(entries) = fs::read_dir(dir) else { continue };
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
let extension = path.extension().and_then(|e| e.to_str()).unwrap_or_default();
|
||||
if !EXTENSIONS.contains(&extension) {
|
||||
continue;
|
||||
}
|
||||
// One `metadata` — the same call `is_file()` was, with the length
|
||||
// it always had kept rather than thrown away. It follows symlinks,
|
||||
// exactly as `is_file()` did.
|
||||
let Ok(meta) = fs::metadata(&path) else { continue };
|
||||
if meta.is_file() {
|
||||
out.push(Found { path, len: Some(meta.len()) });
|
||||
}
|
||||
}
|
||||
}
|
||||
ScanTrace::add(&mut trace.walk_ms, walking);
|
||||
trace.walk_dirs += dirs.len();
|
||||
let sorting = trace.now();
|
||||
sort_found(&mut out);
|
||||
ScanTrace::add(&mut trace.sort_ms, sorting);
|
||||
out
|
||||
}
|
||||
@@ -20,9 +20,6 @@ use vlog_semantic::{
|
||||
WorkspaceIndex,
|
||||
};
|
||||
|
||||
use lucisv_core::config::Discovery;
|
||||
use lucisv_core::walk::{collect_files, EXTENSIONS};
|
||||
|
||||
use crate::candidates::Candidates;
|
||||
use crate::convert::Positions;
|
||||
use crate::includes::{self, IncludeGraph};
|
||||
@@ -31,11 +28,13 @@ use crate::module_select::{self, Reach};
|
||||
use crate::rename_trace::{self, Rung, SelectionTrace, Wanted};
|
||||
use crate::scan_order::{self, WorkList};
|
||||
|
||||
pub(crate) mod discover;
|
||||
mod scan;
|
||||
|
||||
use crate::scan_trace::{CacheWork, ScanTrace};
|
||||
use crate::settings::{ClientSettings, IndexScope};
|
||||
use crate::uri::uri_to_path;
|
||||
use discover::{oversize, Found};
|
||||
use scan::{Analyzed, HeldAnalyses, ScanKind, Sources};
|
||||
pub use scan::{IndexEvent, Scan};
|
||||
|
||||
@@ -105,6 +104,14 @@ pub struct Document {
|
||||
/// [`crate::fences::of`], which is the only thing that may touch it; it
|
||||
/// is bound to this revision because a change builds a new `Document`.
|
||||
pub fences: std::sync::OnceLock<Vec<vlog_formatter::fence::Region>>,
|
||||
/// This buffer's lint findings, kept while every input that produced them
|
||||
/// is unchanged — read by the diagnostics pass and by quick-fix discovery
|
||||
/// alike, so one revision is linted once rather than twice (review round
|
||||
/// §R1a, `crate::lint_snapshot`). Bound to this revision for the same
|
||||
/// structural reason `fences` is; the inputs that can move *without* a new
|
||||
/// `Document` are the snapshot's own key, and the index moving is
|
||||
/// [`Document::refresh_overlay`], which clears it.
|
||||
pub lint: crate::lint_snapshot::Slot,
|
||||
}
|
||||
|
||||
impl Document {
|
||||
@@ -115,17 +122,19 @@ impl Document {
|
||||
// `tokenize` + `parse_tolerant`, so the tree is identical). A buffer
|
||||
// that does not lex keeps the old path, so its all-error tree and its
|
||||
// lex diagnostic are byte-for-byte what they always were.
|
||||
let (tokens, (tree, diagnostics)) = match tokenize(&text) {
|
||||
use crate::lint_trace::{rebuild, Rebuild};
|
||||
crate::lint_trace::saw_document();
|
||||
let (tokens, (tree, diagnostics)) = match rebuild(Rebuild::Lex, || tokenize(&text)) {
|
||||
Ok(tokens) => {
|
||||
let parsed = parse_tolerant(tokens.clone(), &text);
|
||||
let parsed = rebuild(Rebuild::Parse, || parse_tolerant(tokens.clone(), &text));
|
||||
(tokens, parsed)
|
||||
}
|
||||
Err(_) => (Vec::new(), parse_source_tolerant(&text)),
|
||||
Err(_) => (Vec::new(), rebuild(Rebuild::Parse, || parse_source_tolerant(&text))),
|
||||
};
|
||||
let defines = collect_defines(&tokens);
|
||||
let semantics = analyze(&tree, &text);
|
||||
let external = resolve_external(&semantics, index);
|
||||
let line_index = LineIndex::new(&text);
|
||||
let defines = rebuild(Rebuild::Defines, || collect_defines(&tokens));
|
||||
let semantics = rebuild(Rebuild::Analyze, || analyze(&tree, &text));
|
||||
let external = rebuild(Rebuild::External, || resolve_external(&semantics, index));
|
||||
let line_index = rebuild(Rebuild::Lines, || LineIndex::new(&text));
|
||||
let large = false;
|
||||
Document {
|
||||
path,
|
||||
@@ -139,6 +148,7 @@ impl Document {
|
||||
external,
|
||||
large,
|
||||
fences: std::sync::OnceLock::new(),
|
||||
lint: crate::lint_snapshot::Slot::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +175,7 @@ impl Document {
|
||||
external: ExternalResolutions::default(),
|
||||
large: true,
|
||||
fences: std::sync::OnceLock::new(),
|
||||
lint: crate::lint_snapshot::Slot::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +195,12 @@ impl Document {
|
||||
/// single-file analysis is unaffected by other files, by construction.
|
||||
pub fn refresh_overlay(&mut self, index: &WorkspaceIndex) {
|
||||
self.external = resolve_external(&self.semantics, index);
|
||||
// The index is what the census oracle answers from, so a lint result
|
||||
// taken under the old one is no longer this buffer's answer. This is
|
||||
// the whole of the snapshot's index invalidation: every mutation of
|
||||
// `Workspace::index` ends in the loop that calls this, so there is no
|
||||
// generation counter to keep in step (review round §R1a).
|
||||
self.lint.clear();
|
||||
}
|
||||
|
||||
/// What this buffer contributes to the workspace index, read off the
|
||||
@@ -273,33 +290,6 @@ pub fn mixed_buffer(blocks: usize) -> String {
|
||||
src
|
||||
}
|
||||
|
||||
/// What the scope ladder decided: the files to index, the directories an
|
||||
/// `` `include`` in them is looked for in, and what to tell the user.
|
||||
#[derive(Default)]
|
||||
struct Scope {
|
||||
files: Vec<PathBuf>,
|
||||
/// The filelist's `+incdir+`s, in filelist order. Empty for every rung
|
||||
/// but the filelist — nothing else names an include path.
|
||||
incdirs: Vec<PathBuf>,
|
||||
warnings: Vec<String>,
|
||||
}
|
||||
|
||||
/// The size of `path` when it is over `cap`, else `None` — the whole of the
|
||||
/// `lucisv.index.maxFileSize` test.
|
||||
///
|
||||
/// Metadata only: the point of the cap is that a 200 MB netlist is never read
|
||||
/// into memory, so asking the filesystem how big it is has to come first. A
|
||||
/// `cap` of 0 is the client asking for no cap, and a file whose metadata
|
||||
/// cannot be read is not skipped here — it simply fails the read below, as it
|
||||
/// always did.
|
||||
fn oversize(path: &Path, cap: u64) -> Option<u64> {
|
||||
if cap == 0 {
|
||||
return None;
|
||||
}
|
||||
let size = fs::metadata(path).ok()?.len();
|
||||
(size > cap).then_some(size)
|
||||
}
|
||||
|
||||
/// How many bytes of buffer text a scan carries for its whole life — every
|
||||
/// other file's text lives from its own step to the end of that step.
|
||||
fn held_bytes(buffered: &HashMap<PathBuf, String>) -> usize {
|
||||
@@ -486,6 +476,22 @@ impl Workspace {
|
||||
&self.index
|
||||
}
|
||||
|
||||
/// The index record this workspace already holds for **exactly these
|
||||
/// bytes**, or nothing.
|
||||
///
|
||||
/// What `vlog_refactor::KnownFacts` asks a refactoring's caller. Exactly
|
||||
/// one thing in this server can promise it: the persistent index cache
|
||||
/// files each record under the FNV-1a of the bytes it was read off, so
|
||||
/// record and key are one store entry written by one read
|
||||
/// ([`crate::index_cache::IndexCache::facts_now`]). Not a modified time,
|
||||
/// not a size, and **not the workspace index's own record**, which carries
|
||||
/// no hash of the text it came from. An unsaved buffer misses for the same
|
||||
/// reason a changed file does, so precedence needs no rule here
|
||||
/// (`docs/features/perf5r-scope-reuse/README.md`).
|
||||
pub fn known_facts(&self, path: &Path, text: &str) -> Option<FileFacts> {
|
||||
self.cache.facts_now(path, text)
|
||||
}
|
||||
|
||||
/// The project-wide completion tables, as of the last index rebuild.
|
||||
pub fn candidates(&self) -> &Candidates {
|
||||
&self.candidates
|
||||
@@ -823,17 +829,18 @@ impl Workspace {
|
||||
self.views.borrow_mut().clear();
|
||||
let discovering = trace.now();
|
||||
let mut skipped = 0usize;
|
||||
let mut scope = {
|
||||
// The cap's skips are reported by `collect_sources` and counted
|
||||
// here, because the end message names them and the scan is what
|
||||
// owns that number now.
|
||||
let mut counting = |event: IndexEvent<'_>| {
|
||||
if matches!(event, IndexEvent::Skipped { .. }) {
|
||||
skipped += 1;
|
||||
}
|
||||
watch(event);
|
||||
};
|
||||
self.collect_sources(&mut counting, HeldAnalyses::Wanted)
|
||||
// The cap's skips are reported by `collect_sources` and counted here,
|
||||
// because the end message names them and the scan is what owns that
|
||||
// number now.
|
||||
let mut counting = |event: IndexEvent<'_>, skipped: &mut usize| {
|
||||
if matches!(event, IndexEvent::Skipped { .. }) {
|
||||
*skipped += 1;
|
||||
}
|
||||
watch(event);
|
||||
};
|
||||
let (mut scope, pending) = {
|
||||
let mut count = |event: IndexEvent<'_>| counting(event, &mut skipped);
|
||||
self.first_scope(&mut count, &mut trace)
|
||||
};
|
||||
ScanTrace::add(&mut trace.discovery_ms, discovering);
|
||||
let buffered = std::mem::take(&mut scope.buffered);
|
||||
@@ -842,7 +849,15 @@ impl Workspace {
|
||||
// The same list the index will be built from, with the user's own
|
||||
// neighbourhood moved to the front of it.
|
||||
let WorkList { files: work, head } = self.open_first(std::mem::take(&mut scope.files));
|
||||
let head = scan_order::worth_waiting(head, work.len());
|
||||
// A scan that has not walked the whole workspace yet cannot ask
|
||||
// whether its head is a minority of it — the count that would answer
|
||||
// is the walk it is postponing. `splits_discovery` is what bounds the
|
||||
// head instead, and it refuses exactly the case `worth_waiting`
|
||||
// refuses: a buffer whose folder is the workspace.
|
||||
let head = match pending.is_some() {
|
||||
true => head,
|
||||
false => scan_order::worth_waiting(head, work.len()),
|
||||
};
|
||||
let paths = work.clone();
|
||||
ScanTrace::add(&mut trace.order_ms, ordering);
|
||||
// Re-opened rather than held across rescans: the directory it belongs
|
||||
@@ -865,6 +880,7 @@ impl Workspace {
|
||||
incdirs: scope.incdirs,
|
||||
warnings: scope.warnings,
|
||||
at: 0,
|
||||
pending,
|
||||
staged: Vec::new(),
|
||||
staged_at: Vec::new(),
|
||||
words: HashMap::new(),
|
||||
@@ -874,6 +890,40 @@ impl Workspace {
|
||||
}
|
||||
}
|
||||
|
||||
/// Walk the rest of the workspace, once the user's own neighbourhood has
|
||||
/// been indexed and published — the second half of a split discovery
|
||||
/// ([`PendingDiscovery`]). Reports whether there was anything to walk.
|
||||
///
|
||||
/// **Its own step, indexing nothing.** The step it shares a call with
|
||||
/// would otherwise report a file against a denominator that grew inside
|
||||
/// the same call, and a bar whose percentage falls is worse than one that
|
||||
/// waits (`docs/features/indexing-ux/README.md`). So this discovers, says
|
||||
/// "there is more", and lets the next step be an ordinary one.
|
||||
fn discover_the_rest(&mut self, scan: &mut Scan, watch: &mut dyn FnMut(IndexEvent)) -> bool {
|
||||
let Some(mut pending) = scan.take_pending() else { return false };
|
||||
let discovering = scan.trace.now();
|
||||
let mut skipped = 0usize;
|
||||
let (files, warnings, walked_skips) = {
|
||||
let mut counting = |event: IndexEvent<'_>| {
|
||||
if matches!(event, IndexEvent::Skipped { .. }) {
|
||||
skipped += 1;
|
||||
}
|
||||
watch(event);
|
||||
};
|
||||
self.rest_of_scope(&mut pending, &mut counting, &mut scan.trace)
|
||||
};
|
||||
debug_assert_eq!(skipped, walked_skips, "the cap reports every skip it counts");
|
||||
ScanTrace::add(&mut scan.trace.discovery_ms, discovering);
|
||||
scan.land_discovery(files, warnings, walked_skips, pending.tracker.has_conflict());
|
||||
scan.trace.measure_work(
|
||||
scan.work.len(),
|
||||
held_bytes(&scan.buffered),
|
||||
scan.skipped,
|
||||
scan.trace.cache,
|
||||
);
|
||||
true
|
||||
}
|
||||
|
||||
/// Open the store a whole rescan asked for, if this is the first thing to
|
||||
/// need it ([`StoreOpen`]).
|
||||
///
|
||||
@@ -943,14 +993,16 @@ impl Workspace {
|
||||
// `folder_files` follows — the whole scope is the union of these walks,
|
||||
// so the files this one finds beyond what is already indexed are
|
||||
// exactly the ones the widen owes.
|
||||
for path in self.widened_files(added, &mut |w| warnings.push(w)) {
|
||||
let mut stats = 0usize;
|
||||
for found in self.widened_files(added, &mut |w| warnings.push(w), &mut trace) {
|
||||
let path = found.path.clone();
|
||||
// Already indexed: by another scope directory this walk overlaps,
|
||||
// or by an earlier scan. Re-reading it is the cost this path
|
||||
// exists to avoid.
|
||||
if held.contains(&path) {
|
||||
continue;
|
||||
}
|
||||
if let Some(size) = oversize(&path, cap) {
|
||||
if let Some(size) = oversize(&found, cap, &mut stats) {
|
||||
watch(IndexEvent::Skipped { path: &path, size, cap });
|
||||
skipped += 1;
|
||||
continue;
|
||||
@@ -1017,6 +1069,9 @@ impl Workspace {
|
||||
// buffer can widen — so the only warnings here are the walk's own.
|
||||
warnings,
|
||||
at: 0,
|
||||
// A widen names the directories it is about to walk, so there is
|
||||
// never anything left to discover.
|
||||
pending: None,
|
||||
staged: Vec::new(),
|
||||
staged_at: Vec::new(),
|
||||
words: HashMap::new(),
|
||||
@@ -1026,16 +1081,6 @@ impl Workspace {
|
||||
}
|
||||
}
|
||||
|
||||
/// The files the directories a widen added bring into scope, by the same
|
||||
/// rules [`Workspace::folder_files`] applies to the whole scope — including
|
||||
/// the rootless-at-depth-0 flat read.
|
||||
fn widened_files(&self, added: &[PathBuf], warn: &mut dyn FnMut(String)) -> Vec<PathBuf> {
|
||||
if self.roots.is_empty() && self.client.index_scope_depth == 0 {
|
||||
return sibling_files(added);
|
||||
}
|
||||
self.walked_files(added, warn)
|
||||
}
|
||||
|
||||
/// Index the next file of `scan`, reporting whether there was one.
|
||||
///
|
||||
/// One file is the whole step: **its text is read**, its record is taken —
|
||||
@@ -1059,7 +1104,7 @@ impl Workspace {
|
||||
pub fn scan_step(&mut self, scan: &mut Scan, watch: &mut dyn FnMut(IndexEvent)) -> bool {
|
||||
let (done, total) = (scan.at, scan.work.len());
|
||||
if done == total {
|
||||
return false;
|
||||
return self.discover_the_rest(scan, watch);
|
||||
}
|
||||
scan.at += 1;
|
||||
// The first file of a scan is the first thing to ask the store
|
||||
@@ -1463,7 +1508,7 @@ impl Workspace {
|
||||
// exists to skip.
|
||||
return (!doc.large).then(|| doc.text.clone());
|
||||
}
|
||||
if oversize(path, self.client.max_file_size).is_some() {
|
||||
if oversize(&Found::of(path), self.client.max_file_size, &mut 0).is_some() {
|
||||
return None;
|
||||
}
|
||||
fs::read_to_string(path).ok()
|
||||
@@ -1490,7 +1535,16 @@ impl Workspace {
|
||||
/// buffer is installed and the folder it raises to is known. What was
|
||||
/// already indexed is untouched; only the tail moves, and the finished
|
||||
/// index cannot tell ([`Scan::reorder`]).
|
||||
pub fn open_next(&self, scan: &mut Scan) {
|
||||
/// **The rest of the workspace is walked first when it has not been.** A
|
||||
/// split startup is leading with the folder the user *was* in; a `didOpen`
|
||||
/// says they are somewhere else now, and re-ordering a work list that does
|
||||
/// not yet contain the new folder would answer the request behind that
|
||||
/// `didOpen` off a prefix that cannot hold what it is asking about. The
|
||||
/// walk this order postpones is exactly what makes the new folder
|
||||
/// nameable, so it happens here
|
||||
/// (`docs/features/perf5r-first-answer/README.md`).
|
||||
pub fn open_next(&mut self, scan: &mut Scan, watch: &mut dyn FnMut(IndexEvent)) {
|
||||
self.discover_the_rest(scan, watch);
|
||||
let ordered = self.open_first(scan.remaining());
|
||||
scan.reorder(ordered);
|
||||
}
|
||||
@@ -1528,7 +1582,7 @@ impl Workspace {
|
||||
/// did when `collect_sources` read them all.
|
||||
pub fn sources(&self) -> Vec<(PathBuf, String)> {
|
||||
let Sources { files, mut buffered, .. } =
|
||||
self.collect_sources(&mut |_| {}, HeldAnalyses::Unused);
|
||||
self.collect_sources(&mut |_| {}, HeldAnalyses::Unused, &mut ScanTrace::new(false));
|
||||
files
|
||||
.into_iter()
|
||||
.filter_map(|path| {
|
||||
@@ -1850,78 +1904,6 @@ impl Workspace {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Resolve the scope: which files are in it, with open buffers overriding
|
||||
/// disk, and those buffers' own text.
|
||||
///
|
||||
/// **Metadata only, plus what is already in memory.** Nothing on disk is
|
||||
/// read here — a file's text is read by whoever indexes or rewrites it,
|
||||
/// one file at a time ([`Workspace::scan_step`], [`Workspace::sources`]).
|
||||
///
|
||||
/// This is where `lucisv.index.maxFileSize` applies, and it applies to the
|
||||
/// **walked** files only: an open buffer is folded in below whatever its
|
||||
/// size, because the user opened it deliberately and an editor that
|
||||
/// refused to understand the file on screen would be absurd. The check is
|
||||
/// a `metadata` call, so an oversized file is still never read at all —
|
||||
/// which is the whole saving, and it is still counted and reported here
|
||||
/// so that a scan's skip count is known before its first step.
|
||||
///
|
||||
/// A refactoring reads this same list through `sources()`, so a file the
|
||||
/// cap keeps out of the index is also a file a workspace rename will not
|
||||
/// rewrite. That is the consistent answer: the cap says which files exist
|
||||
/// as far as this server is concerned.
|
||||
fn collect_sources(
|
||||
&self,
|
||||
watch: &mut dyn FnMut(IndexEvent),
|
||||
analyses: HeldAnalyses,
|
||||
) -> Sources {
|
||||
let scope = self.source_files();
|
||||
let cap = self.client.max_file_size;
|
||||
// Every path an open buffer speaks for. Reading such a file from disk
|
||||
// is work thrown away — the buffer's text replaces it below, whatever
|
||||
// the disk says — so the read is skipped rather than undone. The cap is
|
||||
// still consulted first, so an oversized file still reports itself
|
||||
// skipped exactly as it did before the buffer put its own text back.
|
||||
let spoken_for: HashSet<&Path> =
|
||||
self.docs.values().filter_map(|doc| doc.path.as_deref()).collect();
|
||||
let mut files: Vec<PathBuf> = Vec::new();
|
||||
for path in scope.files {
|
||||
if let Some(size) = oversize(&path, cap) {
|
||||
watch(IndexEvent::Skipped { path: &path, size, cap });
|
||||
continue;
|
||||
}
|
||||
if spoken_for.contains(path.as_path()) {
|
||||
continue;
|
||||
}
|
||||
files.push(path);
|
||||
}
|
||||
// Open buffers override what is on disk, and contribute themselves
|
||||
// when they are not on disk at all.
|
||||
//
|
||||
// Except a buffer on the large-file fast path, which overrides disk
|
||||
// with *nothing*: indexing it means parsing the hundred megabytes the
|
||||
// fast path exists not to parse. Removing the path rather than leaving
|
||||
// the disk copy in is the honest half of that — the alternative would
|
||||
// be an index describing a file the user is looking at by bytes it no
|
||||
// longer has. See `docs/features/large-file-mode/README.md` for the
|
||||
// interaction with `lucisv.index.maxFileSize`, whose "an open buffer is
|
||||
// never capped" rule this is the one exception to.
|
||||
let mut analyzed = Analyzed::default();
|
||||
let mut buffered: HashMap<PathBuf, String> = HashMap::new();
|
||||
for doc in self.docs.values() {
|
||||
let Some(path) = doc.path.clone() else { continue };
|
||||
files.retain(|p| p != &path);
|
||||
if !doc.large {
|
||||
if analyses == HeldAnalyses::Wanted {
|
||||
analyzed.facts.insert(path.clone(), doc.facts(path.clone()));
|
||||
analyzed.words.insert(path.clone(), doc.words());
|
||||
}
|
||||
buffered.insert(path.clone(), doc.text.clone());
|
||||
files.push(path);
|
||||
}
|
||||
}
|
||||
Sources { files, buffered, analyzed, incdirs: scope.incdirs, warnings: scope.warnings }
|
||||
}
|
||||
|
||||
/// One **closed** file's text and line index, read at most once per file
|
||||
/// per generation of that file.
|
||||
///
|
||||
@@ -2004,155 +1986,6 @@ impl Workspace {
|
||||
None => fs::read_to_string(path).ok(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The files the index covers, and what the user should be told about how
|
||||
/// they were chosen. The scope ladder, highest first:
|
||||
///
|
||||
/// 1. **A filelist** — `lucisv.filelist`, else a `filelist` key in the
|
||||
/// config governing a workspace root. It names *exactly* the files to
|
||||
/// index; the project said so, and guessing past it would defeat the
|
||||
/// point of having one. This is the "project file", and it is the one
|
||||
/// rung that is whole-project by definition.
|
||||
/// 2. **The workspace-folder walk**, on `lucisv.index.scope:
|
||||
/// "workspace"` — what every session did before 2026-08-27, now opt-in.
|
||||
/// 3. **The folder scope**, the default: each opened buffer's own
|
||||
/// directory raised `lucisv.index.scopeDepth` levels, walked. See
|
||||
/// `docs/features/index-scope/README.md` for what that costs, which is
|
||||
/// that a definition in another folder does not resolve until the
|
||||
/// scope reaches that folder.
|
||||
///
|
||||
/// A configured filelist that cannot be read falls back to rung 2 (or 3)
|
||||
/// with a warning. An editor that shows no symbols because of a typo in a
|
||||
/// path is worse than one that quietly indexes what it can and says so.
|
||||
///
|
||||
/// Only rung 1 can carry `+incdir+` directories: a walked workspace names
|
||||
/// none, so an `` `include`` there resolves against the including file's
|
||||
/// own directory alone (`docs/features/include-nav/README.md`).
|
||||
fn source_files(&self) -> Scope {
|
||||
// The walk's own warnings join the scope's, so an unreadable directory
|
||||
// reaches the output channel by the road a filelist's problems already
|
||||
// travel — said once per scan and never per keystroke.
|
||||
let mut warnings: Vec<String> = Vec::new();
|
||||
let Some(path) = self.filelist_path() else {
|
||||
let files = self.default_files(&mut |w| warnings.push(w));
|
||||
return Scope { files, warnings, ..Default::default() };
|
||||
};
|
||||
match lucisv_core::filelist::read(&path) {
|
||||
Ok(list) => Scope { files: list.files, incdirs: list.incdirs, warnings: list.warnings },
|
||||
Err(problem) => {
|
||||
let files = self.default_files(&mut |w| warnings.push(w));
|
||||
warnings.insert(0, format!("{problem} — indexing the workspace instead"));
|
||||
Scope { files, incdirs: Vec::new(), warnings }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The filelist governing this workspace, if any: the client's setting
|
||||
/// first (absolute, or relative to the first root), else the `filelist`
|
||||
/// key of the config governing a root, in root order.
|
||||
///
|
||||
/// Public because the file watchers must name it: a `.f` edited outside
|
||||
/// the editor changes the index's scope, and nothing else on disk would
|
||||
/// tell us (`docs/features/file-watching/README.md`).
|
||||
pub fn filelist_path(&self) -> Option<PathBuf> {
|
||||
if let Some(setting) = &self.client.filelist {
|
||||
let path = Path::new(setting);
|
||||
return Some(match self.roots.first() {
|
||||
Some(root) if path.is_relative() => root.join(path),
|
||||
_ => path.to_path_buf(),
|
||||
});
|
||||
}
|
||||
let mut discovery = Discovery::new(true);
|
||||
// A broken `lucisv.toml` names no filelist, exactly as it contributes no
|
||||
// excludes below: the user hears about it when they format.
|
||||
self.roots.iter().find_map(|root| discovery.for_dir(root).ok()?.filelist)
|
||||
}
|
||||
|
||||
/// Rungs 2 and 3 of the ladder: the whole-workspace walk when the client
|
||||
/// asked for it, else the folder scope.
|
||||
fn default_files(&self, warn: &mut dyn FnMut(String)) -> Vec<PathBuf> {
|
||||
if self.walks_the_workspace() {
|
||||
return self.walked_files(&self.roots, warn);
|
||||
}
|
||||
self.folder_files(warn)
|
||||
}
|
||||
|
||||
/// Rung 3: the folder scope — [`Workspace::scope_dirs`], walked with every
|
||||
/// filter the workspace walk applies.
|
||||
///
|
||||
/// One exception, kept exactly as it was from before this rung became the
|
||||
/// default: **a rootless session at depth 0 reads its directories flat**,
|
||||
/// one level, no `.gitignore`. That is the "a file opened on its own"
|
||||
/// case, where descending a tree the user never named would be a surprise
|
||||
/// — and the moment the user raises `scopeDepth` they have named one, so
|
||||
/// the walk is what they asked for.
|
||||
fn folder_files(&self, warn: &mut dyn FnMut(String)) -> Vec<PathBuf> {
|
||||
let dirs = self.scope_dirs();
|
||||
if self.roots.is_empty() && self.client.index_scope_depth == 0 {
|
||||
return sibling_files(&dirs);
|
||||
}
|
||||
self.walked_files(&dirs, warn)
|
||||
}
|
||||
|
||||
/// Every source file under `dirs`, found by the CLI's own walk: the same
|
||||
/// extensions, the same `.gitignore` handling, and the `exclude` patterns
|
||||
/// of the config governing each directory. What `lucisv` skips, the index
|
||||
/// skips.
|
||||
///
|
||||
/// `dirs` is the workspace roots for rung 2 and the scope directories for
|
||||
/// rung 3. The one honest difference between the two: `.gitignore` files
|
||||
/// are read from the walk's own starting directory downwards, so a rule
|
||||
/// written in a root's `.gitignore` does not apply to a rung-3 walk that
|
||||
/// starts below it. The `exclude` patterns are matched against whole
|
||||
/// paths and so behave identically either way.
|
||||
fn walked_files(&self, dirs: &[PathBuf], warn: &mut dyn FnMut(String)) -> Vec<PathBuf> {
|
||||
let mut discovery = Discovery::new(true);
|
||||
let mut out = Vec::new();
|
||||
for root in dirs {
|
||||
// The walk names its inputs as strings; every directory here came
|
||||
// from a `file:` URI, which cannot carry a non-UTF-8 path.
|
||||
let Some(input) = root.to_str() else { continue };
|
||||
// A broken `lucisv.toml` must not stop the server from indexing: an
|
||||
// index that excludes nothing is a far better failure than a
|
||||
// server that comes up empty. The error is reported when the user
|
||||
// formats a file in this tree (`format::settings_for`).
|
||||
let mut exclude =
|
||||
discovery.for_dir(root).unwrap_or_default().exclude.unwrap_or_default();
|
||||
// The client's `lucisv.exclude` is *appended*, never substituted —
|
||||
// the CLI appends a config's excludes to `--exclude` the same way,
|
||||
// and a setting that silently dropped a checked-in exclude would
|
||||
// put vendored code back in the index for one user only.
|
||||
exclude.extend(self.client.exclude.iter().cloned());
|
||||
// `.gitignore` is always honoured: it is the CLI's default, and an
|
||||
// editor has no `--no-gitignore` to type. An unreadable directory
|
||||
// is skipped and said — the warning rides out on the scope's own
|
||||
// warnings, which `server/notification.rs` logs once per scan.
|
||||
let _ = collect_files(input, &exclude, true, &mut out, &mut |w| warn(w.to_string()));
|
||||
}
|
||||
out.sort();
|
||||
out.dedup();
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
/// The source files sitting in each of `dirs`, one directory deep. No walk, no
|
||||
/// `.gitignore`: this is the rootless default, where descending a tree the
|
||||
/// user never named would be a surprise.
|
||||
fn sibling_files(dirs: &[PathBuf]) -> Vec<PathBuf> {
|
||||
let mut out = Vec::new();
|
||||
for dir in dirs {
|
||||
let Ok(entries) = fs::read_dir(dir) else { continue };
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
let extension = path.extension().and_then(|e| e.to_str()).unwrap_or_default();
|
||||
if path.is_file() && EXTENSIONS.contains(&extension) {
|
||||
out.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
out.sort();
|
||||
out.dedup();
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -2673,6 +2506,41 @@ mod tests {
|
||||
ws.finish_scan(scan)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_publication_cadence_holds_a_publish_until_enough_has_been_staged() {
|
||||
// **The whole of the cadence, at its exact boundary.** A publish is a
|
||||
// pass over the whole index, and before §61.4 the drain paid one per
|
||||
// burst of requests — 13 to 18 in one warm opentitan scan, 46 % of it
|
||||
// (`docs/features/perf5r-publication/README.md`). `publish_is_due`
|
||||
// spaces them by work done rather than by how often a client asks: no
|
||||
// publish is due until `PUBLISH_EVERY` records are staged, one is due
|
||||
// the moment the 512th lands, and publishing clears the debt.
|
||||
let tree = Tree::new("publishcadence");
|
||||
for n in 0..scan::PUBLISH_EVERY + 2 {
|
||||
tree.package(&format!("p{n:04}.sv"), &format!("p{n:04}"));
|
||||
}
|
||||
let mut ws = Workspace::default();
|
||||
ws.client.index_scope = IndexScope::Workspace;
|
||||
ws.adopt_roots(vec![tree.path.clone()]);
|
||||
let mut scan = ws.begin_scan(&mut |_| {}, false);
|
||||
for taken in 1..scan::PUBLISH_EVERY {
|
||||
assert!(ws.scan_step(&mut scan, &mut |_| {}), "premise: file {taken} exists");
|
||||
assert!(!scan.publish_is_due(), "{taken} staged is not yet a publish");
|
||||
}
|
||||
assert!(ws.scan_step(&mut scan, &mut |_| {}), "premise: the 512th file exists");
|
||||
assert!(scan.publish_is_due(), "{} staged is", scan::PUBLISH_EVERY);
|
||||
ws.publish_scan(&mut scan);
|
||||
assert!(!scan.publish_is_due(), "and publishing clears the debt");
|
||||
|
||||
// The cadence is a latency decision and nothing else: what this scan
|
||||
// lands is what a one-shot scan over the same tree lands.
|
||||
while ws.scan_step(&mut scan, &mut |_| {}) {}
|
||||
ws.finish_scan(scan);
|
||||
let mut one_shot = Workspace::default();
|
||||
one_shot.open_whole_workspace(vec![tree.path.clone()]);
|
||||
assert_eq!(everything(&one_shot), everything(&ws));
|
||||
}
|
||||
|
||||
/// A tree of three files that declare each other's names and include each
|
||||
/// other, so a half-published index has something to get wrong.
|
||||
fn tangled(tag: &str) -> Tree {
|
||||
@@ -2791,7 +2659,7 @@ mod tests {
|
||||
let jumped = uri(&format!("file://{}", tree.path.join("c.sv").display()));
|
||||
let jumped_text = fs::read_to_string(tree.path.join("c.sv")).expect("the fixture");
|
||||
stepped.set_document(jumped, jumped_text);
|
||||
stepped.open_next(&mut scan);
|
||||
stepped.open_next(&mut scan, &mut |_| {});
|
||||
assert!(stepped.scan_step(&mut scan, &mut |_| {}));
|
||||
stepped.publish_scan(&mut scan);
|
||||
assert!(!stepped.index().units("c").is_empty(), "c.sv was indexed next, not last");
|
||||
@@ -2924,7 +2792,7 @@ mod tests {
|
||||
ws.open_whole_workspace(vec![tree.path.clone()]);
|
||||
assert_eq!(indexed(&ws, &["a", "b"]), ["a", "b"]);
|
||||
assert_eq!(
|
||||
ws.walked_files(from_ref(&tree.path), &mut |_| {}).len(),
|
||||
ws.walked_files(from_ref(&tree.path), &mut |_| {}, &mut ScanTrace::new(false)).len(),
|
||||
2,
|
||||
"two files, once each"
|
||||
);
|
||||
@@ -4208,7 +4076,7 @@ mod tests {
|
||||
let mut scan = ws.begin_scan(&mut |_| {}, false);
|
||||
assert!(ws.scan_step(&mut scan, &mut |_| {}), "the buffer's own file goes first");
|
||||
open(&mut ws, &tree, "ip/uart/rtl/uart.sv");
|
||||
ws.open_next(&mut scan);
|
||||
ws.open_next(&mut scan, &mut |_| {});
|
||||
// `uart.sv` is now the head of what is left, and at the shipped
|
||||
// `scopeDepth: 2` its own folder raises to `ip` — which brings
|
||||
// `ip/kmac` in with it. Four files of waiting, one behind the file
|
||||
@@ -5995,4 +5863,73 @@ mod tests {
|
||||
assert_eq!(ws.index().member("a_pkg", "EDITED").len(), 1, "the live edit is indexed");
|
||||
assert_eq!(ws.index().member("a_pkg", "K").len(), 0);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// TODO §63.2 QA: the trace's arithmetic, attacked with the three
|
||||
// shapes TODO.md names — a buffer that fails to lex, a `define` edit
|
||||
// that changes the macro table, and (below, via the server-level
|
||||
// parity re-run) an edit that moves a fence.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// A buffer that never lexes still reports a `Lex` stage (the failed
|
||||
/// attempt is real work and costs real time) and a `Parse` stage (the
|
||||
/// `parse_source_tolerant` fallback), and still counts as one document.
|
||||
/// `defines`/`analyze`/`external`/`lines` all still run over the empty
|
||||
/// token stream and empty-error tree exactly as the un-instrumented
|
||||
/// path always did — the wrapping must not skip a stage just because
|
||||
/// an earlier one errored.
|
||||
#[test]
|
||||
fn a_buffer_that_fails_to_lex_still_records_every_rebuild_stage() {
|
||||
crate::lint_trace::arm();
|
||||
// An unterminated string literal is an unambiguous lex error that
|
||||
// does not depend on lexer internals that could drift between
|
||||
// versions (`vlog_parser::tokenize` is documented all-or-nothing).
|
||||
let text = "module m;\n string s = \"unterminated\nendmodule\n".to_string();
|
||||
let doc = Document::new(None, text, &WorkspaceIndex::default());
|
||||
assert!(doc.tokens.is_empty(), "a lex failure leaves an empty token stream");
|
||||
assert!(!doc.diagnostics.is_empty(), "a lex failure is a diagnostic");
|
||||
let trace = crate::lint_trace::disarm().expect("armed");
|
||||
// Every stage's field is present on the line, whether or not it
|
||||
// took measurable time (`saw_document`, not a duration, is what
|
||||
// says a rebuild happened at all — see the flaky test this round
|
||||
// fixed in `lint_trace.rs`).
|
||||
let line = trace.line();
|
||||
assert!(line.contains("documents=1"), "{line}");
|
||||
for stage in ["lex=", "parse=", "defines=", "analyze=", "external=", "lines=", "publish="] {
|
||||
assert!(line.contains(stage), "{line}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A `` `define `` edit changes the macro table `collect_defines`
|
||||
/// produces, and nothing about wrapping that call in `rebuild` changes
|
||||
/// which tokens it sees or what it returns: the new revision's table
|
||||
/// reflects only the new text, never a stale value from the revision
|
||||
/// before it (`Document::new` builds a fresh `DefineTable` every time,
|
||||
/// same as before this round).
|
||||
#[test]
|
||||
fn a_define_edit_changes_the_macro_table_the_rebuild_reports_on() {
|
||||
crate::lint_trace::arm();
|
||||
let before = Document::new(
|
||||
None,
|
||||
"`define WIDTH 8\nmodule m;\n wire [`WIDTH-1:0] w;\nendmodule\n".to_string(),
|
||||
&WorkspaceIndex::default(),
|
||||
);
|
||||
assert_eq!(before.defines.latest("WIDTH").map(|d| d.body.trim()), Some("8"));
|
||||
assert!(before.defines.latest("DEPTH").is_none());
|
||||
|
||||
let after = Document::new(
|
||||
None,
|
||||
"`define DEPTH 16\nmodule m;\n wire [`DEPTH-1:0] w;\nendmodule\n".to_string(),
|
||||
&WorkspaceIndex::default(),
|
||||
);
|
||||
assert!(after.defines.latest("WIDTH").is_none(), "no macro survives across documents");
|
||||
assert_eq!(after.defines.latest("DEPTH").map(|d| d.body.trim()), Some("16"));
|
||||
|
||||
let trace = crate::lint_trace::disarm().expect("armed");
|
||||
let line = trace.line();
|
||||
assert!(
|
||||
line.contains("documents=2"),
|
||||
"two fresh Document::new calls, two rebuilds: {line}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
//! `pub(super)` and visible exactly where they were before the move: inside
|
||||
//! `crate::state` and nowhere else.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -126,6 +126,11 @@ pub struct Scan {
|
||||
pub(super) warnings: Vec<String>,
|
||||
/// How many of `work` have been indexed.
|
||||
pub(super) at: usize,
|
||||
/// The rest of the workspace, still to be discovered — see
|
||||
/// [`PendingDiscovery`]. `None` for every scan that resolved its whole
|
||||
/// scope before it started, which is every scan but a workspace-scoped
|
||||
/// startup with a buffer already open.
|
||||
pub(super) pending: Option<PendingDiscovery>,
|
||||
/// The records taken since the last publish, and which files of `work`
|
||||
/// they came from. Staged rather than merged because a merge is a pass
|
||||
/// over the whole index — see [`vlog_semantic::WorkspaceIndex::absorb`].
|
||||
@@ -144,6 +149,50 @@ pub struct Scan {
|
||||
pub(super) trace: ScanTrace,
|
||||
}
|
||||
|
||||
/// The half of a scan's scope that has not been walked yet.
|
||||
///
|
||||
/// **One scan, discovered in two goes.** A workspace-scoped session with a
|
||||
/// buffer already open walks that buffer's own folders first, indexes them,
|
||||
/// publishes them and answers the request that has been waiting — and only
|
||||
/// then walks the remaining 3 800 directories, whose 155 ms used to sit in
|
||||
/// front of every one of those steps (`docs/features/perf5r-first-answer`).
|
||||
/// It is emphatically **not** two scans: one work list, one index, one
|
||||
/// `finish_scan`, one `gone` computed against the whole of it, and every file
|
||||
/// stepped exactly once — which is what `seen` is for.
|
||||
pub(super) struct PendingDiscovery {
|
||||
/// The directories still to walk: the workspace roots.
|
||||
pub(super) roots: Vec<PathBuf>,
|
||||
/// Every path the neighbourhood walk yielded — the ones it indexed, the
|
||||
/// ones the size cap kept out, and every open buffer's own path. The
|
||||
/// remaining walk covers the roots, so it finds all of these again; each
|
||||
/// one it names here has already been decided about, and deciding twice
|
||||
/// would step a file twice or report one skip as two.
|
||||
pub(super) seen: HashSet<PathBuf>,
|
||||
/// Every directory identity the neighbourhood walk entered, and the path
|
||||
/// it entered each one by.
|
||||
///
|
||||
/// **The two walks share it, and that is what makes them one walk.** An
|
||||
/// ordinary walk visits each directory identity once and reports its files
|
||||
/// under the first spelling that reached it
|
||||
/// (`docs/features/walk-cycles/README.md`); two walks with two sets would
|
||||
/// report a symlinked directory's files twice, under two spellings a path
|
||||
/// set cannot tell apart, and the index would hold every module in it
|
||||
/// twice. Sharing the tracker restores that contract across the split.
|
||||
pub(super) tracker: lucisv_core::walk::DirectoryTracker,
|
||||
}
|
||||
|
||||
/// How many records may be staged before another mid-scan publish is worth the
|
||||
/// whole-index merge it costs — see [`Scan::publish_is_due`].
|
||||
///
|
||||
/// **512 is a work bound, and it is deliberately the same number
|
||||
/// `HEAD_WALK_MAX` is.** Both answer "how much of this workspace may a user
|
||||
/// wait for before an answer stops being worth waiting for": 512 warm steps is
|
||||
/// ~100 ms of scanning on the corpus the round measured
|
||||
/// (`docs/features/perf5r-first-answer/README.md`), so a request landing
|
||||
/// between two publishes reads an index at most that far behind and the whole
|
||||
/// scan pays at most one merge per 512 files instead of one per burst.
|
||||
pub(crate) const PUBLISH_EVERY: usize = 512;
|
||||
|
||||
/// Which of the two shapes a [`Scan`] is.
|
||||
///
|
||||
/// One enum rather than two `finish` methods so a caller cannot pair the wrong
|
||||
@@ -195,6 +244,106 @@ impl Scan {
|
||||
self.at >= self.head
|
||||
}
|
||||
|
||||
/// Whether enough has been staged since the last publish for another one
|
||||
/// to be worth the merge it costs — the **publication cadence**.
|
||||
///
|
||||
/// **A publish is a pass over the whole index, and it used to be one per
|
||||
/// burst of requests.** `answer_what_is_waiting` published whenever
|
||||
/// anything at all was waiting, so a client asking ten times a second
|
||||
/// bought ten merges a second over a table that grows all the way to the
|
||||
/// end of the scan. Measured on opentitan under a definition every 100 ms
|
||||
/// (`docs/features/perf5r-publication/README.md`): 13 to 18 publishes in
|
||||
/// one warm scan, and `absorb` + `candidates` alone were 46 % of it.
|
||||
///
|
||||
/// The rule this asks is **how much new the next answer would see**, not
|
||||
/// how long ago the last publish was: a merge's cost is the index's size
|
||||
/// and its value is the records it makes answerable, so files staged is
|
||||
/// the currency both are in — and it is a count, so what a scan does is
|
||||
/// the same on a fast machine and a slow one, and a test may assert it.
|
||||
///
|
||||
/// It bounds staleness, never correctness: a request answered between two
|
||||
/// publishes reads a prefix at most [`PUBLISH_EVERY`] files older than the
|
||||
/// one it could have had, and every table in it still agrees with every
|
||||
/// other ([`Workspace::publish_scan`](super::Workspace::publish_scan)).
|
||||
/// The **first** publish of a scan is never deferred by it — that one is
|
||||
/// the session's first useful answer, and `server/index.rs` asks for it by
|
||||
/// a different door.
|
||||
pub fn publish_is_due(&self) -> bool {
|
||||
self.staged.len() >= PUBLISH_EVERY
|
||||
}
|
||||
|
||||
/// Whether this scan still owes itself the rest of its own scope — see
|
||||
/// [`PendingDiscovery`].
|
||||
///
|
||||
/// Two callers, and they want it for the same reason: `scan_once` must
|
||||
/// interleave a scan whose work list is short *so far*, and must not paint
|
||||
/// a percentage against a denominator that is going to grow
|
||||
/// (`docs/features/indexing-ux/README.md`).
|
||||
pub fn discovery_pending(&self) -> bool {
|
||||
self.pending.is_some()
|
||||
}
|
||||
|
||||
/// Take the remaining discovery, so the workspace can run it.
|
||||
pub(super) fn take_pending(&mut self) -> Option<PendingDiscovery> {
|
||||
self.pending.take()
|
||||
}
|
||||
|
||||
/// Whether this scan's answers are right but **spelled** differently from
|
||||
/// what a plain walk of the same tree would spell them, so one ordinary
|
||||
/// rescan is owed.
|
||||
///
|
||||
/// The case: a directory alias outside the open folder's ancestor chain —
|
||||
/// `other/link -> z_real`, with `other` sorting first. The head leads with
|
||||
/// `z_real`; the remaining walk meets `other/link`, recognises the
|
||||
/// directory the head already entered and skips it, so nothing is
|
||||
/// discovered twice and every answer this scan gives is one target and one
|
||||
/// file. But a walk of the root on its own — the next rescan, or a session
|
||||
/// that opens nothing — spells those same files `other/link/…`, and a
|
||||
/// startup that disagreed with every later scan about a path is the defect
|
||||
/// this whole tracker exists to close (`docs/performance_052_review.md`
|
||||
/// F1). So the scan asks for the canonical walk once it has landed, and
|
||||
/// the spelling converges there.
|
||||
///
|
||||
/// **Exactly one rescan can ever come of it.** Only a session's first scan
|
||||
/// splits its discovery ([`Workspace::first_scope`]), so the scan this
|
||||
/// asks for resolves its whole scope in one walk, has no
|
||||
/// [`PendingDiscovery`], and cannot ask again.
|
||||
///
|
||||
/// The answer is the trace's own counter, which is written whether or not
|
||||
/// anybody asked for a trace — like `publishes`, it is a fact about the
|
||||
/// scan rather than a stopwatch reading, so it lives where the scan's
|
||||
/// facts live and the `--verbose` count line says it out loud.
|
||||
pub fn wants_rescan(&self) -> bool {
|
||||
self.trace.rescan_requested > 0
|
||||
}
|
||||
|
||||
/// Fold the rest of the scope into this scan: its files onto the end of
|
||||
/// the work list, its paths into the set the include graph learns from,
|
||||
/// its warnings and its skips onto the scan's own — and whether the walk
|
||||
/// that found them disagreed with the head about a directory's spelling
|
||||
/// ([`Scan::wants_rescan`]).
|
||||
///
|
||||
/// Appended rather than re-ordered: the neighbourhood at the front has
|
||||
/// already been stepped, and `vlog_semantic::IndexBuilder` sorts by path
|
||||
/// inside `finish`, so what arrives here decides latency and nothing else
|
||||
/// ([`Scan::reorder`] makes the same argument).
|
||||
pub(super) fn land_discovery(
|
||||
&mut self,
|
||||
files: Vec<PathBuf>,
|
||||
warnings: Vec<String>,
|
||||
skipped: usize,
|
||||
conflict: bool,
|
||||
) {
|
||||
self.trace.conflict += usize::from(conflict);
|
||||
self.trace.rescan_requested += usize::from(conflict);
|
||||
self.paths.extend(files.iter().cloned());
|
||||
self.paths.sort();
|
||||
self.paths.dedup();
|
||||
self.work.extend(files);
|
||||
self.warnings.extend(warnings);
|
||||
self.skipped += skipped;
|
||||
}
|
||||
|
||||
/// The text of one file of this scan's work list, at the moment its step
|
||||
/// comes — `None` when it cannot be read.
|
||||
///
|
||||
|
||||
@@ -8631,3 +8631,113 @@ fn organize_imports_is_offered_under_its_own_kind_and_runs_as_a_command() {
|
||||
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// TODO §64.1 over the wire. `leaf` declares an internal net; `top.sv` names it
|
||||
/// through a hierarchical tail and `leaf.sv` uses it itself. Before §64.1
|
||||
/// `textDocument/references` answered `leaf.sv`'s two lines from the
|
||||
/// declaration and never the tail, while `textDocument/rename` at the same
|
||||
/// position edited both files — lucisv could change a reference it could not
|
||||
/// list. Asserted here from both ends, with `leaf.sv` the only open buffer, so
|
||||
/// the tail comes out of the persisted postings and `leaf.sv`'s own use out of
|
||||
/// the live one; then from `top.sv` with `leaf.sv` closed, where that file's
|
||||
/// own use is served by one re-analysis of it.
|
||||
#[test]
|
||||
fn a_hierarchical_nets_references_and_rename_agree_over_the_wire() {
|
||||
let dir = temp_dir("hierrefs");
|
||||
let leaf = dir.join("leaf.sv");
|
||||
let leaf_text = "\
|
||||
module leaf (input logic clk_i);
|
||||
logic sig;
|
||||
assign sig = clk_i;
|
||||
endmodule
|
||||
";
|
||||
std::fs::write(&leaf, leaf_text).expect("write");
|
||||
let top = dir.join("top.sv");
|
||||
let top_text = "\
|
||||
module top;
|
||||
leaf u_leaf (.clk_i(1'b0));
|
||||
wire w;
|
||||
assign w = u_leaf.sig;
|
||||
endmodule
|
||||
";
|
||||
std::fs::write(&top, top_text).expect("write");
|
||||
|
||||
let root = format!("file://{}", dir.display());
|
||||
let leaf_uri = format!("file://{}", leaf.display());
|
||||
let top_uri = format!("file://{}", top.display());
|
||||
|
||||
// `sig` is declared at line 1 column 8 of `leaf.sv`, used at line 2
|
||||
// column 9 there, and named at line 3 column 20 of `top.sv`.
|
||||
let session = [
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"processId":null,"rootUri":"{root}","capabilities":{{}}}}}}"#
|
||||
)),
|
||||
frame(r#"{"jsonrpc":"2.0","method":"initialized","params":{}}"#),
|
||||
frame(WIDE_SCOPE),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{leaf_uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
|
||||
serde_json::to_string(leaf_text).expect("json")
|
||||
)),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":2,"method":"textDocument/references","params":{{"textDocument":{{"uri":"{leaf_uri}"}},"position":{{"line":1,"character":8}},"context":{{"includeDeclaration":true}}}}}}"#
|
||||
)),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":3,"method":"textDocument/rename","params":{{"textDocument":{{"uri":"{leaf_uri}"}},"position":{{"line":1,"character":8}},"newName":"renamed"}}}}"#
|
||||
)),
|
||||
// Now from the other side, with `leaf.sv` shut.
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","method":"textDocument/didClose","params":{{"textDocument":{{"uri":"{leaf_uri}"}}}}}}"#
|
||||
)),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{top_uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
|
||||
serde_json::to_string(top_text).expect("json")
|
||||
)),
|
||||
frame(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":4,"method":"textDocument/references","params":{{"textDocument":{{"uri":"{top_uri}"}},"position":{{"line":3,"character":20}},"context":{{"includeDeclaration":true}}}}}}"#
|
||||
)),
|
||||
frame(r#"{"jsonrpc":"2.0","id":9,"method":"shutdown","params":null}"#),
|
||||
frame(r#"{"jsonrpc":"2.0","method":"exit","params":null}"#),
|
||||
]
|
||||
.concat();
|
||||
|
||||
let messages = talk(&session);
|
||||
let response = |id: u32| -> &serde_json::Value {
|
||||
messages
|
||||
.iter()
|
||||
.find(|m| m["id"] == id)
|
||||
.unwrap_or_else(|| panic!("no response {id} in {messages:#?}"))
|
||||
};
|
||||
|
||||
// Every place naming the net, as `(file, line)`.
|
||||
let places = |id: u32| -> Vec<(String, i64)> {
|
||||
let mut out: Vec<(String, i64)> = response(id)["result"]
|
||||
.as_array()
|
||||
.expect("a list")
|
||||
.iter()
|
||||
.map(|location| {
|
||||
let uri = location["uri"].as_str().expect("a uri");
|
||||
let name = uri.rsplit('/').next().unwrap_or("?").to_string();
|
||||
(name, location["range"]["start"]["line"].as_i64().expect("a line"))
|
||||
})
|
||||
.collect();
|
||||
out.sort();
|
||||
out
|
||||
};
|
||||
let everywhere =
|
||||
vec![("leaf.sv".to_string(), 1), ("leaf.sv".to_string(), 2), ("top.sv".to_string(), 3)];
|
||||
assert_eq!(places(2), everywhere, "from the declaration");
|
||||
assert_eq!(places(4), everywhere, "from the tail, with `leaf.sv` closed");
|
||||
|
||||
// And the rename that was already editing both files edits exactly those
|
||||
// places — the asymmetry §64.1 was filed for, closed from both sides.
|
||||
let changes = &response(3)["result"]["changes"];
|
||||
let own = changes[&leaf_uri].as_array().expect("edits for the declaring file");
|
||||
assert_eq!(own.len(), 2, "{own:#?}");
|
||||
let elsewhere = changes[&top_uri].as_array().expect("edits for the naming file");
|
||||
assert_eq!(elsewhere.len(), 1, "{elsewhere:#?}");
|
||||
assert_eq!(elsewhere[0]["range"]["start"]["line"], 3);
|
||||
assert_eq!(elsewhere[0]["range"]["start"]["character"], 20);
|
||||
assert!(elsewhere.iter().all(|e| e["newText"] == "renamed"), "{elsewhere:#?}");
|
||||
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
+280
-62
@@ -403,8 +403,14 @@ impl<'a> RawLexer<'a> {
|
||||
});
|
||||
}
|
||||
|
||||
// Operators, longest match first.
|
||||
// Operators, longest match first. The first-byte test is not a second
|
||||
// way of matching — `starts_with` still decides — it is what keeps a
|
||||
// `;` from being compared against all 42 spellings: one byte compare
|
||||
// rejects every operator that cannot start here (TODO §63.2).
|
||||
for op in OPERATORS {
|
||||
if op.as_bytes()[0] != c {
|
||||
continue;
|
||||
}
|
||||
if self.starts_with(op) {
|
||||
for _ in 0..op.len() {
|
||||
self.bump();
|
||||
@@ -918,80 +924,111 @@ fn is_line_directive(word: &str) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
/// What the attachment phase carries from one raw token to the next.
|
||||
#[derive(Default)]
|
||||
struct Attaching {
|
||||
/// Comments waiting for the real token they lead.
|
||||
pending: Vec<Comment>,
|
||||
/// Whether a blank line was seen since the last pending comment.
|
||||
pending_blank: bool,
|
||||
}
|
||||
|
||||
/// Tokenize source text, attaching comments and blank-line info to tokens.
|
||||
///
|
||||
/// The two phases are **fused**: each raw token is attached as it is lexed,
|
||||
/// rather than collected into a `Vec<RawTok>` the attachment loop then walks.
|
||||
/// Attachment only ever reads the raw token in hand and the token last pushed,
|
||||
/// so the fusion is a pure reordering — it drops a second whole-file vector
|
||||
/// (a 40 267-line file's worth of it is ~22 MB of allocation, growth copying
|
||||
/// and teardown), which is why the first request after an edit pays less for
|
||||
/// the same tokens (TODO §63.2).
|
||||
pub fn tokenize(source: &str) -> Result<Vec<Token>, LexError> {
|
||||
let mut raw_lexer = RawLexer::new(source.as_bytes());
|
||||
let mut raws: Vec<RawTok> = Vec::new();
|
||||
let mut tokens: Vec<Token> = Vec::with_capacity(estimated_tokens(source.len()));
|
||||
let mut state = Attaching::default();
|
||||
loop {
|
||||
let tok = raw_lexer.next_raw()?;
|
||||
let is_eof = tok.kind == RawKind::Real(TokenKind::Eof);
|
||||
raws.push(tok);
|
||||
let raw = raw_lexer.next_raw()?;
|
||||
let is_eof = raw.kind == RawKind::Real(TokenKind::Eof);
|
||||
attach(raw, &mut tokens, &mut state);
|
||||
if is_eof {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(tokens)
|
||||
}
|
||||
|
||||
// Attachment phase.
|
||||
let mut tokens: Vec<Token> = Vec::new();
|
||||
let mut pending: Vec<Comment> = Vec::new();
|
||||
let mut pending_blank = false;
|
||||
/// How many tokens a source of `bytes` bytes is guessed to hold.
|
||||
///
|
||||
/// Only to spare the growing vector its early doublings; a wrong guess costs
|
||||
/// nothing but the growth it would have paid anyway. Six bytes a token is the
|
||||
/// measured average over the corpus and over opentitan's generated register
|
||||
/// files alike, and the guess is capped so a pathological file (one enormous
|
||||
/// string literal) cannot reserve more than it could ever need.
|
||||
fn estimated_tokens(bytes: usize) -> usize {
|
||||
(bytes / 6).min(1 << 20)
|
||||
}
|
||||
|
||||
for raw in raws {
|
||||
match raw.kind {
|
||||
RawKind::LineComment | RawKind::BlockComment => {
|
||||
let same_line_as_prev =
|
||||
raw.newlines_before == 0 && !tokens.is_empty() && pending.is_empty();
|
||||
let comment = Comment {
|
||||
text: raw.text,
|
||||
blank_before: raw.newlines_before > 1 || pending_blank,
|
||||
line: raw.line,
|
||||
col: raw.col,
|
||||
span: raw.span,
|
||||
};
|
||||
if same_line_as_prev {
|
||||
// Trailing comment for the previous real token.
|
||||
let prev = tokens.last_mut().unwrap();
|
||||
match &mut prev.trailing {
|
||||
Some(existing) => {
|
||||
// Two comments on one line become one node, so its
|
||||
// span has to cover both — the merge normalizes
|
||||
// the gap between them to a single space, which is
|
||||
// why a merged comment is the one comment whose
|
||||
// text can differ from `source[span]`.
|
||||
existing.text.push(' ');
|
||||
existing.text.push_str(&comment.text);
|
||||
existing.span = TextRange::new(existing.span.start, comment.span.end);
|
||||
}
|
||||
None => prev.trailing = Some(comment),
|
||||
}
|
||||
} else {
|
||||
pending.push(comment);
|
||||
pending_blank = false;
|
||||
}
|
||||
}
|
||||
RawKind::Real(kind) => {
|
||||
let blank_before = if pending.is_empty() {
|
||||
raw.newlines_before > 1
|
||||
} else {
|
||||
// Comments already carry their own blank flags; the token
|
||||
// is blank-separated only if there was a blank line
|
||||
// between the last comment and the token itself.
|
||||
raw.newlines_before > 1
|
||||
};
|
||||
tokens.push(Token {
|
||||
kind,
|
||||
text: raw.text,
|
||||
line: raw.line,
|
||||
col: raw.col,
|
||||
span: raw.span,
|
||||
leading: std::mem::take(&mut pending),
|
||||
trailing: None,
|
||||
blank_before,
|
||||
});
|
||||
/// Fold one raw token into the token stream: a comment onto its neighbour,
|
||||
/// a real token onto the end with whatever comments were waiting for it.
|
||||
fn attach(raw: RawTok, tokens: &mut Vec<Token>, state: &mut Attaching) {
|
||||
match raw.kind {
|
||||
RawKind::LineComment | RawKind::BlockComment => {
|
||||
let same_line_as_prev =
|
||||
raw.newlines_before == 0 && !tokens.is_empty() && state.pending.is_empty();
|
||||
let comment = Comment {
|
||||
text: raw.text,
|
||||
blank_before: raw.newlines_before > 1 || state.pending_blank,
|
||||
line: raw.line,
|
||||
col: raw.col,
|
||||
span: raw.span,
|
||||
};
|
||||
// A comment that finds no token to trail — unreachable while
|
||||
// `same_line_as_prev` requires one, kept as a rule rather than a
|
||||
// hope — leads the next token instead of vanishing (invariant 3).
|
||||
let orphan =
|
||||
if same_line_as_prev { attach_trailing(tokens, comment) } else { Some(comment) };
|
||||
if let Some(comment) = orphan {
|
||||
state.pending.push(comment);
|
||||
state.pending_blank = false;
|
||||
}
|
||||
}
|
||||
RawKind::Real(kind) => {
|
||||
// Comments already carry their own blank flags; the token is
|
||||
// blank-separated only if there was a blank line between the last
|
||||
// comment and the token itself — which is the same test either
|
||||
// way, so `pending` does not enter into it.
|
||||
let blank_before = raw.newlines_before > 1;
|
||||
tokens.push(Token {
|
||||
kind,
|
||||
text: raw.text,
|
||||
line: raw.line,
|
||||
col: raw.col,
|
||||
span: raw.span,
|
||||
leading: std::mem::take(&mut state.pending),
|
||||
trailing: None,
|
||||
blank_before,
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(tokens)
|
||||
}
|
||||
|
||||
/// Hang a comment off the token before it, merging with one already there.
|
||||
/// Handed back untouched when there is no token before it.
|
||||
fn attach_trailing(tokens: &mut [Token], comment: Comment) -> Option<Comment> {
|
||||
let Some(prev) = tokens.last_mut() else { return Some(comment) };
|
||||
match &mut prev.trailing {
|
||||
Some(existing) => {
|
||||
// Two comments on one line become one node, so its span has to
|
||||
// cover both — the merge normalizes the gap between them to a
|
||||
// single space, which is why a merged comment is the one comment
|
||||
// whose text can differ from `source[span]`.
|
||||
existing.text.push(' ');
|
||||
existing.text.push_str(&comment.text);
|
||||
existing.span = TextRange::new(existing.span.start, comment.span.end);
|
||||
}
|
||||
None => prev.trailing = Some(comment),
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -1510,4 +1547,185 @@ mod tests {
|
||||
assert!(texts.contains(&"!=="));
|
||||
assert!(texts.contains(&"<="));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// TODO §63.2 QA: the fused attach phase, attacked
|
||||
//
|
||||
// These cover the shapes the two-phase code (a `Vec<RawTok>` fully
|
||||
// built, then walked) could tell apart from the fused one-pass code
|
||||
// (each raw token attached as it is produced) if the fusion were not a
|
||||
// pure reordering: a comment with no token before it at all, comments
|
||||
// that never see a "previous token" until much later, EOF immediately
|
||||
// after a trailing comment, and so on. Every one of these was also
|
||||
// cross-checked, file for file, against `tokenize` built from 1b8723c
|
||||
// (the pre-fusion tree) with a throwaway digest tool in the QA
|
||||
// scratchpad — token-for-token identical, hash and manual `Debug`
|
||||
// inspection alike; the assertions below pin that result durably.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_comment_as_the_very_first_thing_in_the_file_is_the_first_token_s_leading() {
|
||||
let toks = tokenize("// only thing before the module\nmodule m;\nendmodule").unwrap();
|
||||
assert_eq!(toks[0].leading.len(), 1);
|
||||
assert_eq!(toks[0].leading[0].text, "// only thing before the module");
|
||||
assert!(!toks[0].leading[0].blank_before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_comments_on_the_first_line_before_any_token_both_lead_it() {
|
||||
// Two *separate* comments here means two lines, each its own line
|
||||
// comment (a line comment always runs to end of line, so "two
|
||||
// comments on one line" before any token is only possible with
|
||||
// block comments — covered by `two_block_comments_on_one_line_merge`
|
||||
// below).
|
||||
let toks = tokenize("// one\n// two\nmodule m;\nendmodule").unwrap();
|
||||
assert_eq!(toks[0].leading.len(), 2);
|
||||
assert_eq!(toks[0].leading[0].text, "// one");
|
||||
assert_eq!(toks[0].leading[1].text, "// two");
|
||||
assert!(!toks[0].leading[1].blank_before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_trailing_comment_after_the_last_real_token_reaches_eof() {
|
||||
let toks = tokenize("module m;\nendmodule // trailing at eof\n").unwrap();
|
||||
let end = toks.iter().find(|t| t.is_kw("endmodule")).unwrap();
|
||||
let trailing = end.trailing.as_ref().expect("trailing comment on endmodule");
|
||||
assert_eq!(trailing.text, "// trailing at eof");
|
||||
assert_eq!(toks.last().unwrap().kind, TokenKind::Eof);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_block_comments_on_one_line_merge_into_one_trailing_comment() {
|
||||
let toks = tokenize("wire w; /* one */ /* two */\nendmodule").unwrap();
|
||||
let semi = toks.iter().find(|t| t.is_sym(";")).unwrap();
|
||||
let trailing = semi.trailing.as_ref().expect("merged trailing comment");
|
||||
assert_eq!(trailing.text, "/* one */ /* two */");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_blank_line_between_a_comment_and_its_token_marks_both() {
|
||||
let toks = tokenize("// lead\n\nmodule m;\nendmodule").unwrap();
|
||||
assert_eq!(toks[0].leading.len(), 1);
|
||||
// The comment itself is not blank-separated from what came before it
|
||||
// (nothing did); the blank line sits between the comment and the
|
||||
// token, so the *token* carries the flag.
|
||||
assert!(!toks[0].leading[0].blank_before);
|
||||
assert!(toks[0].blank_before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn crlf_line_endings_lex_like_lf_with_the_same_comment_attachment() {
|
||||
let toks = tokenize("module m; // c\r\nendmodule\r\n").unwrap();
|
||||
let semi = toks.iter().find(|t| t.is_sym(";")).unwrap();
|
||||
assert_eq!(semi.trailing.as_ref().unwrap().text, "// c");
|
||||
let end = toks.iter().find(|t| t.is_kw("endmodule")).unwrap();
|
||||
assert_eq!(end.line, 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_block_comment_spanning_lines_still_leads_a_same_line_token() {
|
||||
let toks = tokenize("/* block\n spanning\n lines */ module m;\nendmodule").unwrap();
|
||||
assert_eq!(toks[0].leading.len(), 1);
|
||||
assert!(toks[0].leading[0].text.starts_with("/* block"));
|
||||
assert!(toks[0].leading[0].text.ends_with("lines */"));
|
||||
// The module keyword itself sits on the block comment's last line.
|
||||
assert_eq!(toks[0].line, 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_comment_between_a_macro_invocation_and_its_arguments_trails_the_macro() {
|
||||
let toks = tokenize("module m;\n`MYMACRO /*c*/ (a, b);\nendmodule").unwrap();
|
||||
let mac = toks.iter().find(|t| t.text == "`MYMACRO").unwrap();
|
||||
assert_eq!(mac.trailing.as_ref().unwrap().text, "/*c*/");
|
||||
// The macro call's parenthesized arguments are unaffected — still
|
||||
// ordinary tokens right after, comment or not.
|
||||
let open_paren_idx = toks.iter().position(|t| t.is_sym("(")).unwrap();
|
||||
assert_eq!(toks[open_paren_idx + 1].text, "a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_file_that_is_only_comments_attaches_them_all_to_the_synthetic_eof() {
|
||||
let toks = tokenize("// only a comment, nothing else\n").unwrap();
|
||||
assert_eq!(toks.len(), 1);
|
||||
assert_eq!(toks[0].kind, TokenKind::Eof);
|
||||
assert_eq!(toks[0].leading.len(), 1);
|
||||
assert_eq!(toks[0].leading[0].text, "// only a comment, nothing else");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_file_lexes_to_a_lone_eof_with_no_comments() {
|
||||
let toks = tokenize("").unwrap();
|
||||
assert_eq!(toks.len(), 1);
|
||||
assert_eq!(toks[0].kind, TokenKind::Eof);
|
||||
assert!(toks[0].leading.is_empty());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// TODO §63.2 QA: the operator table's first-byte test
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn every_operator_s_first_byte_is_a_single_ascii_byte() {
|
||||
// `op.as_bytes()[0] != c` compares one byte of `c: u8` against the
|
||||
// table entry's first *byte*. If any entry's first character were
|
||||
// multi-byte UTF-8, its first byte alone would not identify it and
|
||||
// the guard could reject a spelling it should have let through. Every
|
||||
// entry here is pure ASCII punctuation, so the byte comparison is the
|
||||
// whole character.
|
||||
for op in OPERATORS {
|
||||
let first = op.chars().next().expect("no empty operator spellings");
|
||||
assert!(first.is_ascii(), "{op:?} does not start with an ASCII byte");
|
||||
assert_eq!(
|
||||
op.as_bytes()[0],
|
||||
first as u8,
|
||||
"{op:?}'s first byte does not match its first char"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_operator_table_has_no_duplicate_or_empty_entries() {
|
||||
// A duplicate wastes a comparison; an empty entry would make
|
||||
// `op.as_bytes()[0]` panic before ever reaching `starts_with`.
|
||||
for op in OPERATORS {
|
||||
assert!(!op.is_empty());
|
||||
}
|
||||
let mut sorted = OPERATORS.to_vec();
|
||||
sorted.sort_unstable();
|
||||
sorted.dedup();
|
||||
assert_eq!(sorted.len(), OPERATORS.len(), "OPERATORS has a duplicate entry");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_operator_followed_by_every_other_operator_still_lexes_without_a_gap() {
|
||||
// The first-byte test must not change *which* entry `starts_with`
|
||||
// picks — only how many entries are tried before it does. Lexing
|
||||
// every `op1 op2` concatenation (no space) and requiring the token
|
||||
// stream to account for every byte with no lex error is the
|
||||
// regression gate: a wrong short-circuit would either misplace the
|
||||
// split point or leave a byte unconsumed. Cross-checked pair for
|
||||
// pair against `tokenize` built from 1b8723c (pre-first-byte-test)
|
||||
// in the QA scratchpad: 1 764 pairs, 0 differ.
|
||||
for &op1 in OPERATORS {
|
||||
for &op2 in OPERATORS {
|
||||
let src = format!("{op1}{op2} ;");
|
||||
let toks = tokenize(&src)
|
||||
.unwrap_or_else(|e| panic!("lexing {op1:?} followed by {op2:?} failed: {e}"));
|
||||
// Everything up to the space must be Symbol tokens whose
|
||||
// texts concatenate back to exactly op1 followed by op2,
|
||||
// with no gap and no overlap.
|
||||
let mut consumed = String::new();
|
||||
let mut i = 0;
|
||||
while toks[i].kind == TokenKind::Symbol && toks[i].text != ";" {
|
||||
consumed.push_str(&toks[i].text);
|
||||
i += 1;
|
||||
}
|
||||
assert_eq!(
|
||||
consumed,
|
||||
format!("{op1}{op2}"),
|
||||
"{op1:?} followed by {op2:?} did not round-trip"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,11 +53,11 @@ impl<'a> Parser<'a> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
if self.cur().kind == TokenKind::Ident && self.nth(1).is_sym(":") {
|
||||
self.bump();
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip();
|
||||
}
|
||||
// `assert` / `assume` / `cover` / `restrict`.
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expect_kw("property")?;
|
||||
self.expect_sym("(")?;
|
||||
self.skip_balanced("(", ")")?;
|
||||
@@ -132,22 +132,22 @@ impl<'a> Parser<'a> {
|
||||
at_stmt_start = false;
|
||||
let t = self.cur();
|
||||
if t.is_sym("(") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip_balanced("(", ")")?;
|
||||
} else if t.is_sym("[") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip_balanced("[", "]")?;
|
||||
} else if t.is_sym("{") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip_balanced("{", "}")?;
|
||||
} else if (t.is_kw("disable") || t.is_kw("wait")) && self.nth(1).is_kw("fork") {
|
||||
// `disable fork` / `wait fork` name the enclosing block; they
|
||||
// do not open one.
|
||||
self.bump();
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip();
|
||||
} else if BLOCK_OPENERS.iter().any(|k| t.is_kw(k)) {
|
||||
depth += 1;
|
||||
self.bump();
|
||||
self.skip();
|
||||
} else if BLOCK_CLOSERS.iter().any(|k| t.is_kw(k)) {
|
||||
if depth == 0 {
|
||||
// A closer with nothing open: the action statement is
|
||||
@@ -156,7 +156,7 @@ impl<'a> Parser<'a> {
|
||||
return self.error("expected `;`");
|
||||
}
|
||||
depth -= 1;
|
||||
self.bump();
|
||||
self.skip();
|
||||
if depth == 0 {
|
||||
self.parse_label()?;
|
||||
if !self.eat_kw("else") {
|
||||
@@ -167,7 +167,7 @@ impl<'a> Parser<'a> {
|
||||
} else if depth == 0 && self.eat_sym(";") {
|
||||
return Ok(());
|
||||
} else {
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,9 +199,9 @@ impl<'a> Parser<'a> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
let end_kw = if self.cur().is_kw("sequence") { "endsequence" } else { "endproperty" };
|
||||
self.bump();
|
||||
self.skip();
|
||||
while !self.at_eof() && !self.cur().is_kw(end_kw) {
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
self.expect_closer(end_kw)?;
|
||||
self.parse_label()?;
|
||||
@@ -220,7 +220,7 @@ impl<'a> Parser<'a> {
|
||||
fn parse_default_disable(&mut self) -> PResult<RawText> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
self.bump(); // default
|
||||
self.skip(); // default
|
||||
self.expect_kw("disable")?;
|
||||
self.expect_kw("iff")?;
|
||||
self.skip_to_semi()?;
|
||||
@@ -252,7 +252,7 @@ impl<'a> Parser<'a> {
|
||||
fn parse_prop_seq_decl_inner(&mut self) -> PResult<PropSeqDecl> {
|
||||
let kw = self.cur().text.clone();
|
||||
let end_kw = if kw == "sequence" { "endsequence" } else { "endproperty" };
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before_name = self.take_gap();
|
||||
let name = self.expect_name()?;
|
||||
let before_args = self.take_before_open("(");
|
||||
@@ -407,7 +407,7 @@ impl<'a> Parser<'a> {
|
||||
let mut action = ActionBlock::default();
|
||||
if self.cur().is_sym(";") {
|
||||
action.before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(action);
|
||||
}
|
||||
if !self.cur().is_kw("else") {
|
||||
@@ -415,7 +415,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
if self.cur().is_kw("else") {
|
||||
action.before_else = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
action.after_else = self.take_gap();
|
||||
action.fail = Some(Box::new(self.parse_stmt()?));
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ impl<'a> Parser<'a> {
|
||||
let mut after_hash = Vec::new();
|
||||
let mut param_directives = Vec::new();
|
||||
if self.cur().is_sym("#") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_hash = self.take_gap();
|
||||
self.expect_sym("(")?;
|
||||
let mark = self.diags_mark();
|
||||
@@ -305,7 +305,7 @@ impl<'a> Parser<'a> {
|
||||
return self.parse_constraint_foreach();
|
||||
}
|
||||
if self.cur().is_kw("unique") && self.nth(1).is_sym("{") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let comments = self.take_gap();
|
||||
let items = self.parse_constraint_expr_set()?;
|
||||
return Ok(ConstraintItemKind::Unique { items, comments });
|
||||
@@ -314,9 +314,9 @@ impl<'a> Parser<'a> {
|
||||
// `soft` is matched by text, for the reason `parse_constraint_expr`
|
||||
// gives.
|
||||
if self.cur().is_kw("disable") && word_at(self.nth(1), "soft") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after = self.take_gap();
|
||||
let expr = self.parse_expr()?;
|
||||
return Ok(ConstraintItemKind::DisableSoft {
|
||||
@@ -341,7 +341,7 @@ impl<'a> Parser<'a> {
|
||||
let soft = self.at_soft_constraint();
|
||||
let mut after_soft = Vec::new();
|
||||
if soft {
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_soft = self.take_gap();
|
||||
}
|
||||
let mark = self.pending_trailing.len();
|
||||
@@ -374,7 +374,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
if !soft && self.cur().is_sym("->") {
|
||||
let before = self.take_around(mark);
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after = self.take_around(mark);
|
||||
let set = self.parse_constraint_set()?;
|
||||
return Ok(ConstraintItemKind::Implication {
|
||||
@@ -403,7 +403,7 @@ impl<'a> Parser<'a> {
|
||||
let mut els = None;
|
||||
if self.cur().is_kw("else") {
|
||||
else_comments = self.take_dangling();
|
||||
self.bump();
|
||||
self.skip();
|
||||
// The gap after `else` is this item's when the set it introduces
|
||||
// opens with a token of its own — a `{`, or the `if` of a chain.
|
||||
// A set written on the next line leaves it to that item's own
|
||||
@@ -458,13 +458,13 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
fn parse_solve_before(&mut self) -> PResult<ConstraintItemKind> {
|
||||
self.bump(); // solve
|
||||
self.skip(); // solve
|
||||
let solve = self.parse_solve_operands()?;
|
||||
if !word_at(self.cur(), "before") {
|
||||
return self.error("expected `before`");
|
||||
}
|
||||
let before_comments = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before = self.parse_solve_operands()?;
|
||||
Ok(ConstraintItemKind::SolveBefore { solve, before_comments, before })
|
||||
}
|
||||
@@ -526,7 +526,7 @@ impl<'a> Parser<'a> {
|
||||
expr: Expr,
|
||||
before: Vec<Comment>,
|
||||
) -> PResult<Expr> {
|
||||
self.bump(); // dist
|
||||
self.skip(); // dist
|
||||
let after = self.take_gap();
|
||||
self.expect_sym("{")?;
|
||||
let mut weights: Vec<DistItem> = Vec::new();
|
||||
@@ -539,8 +539,8 @@ impl<'a> Parser<'a> {
|
||||
let mut op_comments = BinaryComments::default();
|
||||
if let Some(spelling) = self.dist_weight_op() {
|
||||
op_comments.before = self.take_gap();
|
||||
self.bump();
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip();
|
||||
op_comments.after = self.take_gap();
|
||||
op = Some(spelling.to_string());
|
||||
weight = Some(self.parse_ternary()?);
|
||||
|
||||
@@ -56,7 +56,7 @@ impl<'a> Parser<'a> {
|
||||
self.take_member_prefix();
|
||||
self.expect_kw("covergroup")?;
|
||||
while !self.at_eof() && !self.cur().is_kw("endgroup") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
self.expect_closer("endgroup")?;
|
||||
self.parse_label()?;
|
||||
@@ -139,7 +139,7 @@ impl<'a> Parser<'a> {
|
||||
fn parse_coverage_event(&mut self) -> PResult<Option<CoverageEvent>> {
|
||||
if self.cur().is_kw("with") {
|
||||
let before_with = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_with = self.take_gap();
|
||||
self.expect_kw("function")?;
|
||||
let after_function = self.take_gap();
|
||||
@@ -147,7 +147,7 @@ impl<'a> Parser<'a> {
|
||||
return self.error("expected `sample`");
|
||||
}
|
||||
let name = Name { text: self.cur().text.clone(), span: self.cur().span };
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before_args = self.take_before_open("(");
|
||||
let has_parens = self.cur().is_sym("(");
|
||||
let args = self.parse_tf_ports(false)?.args;
|
||||
@@ -163,7 +163,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
if self.cur().is_sym("@") {
|
||||
let before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let sens = self.parse_sens_list()?;
|
||||
return Ok(Some(CoverageEvent::Clocking { before, sens }));
|
||||
}
|
||||
@@ -206,9 +206,9 @@ impl<'a> Parser<'a> {
|
||||
&& (word_at(self.nth(2), "coverpoint") || word_at(self.nth(2), "cross"))
|
||||
{
|
||||
let name = Name { text: self.cur().text.clone(), span: self.cur().span };
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before = self.take_gap();
|
||||
self.bump(); // :
|
||||
self.skip(); // :
|
||||
let after = self.take_gap();
|
||||
Some(CoverLabel { name, comments: Box::new(BinaryComments { before, after }) })
|
||||
} else {
|
||||
@@ -224,7 +224,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
fn parse_coverpoint(&mut self, label: Option<CoverLabel>) -> PResult<CoverpointDecl> {
|
||||
self.bump(); // coverpoint
|
||||
self.skip(); // coverpoint
|
||||
let after_kw = self.take_gap();
|
||||
let expr = self.parse_expr()?;
|
||||
let iff = self.parse_cover_iff()?;
|
||||
@@ -234,7 +234,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
fn parse_cross(&mut self, label: Option<CoverLabel>) -> PResult<CrossDecl> {
|
||||
self.bump(); // cross
|
||||
self.skip(); // cross
|
||||
let after_kw = self.take_gap();
|
||||
let mut items: Vec<ExprItem> = Vec::new();
|
||||
loop {
|
||||
@@ -265,7 +265,7 @@ impl<'a> Parser<'a> {
|
||||
return Ok(None);
|
||||
}
|
||||
let before_kw = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_kw = self.take_gap();
|
||||
self.expect_sym("(")?;
|
||||
let after_open = self.take_gap();
|
||||
@@ -356,13 +356,13 @@ impl<'a> Parser<'a> {
|
||||
let wildcard = word_at(self.cur(), "wildcard") && bin_kind_at(self.nth(1)).is_some();
|
||||
let mut after_wildcard = Vec::new();
|
||||
if wildcard {
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_wildcard = self.take_gap();
|
||||
}
|
||||
let Some(kind) = bin_kind_at(self.cur()) else {
|
||||
return self.error("expected `bins`, `ignore_bins` or `illegal_bins`");
|
||||
};
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before_name = self.take_gap();
|
||||
let name = self.expect_name()?;
|
||||
let array = self.parse_bin_array()?;
|
||||
@@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
|
||||
return Ok(None);
|
||||
}
|
||||
let before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let inner_before = self.take_gap();
|
||||
let size = if self.cur().is_sym("]") { None } else { Some(self.parse_expr()?) };
|
||||
let inner_after = self.gap_before("]");
|
||||
@@ -412,12 +412,12 @@ impl<'a> Parser<'a> {
|
||||
/// `bins b = (1'b1[*5]);` wrong.
|
||||
fn parse_bin_spec(&mut self, in_cross: bool) -> PResult<BinSpec> {
|
||||
if self.cur().is_kw("default") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
// `sequence` really is a lexer keyword (a `sequence ... endsequence`
|
||||
// declaration), so this one is not matched by text.
|
||||
if self.cur().is_kw("sequence") {
|
||||
let comments = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(BinSpec::DefaultSequence { comments });
|
||||
}
|
||||
return Ok(BinSpec::Default);
|
||||
@@ -446,7 +446,7 @@ impl<'a> Parser<'a> {
|
||||
break;
|
||||
}
|
||||
let before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after = self.take_gap();
|
||||
arrow = BinaryComments { before, after };
|
||||
}
|
||||
@@ -494,7 +494,7 @@ impl<'a> Parser<'a> {
|
||||
return Ok(None);
|
||||
}
|
||||
let before = self.take_gap();
|
||||
self.bump(); // [
|
||||
self.skip(); // [
|
||||
let after_open = self.take_gap();
|
||||
let op = self.bump().text;
|
||||
let inner_before = self.take_gap();
|
||||
@@ -503,7 +503,7 @@ impl<'a> Parser<'a> {
|
||||
let mut hi = None;
|
||||
if self.cur().is_sym(":") {
|
||||
colon.before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
colon.after = self.take_gap();
|
||||
hi = Some(self.parse_expr()?);
|
||||
}
|
||||
@@ -541,13 +541,13 @@ impl<'a> Parser<'a> {
|
||||
|
||||
fn parse_select_primary(&mut self) -> PResult<SelectExpr> {
|
||||
if self.cur().is_sym("!") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let comments = self.take_gap();
|
||||
let expr = self.parse_select_primary()?;
|
||||
return Ok(SelectExpr::Not { comments, expr: Box::new(expr) });
|
||||
}
|
||||
if self.cur().is_sym("(") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before = self.take_gap();
|
||||
let expr = self.parse_select_expr()?;
|
||||
let after = self.gap_before(")");
|
||||
@@ -577,7 +577,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
fn parse_binsof(&mut self) -> PResult<BinsofSel> {
|
||||
self.bump(); // binsof
|
||||
self.skip(); // binsof
|
||||
let after_kw = self.take_gap();
|
||||
self.expect_sym("(")?;
|
||||
let after_open = self.take_gap();
|
||||
@@ -589,7 +589,7 @@ impl<'a> Parser<'a> {
|
||||
let mut intersect = None;
|
||||
if word_at(self.cur(), "intersect") {
|
||||
before_intersect = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_intersect = self.take_gap();
|
||||
intersect = Some(self.parse_constraint_expr_set()?);
|
||||
}
|
||||
@@ -610,7 +610,7 @@ impl<'a> Parser<'a> {
|
||||
return Ok(None);
|
||||
}
|
||||
let before_kw = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_kw = self.take_gap();
|
||||
self.expect_sym("(")?;
|
||||
let after_open = self.take_gap();
|
||||
|
||||
@@ -63,6 +63,31 @@ impl<'a> Parser<'a> {
|
||||
t
|
||||
}
|
||||
|
||||
/// Consume the current token without building a copy of it.
|
||||
///
|
||||
/// Exactly [`Parser::bump`] for the caller that throws the token away —
|
||||
/// the same comment plumbing, the same cursor step, the same `self.tokens`
|
||||
/// left untouched — minus the clone. `bump` copies the token's `text`
|
||||
/// (a `String`, so an allocation) and its comment buckets for a value most
|
||||
/// callers drop on the next line; on a 40 267-line generated file that is
|
||||
/// one allocate-and-free per token consumed (TODO §63.2).
|
||||
pub(super) fn skip(&mut self) {
|
||||
let token = &self.tokens[self.pos];
|
||||
// Cloned rather than moved out, because `bump` moved them out of its
|
||||
// *copy*: the stream keeps its comments either way, which is what the
|
||||
// rewind of a speculative parse relies on.
|
||||
let (mut leading, trailing) = (token.leading.clone(), token.trailing.clone());
|
||||
if self.pos + 1 < self.tokens.len() {
|
||||
self.pos += 1;
|
||||
}
|
||||
if !leading.is_empty() {
|
||||
self.pending_leading.append(&mut leading);
|
||||
}
|
||||
if let Some(trailing) = trailing {
|
||||
self.pending_trailing.push(trailing);
|
||||
}
|
||||
}
|
||||
|
||||
/// Open one level of nesting, refusing to recurse past
|
||||
/// [`MAX_NESTING_DEPTH`]. Callers that succeed must pair this with
|
||||
/// [`Parser::leave`] on every path out, including the error paths.
|
||||
@@ -199,7 +224,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
pub(super) fn eat_sym(&mut self, sym: &str) -> bool {
|
||||
if self.cur().is_sym(sym) {
|
||||
self.bump();
|
||||
self.skip();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
@@ -208,7 +233,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
pub(super) fn eat_kw(&mut self, kw: &str) -> bool {
|
||||
if self.cur().is_kw(kw) {
|
||||
self.bump();
|
||||
self.skip();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
||||
@@ -39,7 +39,7 @@ impl<'a> Parser<'a> {
|
||||
// this function with the `virtual` already taken into
|
||||
// `DataDecl::qualifiers`, so this only fires for the other positions.)
|
||||
if self.cur().is_kw("virtual") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
ty.virt =
|
||||
Some(if self.eat_kw("interface") { VirtualKw::Interface } else { VirtualKw::Bare });
|
||||
// `virtual spi_if.tb sif` — a modport-qualified virtual interface
|
||||
@@ -97,12 +97,12 @@ impl<'a> Parser<'a> {
|
||||
// comment inside the brackets could attach.
|
||||
let mut comments =
|
||||
SegmentComments { before_open: self.take_gap(), ..Default::default() };
|
||||
self.bump();
|
||||
self.skip();
|
||||
comments.after_open = self.take_gap();
|
||||
let kind = if self.cur().is_sym("]") {
|
||||
// `[]` — a dynamic array.
|
||||
comments.before_close = std::mem::take(&mut comments.after_open);
|
||||
self.bump();
|
||||
self.skip();
|
||||
dims.push(Dim {
|
||||
kind: DimKind::Dynamic,
|
||||
comments: Box::new(comments),
|
||||
@@ -111,7 +111,7 @@ impl<'a> Parser<'a> {
|
||||
continue;
|
||||
} else if self.cur().is_sym("*") && self.nth(1).is_sym("]") {
|
||||
// `[*]` — a wildcard-keyed associative array.
|
||||
self.bump();
|
||||
self.skip();
|
||||
DimKind::Wildcard
|
||||
} else {
|
||||
let a = self.parse_expr()?;
|
||||
@@ -303,7 +303,7 @@ impl<'a> Parser<'a> {
|
||||
// `wire /* c */ #5 w;`. Taken only here — when the read does not
|
||||
// happen the gap belongs to whatever comes next.
|
||||
let before_hash = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_hash = self.take_gap();
|
||||
Ok(Some(NetDelay { before_hash, after_hash, expr: self.parse_delay_value()?, after_type }))
|
||||
}
|
||||
@@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
|
||||
let mut eq_comments = BinaryComments::default();
|
||||
let value = if self.cur().is_sym("=") {
|
||||
eq_comments.before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
eq_comments.after = self.take_gap();
|
||||
Some(self.parse_expr()?)
|
||||
} else {
|
||||
@@ -436,7 +436,7 @@ impl<'a> Parser<'a> {
|
||||
// grammar of their own and are still a clean parse error.
|
||||
let tagged = word_at(self.cur(), "tagged");
|
||||
if tagged {
|
||||
self.bump();
|
||||
self.skip();
|
||||
header_comments.after_tagged = self.take_gap();
|
||||
}
|
||||
let packed = self.eat_kw("packed");
|
||||
|
||||
@@ -347,8 +347,8 @@ impl<'a> Parser<'a> {
|
||||
let raw = if self.at_spaced_macro_call() {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
self.bump(); // `NAME
|
||||
self.bump(); // (
|
||||
self.skip(); // `NAME
|
||||
self.skip(); // (
|
||||
self.skip_balanced("(", ")")?;
|
||||
// Verbatim, space included: the argument text is preprocessor
|
||||
// input lucisv does not model, and closing the gap would make the
|
||||
|
||||
@@ -64,7 +64,7 @@ impl<'a> Parser<'a> {
|
||||
// Each of the four gaps inside a `? :` can hold comments; kept
|
||||
// apart so none of them drifts across the `?` or the `:`.
|
||||
let before_question = self.take_around(mark);
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_question = self.take_around(mark);
|
||||
let then = self.parse_expr()?;
|
||||
let before_colon = self.take_around(mark);
|
||||
@@ -144,7 +144,7 @@ impl<'a> Parser<'a> {
|
||||
// The word is an operator like any other, and keeps the
|
||||
// comments written on either side of it the same way.
|
||||
let before = self.take_around(mark);
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after = self.take_around(mark);
|
||||
let comments = Box::new(BinaryComments { before, after });
|
||||
// `x inside `MACRO` — the macro expands to the `{...}` set,
|
||||
@@ -324,7 +324,7 @@ impl<'a> Parser<'a> {
|
||||
let base = Box::new(base);
|
||||
if self.cur().is_sym(".") || self.cur().is_sym("::") {
|
||||
let scoped = self.cur().is_sym("::");
|
||||
self.bump();
|
||||
self.skip();
|
||||
comments.after_open = self.take_gap();
|
||||
let name = self.expect_ident()?;
|
||||
let comments = Box::new(comments);
|
||||
@@ -415,7 +415,7 @@ impl<'a> Parser<'a> {
|
||||
before_open: self.take_before_open("("),
|
||||
..CallComments::default()
|
||||
};
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mut args = Vec::new();
|
||||
if !self.cur().is_sym(")") {
|
||||
let arg_start = self.here();
|
||||
@@ -462,14 +462,14 @@ impl<'a> Parser<'a> {
|
||||
},
|
||||
);
|
||||
} else if self.nth(1).is_sym("[") {
|
||||
self.bump(); // with
|
||||
self.skip(); // with
|
||||
let range = self.parse_stream_range(comments)?;
|
||||
expr = self.expr_at(
|
||||
start,
|
||||
ExprKind::StreamWith { base: Box::new(expr), range: Box::new(range) },
|
||||
);
|
||||
} else {
|
||||
self.bump(); // with
|
||||
self.skip(); // with
|
||||
comments.after_kw = self.take_before_open("(");
|
||||
// `( expression )` — an ordinary parenthesized primary,
|
||||
// which is what IEEE 1800 §7.12 spells here.
|
||||
@@ -511,9 +511,9 @@ impl<'a> Parser<'a> {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
self.bump(); // '
|
||||
self.skip(); // '
|
||||
comments.after_tick = self.take_gap();
|
||||
self.bump(); // (
|
||||
self.skip(); // (
|
||||
comments.after_open = self.take_gap();
|
||||
let inner = self.parse_expr()?;
|
||||
comments.before_close = self.gap_before(")");
|
||||
|
||||
@@ -24,7 +24,7 @@ impl<'a> Parser<'a> {
|
||||
let mut after_hash = Vec::new();
|
||||
let mut after_delay = Vec::new();
|
||||
let delay = if self.cur().is_sym("#") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_hash = self.take_gap();
|
||||
let delay = self.parse_delay_value()?;
|
||||
// The gap between the delay and the first left-hand side is the
|
||||
@@ -82,7 +82,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
let mut comments =
|
||||
Box::new(DriveStrengthComments { before_open: self.take_gap(), ..Default::default() });
|
||||
self.bump(); // (
|
||||
self.skip(); // (
|
||||
comments.after_open = self.take_gap();
|
||||
let first = self.bump().text;
|
||||
// The gap after the first strength ends either at the `,` or at the
|
||||
@@ -121,7 +121,7 @@ impl<'a> Parser<'a> {
|
||||
// What is written just inside the `(` belongs to the first value; the
|
||||
// gap before each `,` and the gap after it belong to the values either
|
||||
// side of it.
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mut leading = self.take_gap();
|
||||
let mut out: Vec<DelayValue> = Vec::new();
|
||||
loop {
|
||||
@@ -242,7 +242,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
/// `bind <target> [: <inst>, ...] <module> [#(...)] <name> (...);`
|
||||
pub(super) fn parse_bind(&mut self) -> PResult<BindDirective> {
|
||||
self.bump(); // `bind`
|
||||
self.skip(); // `bind`
|
||||
// The target is a bare string, so a comment written before it has no
|
||||
// node to attach to: harvest it here, where source order is still
|
||||
// known, rather than letting it drift onto the instance below.
|
||||
@@ -250,7 +250,7 @@ impl<'a> Parser<'a> {
|
||||
let start = self.here();
|
||||
let mut target = vec![self.parse_path_segment()?];
|
||||
while self.cur().is_sym(".") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
target.push(self.parse_path_segment()?);
|
||||
}
|
||||
let target_span = self.span_from(start);
|
||||
@@ -278,7 +278,7 @@ impl<'a> Parser<'a> {
|
||||
let start = self.here();
|
||||
let mut text = self.expect_ident()?;
|
||||
while self.cur().is_sym(".") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let segment = self.expect_ident()?;
|
||||
Self::push_path_segment(&mut text, &segment);
|
||||
}
|
||||
@@ -301,7 +301,7 @@ impl<'a> Parser<'a> {
|
||||
let module_start = self.here();
|
||||
let mut module = self.expect_ident()?;
|
||||
while self.cur().is_sym("::") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let segment = self.expect_ident()?;
|
||||
Self::push_scope_segment(&mut module, &segment);
|
||||
}
|
||||
@@ -312,7 +312,7 @@ impl<'a> Parser<'a> {
|
||||
let mut after_hash = Vec::new();
|
||||
let mut param_directives = Vec::new();
|
||||
if self.cur().is_sym("#") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_hash = self.take_gap();
|
||||
self.expect_sym("(")?;
|
||||
let mut list = Vec::new();
|
||||
@@ -571,7 +571,7 @@ impl<'a> Parser<'a> {
|
||||
// `.name(/* unused */)`: the comments were written inside
|
||||
// these parens and are printed back inside them.
|
||||
let inside = self.take_around(mark);
|
||||
self.bump();
|
||||
self.skip();
|
||||
Some(self.expr_at(paren_start, ExprKind::Empty(inside)))
|
||||
} else {
|
||||
after_open = self.take_gap();
|
||||
@@ -684,7 +684,7 @@ impl<'a> Parser<'a> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
while self.pos < end_pos && !self.at_eof() {
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
let raw = self.verbatim_since(start, col);
|
||||
self.expr_at(start, ExprKind::Verbatim(raw))
|
||||
@@ -699,7 +699,7 @@ impl<'a> Parser<'a> {
|
||||
let before_hash = self.take_before_open("#");
|
||||
let mut after_hash = Vec::new();
|
||||
let delay = if self.cur().is_sym("#") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_hash = self.take_gap();
|
||||
self.parse_delay_values()?
|
||||
} else {
|
||||
|
||||
@@ -155,7 +155,7 @@ impl<'a> Parser<'a> {
|
||||
// `TokenKind` match below because punctuation is matched by text
|
||||
// everywhere in this file. See `ItemKind::Empty`.
|
||||
if self.cur().is_sym(";") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(ItemKind::Empty);
|
||||
}
|
||||
let t = self.cur();
|
||||
@@ -209,7 +209,7 @@ impl<'a> Parser<'a> {
|
||||
"modport" => self.parse_modport().map(ItemKind::Modport),
|
||||
"clocking" => self.parse_clocking(false).map(ItemKind::Clocking),
|
||||
"default" if self.nth(1).is_kw("clocking") => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.parse_clocking(true).map(ItemKind::Clocking)
|
||||
}
|
||||
"default" if self.nth(1).is_kw("disable") => self.parse_default_disable_item(),
|
||||
@@ -243,7 +243,7 @@ impl<'a> Parser<'a> {
|
||||
Ok(ItemKind::PortDecl(d))
|
||||
}
|
||||
"genvar" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mut names = vec![self.expect_name()?];
|
||||
while self.eat_sym(",") {
|
||||
names.push(self.expect_name()?);
|
||||
@@ -258,15 +258,15 @@ impl<'a> Parser<'a> {
|
||||
Ok(ItemKind::Always { kw, stmt })
|
||||
}
|
||||
"initial" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
Ok(ItemKind::Initial(self.parse_stmt()?))
|
||||
}
|
||||
"final" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
Ok(ItemKind::Final(self.parse_stmt()?))
|
||||
}
|
||||
"generate" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mut items = Vec::new();
|
||||
while !self.at_body_end("endgenerate") {
|
||||
items.push(self.item_or_recover()?);
|
||||
@@ -339,7 +339,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
"defparam" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mut pairs = Vec::new();
|
||||
loop {
|
||||
let lhs = self.parse_expr()?;
|
||||
@@ -492,7 +492,7 @@ impl<'a> Parser<'a> {
|
||||
loop {
|
||||
let star = self.cur().span;
|
||||
let pkg = if allow_star_pkg && self.cur().is_sym("*") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
Name { text: "*".to_string(), span: star }
|
||||
} else {
|
||||
self.expect_name()?
|
||||
@@ -578,7 +578,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
let span = self.cur().span;
|
||||
let name = Name { text: self.bump().text, span };
|
||||
self.bump();
|
||||
self.skip();
|
||||
Some(name)
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ impl<'a> Parser<'a> {
|
||||
let then = self.parse_gen_block()?;
|
||||
let els = if self.cur().is_kw("else") {
|
||||
let meta = self.take_meta();
|
||||
self.bump();
|
||||
self.skip();
|
||||
if self.cur().is_kw("if") {
|
||||
Some(Box::new(GenElse::If(meta, Box::new(self.parse_gen_if()?))))
|
||||
} else {
|
||||
@@ -688,7 +688,7 @@ impl<'a> Parser<'a> {
|
||||
// The gap between whatever came before and the `begin` belongs to
|
||||
// the block — nothing else was written where it could attach.
|
||||
let before_kw = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let before_colon = self.gap_before(":");
|
||||
let mut after_colon = Vec::new();
|
||||
let label_name = if self.eat_sym(":") {
|
||||
|
||||
@@ -22,7 +22,7 @@ impl<'a> Parser<'a> {
|
||||
let kw = self.cur().text.clone();
|
||||
match kw.as_str() {
|
||||
"begin" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let (label_comments, label_name) = self.parse_label_with()?;
|
||||
let (label, label_span) = split_label(label_name);
|
||||
let mut stmts = Vec::new();
|
||||
@@ -45,7 +45,7 @@ impl<'a> Parser<'a> {
|
||||
})
|
||||
}
|
||||
"fork" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let (label_comments, label_name) = self.parse_label_with()?;
|
||||
let (label, label_span) = split_label(label_name);
|
||||
let mut stmts = Vec::new();
|
||||
@@ -88,7 +88,7 @@ impl<'a> Parser<'a> {
|
||||
"case" | "casex" | "casez" => self.parse_case_stmt(None),
|
||||
"for" => self.parse_for_stmt(),
|
||||
"while" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expect_sym("(")?;
|
||||
let cond = self.cond_or_recover()?;
|
||||
let recovered = cond.is_error();
|
||||
@@ -96,7 +96,7 @@ impl<'a> Parser<'a> {
|
||||
Ok(StmtKind::While { cond, body: Box::new(self.body_after_recovery(recovered)?) })
|
||||
}
|
||||
"do" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let body = Box::new(self.parse_stmt()?);
|
||||
self.expect_kw("while")?;
|
||||
let mut comments =
|
||||
@@ -110,7 +110,7 @@ impl<'a> Parser<'a> {
|
||||
Ok(StmtKind::DoWhile { body, cond, comments: Box::new(comments) })
|
||||
}
|
||||
"repeat" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expect_sym("(")?;
|
||||
let count = self.cond_or_recover()?;
|
||||
let recovered = count.is_error();
|
||||
@@ -118,11 +118,11 @@ impl<'a> Parser<'a> {
|
||||
Ok(StmtKind::Repeat { count, body: Box::new(self.body_after_recovery(recovered)?) })
|
||||
}
|
||||
"forever" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
Ok(StmtKind::Forever { body: Box::new(self.parse_stmt()?) })
|
||||
}
|
||||
"foreach" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mut comments =
|
||||
HeaderComments { after_kw: self.take_gap(), ..Default::default() };
|
||||
self.expect_sym("(")?;
|
||||
@@ -141,41 +141,41 @@ impl<'a> Parser<'a> {
|
||||
})
|
||||
}
|
||||
"randcase" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let (items, dangling) = self.parse_case_body()?;
|
||||
Ok(StmtKind::RandCase { items, dangling })
|
||||
}
|
||||
"return" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_kw = self.take_gap();
|
||||
let expr = if self.cur().is_sym(";") { None } else { Some(self.parse_expr()?) };
|
||||
self.expect_stmt_semi()?;
|
||||
Ok(StmtKind::Return { after_kw, expr })
|
||||
}
|
||||
"break" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expect_stmt_semi()?;
|
||||
Ok(StmtKind::Break)
|
||||
}
|
||||
"continue" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expect_stmt_semi()?;
|
||||
Ok(StmtKind::Continue)
|
||||
}
|
||||
"disable" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
// `disable fork;` kills every process the enclosing `fork`
|
||||
// started; `fork` is a keyword, not a block name.
|
||||
if self.cur().is_kw("fork") {
|
||||
let name_span = self.cur().span;
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expect_stmt_semi()?;
|
||||
return Ok(StmtKind::Disable { name: "fork".to_string(), name_span });
|
||||
}
|
||||
let start = self.here();
|
||||
let mut name = self.expect_ident()?;
|
||||
while self.cur().is_sym(".") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
name.push('.');
|
||||
name.push_str(&self.expect_ident()?);
|
||||
}
|
||||
@@ -184,11 +184,11 @@ impl<'a> Parser<'a> {
|
||||
Ok(StmtKind::Disable { name, name_span })
|
||||
}
|
||||
"wait" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
// `wait fork;` waits for the enclosing `fork`'s children
|
||||
// (IEEE 1800 §9.6.1); `fork` is a keyword, not a condition.
|
||||
if self.cur().is_kw("fork") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expect_stmt_semi()?;
|
||||
return Ok(StmtKind::WaitFork);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ impl<'a> Parser<'a> {
|
||||
Ok(StmtKind::Assert { kw, cond, then, els })
|
||||
}
|
||||
"force" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let lhs = self.parse_unary()?;
|
||||
self.expect_sym("=")?;
|
||||
let rhs = self.parse_expr()?;
|
||||
@@ -290,7 +290,7 @@ impl<'a> Parser<'a> {
|
||||
/// is parsed as usual. The init entries read before the failure are kept
|
||||
/// — they are what declares the loop variable the body uses.
|
||||
fn parse_for_stmt(&mut self) -> PResult<StmtKind> {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mut comments = ForComments { after_kw: self.take_gap(), ..Default::default() };
|
||||
self.expect_sym("(")?;
|
||||
comments.after_open = self.take_gap();
|
||||
|
||||
@@ -431,7 +431,7 @@ impl<'a> Parser<'a> {
|
||||
let mut scope: Vec<ScopeSeg> = Vec::new();
|
||||
while self.cur().is_sym("::") {
|
||||
let before_sep = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_sep = self.take_gap();
|
||||
let next = self.expect_name()?;
|
||||
scope.push(ScopeSeg { name, before_sep, after_sep });
|
||||
@@ -474,7 +474,7 @@ impl<'a> Parser<'a> {
|
||||
let start = self.here();
|
||||
let mut name = self.expect_ident()?;
|
||||
while self.cur().is_sym("::") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let segment = self.expect_ident()?;
|
||||
Self::push_scope_segment(&mut name, &segment);
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ impl<'a> Parser<'a> {
|
||||
return Ok(None);
|
||||
}
|
||||
let before_dir = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_dir = self.take_gap();
|
||||
Ok(Some(ClockingDefault { before_dir, after_dir, skew: self.parse_clocking_skew()? }))
|
||||
}
|
||||
@@ -387,7 +387,7 @@ impl<'a> Parser<'a> {
|
||||
if !self.cur().is_sym("#") {
|
||||
return Ok(out);
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
out.after_hash = self.take_gap();
|
||||
self.expect_sym("(")?;
|
||||
let mark = self.diags_mark();
|
||||
@@ -438,7 +438,7 @@ impl<'a> Parser<'a> {
|
||||
return Ok((Box::default(), None));
|
||||
}
|
||||
let before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after = self.take_gap();
|
||||
let value = parse(self)?;
|
||||
Ok((Box::new(BinaryComments { before, after }), Some(value)))
|
||||
@@ -507,7 +507,7 @@ impl<'a> Parser<'a> {
|
||||
if !self.cur().is_sym("(") {
|
||||
return Ok((PortList::None, Vec::new(), Vec::new()));
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
let mark = self.diags_mark();
|
||||
// Directives before the first port. Harvested here rather than in the
|
||||
// loop below because both the ANSI/non-ANSI decision and the
|
||||
@@ -517,7 +517,7 @@ impl<'a> Parser<'a> {
|
||||
if self.cur().is_sym(")") {
|
||||
// `module m (/* c */);` — the comments stay between the parens.
|
||||
let dangling = self.take_dangling();
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok((PortList::Empty, dangling, directives));
|
||||
}
|
||||
let ansi = {
|
||||
|
||||
@@ -31,7 +31,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
TokenKind::Ident | TokenKind::SystemIdent => {
|
||||
if self.at_shallow_copy() {
|
||||
self.bump(); // new
|
||||
self.skip(); // new
|
||||
let src = self.parse_postfix()?;
|
||||
return Ok(self.expr_at(start, ExprKind::New(Box::new(src))));
|
||||
}
|
||||
@@ -53,9 +53,9 @@ impl<'a> Parser<'a> {
|
||||
let ty = self.expr_at(ty_start, ExprKind::Ident(ty_text));
|
||||
let mut comments =
|
||||
CastComments { before_tick: self.take_gap(), ..Default::default() };
|
||||
self.bump(); // '
|
||||
self.skip(); // '
|
||||
comments.after_tick = self.take_gap();
|
||||
self.bump(); // (
|
||||
self.skip(); // (
|
||||
comments.after_open = self.take_gap();
|
||||
let inner = self.parse_expr()?;
|
||||
comments.before_close = self.gap_before(")");
|
||||
@@ -85,14 +85,14 @@ impl<'a> Parser<'a> {
|
||||
// work through the existing expression grammar, and lucisv
|
||||
// checks legality nowhere else either.
|
||||
"$" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
Ok(self.expr_at(start, ExprKind::Ident("$".to_string())))
|
||||
}
|
||||
"(" => {
|
||||
// Comments written just inside the parens stay there;
|
||||
// anything else would move them across a token.
|
||||
let mut before = self.take_trailing_here();
|
||||
self.bump();
|
||||
self.skip();
|
||||
before.append(&mut self.take_leading_here());
|
||||
let mark = self.pending_trailing.len();
|
||||
let inner_start = self.here();
|
||||
@@ -106,7 +106,7 @@ impl<'a> Parser<'a> {
|
||||
))
|
||||
}
|
||||
"{" => {
|
||||
self.bump();
|
||||
self.skip();
|
||||
if self.cur().is_sym("<<") || self.cur().is_sym(">>") {
|
||||
return self.parse_stream_concat(start);
|
||||
}
|
||||
@@ -114,13 +114,13 @@ impl<'a> Parser<'a> {
|
||||
// `{}` — the empty queue/dynamic-array literal
|
||||
// (`q = {};`). Illegal as a Verilog concatenation,
|
||||
// but lucisv is not a legality checker.
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(self.expr_at(start, ExprKind::Concat(Vec::new())));
|
||||
}
|
||||
let first = self.parse_expr_item()?;
|
||||
if self.cur().is_sym("{") {
|
||||
// Replication {N{a, b}}
|
||||
self.bump();
|
||||
self.skip();
|
||||
let inner_first = self.parse_expr_item()?;
|
||||
let inner = self.parse_expr_list(inner_first, "}")?;
|
||||
self.expect_sym("}")?;
|
||||
@@ -241,7 +241,7 @@ impl<'a> Parser<'a> {
|
||||
/// (`ty'{...}`) keeps the type outside the pattern's span, in the `Cast`
|
||||
/// node that wraps it.
|
||||
pub(super) fn parse_assign_pattern(&mut self, start: u32) -> PResult<Expr> {
|
||||
self.bump(); // '{
|
||||
self.skip(); // '{
|
||||
if self.at_assign_pattern_repl() {
|
||||
return self.parse_assign_pattern_repl(start);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ impl<'a> Parser<'a> {
|
||||
let item_start = self.here();
|
||||
let mut meta = self.take_meta();
|
||||
let key_or_val = if self.cur().is_kw("default") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.expr_at(item_start, ExprKind::Ident("default".to_string()))
|
||||
} else {
|
||||
self.parse_expr_or_type()?
|
||||
@@ -352,7 +352,7 @@ impl<'a> Parser<'a> {
|
||||
/// the `.` and the next token is an identifier.
|
||||
pub(super) fn parse_named_arg(&mut self) -> PResult<Expr> {
|
||||
let start = self.here();
|
||||
self.bump(); // .
|
||||
self.skip(); // .
|
||||
let after_dot = self.take_gap();
|
||||
let Name { text: name, span: name_span } = self.expect_name()?;
|
||||
let before_open = self.take_before_open("(");
|
||||
@@ -365,7 +365,7 @@ impl<'a> Parser<'a> {
|
||||
// between the parens, exactly as an empty connection does. The
|
||||
// span covers the `( )` pair.
|
||||
let comments = self.take_around(mark);
|
||||
self.bump();
|
||||
self.skip();
|
||||
(self.expr_at(paren_start, ExprKind::Empty(comments)), Vec::new())
|
||||
} else {
|
||||
after_open = self.take_gap();
|
||||
@@ -403,7 +403,7 @@ impl<'a> Parser<'a> {
|
||||
pub(super) fn parse_value_range(&mut self) -> PResult<Expr> {
|
||||
let start = self.here();
|
||||
let mut comments = SegmentComments { before_open: self.take_gap(), ..Default::default() };
|
||||
self.bump(); // [
|
||||
self.skip(); // [
|
||||
comments.after_open = self.take_gap();
|
||||
let lo = self.parse_expr()?;
|
||||
comments.before_op = self.gap_before(":");
|
||||
|
||||
@@ -52,7 +52,7 @@ impl<'a> Parser<'a> {
|
||||
// The gap in front of the `|` belongs to the alternative it opens,
|
||||
// so it prints on the bar's own side of the previous one.
|
||||
let before_bar = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
alternatives.push(self.parse_alternative(before_bar)?);
|
||||
}
|
||||
let span = self.span_from(start);
|
||||
@@ -107,8 +107,8 @@ impl<'a> Parser<'a> {
|
||||
let mut weight = None;
|
||||
if self.at_weight_op() {
|
||||
before_weight = self.take_gap();
|
||||
self.bump(); // :
|
||||
self.bump(); // =
|
||||
self.skip(); // :
|
||||
self.skip(); // =
|
||||
weight = Some(self.parse_weight()?);
|
||||
}
|
||||
Ok(Alternative { before_bar, after_bar, items, before_weight, weight })
|
||||
@@ -170,7 +170,7 @@ impl<'a> Parser<'a> {
|
||||
return self.parse_rs_if();
|
||||
}
|
||||
if t.is_kw("repeat") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_kw = self.take_before_open("(");
|
||||
self.expect_sym("(")?;
|
||||
let count = self.parse_expr()?;
|
||||
@@ -240,7 +240,7 @@ impl<'a> Parser<'a> {
|
||||
// A `default` arm may write no `:` at all (§18.17.4).
|
||||
let has_colon = self.cur().is_sym(":");
|
||||
if has_colon {
|
||||
self.bump();
|
||||
self.skip();
|
||||
} else if !is_default {
|
||||
return self.error("expected `:` in a randsequence case arm");
|
||||
}
|
||||
@@ -271,7 +271,7 @@ impl<'a> Parser<'a> {
|
||||
let after_rand = self.take_gap();
|
||||
self.expect_kw("join")?;
|
||||
let weight = if self.cur().is_sym("(") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let e = self.parse_expr()?;
|
||||
self.expect_sym(")")?;
|
||||
Some(e)
|
||||
@@ -292,7 +292,7 @@ impl<'a> Parser<'a> {
|
||||
let has_parens = self.cur().is_sym("(");
|
||||
let mut args = Vec::new();
|
||||
if has_parens {
|
||||
self.bump();
|
||||
self.skip();
|
||||
if !self.cur().is_sym(")") {
|
||||
let first = self.parse_expr_item()?;
|
||||
args = self.parse_expr_list(first, ")")?;
|
||||
|
||||
@@ -102,7 +102,7 @@ impl<'a> Parser<'a> {
|
||||
/// error node.
|
||||
pub(super) fn expect_closer(&mut self, kw: &str) -> PResult<()> {
|
||||
if self.cur().is_kw(kw) {
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(());
|
||||
}
|
||||
if self.tolerant {
|
||||
@@ -150,7 +150,7 @@ impl<'a> Parser<'a> {
|
||||
return;
|
||||
}
|
||||
if t.is_sym(";") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ impl<'a> Parser<'a> {
|
||||
} else if open > 0 && (t.is_sym(")") || t.is_sym("]") || t.is_sym("}")) {
|
||||
open -= 1;
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ impl<'a> Parser<'a> {
|
||||
if self.pos == start_pos {
|
||||
// The failed construct consumed nothing, so skipping might not
|
||||
// either; take one token to guarantee the enclosing loop advances.
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
self.skip_to_sync();
|
||||
// Comments inside the skipped range are part of the raw text below.
|
||||
|
||||
@@ -227,7 +227,7 @@ impl<'a> Parser<'a> {
|
||||
if self.pos == start_pos && !self.cur().is_sym(")") {
|
||||
// The header consumed nothing and the skip below may not either;
|
||||
// take one token so the statement cannot be re-read forever.
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
self.skip_inside_brackets(true);
|
||||
// As in `recover`: comments inside the skipped range are bytes of the
|
||||
@@ -247,7 +247,7 @@ impl<'a> Parser<'a> {
|
||||
// Nothing was consumed and nothing below will be: the list loop
|
||||
// neither ends here nor eats a separator, so take one token to
|
||||
// guarantee it advances.
|
||||
self.bump();
|
||||
self.skip();
|
||||
} else if self.at_open_bracket() {
|
||||
// The element gave up standing *on* a bracket, which is therefore
|
||||
// one it opened and never closed — the `(` of a half-typed
|
||||
@@ -258,7 +258,7 @@ impl<'a> Parser<'a> {
|
||||
// the body would be swallowed looking for a `)` that was never
|
||||
// written. Taken here, the skip starts inside it at the list's own
|
||||
// level and stops at the next line as it does everywhere else.
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
self.skip_inside_brackets(false);
|
||||
let _ = self.take_dangling();
|
||||
@@ -310,7 +310,7 @@ impl<'a> Parser<'a> {
|
||||
} else if closes {
|
||||
open -= 1;
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ impl<'a> Parser<'a> {
|
||||
// already moved — are dropped by `verbatim_since`.
|
||||
self.pos = mark.pos;
|
||||
while self.pos < end_pos && !self.at_eof() {
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
self.verbatim_since(start, col)
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ impl<'a> Parser<'a> {
|
||||
return Ok(StmtKind::Directive(self.take_raw_text()));
|
||||
}
|
||||
if t.is_sym(";") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(StmtKind::Null);
|
||||
}
|
||||
if t.is_sym("#") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_hash = self.take_gap();
|
||||
let delay = self.parse_delay_value()?;
|
||||
let stmt = if self.eat_stmt_semi() { None } else { Some(Box::new(self.parse_stmt()?)) };
|
||||
@@ -139,7 +139,7 @@ impl<'a> Parser<'a> {
|
||||
});
|
||||
}
|
||||
if t.is_sym("@") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let sens = self.parse_sens_list()?;
|
||||
let stmt = if self.eat_stmt_semi() { None } else { Some(Box::new(self.parse_stmt()?)) };
|
||||
return Ok(StmtKind::Timing { control: TimingControl::Event(sens), stmt });
|
||||
@@ -204,7 +204,7 @@ impl<'a> Parser<'a> {
|
||||
// keyword's left; the then-branch has already taken its own
|
||||
// trailing comment.
|
||||
else_comments = self.take_dangling();
|
||||
self.bump();
|
||||
self.skip();
|
||||
Some(Box::new(self.parse_stmt()?))
|
||||
} else {
|
||||
None
|
||||
@@ -306,7 +306,7 @@ impl<'a> Parser<'a> {
|
||||
if let Some(last) = vars.last_mut() {
|
||||
last.after = self.take_gap();
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
vars.push(self.parse_foreach_var()?);
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ impl<'a> Parser<'a> {
|
||||
if self.cur().kind == TokenKind::Symbol && (ASSIGN_OPS.contains(&op.as_str()) || op == "<=")
|
||||
{
|
||||
let before = self.take_around(mark);
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after = self.take_gap();
|
||||
let rhs = self.parse_expr()?;
|
||||
Ok(ForStep::Assign(SimpleAssign {
|
||||
@@ -377,16 +377,16 @@ impl<'a> Parser<'a> {
|
||||
// it (`x[6:0] /* opcode */ = v;`); left in the pending buffers
|
||||
// they would be lost and the safety net would refuse the file.
|
||||
let op_comments = self.take_around(mark);
|
||||
self.bump();
|
||||
self.skip();
|
||||
let rhs_comments = self.take_around(mark);
|
||||
let timing = if self.cur().is_sym("#") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
Some(TimingControl::Delay {
|
||||
after_hash: self.take_gap(),
|
||||
expr: self.parse_delay_value()?,
|
||||
})
|
||||
} else if self.cur().is_sym("@") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
Some(TimingControl::Event(self.parse_sens_list()?))
|
||||
} else {
|
||||
None
|
||||
@@ -430,7 +430,7 @@ impl<'a> Parser<'a> {
|
||||
if self.cur().is_sym("*") {
|
||||
// `@*` without parens — the gap after the `@` is the `*`'s own
|
||||
// `before` slot, which the formatter prints in the same place.
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(SensList::Star { before: after_at, after: Vec::new() });
|
||||
}
|
||||
if self.cur().kind == TokenKind::Ident {
|
||||
@@ -449,10 +449,10 @@ impl<'a> Parser<'a> {
|
||||
// to whatever node comes next.
|
||||
let mut before = after_at;
|
||||
before.append(&mut self.take_trailing_here());
|
||||
self.bump(); // (
|
||||
self.skip(); // (
|
||||
before.append(&mut self.take_leading_here());
|
||||
let mut after = self.take_trailing_here();
|
||||
self.bump(); // *
|
||||
self.skip(); // *
|
||||
after.append(&mut self.take_leading_here());
|
||||
self.expect_sym(")")?;
|
||||
return Ok(SensList::Star { before, after });
|
||||
|
||||
@@ -218,7 +218,7 @@ impl<'a> Parser<'a> {
|
||||
self.link()?;
|
||||
let before = self.take_around(mark);
|
||||
for _ in 0..tokens {
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
let after = self.take_around(mark);
|
||||
let rhs = self.parse_prop_expr(Self::right_operand_prec(prec, right))?;
|
||||
@@ -316,7 +316,7 @@ impl<'a> Parser<'a> {
|
||||
let mut count = None;
|
||||
let mut after_count = Vec::new();
|
||||
if counted && self.cur().is_sym("[") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_open = self.take_gap();
|
||||
count = Some(Box::new(SvaRange { after_open, ..self.parse_sva_bounds()? }));
|
||||
after_count = self.take_gap();
|
||||
@@ -367,7 +367,7 @@ impl<'a> Parser<'a> {
|
||||
let mut els = None;
|
||||
if self.cur().is_kw("else") {
|
||||
before_else = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_else = self.take_gap();
|
||||
els = Some(self.parse_prop_expr(0)?);
|
||||
}
|
||||
@@ -421,7 +421,7 @@ impl<'a> Parser<'a> {
|
||||
let mut labels = Vec::new();
|
||||
let is_default = self.cur().is_kw("default");
|
||||
if is_default {
|
||||
self.bump();
|
||||
self.skip();
|
||||
} else {
|
||||
loop {
|
||||
labels.push(self.parse_expr_item()?);
|
||||
@@ -463,7 +463,7 @@ impl<'a> Parser<'a> {
|
||||
while self.at_repeat_bracket() {
|
||||
self.link()?;
|
||||
let before_open = self.take_gap();
|
||||
self.bump(); // [
|
||||
self.skip(); // [
|
||||
let after_open = self.take_gap();
|
||||
// `[+]` writes no operator of its own: its `+` is the bound.
|
||||
let (op, after_op) = if self.cur().is_sym("+") {
|
||||
@@ -493,7 +493,7 @@ impl<'a> Parser<'a> {
|
||||
range.lo = Some(self.parse_expr()?);
|
||||
if self.cur().is_sym(":") {
|
||||
range.before_colon = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
range.after_colon = self.take_gap();
|
||||
range.hi = Some(self.parse_expr()?);
|
||||
}
|
||||
@@ -509,7 +509,7 @@ impl<'a> Parser<'a> {
|
||||
self.expect_sym("##")?;
|
||||
let after_hash = self.take_gap();
|
||||
if self.cur().is_sym("[") {
|
||||
self.bump();
|
||||
self.skip();
|
||||
let after_open = self.take_gap();
|
||||
let range = Box::new(SvaRange { after_open, ..self.parse_sva_bounds()? });
|
||||
return Ok(CycleDelay { after_hash, expr: None, range: Some(range) });
|
||||
@@ -707,7 +707,7 @@ impl<'a> Parser<'a> {
|
||||
let mut items = Vec::new();
|
||||
while self.cur().is_sym(",") {
|
||||
let before_comma = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
let start = self.here();
|
||||
let meta = self.take_meta();
|
||||
let lhs = self.parse_expr()?;
|
||||
|
||||
@@ -227,12 +227,12 @@ impl<'a> Parser<'a> {
|
||||
if !self.cur().is_sym("(") {
|
||||
return Ok(TfPorts::default());
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
if self.cur().is_sym(")") {
|
||||
// Only what was written *inside* the empty `()`, as an empty
|
||||
// argument list of a call keeps.
|
||||
let dangling = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
return Ok(TfPorts { args, dangling });
|
||||
}
|
||||
let mark = self.diags_mark();
|
||||
@@ -272,9 +272,9 @@ impl<'a> Parser<'a> {
|
||||
// `ibex/vendor/lowrisc_ip/dv/sv/dv_utils/dv_utils_pkg.sv:104`.
|
||||
// Two keywords, so the gap between them is a slot of its own —
|
||||
// no other direction has an inside.
|
||||
self.bump();
|
||||
self.skip();
|
||||
after_const = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
Some("const ref".to_string())
|
||||
} else if t.is_kw("input") || t.is_kw("output") || t.is_kw("inout") || t.is_kw("ref") {
|
||||
Some(self.bump().text)
|
||||
@@ -298,7 +298,7 @@ impl<'a> Parser<'a> {
|
||||
let mut eq_comments = BinaryComments::default();
|
||||
let default = if self.cur().is_sym("=") {
|
||||
eq_comments.before = self.take_gap();
|
||||
self.bump();
|
||||
self.skip();
|
||||
eq_comments.after = self.take_gap();
|
||||
Some(self.parse_expr()?)
|
||||
} else {
|
||||
|
||||
@@ -38,7 +38,7 @@ impl<'a> Parser<'a> {
|
||||
} else if t.is_kw(&open) {
|
||||
depth += 1;
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
self.expect_closer(close)?;
|
||||
self.parse_label()?;
|
||||
@@ -52,7 +52,7 @@ impl<'a> Parser<'a> {
|
||||
pub(super) fn parse_opaque_line(&mut self) -> PResult<RawText> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip_to_semi()?;
|
||||
Ok(self.verbatim_since(start, col))
|
||||
}
|
||||
@@ -94,7 +94,7 @@ impl<'a> Parser<'a> {
|
||||
/// than as a nested assignment. How many there are, and whether they are
|
||||
/// legal lvalues, is a checker's business.
|
||||
pub(super) fn parse_alias(&mut self) -> PResult<ItemKind> {
|
||||
self.bump(); // alias
|
||||
self.skip(); // alias
|
||||
let mut nets = vec![self.parse_expr()?];
|
||||
while self.eat_sym("=") {
|
||||
nets.push(self.parse_expr()?);
|
||||
@@ -154,7 +154,7 @@ impl<'a> Parser<'a> {
|
||||
pub(super) fn parse_expect_statement(&mut self) -> PResult<RawText> {
|
||||
let start = self.here();
|
||||
let col = self.cur().col;
|
||||
self.bump(); // expect
|
||||
self.skip(); // expect
|
||||
self.expect_sym("(")?;
|
||||
self.skip_balanced("(", ")")?;
|
||||
self.skip_action_block()?;
|
||||
@@ -176,7 +176,7 @@ impl<'a> Parser<'a> {
|
||||
} else if t.is_sym(close) {
|
||||
depth -= 1;
|
||||
}
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -215,12 +215,12 @@ impl<'a> Parser<'a> {
|
||||
"[" => ("[", "]"),
|
||||
_ => ("{", "}"),
|
||||
};
|
||||
self.bump();
|
||||
self.skip();
|
||||
self.skip_balanced(open, close)?;
|
||||
} else if self.eat_sym(";") {
|
||||
return Ok(());
|
||||
} else {
|
||||
self.bump();
|
||||
self.skip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,12 +181,7 @@ impl Extraction {
|
||||
let Some(text) = scope.text(here) else { return Err(not_in_scope(file)) };
|
||||
let (tree, diagnostics) = parse_source_tolerant(text);
|
||||
if let Some(problem) = diagnostics.first() {
|
||||
return Err(format!(
|
||||
"{} does not parse ({} at line {}), so lucisv will not extract from it.",
|
||||
display(file),
|
||||
problem.message,
|
||||
problem.line
|
||||
));
|
||||
return Err(does_not_parse(file, problem));
|
||||
}
|
||||
let region = Region::read(&tree, text, TextRange::new(start, end))?;
|
||||
let module = region.module_name().to_string();
|
||||
@@ -468,6 +463,20 @@ fn occupied(path: &Path) -> String {
|
||||
format!("there is already a `{}` beside this file; pick another name.", display(path))
|
||||
}
|
||||
|
||||
/// Why a file lucisv cannot read is a file it will not extract from.
|
||||
///
|
||||
/// Reachable through `extract_module` alone: a server calls [`extract_site_in`]
|
||||
/// first, and that answers `None` for a file with any parse diagnostic, so the
|
||||
/// sentence is for the caller that comes straight to the engine.
|
||||
fn does_not_parse(file: &Path, problem: &ParseDiagnostic) -> String {
|
||||
format!(
|
||||
"{} does not parse ({} at line {}), so lucisv will not extract from it.",
|
||||
display(file),
|
||||
problem.message,
|
||||
problem.line
|
||||
)
|
||||
}
|
||||
|
||||
fn escaped(name: &str) -> String {
|
||||
format!(
|
||||
"`{name}` is declared inside the selection and used outside it; move the declaration of `{name}` out of the selection first."
|
||||
|
||||
@@ -59,10 +59,10 @@ pub use ports::{
|
||||
PortOfferKind,
|
||||
};
|
||||
pub use rename::{
|
||||
contains_word, prepare_rename, prepare_rename_here, rename, rename_name_at, rename_traced,
|
||||
RenameTarget,
|
||||
contains_word, prepare_rename, prepare_rename_here, rename, rename_name_at, rename_preflight,
|
||||
rename_traced, rename_traced_with, KnownFacts, RenameTarget,
|
||||
};
|
||||
pub use trace::{RenameTrace, Stage, VerifyTrace};
|
||||
pub use trace::{IndexTrace, RenameTrace, Stage, VerifyTrace, WarnTrace};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
@@ -12,12 +12,17 @@
|
||||
//! workspace every refactoring in this crate reads through, and `warnings` is
|
||||
//! what a finished rename says about the occurrences it could not edit.
|
||||
|
||||
mod preflight;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod warnings;
|
||||
|
||||
pub use preflight::rename_preflight;
|
||||
|
||||
// The rename was the first refactoring, so most of the crate still spells the
|
||||
// workspace `crate::rename::Scope`. It lives at `crate::scope` now (§29.1).
|
||||
// workspace `crate::rename::Scope`. It lives at `crate::scope` now (§29.1),
|
||||
// and so does the door a caller hands its own index records through.
|
||||
pub use crate::scope::KnownFacts;
|
||||
pub(crate) use crate::scope::{display, Scope};
|
||||
pub use warnings::contains_word;
|
||||
|
||||
@@ -177,7 +182,29 @@ pub fn rename_traced(
|
||||
trace: &mut RenameTrace,
|
||||
) -> Result<RefactorEdit, String> {
|
||||
let started = vlog_parser::stats::parses();
|
||||
let out = renaming(files, file, offset, new_name, trace);
|
||||
let out = renaming(files, file, offset, new_name, None, trace);
|
||||
trace.parses = vlog_parser::stats::parses() - started;
|
||||
out
|
||||
}
|
||||
|
||||
/// [`rename_traced`], letting the caller answer for the index records of the
|
||||
/// files it is handing over — see [`KnownFacts`].
|
||||
///
|
||||
/// The same rename over the same files, deciding everything the same way: a
|
||||
/// record the caller answers with is one this call would otherwise have
|
||||
/// produced by parsing that file, so the only difference is that it did not
|
||||
/// parse it (review round §R3b). A caller that answers `None` to everything
|
||||
/// gets [`rename_traced`] exactly.
|
||||
pub fn rename_traced_with(
|
||||
files: &[(PathBuf, String)],
|
||||
file: &Path,
|
||||
offset: u32,
|
||||
new_name: &str,
|
||||
known: &dyn KnownFacts,
|
||||
trace: &mut RenameTrace,
|
||||
) -> Result<RefactorEdit, String> {
|
||||
let started = vlog_parser::stats::parses();
|
||||
let out = renaming(files, file, offset, new_name, Some(known), trace);
|
||||
trace.parses = vlog_parser::stats::parses() - started;
|
||||
out
|
||||
}
|
||||
@@ -189,6 +216,7 @@ fn renaming(
|
||||
file: &Path,
|
||||
offset: u32,
|
||||
new_name: &str,
|
||||
known: Option<&dyn KnownFacts>,
|
||||
trace: &mut RenameTrace,
|
||||
) -> Result<RefactorEdit, String> {
|
||||
check_new_name(new_name)?;
|
||||
@@ -199,16 +227,23 @@ fn renaming(
|
||||
// name under the cursor — which the request file's own analysis, the first
|
||||
// one the build makes, is what says. A wrong guess costs a re-parse and
|
||||
// can change nothing: retention is a cache.
|
||||
let mut scope = trace.index.measure(|| {
|
||||
Scope::build_keeping(files, file, |here| {
|
||||
let cursor = here.and_then(|semantics| rename_name_at(semantics, offset));
|
||||
cursor.into_iter().chain(Some(new_name.to_string())).collect()
|
||||
})
|
||||
let RenameTrace { index, indexing, .. } = &mut *trace;
|
||||
let mut scope = index.measure(|| {
|
||||
Scope::build_keeping(
|
||||
files,
|
||||
file,
|
||||
|here| {
|
||||
let cursor = here.and_then(|semantics| rename_name_at(semantics, offset));
|
||||
cursor.into_iter().chain(Some(new_name.to_string())).collect()
|
||||
},
|
||||
known,
|
||||
indexing,
|
||||
)
|
||||
});
|
||||
trace.selected = scope.len();
|
||||
let target = trace.locate.measure(|| scope.locate(file, offset))?;
|
||||
if target.name == new_name {
|
||||
return Err(format!("`{new_name}` is the name it already has."));
|
||||
return Err(already_named(new_name));
|
||||
}
|
||||
let edits = trace.edits.measure(|| scope.collect_edits(&target, new_name))?;
|
||||
trace.edited = edits.len();
|
||||
@@ -217,7 +252,8 @@ fn renaming(
|
||||
let RenameTrace { verify, checks, .. } = &mut *trace;
|
||||
verify.measure(|| check::verify(&mut scope, &edits, &target.name, new_name, checks))?;
|
||||
|
||||
let warnings = trace.warnings.measure(|| scope.warnings(&target, &edits));
|
||||
let RenameTrace { warnings: stage, warning_scans, .. } = &mut *trace;
|
||||
let warnings = stage.measure(|| scope.warnings(&target, &edits, warning_scans));
|
||||
let mut out: Vec<(PathBuf, Vec<TextEdit>)> = edits
|
||||
.into_iter()
|
||||
.filter_map(|(i, edits)| Some((scope.path(i)?.to_path_buf(), edits)))
|
||||
@@ -508,10 +544,14 @@ impl<'a> Scope<'a> {
|
||||
|
||||
const NOTHING_HERE: &str = "there is no symbol to rename at this position.";
|
||||
|
||||
// The refusal sentences, each written once. Two callers reach four of them
|
||||
// now: the whole-workspace `Scope::locate` and the buffer-and-index
|
||||
// `prepare_rename_here`, which must refuse in exactly the same words or the
|
||||
// user gets two different explanations for one situation.
|
||||
// The refusal sentences, each written once. Three callers reach them now: the
|
||||
// whole-workspace `Scope::locate`, the buffer-and-index `prepare_rename_here`,
|
||||
// and the buffer-only `rename_preflight` — which must refuse in exactly the
|
||||
// same words or the user gets two different explanations for one situation.
|
||||
|
||||
fn already_named(new_name: &str) -> String {
|
||||
format!("`{new_name}` is the name it already has.")
|
||||
}
|
||||
|
||||
fn ambiguous(name: &str) -> String {
|
||||
format!(
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
//! The refusals a rename can reach from the request buffer alone.
|
||||
//!
|
||||
//! `renaming` builds a whole [`Scope`](crate::scope::Scope) — one parse and
|
||||
//! one analysis per in-scope file — before `locate` looks at the cursor. On
|
||||
//! OpenTitan a cursor sitting on a comment cost **3 975 parses and 1.9 s**
|
||||
//! before a 0.1 ms refusal that read nothing but the request file (take 5
|
||||
//! review, §3 item 6). This is that refusal, taken first.
|
||||
//!
|
||||
//! **What it is allowed to take.** Only a refusal `renaming` is *certain* to
|
||||
//! reach in the same words, from facts that are a pure function of the request
|
||||
//! buffer's own text: the new-name check, and the cursor refusals the buffer's
|
||||
//! own `Semantics` settles. `Semantics` is `analyze(&parse(text), text)` and
|
||||
//! consults nothing else, so the buffer's analysis and the scope's analysis of
|
||||
//! that same file are the same value.
|
||||
//!
|
||||
//! **What it must not take.** Every refusal whose answer comes from the
|
||||
//! *workspace index*: whether a name is declared in more than one file, and
|
||||
//! which file a cross-file use means. The index is rebuilt on save and on a
|
||||
//! watcher event, never on a keystroke (`state/mod.rs::set_document` reads it
|
||||
//! and does not touch it), so an unsaved edit that adds or removes a
|
||||
//! file-scope declaration is not in it. `prepare_rename_here` may read it
|
||||
//! anyway — an optimistic `prepareRename` is LSP-legal and the rename that
|
||||
//! follows corrects it — but `rename` **is** that correction, and a refusal
|
||||
//! invented here from a stale count is a rename the user cannot get. Those
|
||||
//! stay on the slow road, which re-derives the count from the current texts.
|
||||
//!
|
||||
//! `Ok(())` therefore means "proceed exactly as before", never "this rename
|
||||
//! will succeed".
|
||||
|
||||
use vlog_semantic::{Resolution, Semantics, SymbolId};
|
||||
|
||||
use super::{already_named, check_new_name, from_base, unresolved, unspelled, NOTHING_HERE};
|
||||
|
||||
/// The refusal `rename` would make for this cursor and this new name, when the
|
||||
/// request buffer alone is enough to know it — and `Ok(())` when it is not.
|
||||
///
|
||||
/// A caller must only ask this about a file it is going to hand `rename` as
|
||||
/// one of its in-scope files: `locate` refuses a file it was not given
|
||||
/// *before* it looks at the cursor, and that refusal has to keep its place in
|
||||
/// the order. Both of the server's source selectors always include the
|
||||
/// requesting buffer, so both satisfy it.
|
||||
pub fn rename_preflight(semantics: &Semantics, offset: u32, new_name: &str) -> Result<(), String> {
|
||||
// First in `renaming`, and so first here: an invalid new name outranks
|
||||
// everything the cursor could say.
|
||||
check_new_name(new_name)?;
|
||||
let found = semantics.reference_id_at(offset).and_then(|id| semantics.reference(id));
|
||||
let Some(reference) = found else {
|
||||
// The cursor is on a declaration written here, or on nothing at all.
|
||||
let Some(symbol) = semantics.symbol_at(offset) else {
|
||||
return Err(NOTHING_HERE.to_string());
|
||||
};
|
||||
return declared_here(semantics, symbol, new_name);
|
||||
};
|
||||
match &reference.resolution {
|
||||
Resolution::Resolved(symbol) => declared_here(semantics, *symbol, new_name),
|
||||
Resolution::NotFound => Err(unresolved(&reference.name)),
|
||||
Resolution::InheritedCandidate { base, .. } => Err(from_base(&reference.name, base)),
|
||||
// Which file declares this name — and whether several do — is the
|
||||
// index's word, and the index is not the authority a rename is.
|
||||
Resolution::ExternalCandidate { .. } => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
/// `Scope::declaration` for a declaration written in the request buffer, as
|
||||
/// far as the buffer can carry it.
|
||||
fn declared_here(semantics: &Semantics, symbol: SymbolId, new_name: &str) -> Result<(), String> {
|
||||
// `locate` answers a symbol id it cannot look up with `NOTHING_HERE`. It
|
||||
// came from this same analysis, so it can be looked up; deferring rather
|
||||
// than asserting keeps the impossible case on the road that handles it.
|
||||
let Some(declaration) = semantics.symbol(symbol) else { return Ok(()) };
|
||||
if declaration.name_span.is_empty() {
|
||||
return Err(unspelled(&declaration.name));
|
||||
}
|
||||
// A file-scope unit is refused when the index holds its name more than
|
||||
// once, and that count belongs to the slow road — so nothing after it may
|
||||
// be decided here either, or a refusal would jump the ambiguity check.
|
||||
if declaration.scope == semantics.file_scope() {
|
||||
return Ok(());
|
||||
}
|
||||
if declaration.name == new_name {
|
||||
return Err(already_named(new_name));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
//! against `prepare_rename` at every byte of a buffer.
|
||||
|
||||
use vlog_parser::parse_source_tolerant;
|
||||
use vlog_semantic::{analyze, resolve_external};
|
||||
use vlog_semantic::{analyze, resolve_external, FileFacts};
|
||||
|
||||
use crate::RefactorEdit;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -333,3 +335,168 @@ fn a_rename_that_would_make_a_third_files_use_ambiguous_is_refused() {
|
||||
// the refusal is about `use.sv`, not about `a.sv` alone.
|
||||
assert!(rename(&sources, &path, at, "b_pkg").is_ok(), "an unclaimed name still renames");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the known-facts door (review round §R3b) — the parse budget with reuse,
|
||||
// and the two things the engine itself can check
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// An honest caller: for the files it was told to know, it answers with the
|
||||
/// record `FileFacts::of` produces — and only when the text it is handed is
|
||||
/// byte-for-byte the text that record was read off.
|
||||
///
|
||||
/// This is what a correct [`KnownFacts`] implementation *is*, with string
|
||||
/// equality standing in for the server's content hash (a stronger key, not a
|
||||
/// weaker one). The records are read before the rename runs, so asking costs
|
||||
/// no parse and the rename's parse budget is the rename's own.
|
||||
struct Honest {
|
||||
known: Vec<(PathBuf, String, FileFacts)>,
|
||||
}
|
||||
|
||||
impl Honest {
|
||||
/// The records of those of [`EIGHT`]'s files, read off their own text.
|
||||
fn about(paths: &[&str]) -> Honest {
|
||||
let known = EIGHT
|
||||
.iter()
|
||||
.filter(|(name, _)| paths.contains(name))
|
||||
.map(|(name, text)| {
|
||||
let path = PathBuf::from(*name);
|
||||
(path.clone(), (*text).to_string(), FileFacts::of(path, text))
|
||||
})
|
||||
.collect();
|
||||
Honest { known }
|
||||
}
|
||||
}
|
||||
|
||||
impl KnownFacts for Honest {
|
||||
fn facts_for(&self, path: &Path, text: &str) -> Option<FileFacts> {
|
||||
self.known
|
||||
.iter()
|
||||
.find(|(held, bytes, _)| held == path && bytes == text)
|
||||
.map(|(_, _, facts)| facts.clone())
|
||||
}
|
||||
}
|
||||
|
||||
/// The rename of `EIGHT`'s `sig`, with and without a caller that knows some
|
||||
/// records — the whole result, as a comparable value.
|
||||
fn eight_renamed(known: Option<&dyn KnownFacts>) -> (String, RenameTrace) {
|
||||
let sources = workspace(&EIGHT);
|
||||
let path = PathBuf::from("/w/sub.sv");
|
||||
let text = EIGHT[0].1;
|
||||
let at = text.find("wire sig").expect("the declaration") as u32 + 5;
|
||||
let mut trace = RenameTrace::default();
|
||||
let edit = match known {
|
||||
Some(known) => rename_traced_with(&sources, &path, at, "renamed_sig", known, &mut trace),
|
||||
None => rename_traced(&sources, &path, at, "renamed_sig", &mut trace),
|
||||
};
|
||||
(print_edit(&edit.expect("the rename succeeds")), trace)
|
||||
}
|
||||
|
||||
/// Every edit and every warning a refactoring makes, as one comparable string.
|
||||
fn print_edit(edit: &RefactorEdit) -> String {
|
||||
let mut out = String::new();
|
||||
for (path, edits) in &edit.edits {
|
||||
for one in edits {
|
||||
out.push_str(&format!(
|
||||
"{} {}..{} -> {}\n",
|
||||
path.display(),
|
||||
one.range.start,
|
||||
one.range.end,
|
||||
one.new_text
|
||||
));
|
||||
}
|
||||
}
|
||||
for warning in &edit.warnings {
|
||||
out.push_str(&format!("warn {warning}\n"));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// **The R3b proof.** A rename whose caller knows the records of the files
|
||||
/// nothing analyses makes exactly the edits and says exactly the warnings the
|
||||
/// same rename makes without it — and parses fewer files by exactly the number
|
||||
/// of records it reused.
|
||||
///
|
||||
/// `K + E` becomes `(K − reused) + E`: the reuse takes parses out of the index
|
||||
/// stage and out of nowhere else, which is what the per-stage counts assert.
|
||||
#[test]
|
||||
fn a_reused_record_removes_that_files_parse_and_changes_no_edit() {
|
||||
let (plain, plain_trace) = eight_renamed(None);
|
||||
// The three files that spell neither `sig` nor `renamed_sig`: the
|
||||
// containers a scope indexes and no later stage reads.
|
||||
let known = Honest::about(&["/w/pkg.sv", "/w/quiet_a.sv", "/w/quiet_b.sv"]);
|
||||
let (reused, trace) = eight_renamed(Some(&known));
|
||||
|
||||
assert_eq!(plain, reused, "the reuse changed an edit or a warning");
|
||||
assert_eq!(trace.indexing.reused_files, 3, "three records came from the caller: {trace:?}");
|
||||
assert_eq!(
|
||||
trace.indexing.other_files, 4,
|
||||
"and the unread class is four, so this index is part reused and part parsed"
|
||||
);
|
||||
assert_eq!(trace.indexing.reused.parses, 0, "the caller's answers cost no parse");
|
||||
assert_eq!(
|
||||
trace.parses,
|
||||
plain_trace.parses - 3,
|
||||
"three parses fewer, and no other stage moved: {trace:?}"
|
||||
);
|
||||
let (k, e) = (trace.selected as u64, trace.edited as u64);
|
||||
assert_eq!(trace.parses, (k - 3) + e, "(K - reused) + E");
|
||||
assert_eq!(trace.index.parses, k - 3, "every input file but the reused ones");
|
||||
assert_eq!(trace.locate.parses, 0, "the cursor's file was kept");
|
||||
assert_eq!(trace.edits.parses, 0, "so was every file the occurrence walk reads");
|
||||
assert_eq!(trace.checks.before.parses, 0, "and every watched file");
|
||||
assert_eq!(trace.checks.after.parses, 0);
|
||||
}
|
||||
|
||||
/// A caller that knows **every** file's record still parses the ones whose
|
||||
/// analysis a later stage reads — the record is the index's half and the
|
||||
/// `Semantics` is the other, and only the second needs the parse.
|
||||
///
|
||||
/// The reuse is therefore never a reason to skip an analysis something asks
|
||||
/// for: it removes the parse of a file nothing asks about, and nothing else.
|
||||
#[test]
|
||||
fn a_file_whose_analysis_is_read_is_still_parsed_when_its_record_is_known() {
|
||||
let all: Vec<&str> = EIGHT.iter().map(|(name, _)| *name).collect();
|
||||
let known = Honest::about(&all);
|
||||
let (plain, plain_trace) = eight_renamed(None);
|
||||
let (reused, trace) = eight_renamed(Some(&known));
|
||||
|
||||
assert_eq!(plain, reused, "knowing every record changed an answer");
|
||||
assert_eq!(trace.indexing.reused_files, 8, "every record came from the caller");
|
||||
assert_eq!(
|
||||
trace.parses,
|
||||
plain_trace.parses - trace.indexing.other_files as u64,
|
||||
"only the unread class stopped being parsed: {trace:?}"
|
||||
);
|
||||
assert!(trace.indexing.kept_files > 0, "premise: some files are read later");
|
||||
assert_eq!(
|
||||
trace.index.parses,
|
||||
trace.indexing.kept_files as u64 + 1,
|
||||
"the kept ones, and the lead"
|
||||
);
|
||||
}
|
||||
|
||||
/// A record filed under **another path** is refused, because merging it would
|
||||
/// put one file's declarations under another's name. This is one of the two
|
||||
/// things the engine can check for itself; the other is that it asks with the
|
||||
/// very text it is about to index, which is how it asks.
|
||||
#[test]
|
||||
fn a_record_that_names_another_file_is_not_taken() {
|
||||
/// A caller that answers every question with one file's record.
|
||||
struct Misfiled(FileFacts);
|
||||
impl KnownFacts for Misfiled {
|
||||
fn facts_for(&self, _path: &Path, _text: &str) -> Option<FileFacts> {
|
||||
Some(self.0.clone())
|
||||
}
|
||||
}
|
||||
// A record of a file this workspace does not hold, so the only thing that
|
||||
// could make it reach the index is the engine failing to look at its path.
|
||||
let elsewhere =
|
||||
FileFacts::of(PathBuf::from("/w/absent.sv"), "module absent;\n logic sig;\nendmodule\n");
|
||||
let (plain, plain_trace) = eight_renamed(None);
|
||||
let (guarded, trace) = eight_renamed(Some(&Misfiled(elsewhere)));
|
||||
|
||||
assert_eq!(plain, guarded, "a misfiled record must not reach the index");
|
||||
assert_eq!(trace.indexing.reused_files, 0, "and must not be counted as reuse");
|
||||
assert_eq!(trace.parses, plain_trace.parses, "so every file was parsed as it always was");
|
||||
}
|
||||
@@ -28,6 +28,7 @@ use crate::TextEdit;
|
||||
|
||||
use super::Target;
|
||||
use crate::scope::{display, Scope};
|
||||
use crate::trace::WarnTrace;
|
||||
|
||||
/// One file's token stream and its line index, built at most once per
|
||||
/// [`Scope::warnings`] call and lent to every scan that asks.
|
||||
@@ -54,6 +55,12 @@ impl FileScan {
|
||||
self.lines.get_or_insert_with(|| LineIndex::new(text))
|
||||
}
|
||||
|
||||
/// Whether any scan got far enough past its prefilter to ask for the
|
||||
/// tokens — what the warning pass's per-file cost really is.
|
||||
fn lexed(&self) -> bool {
|
||||
self.tokens.is_some()
|
||||
}
|
||||
|
||||
/// Both at once, for a scan that walks the tokens and asks the index for
|
||||
/// each hit's line — two borrows it cannot take one after the other.
|
||||
fn tokens_and_lines(&mut self, text: &str) -> (Option<&[Token]>, &LineIndex) {
|
||||
@@ -76,10 +83,14 @@ impl<'a> Scope<'a> {
|
||||
/// workspace could not finish is spelled with the old name either way.
|
||||
/// Their sentences are collected per scan and concatenated in that order,
|
||||
/// which is the order they were emitted in when each scan had its own loop.
|
||||
///
|
||||
/// `trace` is filled in as the pass runs — the per-scan split the review's
|
||||
/// §3 item 3 asked for. Nothing in the pass reads it back.
|
||||
pub(super) fn warnings(
|
||||
&mut self,
|
||||
target: &Target,
|
||||
edits: &[(usize, Vec<TextEdit>)],
|
||||
trace: &mut WarnTrace,
|
||||
) -> Vec<String> {
|
||||
let name = &target.name;
|
||||
let (mut defines, mut macro_uses) = (Vec::new(), Vec::new());
|
||||
@@ -89,10 +100,16 @@ impl<'a> Scope<'a> {
|
||||
let mut kept: HashMap<usize, FileScan> = HashMap::new();
|
||||
for i in 0..self.len() {
|
||||
let mut scan = FileScan::default();
|
||||
defines.extend(self.define_warnings(i, name, &mut scan));
|
||||
macro_uses.extend(self.macro_use_warnings(i, name, &mut scan));
|
||||
fallbacks.extend(self.sva_fallback_warnings(i, name, &mut scan));
|
||||
unfinished.extend(self.unresolved_candidate_warnings(i, name, &mut scan));
|
||||
defines.extend(trace.defines.measure(|| self.define_warnings(i, name, &mut scan)));
|
||||
macro_uses
|
||||
.extend(trace.macro_uses.measure(|| self.macro_use_warnings(i, name, &mut scan)));
|
||||
fallbacks.extend(trace.sva.measure(|| self.sva_fallback_warnings(i, name, &mut scan)));
|
||||
unfinished.extend(
|
||||
trace.unfinished.measure(|| self.unresolved_candidate_warnings(i, name, &mut scan)),
|
||||
);
|
||||
// Free, and the number the four times above are mostly made of: a
|
||||
// file only reaches a lex when a scan's prefilter let it through.
|
||||
trace.scanned += usize::from(scan.lexed());
|
||||
if edits.iter().any(|(file, _)| *file == i) {
|
||||
kept.insert(i, scan);
|
||||
}
|
||||
@@ -103,7 +120,9 @@ impl<'a> Scope<'a> {
|
||||
warnings.extend(unfinished);
|
||||
for (i, edits) in edits {
|
||||
let mut scan = kept.remove(i).unwrap_or_default();
|
||||
warnings.extend(self.unaccounted_warnings(*i, name, edits, &mut scan));
|
||||
warnings.extend(
|
||||
trace.unaccounted.measure(|| self.unaccounted_warnings(*i, name, edits, &mut scan)),
|
||||
);
|
||||
}
|
||||
warnings.dedup();
|
||||
warnings
|
||||
@@ -627,7 +646,7 @@ fn is_name_byte(byte: u8) -> bool {
|
||||
mod tests {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::{contains_word, Scope};
|
||||
use super::{contains_word, Scope, WarnTrace};
|
||||
|
||||
#[test]
|
||||
fn whole_word_search_ignores_substrings() {
|
||||
@@ -928,7 +947,7 @@ mod tests {
|
||||
let mut shared = Scope::build(&sources);
|
||||
let target = shared.locate(&path, at).expect("the cursor names something renameable");
|
||||
let edits = shared.collect_edits(&target, case.new_name).expect("the rename has edits");
|
||||
let said = shared.warnings(&target, &edits);
|
||||
let said = shared.warnings(&target, &edits, &mut WarnTrace::default());
|
||||
|
||||
let mut apart = Scope::build(&sources);
|
||||
let target = apart.locate(&path, at).expect("the cursor names something renameable");
|
||||
|
||||
@@ -13,6 +13,16 @@
|
||||
//! is retained is a *cache and nothing else*: a file whose analysis was not
|
||||
//! kept is analysed on demand exactly as before, so a retention rule that
|
||||
//! guesses wrong costs time and cannot change an answer.
|
||||
//!
|
||||
//! **And no parse at all, for a file the caller already has the record of**
|
||||
//! (review round §R3b). Two thirds of that per-file cost is the lexer and the
|
||||
//! parser, and a third of a rename's files are containers it indexes and never
|
||||
//! reads again — so [`KnownFacts`] lets a caller hand back the [`FileFacts`]
|
||||
//! it holds *for exactly the bytes it is handing over*, and those files are
|
||||
//! never parsed. Unlike retention, this one is not merely a cache: a record
|
||||
//! that does not describe the text it is filed against is a wrong index. The
|
||||
//! contract, and the two halves of it this crate can check itself, are on
|
||||
//! [`KnownFacts`]; `docs/features/perf5r-scope-reuse/README.md` has the rest.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -23,6 +33,121 @@ use vlog_semantic::{
|
||||
WorkspaceIndex,
|
||||
};
|
||||
|
||||
use crate::trace::IndexTrace;
|
||||
|
||||
/// What the caller already knows about the files it is handing over.
|
||||
///
|
||||
/// A refactoring's scope is built by parsing and analysing every in-scope
|
||||
/// file, and most of that work exists only to produce each file's
|
||||
/// [`FileFacts`] — the record the workspace index is merged from. A caller
|
||||
/// that has already read that record off *these very bytes* can hand it back
|
||||
/// here, and the build skips the parse (review round §R3b, TODO §61.5).
|
||||
///
|
||||
/// **The whole contract is the one sentence in `facts_for`**, and it is the
|
||||
/// caller's to keep: this crate cannot check a record against the text it
|
||||
/// claims to describe without doing the parse the record exists to save. The
|
||||
/// engine does the two checks it can — it asks with the exact text it is about
|
||||
/// to index, and it refuses a record filed under another path — and nothing
|
||||
/// else. So an implementation must key its answer on the *content* of the text
|
||||
/// it is handed, from a record and a key it read out of one place; a modified
|
||||
/// time, a size or a path alone is not that key, and neither is a record whose
|
||||
/// hash was recorded by something other than the read that produced it.
|
||||
///
|
||||
/// A wrong answer here is a wrong index, which is a wrong refactoring: this is
|
||||
/// the one thing in the door that is not merely a cache. `None` is always
|
||||
/// safe — the file is analysed exactly as it always was.
|
||||
pub trait KnownFacts {
|
||||
/// The record [`FileFacts::of(path, text)`](FileFacts::of) would produce,
|
||||
/// if the caller can promise it is exactly that; `None` otherwise.
|
||||
fn facts_for(&self, path: &Path, text: &str) -> Option<FileFacts>;
|
||||
}
|
||||
|
||||
/// What the build does with one file, which is also what decides whether its
|
||||
/// analysis is worth keeping.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
enum Class {
|
||||
/// The file the request was made in: analysed first, always kept.
|
||||
Lead,
|
||||
/// A file the retention rule asked for: analysed, and kept.
|
||||
Kept,
|
||||
/// Everything else: it contributes a record to the index and nothing
|
||||
/// reads its analysis, so with a known record it is never analysed.
|
||||
Other,
|
||||
}
|
||||
|
||||
/// One scope build in progress: the records collected so far, the analyses
|
||||
/// kept, and where the time went.
|
||||
struct Building<'k, 't> {
|
||||
builder: IndexBuilder,
|
||||
kept: HashMap<usize, Semantics>,
|
||||
known: Option<&'k dyn KnownFacts>,
|
||||
trace: &'t mut IndexTrace,
|
||||
}
|
||||
|
||||
impl Building<'_, '_> {
|
||||
/// Take one file's contribution: its record, reused when the caller knows
|
||||
/// it for exactly these bytes and read off a fresh analysis otherwise, and
|
||||
/// its analysis when a later stage will read it.
|
||||
///
|
||||
/// The two halves of a reused file are computed apart — the record from
|
||||
/// the caller, the [`Semantics`] from this text — where an analysed file's
|
||||
/// come from one call. They agree because both are pure functions of the
|
||||
/// same bytes, which is the same reason `Scope::analysis`'s on-demand path
|
||||
/// has always been allowed to analyse a file the index build already read.
|
||||
fn take(&mut self, i: usize, path: &Path, text: &str, class: Class) {
|
||||
let known = self.known;
|
||||
let record = self
|
||||
.trace
|
||||
.reused
|
||||
.measure(|| known?.facts_for(path, text))
|
||||
// A record filed under another path would be merged as that file.
|
||||
// The caller cannot mean this, so it is a miss rather than a trust.
|
||||
.filter(|facts| facts.path() == path);
|
||||
self.count(class, text.len(), record.is_some());
|
||||
let wanted = class != Class::Other;
|
||||
let stage = match class {
|
||||
Class::Lead => &mut self.trace.lead,
|
||||
Class::Kept => &mut self.trace.kept,
|
||||
Class::Other => &mut self.trace.other,
|
||||
};
|
||||
let (facts, semantics) = match record {
|
||||
Some(facts) => {
|
||||
let analysed = || stage.measure(|| analyze(&parse_source_tolerant(text).0, text));
|
||||
(facts, wanted.then(analysed))
|
||||
}
|
||||
None => {
|
||||
let (facts, semantics) =
|
||||
stage.measure(|| FileFacts::analyzed(path.to_path_buf(), text));
|
||||
(facts, wanted.then_some(semantics))
|
||||
}
|
||||
};
|
||||
self.builder.add_facts(facts);
|
||||
if let Some(semantics) = semantics {
|
||||
self.kept.insert(i, semantics);
|
||||
}
|
||||
}
|
||||
|
||||
/// The file counted into its class, and into the reuse count when its
|
||||
/// record came from the caller.
|
||||
fn count(&mut self, class: Class, bytes: usize, reused: bool) {
|
||||
match class {
|
||||
Class::Lead => {}
|
||||
Class::Kept => {
|
||||
self.trace.kept_files += 1;
|
||||
self.trace.kept_bytes += bytes;
|
||||
}
|
||||
Class::Other => {
|
||||
self.trace.other_files += 1;
|
||||
self.trace.other_bytes += bytes;
|
||||
}
|
||||
}
|
||||
if reused {
|
||||
self.trace.reused_files += 1;
|
||||
self.trace.reused_bytes += bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One file's two analysis layers, as `textDocument/definition` uses them.
|
||||
pub(crate) struct Analysis {
|
||||
pub(crate) semantics: Semantics,
|
||||
@@ -55,7 +180,7 @@ impl<'a> Scope<'a> {
|
||||
/// again, which is the behaviour every caller but the rename has always
|
||||
/// had. [`Scope::build_keeping`] is the one that keeps them.
|
||||
pub(crate) fn build(files: &'a [(PathBuf, String)]) -> Scope<'a> {
|
||||
Scope::assemble(files, None, |_| Vec::new())
|
||||
Scope::assemble(files, None, |_| Vec::new(), None, &mut IndexTrace::default())
|
||||
}
|
||||
|
||||
/// The in-scope files, indexed, **keeping** the analysis of `lead` and of
|
||||
@@ -73,18 +198,31 @@ impl<'a> Scope<'a> {
|
||||
/// occurrence walk will analyse and every file
|
||||
/// [`crate::check`] will watch (a whole-word subset) is retained, and
|
||||
/// nothing else is.
|
||||
///
|
||||
/// `known`, when the caller has one, is asked for each file's index record
|
||||
/// before that file is analysed — see [`KnownFacts`]. It changes what the
|
||||
/// build *costs* and nothing else: a record it does not answer for is read
|
||||
/// off a fresh analysis exactly as it always was.
|
||||
///
|
||||
/// `trace` is filled in as the build runs — the per-file-class split the
|
||||
/// review's §3 item 1 asked for. A caller with nothing to measure passes
|
||||
/// `&mut IndexTrace::default()`; nothing in the build reads it back.
|
||||
pub(crate) fn build_keeping(
|
||||
files: &'a [(PathBuf, String)],
|
||||
lead: &Path,
|
||||
keep: impl FnOnce(Option<&Semantics>) -> Vec<String>,
|
||||
known: Option<&dyn KnownFacts>,
|
||||
trace: &mut IndexTrace,
|
||||
) -> Scope<'a> {
|
||||
Scope::assemble(files, Some(lead), keep)
|
||||
Scope::assemble(files, Some(lead), keep, known, trace)
|
||||
}
|
||||
|
||||
fn assemble(
|
||||
files: &'a [(PathBuf, String)],
|
||||
lead: Option<&Path>,
|
||||
keep: impl FnOnce(Option<&Semantics>) -> Vec<String>,
|
||||
known: Option<&dyn KnownFacts>,
|
||||
trace: &mut IndexTrace,
|
||||
) -> Scope<'a> {
|
||||
let mut sources: Vec<(&Path, &str)> =
|
||||
files.iter().map(|(p, t)| (p.as_path(), t.as_str())).collect();
|
||||
@@ -93,31 +231,30 @@ impl<'a> Scope<'a> {
|
||||
sources.sort_by(|a, b| a.0.cmp(b.0));
|
||||
sources.dedup_by(|a, b| a.0 == b.0);
|
||||
|
||||
let mut builder = IndexBuilder::new();
|
||||
let mut kept: HashMap<usize, Semantics> = HashMap::new();
|
||||
let mut building =
|
||||
Building { builder: IndexBuilder::new(), kept: HashMap::new(), known, trace };
|
||||
// The lead file first, so its analysis can be read before the rest are
|
||||
// parsed. `IndexBuilder::finish` sorts by path, so feeding it out of
|
||||
// order cannot reach the index.
|
||||
let first = lead.and_then(|path| sources.iter().position(|(held, _)| *held == path));
|
||||
if let Some(i) = first {
|
||||
let (path, text) = sources[i];
|
||||
let (facts, semantics) = FileFacts::analyzed(path.to_path_buf(), text);
|
||||
builder.add_facts(facts);
|
||||
kept.insert(i, semantics);
|
||||
building.take(i, path, text, Class::Lead);
|
||||
}
|
||||
let words = keep(first.and_then(|i| kept.get(&i)));
|
||||
let words = keep(first.and_then(|i| building.kept.get(&i)));
|
||||
for (i, (path, text)) in sources.iter().enumerate() {
|
||||
if Some(i) == first {
|
||||
continue;
|
||||
}
|
||||
let (facts, semantics) = FileFacts::analyzed(path.to_path_buf(), text);
|
||||
builder.add_facts(facts);
|
||||
if words.iter().any(|word| text.contains(word.as_str())) {
|
||||
kept.insert(i, semantics);
|
||||
}
|
||||
// Asked before the file is taken rather than after it — the same
|
||||
// pure question of the same two values, moved so the class it
|
||||
// answers decides what the build does with the file at all.
|
||||
let wanted = words.iter().any(|word| text.contains(word.as_str()));
|
||||
building.take(i, path, text, if wanted { Class::Kept } else { Class::Other });
|
||||
}
|
||||
|
||||
let index = builder.finish();
|
||||
let Building { builder, kept, trace, .. } = building;
|
||||
let index = trace.merge.measure(|| builder.finish());
|
||||
let ids: HashMap<&Path, FileId> = index
|
||||
.files()
|
||||
.iter()
|
||||
@@ -250,8 +387,13 @@ mod tests {
|
||||
let built = WorkspaceIndex::build(files.iter().map(|(p, t)| (p.clone(), t.as_str())));
|
||||
let plain = Scope::build(&files);
|
||||
assert_eq!(plain.index().fingerprint(), built.fingerprint());
|
||||
let keeping =
|
||||
Scope::build_keeping(&files, Path::new("/w/top.sv"), |_| vec!["sig".to_string()]);
|
||||
let keeping = Scope::build_keeping(
|
||||
&files,
|
||||
Path::new("/w/top.sv"),
|
||||
|_| vec!["sig".to_string()],
|
||||
None,
|
||||
&mut IndexTrace::default(),
|
||||
);
|
||||
assert_eq!(keeping.index().fingerprint(), built.fingerprint());
|
||||
for i in 0..plain.len() {
|
||||
assert_eq!(plain.file_id(i), keeping.file_id(i), "file ids move with retention");
|
||||
@@ -266,11 +408,18 @@ mod tests {
|
||||
fn a_retained_analysis_is_the_one_the_on_demand_path_would_compute() {
|
||||
let files = files();
|
||||
let mut plain = Scope::build(&files);
|
||||
let mut keeping = Scope::build_keeping(&files, Path::new("/w/top.sv"), |here| {
|
||||
// Every word in play, so every file is retained.
|
||||
assert!(here.is_some(), "the lead file's analysis is made first");
|
||||
vec!["sig".to_string(), "pkg".to_string(), "u_sub".to_string()]
|
||||
});
|
||||
let mut trace = IndexTrace::default();
|
||||
let mut keeping = Scope::build_keeping(
|
||||
&files,
|
||||
Path::new("/w/top.sv"),
|
||||
|here| {
|
||||
// Every word in play, so every file is retained.
|
||||
assert!(here.is_some(), "the lead file's analysis is made first");
|
||||
vec!["sig".to_string(), "pkg".to_string(), "u_sub".to_string()]
|
||||
},
|
||||
None,
|
||||
&mut trace,
|
||||
);
|
||||
for i in 0..plain.len() {
|
||||
let one = plain.analysis(i).map(print);
|
||||
let two = keeping.analysis(i).map(print);
|
||||
@@ -285,14 +434,97 @@ mod tests {
|
||||
fn the_lead_files_analysis_is_available_to_the_retention_rule() {
|
||||
let files = files();
|
||||
let mut seen = None;
|
||||
let scope = Scope::build_keeping(&files, Path::new("/w/user.sv"), |here| {
|
||||
seen = here.map(|semantics| semantics.symbols().len());
|
||||
Vec::new()
|
||||
});
|
||||
let mut trace = IndexTrace::default();
|
||||
let scope = Scope::build_keeping(
|
||||
&files,
|
||||
Path::new("/w/user.sv"),
|
||||
|here| {
|
||||
seen = here.map(|semantics| semantics.symbols().len());
|
||||
Vec::new()
|
||||
},
|
||||
None,
|
||||
&mut trace,
|
||||
);
|
||||
assert_eq!(seen, Some(2), "`user` and `X` are what user.sv declares");
|
||||
assert_eq!(scope.len(), 4);
|
||||
}
|
||||
|
||||
/// **The R3b fingerprint proof.** An index part *reused* and part parsed is
|
||||
/// the index every file's own text builds — same fingerprint, same file
|
||||
/// ids — and the analyses it keeps are the same analyses either way.
|
||||
///
|
||||
/// This is the whole of the door's correctness at this level: a record
|
||||
/// handed in by a caller who kept the promise is the record the parse
|
||||
/// would have produced, so an index merged from a mixture of the two
|
||||
/// cannot be told from one merged from either.
|
||||
#[test]
|
||||
fn an_index_part_reused_and_part_parsed_is_the_index_the_texts_build() {
|
||||
/// A caller that knows `pkg.sv` and `user.sv`, read off their own text.
|
||||
struct Two(Vec<(PathBuf, String, FileFacts)>);
|
||||
impl KnownFacts for Two {
|
||||
fn facts_for(&self, path: &Path, text: &str) -> Option<FileFacts> {
|
||||
self.0
|
||||
.iter()
|
||||
.find(|(held, bytes, _)| held == path && bytes == text)
|
||||
.map(|(_, _, facts)| facts.clone())
|
||||
}
|
||||
}
|
||||
let files = files();
|
||||
let known = Two(files
|
||||
.iter()
|
||||
.filter(|(path, _)| path.ends_with("pkg.sv") || path.ends_with("user.sv"))
|
||||
.map(|(path, text)| (path.clone(), text.clone(), FileFacts::of(path.clone(), text)))
|
||||
.collect());
|
||||
assert_eq!(known.0.len(), 2, "premise: two of the four are known");
|
||||
|
||||
let built = WorkspaceIndex::build(files.iter().map(|(p, t)| (p.clone(), t.as_str())));
|
||||
let mut trace = IndexTrace::default();
|
||||
let mut mixed = Scope::build_keeping(
|
||||
&files,
|
||||
Path::new("/w/top.sv"),
|
||||
|_| vec!["sig".to_string()],
|
||||
Some(&known),
|
||||
&mut trace,
|
||||
);
|
||||
assert_eq!(trace.reused_files, 2, "both known records were taken: {trace:?}");
|
||||
assert_eq!(mixed.index().fingerprint(), built.fingerprint());
|
||||
|
||||
let mut plain = Scope::build(&files);
|
||||
for i in 0..plain.len() {
|
||||
assert_eq!(plain.file_id(i), mixed.file_id(i), "file ids move with reuse");
|
||||
assert_eq!(plain.path(i), mixed.path(i));
|
||||
assert_eq!(
|
||||
plain.analysis(i).map(print),
|
||||
mixed.analysis(i).map(print),
|
||||
"file {i} analyses differently when its record is reused"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A caller that answers for nothing is the build as it always was — the
|
||||
/// door is opt-in per file, not a mode.
|
||||
#[test]
|
||||
fn a_caller_that_knows_nothing_builds_exactly_what_it_always_did() {
|
||||
struct Nothing;
|
||||
impl KnownFacts for Nothing {
|
||||
fn facts_for(&self, _path: &Path, _text: &str) -> Option<FileFacts> {
|
||||
None
|
||||
}
|
||||
}
|
||||
let files = files();
|
||||
let built = WorkspaceIndex::build(files.iter().map(|(p, t)| (p.clone(), t.as_str())));
|
||||
let mut trace = IndexTrace::default();
|
||||
let scope = Scope::build_keeping(
|
||||
&files,
|
||||
Path::new("/w/top.sv"),
|
||||
|_| vec!["sig".to_string()],
|
||||
Some(&Nothing),
|
||||
&mut trace,
|
||||
);
|
||||
assert_eq!(trace.reused_files, 0);
|
||||
assert_eq!(scope.index().fingerprint(), built.fingerprint());
|
||||
}
|
||||
|
||||
/// A lead the scope does not hold is not an error: nothing is retained,
|
||||
/// and the rest of the build is what it always was.
|
||||
#[test]
|
||||
@@ -300,11 +532,18 @@ mod tests {
|
||||
let files = files();
|
||||
let built = WorkspaceIndex::build(files.iter().map(|(p, t)| (p.clone(), t.as_str())));
|
||||
let mut asked = false;
|
||||
let mut scope = Scope::build_keeping(&files, Path::new("/w/absent.sv"), |here| {
|
||||
asked = true;
|
||||
assert!(here.is_none(), "there is no lead analysis to offer");
|
||||
vec!["sig".to_string()]
|
||||
});
|
||||
let mut trace = IndexTrace::default();
|
||||
let mut scope = Scope::build_keeping(
|
||||
&files,
|
||||
Path::new("/w/absent.sv"),
|
||||
|here| {
|
||||
asked = true;
|
||||
assert!(here.is_none(), "there is no lead analysis to offer");
|
||||
vec!["sig".to_string()]
|
||||
},
|
||||
None,
|
||||
&mut trace,
|
||||
);
|
||||
assert!(asked, "the retention rule is asked either way");
|
||||
assert_eq!(scope.index().fingerprint(), built.fingerprint());
|
||||
assert!(scope.analysis(0).is_some(), "and every file still analyses on demand");
|
||||
|
||||
@@ -44,6 +44,107 @@ impl Stage {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the scope build's time went, by what the build does with each file.
|
||||
///
|
||||
/// The review's §3 item 1 asked for the 229 ms scope stage split, because an
|
||||
/// aggregate cannot say whether a parser or an index optimization is the
|
||||
/// lever. The split that answers it is **by file class**: the request's own
|
||||
/// file, the files whose text spells one of the names in play (whose
|
||||
/// `Semantics` every later stage reads), and the rest — the container files
|
||||
/// §P2d counted, which are analysed for their index record alone and whose
|
||||
/// analysis is dropped unread. `merge` is `IndexBuilder::finish`, the sort and
|
||||
/// the whole-index merge, which is index work and not parse work.
|
||||
///
|
||||
/// `reused` is R3b's: records taken from the caller's known set instead of
|
||||
/// analysed. Zero for every caller that hands none.
|
||||
///
|
||||
/// The lead file is in `lead` and in neither `kept_files` nor `other_files` —
|
||||
/// it is always analysed and always kept, so counting it with either class
|
||||
/// would blur exactly the comparison this exists to make.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq)]
|
||||
pub struct IndexTrace {
|
||||
/// The request's own file, analysed before any other so the retention rule
|
||||
/// can read it.
|
||||
pub lead: Stage,
|
||||
/// The files the retention rule keeps, analysed.
|
||||
pub kept: Stage,
|
||||
/// The files it does not, analysed for the record alone.
|
||||
pub other: Stage,
|
||||
/// Records taken from the caller's known set — the lookup and the clone,
|
||||
/// with no parse in it.
|
||||
pub reused: Stage,
|
||||
/// How many files fell in each class, and their bytes.
|
||||
pub kept_files: usize,
|
||||
pub kept_bytes: usize,
|
||||
pub other_files: usize,
|
||||
pub other_bytes: usize,
|
||||
pub reused_files: usize,
|
||||
pub reused_bytes: usize,
|
||||
/// `IndexBuilder::finish`: the per-file records sorted and merged.
|
||||
pub merge: Stage,
|
||||
}
|
||||
|
||||
impl IndexTrace {
|
||||
/// One group of the trace line, in the order the build runs.
|
||||
fn line(&self) -> String {
|
||||
format!(
|
||||
"index{{lead={:.1}ms kept={:.1} other={:.1} reused={:.1} merge={:.1} \
|
||||
kept_files={} kept_bytes={} other_files={} other_bytes={} \
|
||||
reused_files={} reused_bytes={}}}",
|
||||
self.lead.ms,
|
||||
self.kept.ms,
|
||||
self.other.ms,
|
||||
self.reused.ms,
|
||||
self.merge.ms,
|
||||
self.kept_files,
|
||||
self.kept_bytes,
|
||||
self.other_files,
|
||||
self.other_bytes,
|
||||
self.reused_files,
|
||||
self.reused_bytes,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the warning pass's time went, scan by scan.
|
||||
///
|
||||
/// The five scans of `rename::warnings`, in the order they run. Each is a
|
||||
/// whole pass over the in-scope files, so the split says which of them the
|
||||
/// stage's milliseconds are — `scanned` is how many files got past the
|
||||
/// `text.contains(name)` prefilter into a lex, which is the work the times are
|
||||
/// mostly made of.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq)]
|
||||
pub struct WarnTrace {
|
||||
/// The `` `define`` scan.
|
||||
pub defines: Stage,
|
||||
/// The macro-invocation-argument scan.
|
||||
pub macro_uses: Stage,
|
||||
/// The unstructured-SVA scan.
|
||||
pub sva: Stage,
|
||||
/// The unresolved-candidate scan.
|
||||
pub unfinished: Stage,
|
||||
/// The edited files' unaccounted-occurrence scan.
|
||||
pub unaccounted: Stage,
|
||||
/// Files whose text spelled the name, and which were therefore lexed.
|
||||
pub scanned: usize,
|
||||
}
|
||||
|
||||
impl WarnTrace {
|
||||
/// One group of the trace line, in the order the scans run.
|
||||
fn line(&self) -> String {
|
||||
format!(
|
||||
"warnings{{defines={:.1}ms macro_uses={:.1} sva={:.1} unfinished={:.1} \
|
||||
unaccounted={:.1} scanned={}}}",
|
||||
self.defines.ms,
|
||||
self.macro_uses.ms,
|
||||
self.sva.ms,
|
||||
self.unfinished.ms,
|
||||
self.unaccounted.ms,
|
||||
self.scanned,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// What the verification pass did, stage by stage.
|
||||
///
|
||||
/// The five sub-stages of [`crate::check`]'s `verify`, in the order it runs
|
||||
@@ -83,6 +184,8 @@ pub struct RenameTrace {
|
||||
pub bytes: usize,
|
||||
/// Building the request-local scope: the index over every selected file.
|
||||
pub index: Stage,
|
||||
/// Where that build's time went, by file class (review §3 item 1).
|
||||
pub indexing: IndexTrace,
|
||||
/// Resolving the cursor to the declaration the rename acts on.
|
||||
pub locate: Stage,
|
||||
/// Collecting every occurrence and turning it into edits.
|
||||
@@ -93,6 +196,8 @@ pub struct RenameTrace {
|
||||
pub checks: VerifyTrace,
|
||||
/// Describing the occurrences the rename deliberately left alone.
|
||||
pub warnings: Stage,
|
||||
/// Where that pass's time went, scan by scan (review §3 item 3).
|
||||
pub warning_scans: WarnTrace,
|
||||
/// Files the rename edits.
|
||||
pub edited: usize,
|
||||
/// Whole-file parses over the entire request, from the first byte of the
|
||||
@@ -103,7 +208,15 @@ pub struct RenameTrace {
|
||||
impl RenameTrace {
|
||||
/// One line, in the server's `timing:` style — the whole trace, in the
|
||||
/// order the stages ran.
|
||||
///
|
||||
/// The two per-stage splits come last, each as its own `name{…}` group, so
|
||||
/// a reader of the old fields sees exactly what it always did.
|
||||
pub fn line(&self) -> String {
|
||||
format!("{} {} {}", self.stages(), self.indexing.line(), self.warning_scans.line())
|
||||
}
|
||||
|
||||
/// The stage totals — the line as it was before the splits were added.
|
||||
fn stages(&self) -> String {
|
||||
format!(
|
||||
"selected={} bytes={} edited={} index={:.1}ms locate={:.1} edits={:.1} \
|
||||
verify{{total={:.1} tokens={:.1} watched={} watched_bytes={} before={:.1} \
|
||||
|
||||
@@ -13,9 +13,10 @@ use std::time::Instant;
|
||||
use vlog_parser::ast::{Item, ItemKind, ListElem, PortList};
|
||||
use vlog_refactor::{
|
||||
add_port, convert_to_ansi, expand_wildcard, extract_module, instantiation_plan,
|
||||
module_definition, port_actions, prepare_rename, rename, Home, Layout, ModuleRef,
|
||||
module_definition, port_actions, prepare_rename, rename, rename_traced, rename_traced_with,
|
||||
Home, KnownFacts, Layout, ModuleRef, RenameTrace,
|
||||
};
|
||||
use vlog_semantic::WorkspaceIndex;
|
||||
use vlog_semantic::{FileFacts, WorkspaceIndex};
|
||||
|
||||
fn corpus() -> Option<Vec<PathBuf>> {
|
||||
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../corpus");
|
||||
@@ -1181,3 +1182,122 @@ fn borne(
|
||||
}
|
||||
gained
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the known-facts door over real RTL (review round §R3b, TODO §61.5)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// The corpus's own records, read once, answered back the way a correct
|
||||
/// caller answers: only for the exact bytes each record was read off.
|
||||
///
|
||||
/// The server's implementation is this answer taken out of a store keyed by
|
||||
/// content hash instead of computed here; what this stands in for is the
|
||||
/// promise, not the saving.
|
||||
struct CorpusFacts {
|
||||
known: Vec<(PathBuf, String, FileFacts)>,
|
||||
}
|
||||
|
||||
impl CorpusFacts {
|
||||
/// Every source's record, or every second one when `half` — so a run can
|
||||
/// build an index that is **part reused and part parsed**, which is the
|
||||
/// mixture a real rename gets.
|
||||
fn of(sources: &[(PathBuf, String)], half: bool) -> CorpusFacts {
|
||||
let known = sources
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(i, _)| !half || i % 2 == 0)
|
||||
.map(|(_, (path, text))| {
|
||||
(path.clone(), text.clone(), FileFacts::of(path.clone(), text))
|
||||
})
|
||||
.collect();
|
||||
CorpusFacts { known }
|
||||
}
|
||||
}
|
||||
|
||||
impl KnownFacts for CorpusFacts {
|
||||
fn facts_for(&self, path: &Path, text: &str) -> Option<FileFacts> {
|
||||
self.known
|
||||
.iter()
|
||||
.find(|(held, bytes, _)| held == path && bytes == text)
|
||||
.map(|(_, _, facts)| facts.clone())
|
||||
}
|
||||
}
|
||||
|
||||
/// **The R3b corpus probe.** Over 800 files of real RTL, the same rename asked
|
||||
/// three ways — with no records, with every record, and with every second one
|
||||
/// — makes byte-identical edits and says byte-identical warnings, and the
|
||||
/// reuse removes parses.
|
||||
///
|
||||
/// `#[ignore]`d because it renames a corpus-wide module three times over; run
|
||||
/// it with `cargo test -p vlog_refactor --test corpus -- --ignored --nocapture`
|
||||
/// (through `tools/guard.sh`), which also prints the parse counts.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn a_corpus_rename_says_the_same_thing_however_many_records_are_reused() {
|
||||
let Some(files) = corpus() else { return };
|
||||
let sources = read(&files);
|
||||
let Some((path, text)) =
|
||||
sources.iter().find(|(p, _)| p.file_name().is_some_and(|n| n == "prim_fifo_sync.sv"))
|
||||
else {
|
||||
eprintln!("prim_fifo_sync.sv not in this corpus — skipping");
|
||||
return;
|
||||
};
|
||||
let offset =
|
||||
text.find("module prim_fifo_sync").map(|i| i + 7).expect("the module's name") as u32;
|
||||
|
||||
let mut plain = RenameTrace::default();
|
||||
let one = rename_traced(&sources, path, offset, "prim_fifo_sync_renamed", &mut plain);
|
||||
|
||||
let all = CorpusFacts::of(&sources, false);
|
||||
let mut every = RenameTrace::default();
|
||||
let two =
|
||||
rename_traced_with(&sources, path, offset, "prim_fifo_sync_renamed", &all, &mut every);
|
||||
|
||||
let half = CorpusFacts::of(&sources, true);
|
||||
let mut mixed = RenameTrace::default();
|
||||
let three =
|
||||
rename_traced_with(&sources, path, offset, "prim_fifo_sync_renamed", &half, &mut mixed);
|
||||
|
||||
println!(
|
||||
"corpus reuse over {} files: parses {} (none) / {} (every record) / {} (every second); \
|
||||
reused {} / {}; index {:.1} / {:.1} / {:.1} ms",
|
||||
sources.len(),
|
||||
plain.parses,
|
||||
every.parses,
|
||||
mixed.parses,
|
||||
every.indexing.reused_files,
|
||||
mixed.indexing.reused_files,
|
||||
plain.index.ms,
|
||||
every.index.ms,
|
||||
mixed.index.ms,
|
||||
);
|
||||
|
||||
let say = |outcome: &Result<vlog_refactor::RefactorEdit, String>| match outcome {
|
||||
Ok(edit) => {
|
||||
let mut out: Vec<String> = edit
|
||||
.edits
|
||||
.iter()
|
||||
.flat_map(|(p, edits)| {
|
||||
edits.iter().map(move |e| {
|
||||
format!("{} {}..{} {}", p.display(), e.range.start, e.range.end, e.new_text)
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
out.extend(edit.warnings.iter().cloned());
|
||||
out.join("\n")
|
||||
}
|
||||
Err(message) => format!("refused: {message}"),
|
||||
};
|
||||
assert_eq!(say(&one), say(&two), "reusing every record changed an edit or a warning");
|
||||
assert_eq!(say(&one), say(&three), "reusing half the records changed an edit or a warning");
|
||||
|
||||
assert_eq!(every.indexing.reused_files, sources.len(), "every record was offered and taken");
|
||||
assert!(mixed.indexing.reused_files > 0, "and half of them in the mixed run");
|
||||
assert!(
|
||||
every.parses < plain.parses,
|
||||
"the reuse must remove parses: {} against {}",
|
||||
every.parses,
|
||||
plain.parses
|
||||
);
|
||||
assert!(mixed.parses < plain.parses, "and so must the mixture");
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
//! `rename_preflight` against the road it short-circuits, refusal by refusal.
|
||||
//!
|
||||
//! The preflight answers, from the request file alone, a question `rename`
|
||||
//! would otherwise answer after parsing and analyzing the whole in-scope
|
||||
//! workspace. That is only sound if the two answers are the *same sentence*,
|
||||
//! so this file is the equality oracle: at **every byte** of seven hostile
|
||||
//! buffers, and for every new name worth trying, the fast road's refusal must
|
||||
//! be the slow road's refusal, word for word.
|
||||
//!
|
||||
//! Two directions, and only one of them is allowed:
|
||||
//!
|
||||
//! * the preflight refuses and the whole road refuses **differently**, or
|
||||
//! accepts — an *invented* refusal, which is a rename the user cannot get.
|
||||
//! Always a failure.
|
||||
//! * the preflight says `Ok(())` and the whole road refuses — a *deferral*,
|
||||
//! which is the normal case for everything the request file cannot settle.
|
||||
//! Counted, never asserted away, and asserted to be non-zero where the
|
||||
//! fixture is built to produce one.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use vlog_parser::parse_source_tolerant;
|
||||
use vlog_refactor::{rename, rename_name_at, rename_preflight};
|
||||
use vlog_semantic::analyze;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Fixtures
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const SUB: &str = "module sub #(parameter int W = 1) (input logic clk, output logic q);\n wire local_net;\n assign q = clk & local_net;\nendmodule : sub\n";
|
||||
const TOP: &str = "module top;\n logic c, d;\n sub #(.W(2)) u_sub (.clk(c), .q(d));\n sub u_two (.clk(c), .q(d));\nendmodule\n";
|
||||
const PKG: &str =
|
||||
"package cfg_pkg;\n parameter int DEPTH = 4;\n typedef logic [1:0] mode_t;\nendpackage\n";
|
||||
const USER: &str = "module user;\n import cfg_pkg::*;\n cfg_pkg::mode_t m;\n localparam int D = cfg_pkg::DEPTH;\nendmodule\n";
|
||||
/// A name that resolves to nothing, and one that could only come from a base
|
||||
/// class nothing in the workspace declares.
|
||||
const STRAY: &str = "class kid extends absent_base;\n function void go();\n inherited_thing = 1;\n endfunction\nendclass\nmodule holder;\n missing u_missing (.a(b));\nendmodule\n";
|
||||
/// Macro invocations, a generate block and a genvar.
|
||||
const GEN: &str = "`define BUMP(x) x + 1\n`define WIDTH 8\nmodule gen_holder;\n genvar i;\n generate\n for (i = 0; i < 2; i++) begin : lane\n sub u_lane (.clk(1'b0), .q());\n end\n endgenerate\n wire [`WIDTH-1:0] w;\n assign w = `BUMP(sub);\nendmodule\n";
|
||||
/// Every byte a cursor can sit on that is *not* a symbol: line comments,
|
||||
/// block comments, a string literal, a system task, an attribute, and — for
|
||||
/// the offsets in between — punctuation and whitespace.
|
||||
const PROSE: &str = "// a leading line comment naming clk and sub\n/* a block comment\n naming local_net too */\nmodule prose;\n // clk here is prose\n logic clk;\n initial begin\n $display(\"clk and sub and local_net, all in a string\");\n end\n (* keep = \"true\" *)\n wire tagged_net;\nendmodule\n";
|
||||
const BROKEN: &str = "module broken (input logic clk;\n wire a\n assign a = clk\nendmodule\n";
|
||||
|
||||
fn workspace(files: &[(&str, &str)]) -> Vec<(PathBuf, String)> {
|
||||
files.iter().map(|(name, text)| (PathBuf::from(name), (*text).to_string())).collect()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// The rename oracle
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/// Ask both roads the same rename at every byte of `file`, for every new name
|
||||
/// worth asking about there, and return `(refused, deferred)`.
|
||||
///
|
||||
/// The new names are the four `check_new_name` shapes plus two that can only
|
||||
/// be judged after the cursor is resolved: a novel valid name, and **the name
|
||||
/// the cursor already spells**, which is the one way to reach the "is the name
|
||||
/// it already has" refusal at an arbitrary offset.
|
||||
fn rename_oracle(files: &[(&str, &str)], file: &str) -> (usize, usize) {
|
||||
let sources = workspace(files);
|
||||
let path = PathBuf::from(file);
|
||||
let text = files
|
||||
.iter()
|
||||
.find(|(name, _)| *name == file)
|
||||
.map(|(_, text)| *text)
|
||||
.expect("the file is in the workspace");
|
||||
let semantics = analyze(&parse_source_tolerant(text).0, text);
|
||||
|
||||
let (mut refused, mut deferred) = (0usize, 0usize);
|
||||
for offset in 0..=text.len() as u32 {
|
||||
let here = rename_name_at(&semantics, offset);
|
||||
let mut names: Vec<&str> = vec!["", "module", "1bad", "has space", "renamed_thing"];
|
||||
if let Some(name) = &here {
|
||||
names.push(name.as_str());
|
||||
}
|
||||
for new_name in names {
|
||||
let fast = rename_preflight(&semantics, offset, new_name);
|
||||
let slow = rename(&sources, &path, offset, new_name);
|
||||
match (&fast, &slow) {
|
||||
(Err(fast), Err(slow)) => {
|
||||
assert_eq!(
|
||||
fast, slow,
|
||||
"byte {offset} of {file} renamed to {new_name:?}: \
|
||||
the preflight and the workspace refuse in different words"
|
||||
);
|
||||
refused += 1;
|
||||
}
|
||||
(Err(fast), Ok(_)) => panic!(
|
||||
"byte {offset} of {file} renamed to {new_name:?}: the preflight \
|
||||
invented the refusal {fast:?} for a rename the workspace performs"
|
||||
),
|
||||
// The preflight stood aside. Whatever the workspace then says
|
||||
// is today's answer, unchanged — which is the whole contract.
|
||||
(Ok(()), Err(_)) => deferred += 1,
|
||||
(Ok(()), Ok(_)) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
(refused, deferred)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_preflight_refuses_a_rename_exactly_as_the_workspace_does() {
|
||||
let files = [("sub.sv", SUB), ("top.sv", TOP)];
|
||||
let (refused, _) = rename_oracle(&files, "top.sv");
|
||||
assert!(refused > 0, "the sweep must actually reach the preflight's refusals");
|
||||
rename_oracle(&files, "sub.sv");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cursor_on_prose_is_refused_from_the_buffer_alone() {
|
||||
// Comments, a string literal, a system task and an attribute: the whole
|
||||
// "there is no symbol to rename at this position" family, which is the
|
||||
// 2,192 ms refusal this preflight exists for.
|
||||
let files = [("prose.sv", PROSE), ("sub.sv", SUB), ("top.sv", TOP)];
|
||||
let (refused, _) = rename_oracle(&files, "prose.sv");
|
||||
assert!(refused > 0);
|
||||
|
||||
// And named exactly, so a reworded refusal cannot hide inside the sweep.
|
||||
let sources = workspace(&files);
|
||||
let path = PathBuf::from("prose.sv");
|
||||
let semantics = analyze(&parse_source_tolerant(PROSE).0, PROSE);
|
||||
for (what, at) in [
|
||||
("a line comment", PROSE.find("a leading line").expect("the comment")),
|
||||
("a block comment", PROSE.find("naming local_net").expect("the comment")),
|
||||
("a string literal", PROSE.find("all in a string").expect("the string")),
|
||||
] {
|
||||
let at = at as u32;
|
||||
let fast = rename_preflight(&semantics, at, "renamed_thing").expect_err(what);
|
||||
assert_eq!(fast, "there is no symbol to rename at this position.", "{what}");
|
||||
assert_eq!(fast, rename(&sources, &path, at, "renamed_thing").expect_err(what), "{what}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unresolved_and_an_inherited_reference_keep_their_own_sentences() {
|
||||
let files = [("stray.sv", STRAY), ("sub.sv", SUB)];
|
||||
rename_oracle(&files, "stray.sv");
|
||||
|
||||
// Which byte carries which refusal is the binder's business, so the
|
||||
// fixture is swept for the two sentences rather than told where they are —
|
||||
// and both must be found, or the fixture has stopped exercising them.
|
||||
let sources = workspace(&files);
|
||||
let path = PathBuf::from("stray.sv");
|
||||
let semantics = analyze(&parse_source_tolerant(STRAY).0, STRAY);
|
||||
let (mut unresolved, mut inherited) = (0usize, 0usize);
|
||||
for at in 0..=STRAY.len() as u32 {
|
||||
let Err(fast) = rename_preflight(&semantics, at, "renamed_thing") else { continue };
|
||||
if fast.contains("is not resolved to any declaration") {
|
||||
unresolved += 1;
|
||||
} else if fast.contains("could only come from the base class") {
|
||||
inherited += 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
let slow = rename(&sources, &path, at, "renamed_thing").expect_err("the same refusal");
|
||||
assert_eq!(fast, slow, "at byte {at} of stray.sv");
|
||||
}
|
||||
assert!(unresolved > 0, "the fixture no longer holds a reference that resolves to nothing");
|
||||
assert!(inherited > 0, "the fixture no longer holds an inherited candidate");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_macro_invocation_and_a_generate_block_keep_parity() {
|
||||
rename_oracle(&[("gen.sv", GEN), ("sub.sv", SUB)], "gen.sv");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_buffer_that_does_not_parse_keeps_parity() {
|
||||
rename_oracle(&[("broken.sv", BROKEN), ("sub.sv", SUB)], "broken.sv");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_package_and_its_qualified_users_keep_parity() {
|
||||
let files = [("pkg.sv", PKG), ("user.sv", USER)];
|
||||
rename_oracle(&files, "user.sv");
|
||||
rename_oracle(&files, "pkg.sv");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_name_declared_in_two_files_stays_on_the_slow_road() {
|
||||
// Two modules called `sub`. The ambiguity is the *index's* answer, and the
|
||||
// index is rebuilt on save, never on a keystroke — so the preflight must
|
||||
// not take this refusal, and the sweep must show it deferring instead.
|
||||
let files = [("a.sv", SUB), ("b.sv", SUB), ("top.sv", TOP)];
|
||||
let (_, deferred) = rename_oracle(&files, "top.sv");
|
||||
assert!(deferred > 0, "the ambiguous declaration must reach the workspace to be refused");
|
||||
|
||||
let sources = workspace(&files);
|
||||
let path = PathBuf::from("top.sv");
|
||||
let semantics = analyze(&parse_source_tolerant(TOP).0, TOP);
|
||||
let at = TOP.find("sub #").expect("the instantiation") as u32;
|
||||
assert!(
|
||||
rename_preflight(&semantics, at, "renamed_thing").is_ok(),
|
||||
"the preflight must stand aside for a name the index answers ambiguously"
|
||||
);
|
||||
assert!(rename(&sources, &path, at, "renamed_thing").is_err(), "and the workspace refuses it");
|
||||
}
|
||||
|
||||
/// TODO §63.1 QA. A `bind`'s connection expressions resolve in the *target's*
|
||||
/// scope, which a single buffer never holds — so both shapes must defer, and
|
||||
/// the fixture is swept to prove neither is ever an *invented* refusal.
|
||||
const AES_FOR_BIND: &str = "module aes (input logic clk_i, output logic idle_o);\n \
|
||||
logic entropy_masking_req;\n aes_core u_aes_core (.clk_i(clk_i));\n \
|
||||
assign idle_o = entropy_masking_req;\nendmodule : aes\n";
|
||||
const AES_CORE_FOR_BIND: &str =
|
||||
"module aes_core (input logic clk_i);\n logic seed_en;\n assign seed_en = clk_i;\nendmodule : aes_core\n";
|
||||
const RESEED_IF_FOR_BIND: &str =
|
||||
"module aes_reseed_if (input logic entropy_masking_req, input logic seed_en);\nendmodule : aes_reseed_if\n";
|
||||
const AES_BIND: &str = "module aes_bind;\n bind aes aes_reseed_if u_aes_reseed_if (\n \
|
||||
.entropy_masking_req(entropy_masking_req),\n .seed_en(u_aes_core.seed_en)\n );\nendmodule\n";
|
||||
|
||||
#[test]
|
||||
fn a_binds_connection_expressions_defer_rather_than_invent_a_refusal() {
|
||||
// Before this lane a bare-name connection carried a one-segment external
|
||||
// candidate (deferred already) but a hierarchical tail carried *no*
|
||||
// reference at all — `symbol_at` finds no declaration either, so the
|
||||
// preflight fell to `NOTHING_HERE`, a refusal the workspace does not
|
||||
// agree with (it resolves and edits the tail). The oracle's own
|
||||
// `(Err, Ok)` branch panics on exactly that shape, so a plain sweep is the
|
||||
// proof: nothing here may ever be an invented refusal.
|
||||
let files = [
|
||||
("aes.sv", AES_FOR_BIND),
|
||||
("aes_core.sv", AES_CORE_FOR_BIND),
|
||||
("aes_reseed_if.sv", RESEED_IF_FOR_BIND),
|
||||
("aes_bind.sv", AES_BIND),
|
||||
];
|
||||
let (_, deferred) = rename_oracle(&files, "aes_bind.sv");
|
||||
assert!(deferred > 0, "every connection expression in a bind file defers to the workspace");
|
||||
|
||||
// And named exactly, at the hierarchical tail's own byte: this is the one
|
||||
// Handshakes calls out as changed — `NOTHING_HERE` before, `Ok(())` now.
|
||||
let semantics = analyze(&parse_source_tolerant(AES_BIND).0, AES_BIND);
|
||||
let at =
|
||||
AES_BIND.find("u_aes_core.seed_en").expect("the tail") as u32 + "u_aes_core.".len() as u32;
|
||||
assert!(
|
||||
rename_preflight(&semantics, at, "renamed_thing").is_ok(),
|
||||
"the preflight must stand aside for a bind's hierarchical tail, which only the \
|
||||
workspace can root at the bind target"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer() {
|
||||
let files = [("sub.sv", SUB), ("top.sv", TOP)];
|
||||
let sources = workspace(&files);
|
||||
let path = PathBuf::from("sub.sv");
|
||||
let semantics = analyze(&parse_source_tolerant(SUB).0, SUB);
|
||||
// `local_net` is a declaration inside the module — not at file scope, so
|
||||
// no index question stands between the cursor and this refusal.
|
||||
let at = SUB.find("local_net").expect("the declaration") as u32;
|
||||
let fast = rename_preflight(&semantics, at, "local_net").expect_err("the same name");
|
||||
assert_eq!(fast, "`local_net` is the name it already has.");
|
||||
assert_eq!(fast, rename(&sources, &path, at, "local_net").expect_err("the same name"));
|
||||
|
||||
// A file-scope unit's same-name refusal is the index's to reach, because
|
||||
// the ambiguity check comes first.
|
||||
let at = SUB.find("sub").expect("the module name") as u32;
|
||||
assert!(rename_preflight(&semantics, at, "sub").is_ok(), "deferred, not taken");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_invalid_new_name_outranks_every_cursor_refusal() {
|
||||
// Precedence: `renaming` checks the new name before it builds a scope and
|
||||
// before it looks at the cursor, so a bad name on a cursor that sits on
|
||||
// nothing must produce the *name's* sentence, not the cursor's.
|
||||
let files = [("prose.sv", PROSE), ("sub.sv", SUB)];
|
||||
let sources = workspace(&files);
|
||||
let path = PathBuf::from("prose.sv");
|
||||
let semantics = analyze(&parse_source_tolerant(PROSE).0, PROSE);
|
||||
let at = PROSE.find("a leading line").expect("the comment") as u32;
|
||||
for (name, expected) in [
|
||||
("", "a new name cannot be empty."),
|
||||
("module", "`module` is a Verilog keyword."),
|
||||
("1bad", "`1bad` is not a valid Verilog identifier."),
|
||||
] {
|
||||
let fast = rename_preflight(&semantics, at, name).expect_err(name);
|
||||
assert_eq!(fast, expected, "{name}");
|
||||
assert_eq!(fast, rename(&sources, &path, at, name).expect_err(name), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_preflight_reads_only_the_buffer_it_was_given() {
|
||||
// The proof behind the gate: resolving a cursor that sits on nothing costs
|
||||
// no whole-file parse at all, however large the workspace around it.
|
||||
let semantics = analyze(&parse_source_tolerant(PROSE).0, PROSE);
|
||||
let at = PROSE.find("a leading line").expect("the comment") as u32;
|
||||
let before = vlog_parser::stats::parses();
|
||||
let refusal = rename_preflight(&semantics, at, "renamed_thing").expect_err("no symbol");
|
||||
assert_eq!(vlog_parser::stats::parses() - before, 0, "the preflight parsed something");
|
||||
assert_eq!(refusal, "there is no symbol to rename at this position.");
|
||||
}
|
||||
@@ -0,0 +1,719 @@
|
||||
//! A `bind` directive's own occurrences of a renamed name (TODO §63.1).
|
||||
//!
|
||||
//! `bind aes aes_reseed_if u_x (.entropy_masking_req(entropy_masking_req));`
|
||||
//! writes the target module's internal net down in a file that instantiates
|
||||
//! nothing in the chain. IEEE 1800 §23.11 evaluates such a connection in the
|
||||
//! **target's** scope, so the name is a use of `aes`'s net and a rename must
|
||||
//! edit it — or say out loud that it could not. Silence is a wrong answer: the
|
||||
//! design no longer elaborates after the rename.
|
||||
//!
|
||||
//! Every test here is one of the shapes §63.1 lists, driven through the public
|
||||
//! `rename` over a little in-memory workspace: the bare-name connection, the
|
||||
//! positional one, the two-level hierarchical tail, a `: u_x` instance-list
|
||||
//! target, a hierarchical target path, a `bind` inside a generate block, and
|
||||
//! the one the engine must *not* resolve — a target module the workspace does
|
||||
//! not hold, which is warned about and never edited.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use vlog_refactor::{rename, rename_traced, rename_traced_with, RefactorEdit, RenameTrace};
|
||||
|
||||
/// A workspace of `(file name, text)` pairs, rooted at a fake directory.
|
||||
fn workspace(files: &[(&str, &str)]) -> Vec<(PathBuf, String)> {
|
||||
files.iter().map(|(name, text)| (PathBuf::from("/rtl").join(name), text.to_string())).collect()
|
||||
}
|
||||
|
||||
fn path(name: &str) -> PathBuf {
|
||||
PathBuf::from("/rtl").join(name)
|
||||
}
|
||||
|
||||
/// The offset of the first whole-word `name` at or after `prefix`.
|
||||
fn at(text: &str, prefix: &str, name: &str) -> u32 {
|
||||
let from = match prefix.is_empty() {
|
||||
true => 0,
|
||||
false => {
|
||||
text.find(prefix).unwrap_or_else(|| panic!("`{prefix}` is not in the text"))
|
||||
+ prefix.len()
|
||||
}
|
||||
};
|
||||
let is_word = |b: Option<&u8>| b.is_some_and(|b| b.is_ascii_alphanumeric() || *b == b'_');
|
||||
let bytes = text.as_bytes();
|
||||
let mut search = from;
|
||||
while let Some(hit) = text.get(search..).and_then(|s| s.find(name)) {
|
||||
let start = search + hit;
|
||||
let end = start + name.len();
|
||||
if !is_word(start.checked_sub(1).and_then(|i| bytes.get(i))) && !is_word(bytes.get(end)) {
|
||||
return start as u32;
|
||||
}
|
||||
search = start + 1;
|
||||
}
|
||||
panic!("`{name}` does not occur after `{prefix}`");
|
||||
}
|
||||
|
||||
/// Apply a refactoring's edits for one file.
|
||||
fn apply(text: &str, edit: &RefactorEdit, file: &Path) -> String {
|
||||
let mut out = String::new();
|
||||
let mut cursor = 0usize;
|
||||
for e in edit.edits_for(file) {
|
||||
out.push_str(&text[cursor..e.range.start as usize]);
|
||||
out.push_str(&e.new_text);
|
||||
cursor = e.range.end as usize;
|
||||
}
|
||||
out.push_str(&text[cursor..]);
|
||||
out
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the little AES the fixtures bind into
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// The target module: it declares the net every fixture renames, and it
|
||||
/// instantiates the core the two-level tail walks through.
|
||||
const AES: &str = "\
|
||||
module aes (input logic clk_i, output logic idle_o);
|
||||
logic entropy_masking_req;
|
||||
aes_core u_aes_core (.clk_i(clk_i));
|
||||
assign idle_o = entropy_masking_req;
|
||||
endmodule : aes
|
||||
";
|
||||
|
||||
const AES_CORE: &str = "\
|
||||
module aes_core (input logic clk_i);
|
||||
aes_prng_clearing u_aes_prng_clearing (.clk_i(clk_i));
|
||||
endmodule : aes_core
|
||||
";
|
||||
|
||||
const AES_PRNG: &str = "\
|
||||
module aes_prng_clearing (input logic clk_i);
|
||||
logic seed_en;
|
||||
assign seed_en = clk_i;
|
||||
endmodule : aes_prng_clearing
|
||||
";
|
||||
|
||||
/// The checker a `bind` binds in. Its ports are deliberately spelled like the
|
||||
/// names being renamed, so a fixture also proves the `.port` half is left
|
||||
/// alone: it names *this* module's port, not the target's net.
|
||||
const RESEED_IF: &str = "\
|
||||
module aes_reseed_if (input logic entropy_masking_req, input logic seed_en);
|
||||
endmodule : aes_reseed_if
|
||||
";
|
||||
|
||||
/// The RTL half of every fixture's workspace.
|
||||
fn rtl(bind_file: &str) -> Vec<(PathBuf, String)> {
|
||||
workspace(&[
|
||||
("aes.sv", AES),
|
||||
("aes_core.sv", AES_CORE),
|
||||
("aes_prng_clearing.sv", AES_PRNG),
|
||||
("aes_reseed_if.sv", RESEED_IF),
|
||||
("aes_bind.sv", bind_file),
|
||||
])
|
||||
}
|
||||
|
||||
/// Rename `name` (declared in `decl_file`, at the first whole-word occurrence
|
||||
/// after `prefix`) to `new_name`, and return the bind file's new text together
|
||||
/// with the rename's warnings.
|
||||
fn rename_with_bind(
|
||||
bind_file: &str,
|
||||
decl_file: &str,
|
||||
prefix: &str,
|
||||
name: &str,
|
||||
new_name: &str,
|
||||
) -> (String, Vec<String>) {
|
||||
let files = rtl(bind_file);
|
||||
let text = files
|
||||
.iter()
|
||||
.find(|(p, _)| *p == path(decl_file))
|
||||
.map(|(_, t)| t.clone())
|
||||
.expect("the declaring file is in the workspace");
|
||||
let edit = rename(&files, &path(decl_file), at(&text, prefix, name), new_name)
|
||||
.unwrap_or_else(|e| panic!("the rename was refused: {e}"));
|
||||
(apply(bind_file, &edit, &path("aes_bind.sv")), edit.warnings.clone())
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the shapes that must be edited
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_bare_name_in_a_bind_connection_is_renamed() {
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let (after, warnings) =
|
||||
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert_eq!(
|
||||
after,
|
||||
"\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(masking_req)
|
||||
);
|
||||
endmodule
|
||||
",
|
||||
"the expression half names the target's net; the `.port` half names the checker's port"
|
||||
);
|
||||
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_positional_connection_in_a_bind_is_renamed() {
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (entropy_masking_req, 1'b0);
|
||||
endmodule
|
||||
";
|
||||
let (after, _) =
|
||||
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert_eq!(
|
||||
after,
|
||||
"\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (masking_req, 1'b0);
|
||||
endmodule
|
||||
"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_two_level_hierarchical_tail_in_a_bind_is_renamed() {
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.seed_en(u_aes_core.u_aes_prng_clearing.seed_en)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let (after, warnings) =
|
||||
rename_with_bind(bind, "aes_prng_clearing.sv", "logic", "seed_en", "reseed_en");
|
||||
assert_eq!(
|
||||
after,
|
||||
"\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.seed_en(u_aes_core.u_aes_prng_clearing.reseed_en)
|
||||
);
|
||||
endmodule
|
||||
",
|
||||
"the tail is rooted at the bind target and walks two instances to the declaration"
|
||||
);
|
||||
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_instance_list_target_still_names_the_target_module_scope() {
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes : u_aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let (after, _) =
|
||||
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert!(
|
||||
after.contains(".entropy_masking_req(masking_req)"),
|
||||
"`bind aes : u_aes` still binds into `aes`'s scope: {after}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bind_inside_a_generate_block_is_renamed() {
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
if (1) begin : gen_prng_bind
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
end
|
||||
endmodule
|
||||
";
|
||||
let (after, _) =
|
||||
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert!(
|
||||
after.contains(".entropy_masking_req(masking_req)"),
|
||||
"a generate block changes where the directive is written, not what it binds into: {after}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_hierarchical_target_path_is_followed_through_the_instance_it_names() {
|
||||
let tb = "\
|
||||
module tb;
|
||||
aes u_aes (.clk_i(1'b0), .idle_o());
|
||||
endmodule : tb
|
||||
";
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind tb.u_aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let mut files = rtl(bind);
|
||||
files.push((path("tb.sv"), tb.to_string()));
|
||||
let edit =
|
||||
rename(&files, &path("aes.sv"), at(AES, "logic", "entropy_masking_req"), "masking_req")
|
||||
.expect("renames");
|
||||
assert_eq!(
|
||||
apply(bind, &edit, &path("aes_bind.sv")),
|
||||
"\
|
||||
module aes_bind;
|
||||
bind tb.u_aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(masking_req)
|
||||
);
|
||||
endmodule
|
||||
",
|
||||
"`tb.u_aes` is one instance hop the index can take, so the connection resolves"
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the shape the engine must not resolve
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_bind_into_a_module_the_workspace_does_not_hold_is_warned_about_never_edited() {
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes_shadow aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let (after, warnings) =
|
||||
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert_eq!(after, bind, "nothing in the bind file was edited");
|
||||
assert!(
|
||||
warnings.iter().any(|w| w.contains("aes_bind.sv")
|
||||
&& w.contains("aes_shadow::entropy_masking_req")
|
||||
&& w.contains("could not be resolved")),
|
||||
"the miss is said out loud, with the file and the unit that was searched: {warnings:?}"
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the edited bind file is an ordinary file to everything downstream
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// A regression guard rather than a flipped fixture: the collision is an
|
||||
// ordinary same-file one (`aes.sv` already declares `masking_req`), so
|
||||
// `check::verify` refused it before the bind file was understood at all
|
||||
// (it passes at 2675131 unmodified — QA §63.1, finding 1). What it pins is
|
||||
// that the refusal survives the bind file joining the edited set.
|
||||
#[test]
|
||||
fn a_new_name_the_bind_target_already_declares_is_refused() {
|
||||
let aes = "\
|
||||
module aes (input logic clk_i, output logic idle_o);
|
||||
logic entropy_masking_req;
|
||||
logic masking_req;
|
||||
assign idle_o = entropy_masking_req & masking_req;
|
||||
endmodule : aes
|
||||
";
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let files =
|
||||
workspace(&[("aes.sv", aes), ("aes_reseed_if.sv", RESEED_IF), ("aes_bind.sv", bind)]);
|
||||
let refusal =
|
||||
rename(&files, &path("aes.sv"), at(aes, "logic", "entropy_masking_req"), "masking_req")
|
||||
.expect_err("the new name is already taken in the scope the bind reaches into");
|
||||
assert!(refusal.contains("masking_req"), "the refusal names the collision: {refusal}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renaming_a_bind_connection_back_restores_the_file_byte_for_byte() {
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req),
|
||||
.seed_en (u_aes_core.u_aes_prng_clearing.seed_en)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let (once, _) = rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert_ne!(once, bind, "the first rename moved the bind file");
|
||||
|
||||
// The same workspace with both edits applied, renamed back: the engine
|
||||
// resolves the new spelling exactly as it resolved the old one, so the
|
||||
// bind file returns to the text it started with.
|
||||
let aes_after = AES.replace("entropy_masking_req", "masking_req");
|
||||
let files = workspace(&[
|
||||
("aes.sv", &aes_after),
|
||||
("aes_core.sv", AES_CORE),
|
||||
("aes_prng_clearing.sv", AES_PRNG),
|
||||
("aes_reseed_if.sv", RESEED_IF),
|
||||
("aes_bind.sv", &once),
|
||||
]);
|
||||
let back = rename(
|
||||
&files,
|
||||
&path("aes.sv"),
|
||||
at(&aes_after, "logic", "masking_req"),
|
||||
"entropy_masking_req",
|
||||
)
|
||||
.expect("renames back");
|
||||
assert_eq!(apply(&once, &back, &path("aes_bind.sv")), bind);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// QA attack fixtures (TODO §63.1, task 3): shapes not in the dev's seven
|
||||
// plus two, each aimed at a specific way the fix could be half right.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_bind_connections_bare_name_naming_the_targets_port_is_still_renamed() {
|
||||
// `in_bind_target`'s widened surface is `Connection` records first, then
|
||||
// `Hierarchical`-only ones (`workspace/hierarchy.rs::member`) — so a port
|
||||
// (which was already reachable through the narrow surface) must still
|
||||
// resolve exactly as it did before this lane, through the same fallback
|
||||
// that answers a net. `clk_i` is `aes`'s own port, connected bare in the
|
||||
// `bind`; the `.port` half names the checker's unrelated port of the same
|
||||
// name and must stay put.
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(clk_i)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let (after, warnings) = rename_with_bind(bind, "aes.sv", "input logic", "clk_i", "clk_ix");
|
||||
assert_eq!(
|
||||
after,
|
||||
"\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(clk_ix)
|
||||
);
|
||||
endmodule
|
||||
",
|
||||
"the expression half names `aes`'s port; the `.port` half is the checker's own, untouched"
|
||||
);
|
||||
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bind_connection_resolves_in_the_target_not_a_same_named_decoy_in_the_writing_scope() {
|
||||
// The writing module — normally empty — now declares its own
|
||||
// `entropy_masking_req`, spelling the same name `aes` does. If the
|
||||
// connection ever fell back to the scope the directive is *written* in
|
||||
// (finding 2's bug, for a bare name rather than a hierarchical tail),
|
||||
// this decoy is exactly what it would capture instead of `aes`'s net.
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
logic entropy_masking_req;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let (after, warnings) =
|
||||
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert_eq!(
|
||||
after,
|
||||
"\
|
||||
module aes_bind;
|
||||
logic entropy_masking_req;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(masking_req)
|
||||
);
|
||||
endmodule
|
||||
",
|
||||
"the connection is `aes`'s net, never `aes_bind`'s own decoy of the same name, \
|
||||
which must still read `entropy_masking_req` after the rename"
|
||||
);
|
||||
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused() {
|
||||
// The bare-name path's collision refusal
|
||||
// (`a_new_name_the_bind_target_already_declares_is_refused`) exercises
|
||||
// only `in_bind_target`. This is the same shape one link further down the
|
||||
// spine — the tail rooted at the bind target and walked through
|
||||
// `bind_member`/`member_at`/`descend` — so a collision at the *end* of a
|
||||
// two-level tail must refuse exactly as readily, with no gap specific to
|
||||
// the new code path.
|
||||
let aes_prng = "\
|
||||
module aes_prng_clearing (input logic clk_i);
|
||||
logic seed_en;
|
||||
logic reseed_en;
|
||||
assign seed_en = clk_i;
|
||||
endmodule : aes_prng_clearing
|
||||
";
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if (
|
||||
.seed_en(u_aes_core.u_aes_prng_clearing.seed_en)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let files = workspace(&[
|
||||
("aes.sv", AES),
|
||||
("aes_core.sv", AES_CORE),
|
||||
("aes_prng_clearing.sv", aes_prng),
|
||||
("aes_reseed_if.sv", RESEED_IF),
|
||||
("aes_bind.sv", bind),
|
||||
]);
|
||||
let refusal = rename(
|
||||
&files,
|
||||
&path("aes_prng_clearing.sv"),
|
||||
at(aes_prng, "logic", "seed_en"),
|
||||
"reseed_en",
|
||||
)
|
||||
.expect_err("`reseed_en` already exists in the tail's terminal scope");
|
||||
assert!(refusal.contains("reseed_en"), "the refusal names the collision: {refusal}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_escaped_identifier_bind_target_is_still_resolved() {
|
||||
// `\aes.escaped ` is one identifier (an escaped identifier ends at
|
||||
// whitespace, IEEE 1800 §5.6.2), spelling a name a plain identifier
|
||||
// cannot. `bind_target_path` joins `b.target`'s segments verbatim, so
|
||||
// this is a one-segment path exactly like `bind aes …` — the escaping is
|
||||
// the parser's problem, not the resolver's.
|
||||
let aes_escaped = "\
|
||||
module \\aes.escaped (input logic clk_i, output logic idle_o);
|
||||
logic entropy_masking_req;
|
||||
assign idle_o = entropy_masking_req;
|
||||
endmodule
|
||||
";
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind \\aes.escaped aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let files = workspace(&[
|
||||
("aes.sv", aes_escaped),
|
||||
("aes_reseed_if.sv", RESEED_IF),
|
||||
("aes_bind.sv", bind),
|
||||
]);
|
||||
let edit = rename(
|
||||
&files,
|
||||
&path("aes.sv"),
|
||||
at(aes_escaped, "logic", "entropy_masking_req"),
|
||||
"masking_req",
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("the rename was refused: {e}"));
|
||||
let after = apply(bind, &edit, &path("aes_bind.sv"));
|
||||
assert_eq!(
|
||||
after,
|
||||
"\
|
||||
module aes_bind;
|
||||
bind \\aes.escaped aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(masking_req)
|
||||
);
|
||||
endmodule
|
||||
",
|
||||
"the escaped target's connection still resolves and is edited: {edit:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bind_with_no_connections_naming_the_renamed_signal_is_untouched() {
|
||||
// An empty connection list plus a `defparam` — a shape with nothing for
|
||||
// any connection-surface rung to walk. Nothing here spells the renamed
|
||||
// name, so the file must come back byte for byte and warn about nothing.
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind aes aes_reseed_if u_aes_reseed_if ();
|
||||
defparam u_aes_reseed_if.SOME_PARAM = 1;
|
||||
endmodule
|
||||
";
|
||||
let (after, warnings) =
|
||||
rename_with_bind(bind, "aes.sv", "logic", "entropy_masking_req", "masking_req");
|
||||
assert_eq!(after, bind, "no connection in this bind file spells the renamed name");
|
||||
assert!(warnings.is_empty(), "nothing was left unaccounted for: {warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bind_target_reached_through_a_generate_block_is_warned_about_never_guessed() {
|
||||
// `bind tb.gen[0].u_aes …`: the middle hop is a generate block, which the
|
||||
// index has no record of at all (an indexed segment "keeps only its
|
||||
// name", per `bind_target_path`'s doc comment) — so the path is one the
|
||||
// index cannot walk, and the contract is a warning, never a silent miss
|
||||
// and never a guess at which `u_aes` is meant.
|
||||
let tb = "\
|
||||
module tb;
|
||||
if (1) begin : gen
|
||||
aes u_aes (.clk_i(1'b0), .idle_o());
|
||||
end
|
||||
endmodule : tb
|
||||
";
|
||||
let bind = "\
|
||||
module aes_bind;
|
||||
bind tb.gen[0].u_aes aes_reseed_if u_aes_reseed_if (
|
||||
.entropy_masking_req(entropy_masking_req)
|
||||
);
|
||||
endmodule
|
||||
";
|
||||
let mut files = rtl(bind);
|
||||
files.push((path("tb.sv"), tb.to_string()));
|
||||
let edit =
|
||||
rename(&files, &path("aes.sv"), at(AES, "logic", "entropy_masking_req"), "masking_req")
|
||||
.expect("the rename over the rest of the design still succeeds");
|
||||
assert_eq!(
|
||||
apply(bind, &edit, &path("aes_bind.sv")),
|
||||
bind,
|
||||
"a path through a generate block is never guessed at: {edit:?}"
|
||||
);
|
||||
assert!(
|
||||
edit.warnings
|
||||
.iter()
|
||||
.any(|w| w.contains("aes_bind.sv") && w.contains("could not be resolved")),
|
||||
"the miss is said out loud rather than silently dropped: {:?}",
|
||||
edit.warnings
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// the real tree (TODO §63.1, the three QA renames)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// §61.5's QA renames, run against a real checkout: `WidthPRDSBox` (a package
|
||||
/// parameter used bare through `module aes_sbox import aes_pkg::*;`),
|
||||
/// `entropy_masking_req` (the bare-name `bind` connection this lane is about)
|
||||
/// and `seed_en` (the two-level tail in the same `bind` file). Each is asked
|
||||
/// three ways — with no index records, with every record, and with every
|
||||
/// second one — and the three must answer identically; the two `bind` ones
|
||||
/// must edit `aes_bind.sv`.
|
||||
///
|
||||
/// `#[ignore]`d, and skipped unless `LUCISV_BIND_ROOT` names a tree (it is
|
||||
/// **read** and never written). Run it with
|
||||
/// `LUCISV_BIND_ROOT=$HOME/repo/opentitan tools/guard.sh -m 8 -t 1800 -- \
|
||||
/// cargo test -p vlog_refactor --test rename_bind -- --ignored --nocapture`.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn the_three_qa_renames_agree_across_reuse_modes_and_edit_the_bind_file() {
|
||||
let Ok(root) = std::env::var("LUCISV_BIND_ROOT") else {
|
||||
eprintln!("LUCISV_BIND_ROOT unset — skipping");
|
||||
return;
|
||||
};
|
||||
let root = PathBuf::from(root);
|
||||
if !root.is_dir() {
|
||||
eprintln!("{} is not a directory — skipping", root.display());
|
||||
return;
|
||||
}
|
||||
let mut files = Vec::new();
|
||||
collect(&root, &mut files);
|
||||
files.sort();
|
||||
let sources: Vec<(PathBuf, String)> =
|
||||
files.iter().filter_map(|p| Some((p.clone(), std::fs::read_to_string(p).ok()?))).collect();
|
||||
assert!(!sources.is_empty(), "the tree holds no Verilog");
|
||||
println!("{} files read from {}", sources.len(), root.display());
|
||||
|
||||
// (file, the text the cursor is placed after, the name, the new name,
|
||||
// whether `aes_bind.sv` must be among the edited files)
|
||||
let cases: [(&str, &str, &str, &str, bool); 3] = [
|
||||
(
|
||||
"aes_pkg.sv",
|
||||
"parameter int unsigned WidthPRDSBox",
|
||||
"WidthPRDSBox",
|
||||
"WidthPRDSBoxX",
|
||||
false,
|
||||
),
|
||||
("aes.sv", "entropy_clearing_req, ", "entropy_masking_req", "masking_req_x", true),
|
||||
("aes_prng_clearing.sv", "logic seed_en", "seed_en", "seed_en_x", true),
|
||||
];
|
||||
for (file, prefix, name, new_name, bind_edited) in cases {
|
||||
let Some((path, text)) =
|
||||
sources.iter().find(|(p, _)| p.file_name().is_some_and(|n| n == file))
|
||||
else {
|
||||
eprintln!("{file} not in this tree — skipping that case");
|
||||
continue;
|
||||
};
|
||||
let offset = at(text, prefix, name);
|
||||
|
||||
let mut plain = RenameTrace::default();
|
||||
let none = rename_traced(&sources, path, offset, new_name, &mut plain);
|
||||
let all = Records::of(&sources, false);
|
||||
let mut every = RenameTrace::default();
|
||||
let full = rename_traced_with(&sources, path, offset, new_name, &all, &mut every);
|
||||
let half = Records::of(&sources, true);
|
||||
let mut mixed = RenameTrace::default();
|
||||
let some = rename_traced_with(&sources, path, offset, new_name, &half, &mut mixed);
|
||||
|
||||
let shape = |r: &Result<vlog_refactor::RefactorEdit, String>| match r {
|
||||
Ok(edit) => Ok((edit.edits.clone(), edit.warnings.clone())),
|
||||
Err(e) => Err(e.clone()),
|
||||
};
|
||||
assert_eq!(shape(&none), shape(&full), "{name}: every record changed the answer");
|
||||
assert_eq!(shape(&none), shape(&some), "{name}: half the records changed the answer");
|
||||
|
||||
let edit = none.unwrap_or_else(|e| panic!("{name} was refused: {e}"));
|
||||
let touched: Vec<String> = edit
|
||||
.edits
|
||||
.iter()
|
||||
.filter_map(|(p, _)| p.file_name().map(|n| n.to_string_lossy().into_owned()))
|
||||
.collect();
|
||||
println!(
|
||||
"{name} -> {new_name}: {} files, {} edits, {} warnings; parses {} / {} / {}",
|
||||
edit.edits.len(),
|
||||
edit.edits.iter().map(|(_, e)| e.len()).sum::<usize>(),
|
||||
edit.warnings.len(),
|
||||
plain.parses,
|
||||
every.parses,
|
||||
mixed.parses
|
||||
);
|
||||
for (p, edits) in &edit.edits {
|
||||
println!(" {} x{}", p.display(), edits.len());
|
||||
}
|
||||
for w in &edit.warnings {
|
||||
println!(" warn: {w}");
|
||||
}
|
||||
assert_eq!(
|
||||
touched.iter().any(|n| n == "aes_bind.sv"),
|
||||
bind_edited,
|
||||
"{name}: aes_bind.sv among {touched:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn collect(dir: &Path, out: &mut Vec<PathBuf>) {
|
||||
let Ok(entries) = std::fs::read_dir(dir) else { return };
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
if path.is_dir() {
|
||||
collect(&path, out);
|
||||
} else if matches!(path.extension().and_then(|e| e.to_str()), Some("sv" | "svh")) {
|
||||
out.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Every source's index record, or every second one — the mixture a real
|
||||
/// rename gets from a partly warm store.
|
||||
struct Records {
|
||||
known: Vec<(PathBuf, String, vlog_semantic::FileFacts)>,
|
||||
}
|
||||
|
||||
impl Records {
|
||||
fn of(sources: &[(PathBuf, String)], half: bool) -> Records {
|
||||
let known = sources
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(i, _)| !half || i % 2 == 0)
|
||||
.map(|(_, (path, text))| {
|
||||
(path.clone(), text.clone(), vlog_semantic::FileFacts::of(path.clone(), text))
|
||||
})
|
||||
.collect();
|
||||
Records { known }
|
||||
}
|
||||
}
|
||||
|
||||
impl vlog_refactor::KnownFacts for Records {
|
||||
fn facts_for(&self, path: &Path, text: &str) -> Option<vlog_semantic::FileFacts> {
|
||||
self.known
|
||||
.iter()
|
||||
.find(|(held, bytes, _)| held == path && bytes == text)
|
||||
.map(|(_, _, facts)| facts.clone())
|
||||
}
|
||||
}
|
||||
@@ -333,14 +333,18 @@ impl<'a> Binder<'a> {
|
||||
/// `bind prim_fifo_sync …` names the declaration a `go to definition`
|
||||
/// should jump to. A hierarchical *instance* path (`top.u_dut.u_core`,
|
||||
/// `top.gen[0].u_core`) names a place in an elaborated hierarchy that no
|
||||
/// single file knows, so it records nothing at all: the alternative is a
|
||||
/// guess, and a guess here is a wrong answer.
|
||||
/// single file knows, so it records **no reference of its own**: the
|
||||
/// alternative is a guess, and a guess here is a wrong answer. It is
|
||||
/// still the scope the connections elaborate in, and
|
||||
/// [`bind_target_path`] is that scope written the way the index reads a
|
||||
/// path.
|
||||
/// * the **instantiated module**, exactly as before, so a bind still makes
|
||||
/// the bound module a dependency of this file.
|
||||
/// * each connection: the `.port` half against the module being bound in
|
||||
/// (an ordinary [`Target::Port`], the same one a plain instantiation
|
||||
/// uses), and the expression half in the target's scope
|
||||
/// ([`Target::BindScope`]).
|
||||
/// uses), and the expression half in the target's scope — a bare name
|
||||
/// through [`Target::BindScope`], a hierarchical path through
|
||||
/// [`Target::BindMember`].
|
||||
///
|
||||
/// The instance name is still **not** declared here: it belongs to the
|
||||
/// target scope, and declaring it in this one would put a name in a scope
|
||||
@@ -357,7 +361,7 @@ impl<'a> Binder<'a> {
|
||||
let i = &b.inst;
|
||||
let ns = self.exact_or_empty(i.module_span, &i.module);
|
||||
self.use_name(scope, &i.module, ns, Target::Module);
|
||||
let previous = std::mem::replace(&mut self.bind_target, head.map(|h| h.name.clone()));
|
||||
let previous = std::mem::replace(&mut self.bind_target, bind_target_path(b));
|
||||
for c in i.params.iter().flatten().filter_map(ListElem::ok) {
|
||||
self.bind_connection(c, &i.module, scope);
|
||||
}
|
||||
@@ -588,3 +592,29 @@ impl<'a> Binder<'a> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// The scope a `bind`'s connection expressions are elaborated in, spelled the
|
||||
/// way the workspace's member tables read a path: one `::` per segment.
|
||||
///
|
||||
/// A lone segment is the target module or interface, and `aes` is the unit the
|
||||
/// index answers `aes::entropy_masking_req` in. A hierarchical path is the
|
||||
/// same question one hop at a time — `tb.u_aes` is `tb::u_aes`, which
|
||||
/// `fold_path` walks by asking `tb` for the declared type of its instance
|
||||
/// `u_aes` — so the path resolves whenever the index holds every hop and is
|
||||
/// *said out loud* when it does not, instead of silently resolving the
|
||||
/// connection in the scope the directive is written in, which is not the
|
||||
/// scope it elaborates in.
|
||||
///
|
||||
/// An indexed segment (`gen[0]`) keeps only its name: the index has no record
|
||||
/// of a generate block, so such a path answers nothing either way, and a
|
||||
/// spelling the user can recognize is what the warning needs.
|
||||
fn bind_target_path(b: &BindDirective) -> Option<String> {
|
||||
let mut out = String::new();
|
||||
for seg in &b.target {
|
||||
if !out.is_empty() {
|
||||
out.push_str("::");
|
||||
}
|
||||
out.push_str(&seg.name);
|
||||
}
|
||||
(!out.is_empty()).then_some(out)
|
||||
}
|
||||
@@ -103,6 +103,14 @@ pub(crate) enum Target {
|
||||
/// answers first and the scope the directive is written in second — the
|
||||
/// [`Target::InlineConstraint`] shape, with the same refusal to guess.
|
||||
BindScope { target: String },
|
||||
/// A **hierarchical path** written in the expression half of a `bind`
|
||||
/// directive's connection: `bind aes chk u (.s(u_core.u_prng.seed_en));`.
|
||||
/// The spine is rooted in the target's scope exactly as a bare name is, so
|
||||
/// `head` is looked up there (and not in the scope the directive is
|
||||
/// written in, which is a bind module declaring nothing at all) and each
|
||||
/// of `mids` walks one link further — the [`Target::MemberOf`] walk, with
|
||||
/// its start moved from the writing scope to the target's.
|
||||
BindMember { target: String, head: String, mids: Vec<String> },
|
||||
/// The `x` of `this.x`: the enclosing class's scope only.
|
||||
ThisMember,
|
||||
/// The `x` of `super.x`: always the base class's business.
|
||||
@@ -312,6 +320,12 @@ impl<'a> Binder<'a> {
|
||||
// else. A name written with a head of its own already carries the
|
||||
// right target and is left alone.
|
||||
(None, Some(scope), Target::Lexical) => Target::BindScope { target: scope.clone() },
|
||||
// And the same rule for a hierarchical path in one: its head is a
|
||||
// name in the target's scope, so the whole spine is rooted there
|
||||
// rather than in the scope the directive is written in.
|
||||
(None, Some(scope), Target::MemberOf { head, mids }) => {
|
||||
Target::BindMember { target: scope.clone(), head: head.clone(), mids: mids.clone() }
|
||||
}
|
||||
_ => target,
|
||||
};
|
||||
self.pending.push(Pending { name: name.to_string(), name_span, scope, target });
|
||||
|
||||
@@ -145,7 +145,18 @@ use crate::workspace::{
|
||||
/// u_x.sig;`) as though the tail resolved to nothing — for exactly the files
|
||||
/// it had cached, which is the half-right answer every one of these bumps
|
||||
/// exists to prevent. See `docs/features/hierarchical-tail/README.md`.
|
||||
pub const FACTS_FORMAT: u32 = 19;
|
||||
/// 19 → 20 (2026-09-11, rename-bind-occurrences): no new field, but a
|
||||
/// **different answer in the same fields** — a `bind`'s connection expression
|
||||
/// is now recorded against the *hierarchical* surface of the target scope and
|
||||
/// under the `target::name` path spelling, where it used to carry the
|
||||
/// connection surface and a path with no name on it. So a module's internal
|
||||
/// net named in `bind aes chk u (.req(entropy_masking_req))` is a reference
|
||||
/// where it resolved to nothing before. A store written by a 0.53.0 build
|
||||
/// would answer definition, find-references and the rename of such a name as
|
||||
/// though the `bind` file did not mention it — for exactly the files it had
|
||||
/// cached, which is the half-right answer every one of these bumps exists to
|
||||
/// prevent. See `docs/features/rename-bind-occurrences/README.md`.
|
||||
pub const FACTS_FORMAT: u32 = 20;
|
||||
|
||||
impl FileFacts {
|
||||
/// These facts as one line's worth of fields, tab-separated.
|
||||
|
||||
@@ -75,6 +75,9 @@ pub(crate) fn resolve(scopes: &[Scope], symbols: &[Symbol], p: &Pending) -> Opti
|
||||
}
|
||||
return found;
|
||||
}
|
||||
Target::BindMember { target, head, mids } => {
|
||||
return bind_member(scopes, symbols, target, head, mids, &p.name)
|
||||
}
|
||||
Target::ThisMember => this_member(scopes, symbols, p.scope, &p.name),
|
||||
Target::SuperMember => super_member(scopes, p.scope),
|
||||
})
|
||||
@@ -87,9 +90,18 @@ pub(crate) fn resolve(scopes: &[Scope], symbols: &[Symbol], p: &Pending) -> Opti
|
||||
/// `None`, never `NotFound`: a module opens a scope per generate block, so a
|
||||
/// connection may legitimately name something the module's *own* scope does
|
||||
/// not hold, and "absent from this scope" is not "absent". The target
|
||||
/// declared somewhere else is the very question [`Target::Port`] asks of the
|
||||
/// workspace — "is `name` a member of this module?" — in the same
|
||||
/// one-segment path spelling `follow_one` reads.
|
||||
/// declared somewhere else is the same question a hierarchical tail asks of
|
||||
/// the workspace — "is `name` a member of this module?" — in the
|
||||
/// `unit::name` path spelling `follow_one` reads.
|
||||
///
|
||||
/// The surface is the **hierarchical** one (IEEE 1800 §23.6): a bind's
|
||||
/// connection may name any of the target's declarations, its internal nets
|
||||
/// and variables included, which is exactly what `bind aes chk u
|
||||
/// (.req(entropy_masking_req))` does and what the connection surface — ports
|
||||
/// and parameters only — cannot answer. Asking the narrow surface is what
|
||||
/// made such a connection resolve to nothing, and a `name`-less path is what
|
||||
/// kept the miss silent: the warning scan names the unit a candidate was
|
||||
/// searched in by splitting the path at its `::`.
|
||||
fn in_bind_target(
|
||||
scopes: &[Scope],
|
||||
symbols: &[Symbol],
|
||||
@@ -99,12 +111,45 @@ fn in_bind_target(
|
||||
match owning_scope(scopes, symbols, target, is_instantiable) {
|
||||
Some(scope) => scopes.get(scope.0 as usize)?.lookup_local(name).map(Resolution::Resolved),
|
||||
None => Some(Resolution::ExternalCandidate {
|
||||
paths: vec![target.to_string()],
|
||||
surface: Surface::Connection,
|
||||
paths: vec![format!("{target}::{name}")],
|
||||
surface: Surface::Hierarchical,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
/// A hierarchical path written in a `bind`'s connection, rooted where the
|
||||
/// directive elaborates rather than where it is written.
|
||||
///
|
||||
/// `bind aes chk u (.s(u_aes_core.u_aes_prng_clearing.seed_en))` is
|
||||
/// [`member_of`]'s walk with one substitution: the head starts in `aes`'s
|
||||
/// scope instead of the writing scope's lexical chain. So `head` is simply
|
||||
/// one more link of the spine, and the target is where the spine begins — its
|
||||
/// own scope when this file declares the target, and otherwise the unit the
|
||||
/// workspace answers hierarchical members of.
|
||||
///
|
||||
/// `None` — no reference at all — wherever [`member_of`] would record none:
|
||||
/// a link this file declares as something with no members to search, or a
|
||||
/// name genuinely absent from a scope this file holds whole.
|
||||
fn bind_member(
|
||||
scopes: &[Scope],
|
||||
symbols: &[Symbol],
|
||||
target: &str,
|
||||
head: &str,
|
||||
mids: &[String],
|
||||
name: &str,
|
||||
) -> Option<Resolution> {
|
||||
let mut here = match owning_scope(scopes, symbols, target, is_instantiable) {
|
||||
Some(scope) => MemberSite::Scope(scope),
|
||||
None => MemberSite::Unit { path: target.to_string(), surface: Surface::Hierarchical },
|
||||
};
|
||||
for link in std::iter::once(head).chain(mids.iter().map(String::as_str)) {
|
||||
here = descend(scopes, symbols, here, link)?;
|
||||
}
|
||||
// Never the `InheritedCandidate` shape: that is a class's business, and
|
||||
// the head of this spine is a place in the design hierarchy.
|
||||
member_at(scopes, symbols, here, name, false)
|
||||
}
|
||||
|
||||
/// A name looked up **only** in the scope it is written in, never outward: a
|
||||
/// modport's port list and a clocking block's signal list, both of which name
|
||||
/// members of the interface (or module) they are written in and nothing else.
|
||||
@@ -177,16 +222,34 @@ fn member_of(
|
||||
mids: &[String],
|
||||
name: &str,
|
||||
) -> Option<Resolution> {
|
||||
match member_site(scopes, symbols, from, head, mids)? {
|
||||
let site = member_site(scopes, symbols, from, head, mids)?;
|
||||
member_at(scopes, symbols, site, name, mids.is_empty())
|
||||
}
|
||||
|
||||
/// The **tail** of a spine: `name` looked up in the site the links before it
|
||||
/// landed on.
|
||||
///
|
||||
/// `direct` says whether this is a plain `head.member` — the one shape that
|
||||
/// may report an inherited candidate, because for a longer chain the base is
|
||||
/// the owner of an earlier link, not of this name, and claiming it here would
|
||||
/// send the overlay's inheritance chase after the wrong class.
|
||||
///
|
||||
/// Shared with [`bind_member`], which walks the same links from a different
|
||||
/// start: two spellings of this lookup would eventually answer one name two
|
||||
/// ways.
|
||||
fn member_at(
|
||||
scopes: &[Scope],
|
||||
symbols: &[Symbol],
|
||||
site: MemberSite,
|
||||
name: &str,
|
||||
direct: bool,
|
||||
) -> Option<Resolution> {
|
||||
match site {
|
||||
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, name) {
|
||||
Ok(id) => Some(Resolution::Resolved(id)),
|
||||
// The chain leaves this file: the base, plus the path the
|
||||
// workspace's member table answers it by. Only a **direct**
|
||||
// `head.member` reports the base — for a longer chain the base is
|
||||
// the owner of an earlier link, not of this name, and claiming it
|
||||
// here would send the overlay's inheritance chase after the wrong
|
||||
// class.
|
||||
Err(Some(base)) if mids.is_empty() => Some(Resolution::InheritedCandidate {
|
||||
// workspace's member table answers it by.
|
||||
Err(Some(base)) if direct => Some(Resolution::InheritedCandidate {
|
||||
paths: vec![format!("{}::{name}", last_segment(&base))],
|
||||
base,
|
||||
}),
|
||||
@@ -234,27 +297,41 @@ pub(crate) fn member_site(
|
||||
) -> Option<MemberSite> {
|
||||
let mut here = head_site(scopes, symbols, from, head)?;
|
||||
for mid in mids {
|
||||
here = match here {
|
||||
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, mid) {
|
||||
Ok(id) => link_type(scopes, symbols, id)?,
|
||||
// The chain leaves this file at a base class: everything from
|
||||
// here on is one composed path for the workspace to walk.
|
||||
Err(Some(base)) => MemberSite::Unit {
|
||||
path: format!("{}::{mid}", last_segment(&base)),
|
||||
surface: Surface::Connection,
|
||||
},
|
||||
Err(None) => return None,
|
||||
},
|
||||
// Already outside this file — each further name is one more
|
||||
// segment of the path `follow_one` walks member by member.
|
||||
MemberSite::Unit { path, surface } => {
|
||||
MemberSite::Unit { path: format!("{path}::{mid}"), surface }
|
||||
}
|
||||
};
|
||||
here = descend(scopes, symbols, here, mid)?;
|
||||
}
|
||||
Some(here)
|
||||
}
|
||||
|
||||
/// One more link of a spine: where `here`'s member `link` puts the cursor.
|
||||
///
|
||||
/// Shared with [`bind_member`] for the same reason [`member_at`] is — a
|
||||
/// second spelling of the hop would eventually walk somewhere the first does
|
||||
/// not.
|
||||
fn descend(
|
||||
scopes: &[Scope],
|
||||
symbols: &[Symbol],
|
||||
here: MemberSite,
|
||||
link: &str,
|
||||
) -> Option<MemberSite> {
|
||||
match here {
|
||||
MemberSite::Scope(scope) => match member_in_chain(scopes, symbols, scope, link) {
|
||||
Ok(id) => link_type(scopes, symbols, id),
|
||||
// The chain leaves this file at a base class: everything from
|
||||
// here on is one composed path for the workspace to walk.
|
||||
Err(Some(base)) => Some(MemberSite::Unit {
|
||||
path: format!("{}::{link}", last_segment(&base)),
|
||||
surface: Surface::Connection,
|
||||
}),
|
||||
Err(None) => None,
|
||||
},
|
||||
// Already outside this file — each further name is one more segment
|
||||
// of the path `follow_one` walks member by member.
|
||||
MemberSite::Unit { path, surface } => {
|
||||
Some(MemberSite::Unit { path: format!("{path}::{link}"), surface })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the *first* segment of a spine puts the cursor.
|
||||
fn head_site(
|
||||
scopes: &[Scope],
|
||||
|
||||
@@ -347,13 +347,22 @@ fn facts_from_analysis(
|
||||
}
|
||||
// The **connection** surface only. A `Local` posting exists so that a
|
||||
// declaration another file can point at carries its own file's uses
|
||||
// without that file being re-read, and every consumer of the postings
|
||||
// that matters here — the rename, which re-analyses the declaring file
|
||||
// anyway — already has them. Posting a module's every internal net use
|
||||
// would multiply the reference table by the size of an RTL body for an
|
||||
// answer nothing reads; the hierarchical surface is what a *cross-file*
|
||||
// tail resolves through, and that half is an `External` fact below.
|
||||
// See `docs/features/hierarchical-tail/README.md`, "what did not widen".
|
||||
// without that file being re-read. Posting a module's every internal net
|
||||
// use would multiply the reference table by the size of an RTL body; the
|
||||
// hierarchical surface is what a *cross-file* tail resolves through, and
|
||||
// that half is an `External` fact below.
|
||||
//
|
||||
// Two consumers read the postings for a hierarchical-only declaration,
|
||||
// and each supplies the missing local half by re-analysing that one file:
|
||||
// a rename (`vlog_refactor`), which re-analyses the declaring file
|
||||
// anyway, and — since §64.1 — `lucisv_server`'s
|
||||
// `nav::declaring_file_uses`, which parses exactly the declaring file
|
||||
// when it is closed and a `references` request arrived from a cross-file
|
||||
// use. So the narrow table costs one file's parse on one request shape,
|
||||
// paid by the caller that needs it, instead of a reference table sized by
|
||||
// every RTL body in the workspace. See
|
||||
// `docs/features/hierarchical-tail/README.md`, "what did not widen", and
|
||||
// `docs/features/references-hierarchical-surface/README.md`.
|
||||
// Which kind lands on which surface is `hierarchy::surface_of`, the one
|
||||
// rule this filter and the member tables both read (§49's QA asked for
|
||||
// the pointer).
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
# Implementation Plan: 0.52.0 Performance Review Follow-Up
|
||||
|
||||
## Executive Summary
|
||||
|
||||
An independent review of release `0.52.0` (commit [`3ceba21`](performance_052_review.md)) confirmed major performance improvements over `0.51.0` (e.g., unchanged menu filtering reduced from 24.3 ms to 0.32 ms, queued definition unblocked from 24.4 ms to 0.29 ms, no-symbol preflight reduced from 2.2 s to 0.22 ms, tail rename cut by 17.1%, and server-reported loaded scan time cut by ~58%).
|
||||
|
||||
However, the review uncovered one correctness defect (**F1**) and two benchmark measurement defects (**F2**, **F3**), alongside five architectural guidance points and three unmeasured candidate performance areas (**N1**, **N2**, **N3**):
|
||||
1. **F1 (P2 Correctness):** Split startup discovery duplicates modules behind directory aliases (symlinks), breaking startup/rescan equivalence and blocking valid renames until a full rescan.
|
||||
2. **F2 (P2 Harness):** Standalone `scanload` on a fresh storage directory includes an unprimed cold trial under a warm label (0 hits / 3,974 misses).
|
||||
3. **F3 (P2 Harness):** `scanload` completion and mid-scan classifications conflate client request window chatter with true scan completion.
|
||||
4. **Architectural & Performance Next Actions (Items 3–5 & N1–N3):**
|
||||
- **Item 3 / N1:** Retain the lint snapshot; target the remaining 114 ms first-after-edit cost via dirty-buffer lexer/parser/analysis work reduction.
|
||||
- **Item 4 / N2:** Retain engine-owned preflight and content-tied `KnownFacts` reuse; target the 163 ms scope construction (31 ms store decode) and the 1,251-file / 2.88 s common-port rename (`clk_i`).
|
||||
- **Item 5 / N3:** Retain startup ordering and publication cadence (subject to F1); target publication merge cost (`WorkspaceIndex::absorb`) before considering tighter publication intervals.
|
||||
|
||||
This plan details the technical design, contracts, verification matrix, and sequencing to address these findings without regressing existing performance or breaking repository invariants.
|
||||
|
||||
---
|
||||
|
||||
## User Review Required
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **Zero Source Code Changes in This Planning Phase:** As requested, no source code, test, or harness files have been modified. Execution requires explicit approval of this implementation plan.
|
||||
|
||||
> [!WARNING]
|
||||
> **F1 Fix Strategy (Directory Identity & Path-Selection Contract):** Split startup discovery was introduced to provide immediate responsiveness (78 ms cold / 114 ms warm first answer) by leading with open buffer folders. When a directory has symlink aliases sorting before its real path (e.g. `a_alias -> z_real`), split discovery cannot unilaterally pick `z_real` without diverging from the canonical root walk which selects `a_alias`. The approved strategy is:
|
||||
> 1. Share directory identity (`DirId`) between the neighbourhood walk and root walk.
|
||||
> 2. If an alias sorting before the target is detected (or equivalent path selection cannot be proven ahead of the root walk), execute a bounded fallback to the full single root walk (which runs in <1 ms on test fixtures and ~158 ms on OpenTitan), ensuring 100% path and declaration equivalence across startup, rescan, and restart.
|
||||
|
||||
---
|
||||
|
||||
## Technical Analysis of Findings & Next Actions
|
||||
|
||||
### 1. F1: Split Startup Discovery Duplicates Modules Behind Directory Aliases
|
||||
- **Location:** `crates/lucisv_server/src/state/discover.rs:429-560` (`first_scope`, `neighbourhood_files`, `walked_rest`, `rest_of_scope`), and `crates/lucisv_core/src/walk.rs:121-164` (`collect_files_below`).
|
||||
- **Mechanism:**
|
||||
1. Regular single root walk maintains `Walk.visited: HashSet<DirId>` (`DirId` is `(u64, u64)` dev/ino on Unix, canonical `PathBuf` elsewhere). It enters each directory identity once and yields files under the first path spelling encountered.
|
||||
2. In `first_scope`, `neighbourhood_files` calls `collect_files_below`, which instantiates its own `Walk` with a fresh `visited` set. If `z_real/tb.sv` is open, it walks `z_real`, finding `z_real/child.sv`.
|
||||
3. `first_scope` records `seen: HashSet<PathBuf>` containing `z_real/child.sv`.
|
||||
4. Later, `rest_of_scope` runs `collect_files_with` from workspace root with another fresh `visited` set. The root walk visits `a_alias` first (alphabetically before `z_real`). It discovers `a_alias/child.sv`.
|
||||
5. Filtering in `rest_of_scope` only checks `seen.contains(&found.path)`. Because `a_alias/child.sv != z_real/child.sv`, `a_alias/child.sv` is kept!
|
||||
6. The index now contains both `z_real/child.sv` and `a_alias/child.sv`. Definition returns two targets; `prepareRename` refuses because `child` is declared in multiple indexed files.
|
||||
7. On whole rescan, a single root walk runs (`first_scope` is bypassed for `trace.number > 1`), discovering only `a_alias/child.sv`. Thus startup and rescan disagree.
|
||||
8. Furthermore, `HEAD_WALK_MAX` fallback unconditionally calls `files.extend(head)`, which unions the disjoint walks and reproduces the duplicate bug even when falling back.
|
||||
|
||||
### 2. F2: Standalone Warm Scanload Unprimed First Trial
|
||||
- **Location:** `tools/perf/phases_r4.py:237-260` (`load_cell`), and `tools/perf/lspclient.py:105-110` (`Session.__enter__`).
|
||||
- **Mechanism:**
|
||||
1. When running `scanload` standalone with `--storage <dir>`, `load_cell` sets `cold=(cache == "cold")`.
|
||||
2. For `cache == "warm"`, `cold=False`. `Session.__enter__` calls `os.makedirs(self.storage, exist_ok=True)`.
|
||||
3. If `<dir>` is newly created, it contains no index cache.
|
||||
4. Trial 1 runs cold (0 hits / 3,974 misses, 1,684 ms parse time) and populates the cache.
|
||||
5. Trial 2 runs warm (3,974 hits / 0 misses, 0 ms parse time).
|
||||
6. The harness groups Trial 1 and Trial 2 under the single warm label.
|
||||
|
||||
### 3. F3: Conflation of Scan Completion with Client Request Window
|
||||
- **Location:** `tools/perf/phases_r4.py:128-139` (`settled_at`), consumed by `summary` (lines 178–205).
|
||||
- **Mechanism:**
|
||||
1. `settled_at` calls `s.wait_quiet(QUIET)` after the fixed request window (3,500 ms).
|
||||
2. In `tools/perf/lspclient.py:334-355`, `wait_quiet` checks `len(self.notifications)`.
|
||||
3. A `--verbose` server emits `window/logMessage` lines for requests and timings. Furthermore, `wait_quiet` measures `last - started`, which due to clock reads is always `> 0.0`.
|
||||
4. Consequently, `last = entered + more / 1000.0 if more > 0.0 else quiet_at` always selects `entered + more`, anchoring the settle timestamp at ~3,406 ms regardless of whether the scan ended at 1,770 ms.
|
||||
5. In `summary`, responses are filtered with `a["at"] <= run["settle"]`. All 105 responses fall inside 3,400 ms, classifying 100% of responses as "mid-scan" and 0 as "after-settle".
|
||||
|
||||
### 4. Implementation Assessment Items 3, 4, 5 and Candidate Experiments N1, N2, N3
|
||||
- **Item 3 & N1 (First Action After Edit):**
|
||||
- Lint snapshot in `crates/lucisv_server/src/lint_snapshot.rs` caches clean results (0.23 ms repeat).
|
||||
- First-after-edit costs 113.6 ms because `crates/lucisv_server/src/state/mod.rs:715` invokes `Document::new`, which unconditionally runs `tokenize`, `parse_tolerant`, `collect_defines`, `analyze`, `resolve_external`, and `LineIndex::new` over the full 42,000-line buffer.
|
||||
- Work reduction must target tokenization/parsing/analysis allocations on edited buffers without breaking AST fidelity.
|
||||
- **Item 4 & N2 (Scope Construction, Facts Decode & Common-Port Rename):**
|
||||
- Tail rename scope stage: 163 ms total, with 31 ms in `known.facts_for` (store deserialization) and ~100 ms parsing the 134 kept files.
|
||||
- Common port rename (`clk_i`): 1,251 files mention `clk_i`, requiring 1,251 full parses and semantic analyses (2.88 s wall time, 1.8 GiB peak RSS).
|
||||
- Optimization target: Streamlined deserialization of `KnownFacts` and lighter-weight analysis retention for files whose AST is only needed for identifier occurrence verification.
|
||||
- **Item 5 & N3 (Quiet Scan & Publication Cost):**
|
||||
- A startup scan under load publishes staged records via `crates/lucisv_server/src/state/mod.rs:1183` (`publish_scan`).
|
||||
- Each publication calls `WorkspaceIndex::absorb`, which calls `self.merge(None)`—a full whole-index merge of all symbols and definitions across the entire workspace.
|
||||
- While `PUBLISH_EVERY = 512` reduced publication frequency, each publication still incurs the ~70 ms whole-index merge. Reducing publication cost requires targeted incremental symbol merging in `vlog_semantic`.
|
||||
|
||||
---
|
||||
|
||||
## Detailed Implementation Plan
|
||||
|
||||
### Phase 1: Correctness Fixes & Harness Repairs (F1, F2, F3)
|
||||
|
||||
```
|
||||
[Phase 1 Sequencing]
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Step 1.1: Fix F1 (lucisv_core::walk & server discover state)│
|
||||
└──────────────────────────────┬──────────────────────────────┘
|
||||
│
|
||||
┌──────────────────────────────▼──────────────────────────────┐
|
||||
│ Step 1.2: Fix F2 (Harness warm priming & cache hit counters)│
|
||||
└──────────────────────────────┬──────────────────────────────┘
|
||||
│
|
||||
┌──────────────────────────────▼──────────────────────────────┐
|
||||
│ Step 1.3: Fix F3 (True scan-completion & response partition)│
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
#### Step 1.1: Fix F1 — Directory Identity and Path Selection Across Split Discovery
|
||||
|
||||
##### 1. Handshake & Architecture Amendments (`docs/topo.md`)
|
||||
- **Amend `lucisv_core::walk` API:**
|
||||
Add a directory identity tracking type and update `collect_files_below` / `collect_files_with`:
|
||||
```rust
|
||||
// In crates/lucisv_core/src/walk.rs
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct WalkIdentity {
|
||||
pub dir_id: DirId,
|
||||
pub canonical_path: PathBuf,
|
||||
}
|
||||
|
||||
/// Shared directory identity tracker across walks.
|
||||
#[derive(Default, Debug)]
|
||||
pub struct DirectoryTracker {
|
||||
visited: HashMap<DirId, PathBuf>,
|
||||
}
|
||||
|
||||
impl DirectoryTracker {
|
||||
pub fn new() -> Self;
|
||||
pub fn is_visited(&self, dir: &Path) -> bool;
|
||||
pub fn record_or_check(&mut self, dir: &Path) -> Option<&PathBuf>;
|
||||
}
|
||||
|
||||
pub fn collect_files_below_tracked(
|
||||
root: &Path,
|
||||
input: &Path,
|
||||
exclude: &[String],
|
||||
gitignore: bool,
|
||||
tracker: &mut DirectoryTracker,
|
||||
found: &mut dyn FnMut(PathBuf, Option<u64>),
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String>;
|
||||
|
||||
pub fn collect_files_with_tracker(
|
||||
input: &str,
|
||||
exclude: &[String],
|
||||
gitignore: bool,
|
||||
tracker: &mut DirectoryTracker,
|
||||
found: &mut dyn FnMut(PathBuf, Option<u64>),
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String>;
|
||||
```
|
||||
|
||||
##### 2. Server Discovery Repair (`crates/lucisv_server/src/state/discover.rs`)
|
||||
- **Modify `neighbourhood_files` and `PendingDiscovery`:**
|
||||
- `neighbourhood_files` passes a `&mut DirectoryTracker` into `collect_files_below_tracked`.
|
||||
- Store the populated `DirectoryTracker` in `PendingDiscovery`.
|
||||
- **Pre-check Path Selection Equivalence:**
|
||||
- When inspecting the workspace roots, check if any directory entry in the root is a symlink pointing to an ancestor/sibling of the neighbourhood directory that sorts before the neighbourhood path.
|
||||
- If an alias sorting *before* the target exists (such as `a_alias -> z_real`), split discovery cannot unilaterally index `z_real` without violating the root walk's canonical path choice.
|
||||
- In this case, **trigger the bounded fallback**: discard the partial neighbourhood and execute a single root walk (`self.collect_sources(...)`), returning `(sources, None)`.
|
||||
- **Repair `HEAD_WALK_MAX` Fallback:**
|
||||
- In `first_scope` (lines 450–459), when `head.len() > HEAD_WALK_MAX`:
|
||||
**Do NOT union `head` and `walked_rest`!**
|
||||
Instead, discard `head` and execute `self.collect_sources(watch, HeldAnalyses::Wanted, trace)`, returning `(sources, None)`.
|
||||
- **Modify `rest_of_scope`:**
|
||||
- Use the `DirectoryTracker` from `PendingDiscovery` during the root walk so any directory identity already visited in the neighbourhood walk is recognized and not re-entered under an alternate alias.
|
||||
- Filter `walked` files using both `seen_paths` and `seen_dir_identities`.
|
||||
|
||||
##### 3. Regression Test Fixture (`crates/lucisv_server/src/server/tests/startup.rs`)
|
||||
- Add automated integration tests replicating the review's reproduction:
|
||||
- **Fixture A (Alias sorting before target):** `workspace/a_alias -> z_real`, `workspace/z_real/{child.sv, tb.sv}`.
|
||||
- **Fixture B (Alias sorting after target):** `workspace/z_alias -> a_real`, `workspace/a_real/{child.sv, tb.sv}`.
|
||||
- **Fixture C (Multiple aliases):** `a_alias -> target`, `m_alias -> target`, `target/{child.sv}`.
|
||||
- **Fixture D (Ancestor cycle):** `workspace/sub/up -> ..`.
|
||||
- **Fixture E (Ignore rules):** `.gitignore` excluding files inside aliased directories.
|
||||
- **Fixture F (Open unsaved buffer):** Unsaved buffer open at `z_real/tb.sv` with modified text.
|
||||
- **Fixture G (True duplicates):** Genuine duplicate module declaration in two distinct physical files. Verify ambiguity refusal is preserved!
|
||||
- **Assertions:**
|
||||
1. Index file paths after startup `==` index file paths after a whole rescan `==` index file paths after restart.
|
||||
2. Definition on `child` returns exactly 1 location.
|
||||
3. `textDocument/prepareRename` on `child` is accepted.
|
||||
4. True duplicate module refusal is still refused with identical diagnostic message.
|
||||
|
||||
---
|
||||
|
||||
#### Step 1.2: Fix F2 — Standalone Warm Harness Priming & Cache Counters
|
||||
|
||||
##### 1. Untimed Priming in Harness (`tools/perf/phases_r4.py`)
|
||||
- In `load_cell(cache, buffers, rate, params, where="")`:
|
||||
```python
|
||||
def prime_storage(storage_name, extra):
|
||||
"""Perform an untimed session to prime the index cache before warm trials."""
|
||||
with session("workspace", cold=False, verbose=True, storage_name=storage_name) as s:
|
||||
s.initialize()
|
||||
open_buffers(s, extra)
|
||||
s.wait_quiet(1.5)
|
||||
s.take_notifications()
|
||||
|
||||
# Inside load_cell:
|
||||
if cache == "warm":
|
||||
# If cache store does not exist or has no valid store file:
|
||||
store_path = os.path.join(ARGS.storage, "r4-load")
|
||||
if not os.path.exists(store_path) or not os.listdir(store_path):
|
||||
prime_storage("r4-load", extra)
|
||||
```
|
||||
|
||||
##### 2. Cache Counters Recording & Assertion
|
||||
- Inspect `counts = scans[0].get("counts", {})` parsed from `traces(s)`:
|
||||
- Extract `hits = counts.get("hits", 0)` and `misses = counts.get("misses", 0)`.
|
||||
- In `summary(runs)`: Include `cache_hits: [run["hits"] for run in runs]` and `cache_misses: [run["misses"] for run in runs]`.
|
||||
- In `cell_status(got)`: If `cache == "warm"`, assert `all(h > 0 for h in got["cache_hits"])`. If any warm trial records 0 hits or unexpected misses, set `status = "error"` with diagnostic message.
|
||||
|
||||
##### 3. Verification Test
|
||||
- Execute `tools/perf/bench.py scanload` with a brand-new, non-existent `--storage` directory.
|
||||
- Verify:
|
||||
- Untimed prime runs cleanly.
|
||||
- Trial 1 and Trial 2 both report ~3,974 hits and 0 misses.
|
||||
|
||||
---
|
||||
|
||||
#### Step 1.3: Fix F3 — Decoupling Scan Completion from Client Request Window
|
||||
|
||||
##### 1. Scan-Specific Completion Timestamp (`tools/perf/phases_r4.py`)
|
||||
- **Capture True Scan Completion:**
|
||||
- The server outputs `timing: scan <n> stages (...) total=<ms>` upon scan completion, and sends `$/progress` token with `kind: "end"`.
|
||||
- In `tools/perf/lspclient.py`, record `_scan_completed_at`: the `perf_counter` timestamp when the reader thread parses the scan's final progress notification or `timing: scan` line.
|
||||
- In `phases_r4.py`:
|
||||
Replace the flawed `settled_at` logic with:
|
||||
```python
|
||||
def scan_completed_ms(s, origin):
|
||||
"""Milliseconds from `origin` to the scan's actual completion."""
|
||||
if s.scan_completed_at is not None:
|
||||
return (s.scan_completed_at - origin) * 1000.0
|
||||
# Fallback to server-reported scan total if notification timestamp unavailable:
|
||||
sc = traces(s)
|
||||
if sc and "stages" in sc[0]:
|
||||
return sc[0]["stages"].get("total", 0.0)
|
||||
return None
|
||||
```
|
||||
|
||||
##### 2. Response Partitioning in `summary`
|
||||
- Use `scan_completed_ms` to partition responses:
|
||||
```python
|
||||
inside = [a["ms"] for run in runs for a in run["answers"]
|
||||
if a["at"] <= run["scan_completed_ms"]]
|
||||
after = [a["ms"] for run in runs for a in run["answers"]
|
||||
if a["at"] > run["scan_completed_ms"]]
|
||||
```
|
||||
- Expose both in row output:
|
||||
- `mid_scan_answers = len(inside)`
|
||||
- `after_settle_answers = len(after)`
|
||||
- `mid_scan_median_ms` and `after_settle_median_ms`
|
||||
- Retain raw `a["at"]` (arrival offsets) in `results.jsonl`.
|
||||
|
||||
##### 3. Verification Test
|
||||
- Run a warm session where server scan duration is ~1,770 ms inside a 3,500 ms window.
|
||||
- Verify:
|
||||
- `settled_ms` reflects ~1,770 ms (NOT 3,406 ms).
|
||||
- Out of 35 requests, requests arriving before 1,770 ms (~17 requests) are categorized as `mid_scan_answers`, and requests arriving after 1,770 ms (~18 requests) are categorized as `after_settle_answers`.
|
||||
- Extend window to 5,000 ms: verify scan completion remains unchanged (~1,770 ms) and `after_settle_answers` increases proportionally.
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Performance Follow-Ups (Addressing Assessment Items 3–5 & N1–N3)
|
||||
|
||||
Once Phase 1 is verified and merged, the three performance investigation lanes will proceed conditionally:
|
||||
|
||||
```
|
||||
[Phase 2 Lanes]
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Lane N1: Lexer/Parser & Dirty-Buffer Analysis Work (Item 3) │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Lane N2: Retained-Analysis Parse Work & Scope Decode (Item 4│
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Lane N3: Quiet Scan Decode/Merge & Publication Cost (Item 5)│
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
#### Step 2.1: Lane N1 — Lexer/Parser & Dirty-Buffer Analysis (Addressing Item 3 & N1)
|
||||
- **Baseline:** First-after-edit on `pinmux_reg_top.sv` is 113.6 ms (repeat median 0.23 ms via lint snapshot).
|
||||
- **Target:** Reduce first-after-edit time by ≥15% (stretch: <95 ms) while maintaining exact AST/diagnostic output.
|
||||
- **Approach:**
|
||||
1. Profile `Document::new`:
|
||||
- Tokenize: Measure time and allocations.
|
||||
- Parse tolerant: Inspect grammar node allocations.
|
||||
- Semantic analysis & external resolution.
|
||||
2. Optimize single-document re-tokenization / parsing:
|
||||
- Profile whether token vector reallocation in `tokenize` can reuse a pooled buffer.
|
||||
- Avoid cloning the token stream when passing from `tokenize` into `parse_tolerant` (e.g. transfer ownership or borrow).
|
||||
3. Verification:
|
||||
- Snapshot tests in `vlog_formatter` and `vlog_parser`.
|
||||
- `offeredit` benchmark phase comparing candidate vs 0.52.0 baseline.
|
||||
|
||||
#### Step 2.2: Lane N2 — Retained-Analysis Parse Work & Scope Decode (Addressing Item 4 & N2)
|
||||
- **Baseline:** Tail rename: 324.6 ms (163 ms scope stage, including 31 ms store decode). Common-port rename (`clk_i`): 2,883.7 ms, 1,251 parses, 1.78 GiB peak RSS.
|
||||
- **Target:** Reduce scope build store decode time (<20 ms) and reduce common-port parse overhead without increasing peak RSS.
|
||||
- **Approach:**
|
||||
1. **KnownFacts Store Deserialization:**
|
||||
- In `crates/lucisv_server/src/index_cache.rs`, benchmark `facts_for`.
|
||||
- Evaluate zero-copy / compact binary decoding for `FileFacts` to cut the 31 ms decode bottleneck.
|
||||
2. **Retained Analyses Work:**
|
||||
- In `crates/vlog_refactor/src/scope.rs`, investigate files in `Class::Kept`:
|
||||
- Instead of building full redundant ASTs for files where only identifier occurrence validation is needed, evaluate whether occurrence checking can run against a lighter token stream while strictly preserving warning and refusal semantics.
|
||||
3. **Verification & Guardrails:**
|
||||
- Verify byte-identical edits and warning sentences across all 8 rename shapes (`renamewarn`).
|
||||
- Monitor peak RSS under `tools/guard.sh -m 8` to guarantee peak memory does not exceed the 1.8 GiB envelope.
|
||||
|
||||
#### Step 2.3: Lane N3 — Quiet Scan & Incremental Publication Merge (Addressing Item 5 & N3)
|
||||
- **Baseline:** Warm quiet scan 1,064.7 ms, cold quiet scan 2,886.6 ms, warm loaded scan 1,771 ms.
|
||||
- **Target:** Reduce warm quiet scan below 1,000 ms and reduce publication merge overhead.
|
||||
- **Approach:**
|
||||
1. **Targeted `WorkspaceIndex::absorb`:**
|
||||
- Currently, `WorkspaceIndex::absorb` calls `self.merge(None)`, rebuilding symbol tables across all 3,976 files.
|
||||
- Implement incremental symbol table merging in `crates/vlog_semantic/src/workspace/update.rs`, only updating symbol tables for files added/modified in the batch.
|
||||
2. **Candidate Construction:**
|
||||
- Benchmark candidate table construction during publication; avoid full re-indexing of unchanged completion words.
|
||||
3. **Verification:**
|
||||
- Fingerprint equivalence: `WorkspaceIndex::fingerprint` must be identical between incremental absorb and full rebuild.
|
||||
- `scanload` and `scan` benchmark phases under corrected F2/F3 harness.
|
||||
|
||||
---
|
||||
|
||||
## File Modification Map
|
||||
|
||||
| Component / Layer | Action | Target File | Description |
|
||||
|---|---|---|---|
|
||||
| `lucisv_core` (Walk) | `[MODIFY]` | `crates/lucisv_core/src/walk.rs` | Add `DirectoryTracker` and expose directory identity (`DirId`) tracking across walks |
|
||||
| `lucisv_server` (State) | `[MODIFY]` | `crates/lucisv_server/src/state/discover.rs` | Use `DirectoryTracker`, fix `first_scope`, repair `HEAD_WALK_MAX` fallback, ensure alias equivalence |
|
||||
| `lucisv_server` (State) | `[MODIFY]` | `crates/lucisv_server/src/state/scan.rs` | Update `PendingDiscovery` to hold `DirectoryTracker` |
|
||||
| `lucisv_server` (Tests) | `[MODIFY]` | `crates/lucisv_server/src/server/tests/startup.rs` | Add F1 symlink regression matrix (alias before/after, cycle, ignores, unsaved buffer) |
|
||||
| Documentation | `[MODIFY]` | `docs/topo.md` | Record amended `lucisv_server ──▶ lucisv_core` walk handshake |
|
||||
| Perf Tools (Harness) | `[MODIFY]` | `tools/perf/phases_r4.py` | Fix F2 (untimed warm priming & cache counters) and F3 (scan completion timestamping & response partition) |
|
||||
| Perf Tools (Client) | `[MODIFY]` | `tools/perf/lspclient.py` | Record reader-thread scan completion instant `_scan_completed_at` |
|
||||
| Performance Tracking | `[MODIFY]` | `docs/perf/take5-tracking.md` | Update experiment logs and status for F1, F2, F3 |
|
||||
|
||||
---
|
||||
|
||||
## Verification & QA Plan
|
||||
|
||||
### Automated Correctness & Quality Gates
|
||||
Every step will be verified using the repository's runaway guard:
|
||||
```bash
|
||||
# Code formatting
|
||||
cargo fmt --all -- --check
|
||||
|
||||
# Strict Clippy validation
|
||||
tools/guard.sh -m 8 -t 1800 -- cargo clippy --workspace --all-targets --locked -- -D warnings
|
||||
|
||||
# Full workspace test suite (must meet or exceed 4,374 passed, 0 failed, 45 ignored)
|
||||
tools/guard.sh -m 8 -t 1800 -- cargo test --workspace --locked
|
||||
```
|
||||
|
||||
### Specialized Correctness Assertions for F1
|
||||
Run the dedicated startup test suite:
|
||||
```bash
|
||||
tools/guard.sh -m 8 -t 1800 -- cargo test -p lucisv_server --test server_tests startup
|
||||
```
|
||||
Assert that:
|
||||
1. `alias_sorting_before_target`: `a_alias -> z_real`. Index paths, definition targets, and `prepareRename` match between startup, whole rescan, and restart.
|
||||
2. `alias_sorting_after_target`: `z_alias -> a_real`. Same equivalence check.
|
||||
3. `multiple_aliases`: Multiple symlinks to single target directory do not produce duplicate entries.
|
||||
4. `ancestor_cycle`: Cyclic symlinks terminate safely without duplicate entries.
|
||||
5. `genuine_duplicate_declarations`: Genuine collisions in distinct files remain ambiguous and correctly refused.
|
||||
|
||||
### Benchmark & Harness Verification for F2 and F3
|
||||
1. **F2 Warm Priming Verification:**
|
||||
```bash
|
||||
tools/guard.sh -m 8 -t 1800 -- python3 tools/perf/bench.py scanload --storage /tmp/test-fresh-store --tries 2
|
||||
```
|
||||
Assert that:
|
||||
- Untimed prime runs automatically.
|
||||
- Both Trial 1 and Trial 2 report ~3,974 cache hits and 0 misses.
|
||||
2. **F3 Scan Completion Verification:**
|
||||
```bash
|
||||
tools/guard.sh -m 8 -t 1800 -- python3 tools/perf/bench.py scanload --tries 3
|
||||
```
|
||||
Assert that:
|
||||
- `settled_ms` reflects server scan duration (~1,770 ms), not 3,400 ms.
|
||||
- Responses are partitioned correctly into `mid_scan_answers` and `after_settle_answers`.
|
||||
- Extending fixed window from 3,500 ms to 5,000 ms keeps `settled_ms` constant while increasing `after_settle_answers`.
|
||||
@@ -531,3 +531,14 @@ that a pathological scheduler could in principle defeat it and right not
|
||||
to weaken it; the property is the point of the test, the risk is
|
||||
unreproduced in twelve runs, and if CI ever trips it the QA log already
|
||||
contains the analysis. This completes §9b. Accepted as shipped.
|
||||
|
||||
### 2026-09-08 — the deferred set (perf5r-publication, lead)
|
||||
|
||||
A navigation request whose answer was empty while the startup scan was
|
||||
still growing is put in `Server::deferred` and asked again at the next
|
||||
publish (`docs/features/perf5r-publication/README.md`). Such a request is
|
||||
in no burst, so the burst's own cancel rule (`cancelled_in`) cannot see
|
||||
it; `Server::cancel_deferred` honours a `$/cancelRequest` naming it where
|
||||
the cancel lands — answered `RequestCancelled` at once, removed, never
|
||||
asked again. Every request still gets exactly one response. Found by QA;
|
||||
pinned by `a_cancel_for_a_deferred_request_answers_it_cancelled_and_forgets_it`.
|
||||
@@ -81,6 +81,11 @@ parser** a push does, so the two paths cannot drift.
|
||||
describes only an answer that arrives after the 2 s bound
|
||||
(`CONFIGURATION_WAIT`), which is then an ordinary settings change with an
|
||||
ordinary rescan behind it.
|
||||
**2026-09-08 (perf5r-first-answer):** and the staging window now also
|
||||
holds `OPENING_FILE_WAIT` (25 ms) for the editor's opening `didOpen`, so a
|
||||
buffer that arrives just after the configuration answer still orders the
|
||||
first scan around its folder; a session whose opening burst already holds
|
||||
a `didOpen` spends none of it.
|
||||
**2026-08-27:** `lucisv.index.maxFileSize` joins those two — a pulled cap
|
||||
that differs from the 1 MiB default costs the same one extra rescan — and
|
||||
`lucisv.index.logFiles` shows the other face of the same fact: the startup
|
||||
|
||||
@@ -128,10 +128,26 @@ The `propagate-ports` engine reads `member`/`members_of` and is untouched.
|
||||
- **Reference postings.** `facts_from_analysis` records a `Local` posting only
|
||||
for a use whose declaration is on the **connection** surface. Posting a
|
||||
module's every internal-net use would multiply the reference table by the
|
||||
size of an RTL body for an answer nothing reads: the only consumer is a
|
||||
rename, which re-analyses the declaring file anyway. The *cross-file* half —
|
||||
the tail in the other file — is an `External` fact, and that is what makes
|
||||
the rename work.
|
||||
size of an RTL body. The *cross-file* half — the tail in the other file —
|
||||
is an `External` fact, and that is what makes the rename work.
|
||||
|
||||
**Amended 2026-09-12 (§64.1).** This bullet used to end "for an answer
|
||||
nothing reads: the only consumer is a rename, which re-analyses the
|
||||
declaring file anyway". There are two consumers now, and the sentence is
|
||||
true again only with the second one named: `textDocument/references` reads
|
||||
the postings too, and since §64.1 it answers for a hierarchical-only
|
||||
declaration. It is served the way the rename is —
|
||||
`lucisv_server`'s `nav::declaring_file_uses` parses **exactly the declaring
|
||||
file, exactly once**, and only when that file has no open buffer and the
|
||||
request came in from a cross-file use; an open buffer's own uses come from
|
||||
the live overlay as they always did. Measured on opentitan: `references`
|
||||
from `u_entropy_src_main_sm.state_q` with `entropy_src_main_sm.sv` closed
|
||||
costs 1.0–1.5 ms against the 0.1–0.2 ms of the incomplete answer it
|
||||
replaces, and every connection-surface row of the `nav` harness is
|
||||
unchanged in both result count and time. So the decision stands, with its
|
||||
cost now written down: one file's parse on one request shape, instead of a
|
||||
reference table sized by every RTL body in the workspace. See
|
||||
`docs/features/references-hierarchical-surface/README.md`.
|
||||
- **`workspace/symbol`.** An internal net is still not a workspace symbol: the
|
||||
request answers what a user can name from outside, and a design with 20 000
|
||||
modules has hundreds of thousands of internal signals.
|
||||
|
||||
@@ -142,6 +142,17 @@ The character cap counts `char`s and cuts on a boundary.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-12 — dev (§64.1: `spells_exactly` is now `pub(crate)`)
|
||||
|
||||
Visibility only, no behaviour change here. `nav.rs` needed the same
|
||||
agreement check for a closed file's *span* that this feature applies to a
|
||||
closed file's *snippet* — after §64.1 an index-time `references` span can be
|
||||
rendered against bytes that moved — and QA's lesson above (a fixed-length
|
||||
span still spelling the old name as a **prefix** of a longer identifier) is
|
||||
exactly the case a second copy of the check would have got wrong. So
|
||||
`hover::spells_exactly` is shared rather than duplicated; see
|
||||
`docs/features/references-hierarchical-surface/README.md`.
|
||||
|
||||
### 2026-08-27 — dev
|
||||
|
||||
- Read the brief, `hover.rs`, `nav.rs`, `state.rs` and `convert.rs`. Confirmed
|
||||
|
||||
@@ -642,6 +642,43 @@ is read either way, so an mtime match could only ever have saved this.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-08 — §61.3: the store open, split into its parts (measured, unchanged)
|
||||
|
||||
**Nothing in this feature changed.** With §61.3 putting the workspace walk
|
||||
*behind* the first useful answer, `IndexCache::open` became the largest thing
|
||||
left in front of it — 89 ms of a 115 ms warm answer — so the review's "measure
|
||||
a bounded local-record loading design before proposing a format change" clause
|
||||
came live. It was measured, against the real 46 486 433-byte OpenTitan store
|
||||
(3 977 records, page-cached), with a throwaway instrumented build:
|
||||
|
||||
| part of `IndexCache::open` | ms |
|
||||
|---|---:|
|
||||
| `read` — the whole 46.5 MB | **6.31** |
|
||||
| line split into 3 977 slices | **14.93** |
|
||||
| extracting every line's path field (no checksum, no allocation) | **2.27** |
|
||||
| **verifying every record's checksum** (FNV-1a over ~45 MB) | **60.99** |
|
||||
|
||||
**73 % of the open is verifying records the answer will never look at.** A
|
||||
bounded local load — paths first, then decode only the neighbourhood's ~124
|
||||
records — costs about **26 ms** and would take the warm first answer to roughly
|
||||
50. It is bounded, and it needs **no format change**.
|
||||
|
||||
It was **not implemented**, and the reason is this README's own accounting. The
|
||||
61 ms is owed either way: the other 3 852 records must be verified before the
|
||||
scan can hit them, so lazy verification moves cost rather than removing it. What
|
||||
it *changes* is [`Load::canonical`](#the-store-format) — `dropped` counts the
|
||||
records the checksum rejects, and a load that has not verified them cannot say
|
||||
whether the file it holds is the file `compact` would write. That single flag
|
||||
is what §P4b's compaction skip rests on, and what makes "the store is
|
||||
byte-identical across warm sessions" true (28 stores, three hashes, both
|
||||
binaries, §61.3). It also changes an answer in the attack matrix below: under
|
||||
lazy verification a **corrupt later line for a path would displace a good
|
||||
earlier one** instead of being dropped at load, so
|
||||
`a_corrupt_record_is_dropped_and_the_rest_of_the_store_is_not` would need
|
||||
re-attacking rather than re-running. That is an experiment with its own QA, not
|
||||
a rider on a latency lane. Filed with these numbers in
|
||||
`docs/features/perf5r-first-answer/README.md`.
|
||||
|
||||
### 2026-08-27 — dev agent (a persistent index cache with crash/reopen resume)
|
||||
|
||||
- **The key is the content and only the content, and that is the round's one
|
||||
|
||||
@@ -606,6 +606,44 @@ and it is where the measured cost was.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-08 — §61.3: the workspace rung is discovered in two goes
|
||||
|
||||
**The scope is unchanged; when it is resolved is not.** A rung-2 session with a
|
||||
buffer already open now walks the folders that buffer raises to **first**,
|
||||
indexes and publishes them, and walks the rest of the workspace afterwards —
|
||||
one scan, one work list, every file stepped once, `gone` computed against the
|
||||
whole of it (`docs/features/perf5r-first-answer/README.md`). The first useful
|
||||
definition went from 301 ms warm / 266 cold to **115 / 78**.
|
||||
|
||||
Three things in this README's territory, and all three are "the same rule,
|
||||
asked earlier":
|
||||
|
||||
- **The rung is unchanged.** The split is taken only when rung 2 is in force,
|
||||
so a filelist and the folder rung resolve exactly as they did. `scopes`, eight
|
||||
requests × three scopes × both binaries: 24 of 24 result counts equal, and
|
||||
the persistent store is byte-identical.
|
||||
- **The head obeys the root's rules.** A walk starting at `hw/ip/aes` reads no
|
||||
`.gitignore` above itself, and this README's own note — "a rule written in a
|
||||
root's `.gitignore` does not apply to a rung-3 walk that starts below it" —
|
||||
is a statement about *rung 3*, where the folder **is** the scope. Under
|
||||
rung 2 the root is the scope, so the folder half of one scan must obey the
|
||||
root's rules or the two halves disagree about which files exist.
|
||||
`lucisv_core::walk::collect_files_below` carries the ancestor ignore stack
|
||||
down and refuses an ancestor the root walk would not have entered;
|
||||
`the_split_head_obeys_a_gitignore_written_at_the_workspace_root` is the wire
|
||||
test.
|
||||
- **The bound is `worth_waiting`'s own, asked without the total.** A scan that
|
||||
has not walked the workspace cannot ask whether its head is a minority of it,
|
||||
so the split is refused unless every raised folder is a **strict** descendant
|
||||
of a workspace root — the case that rule exists for — and again if the walk
|
||||
finds more than 512 files there. Refused, the scan is byte-for-byte the one
|
||||
before this round.
|
||||
|
||||
The size cap now reads the length the walk already stat'd
|
||||
(`lucisv_core::walk::collect_files_with`): 3 979 `metadata` calls per scan
|
||||
became **0**, worth a measured 6.9 ms of a 165 ms discovery. A filelist entry
|
||||
is not walked and still stats once, exactly as before.
|
||||
|
||||
### 2026-09-08 — §P4b3: the read moment, and the order the walk is indexed in
|
||||
|
||||
**Two documented behaviours moved. The scope ladder itself — precedence, the
|
||||
|
||||
@@ -345,6 +345,34 @@ nine sizes, and a real 1100-file workspace end to end.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-08 — §61.3: no report while the denominator can still grow
|
||||
|
||||
**Amends the denominator assumption, and keeps both of its properties.** A
|
||||
workspace-scoped startup with a buffer open now takes its work list in two
|
||||
goes — the user's own folder, then the rest of the workspace
|
||||
(`docs/features/perf5r-first-answer/README.md`) — so for the length of that
|
||||
head, "what this scan will do" is not yet known.
|
||||
|
||||
The rule this README states is *"the percentage only counts up, and every one
|
||||
of them is measured"*, and a growing denominator breaks both: 124/124 followed
|
||||
by 125/3 976 is a bar that falls from 100 % to 3 %. Neither of the review's two
|
||||
suggestions was taken — a second `$/progress` token would put two bars on one
|
||||
scan, and a "known so far" denominator is exactly the invented percentage
|
||||
`begin_indexing` refuses. What ships instead costs nothing: **the bar token is
|
||||
withheld while the work list can still grow**. `IndexWatch::tick` needs the
|
||||
token and returns early without one; `IndexWatch::say` does not, so **every
|
||||
file of the head is still named in the per-file log**. The client sees the
|
||||
`begin` (which has carried no percentage since it was written), then the log,
|
||||
then the first *measured* report — against the finished work list, counting up
|
||||
from there. The last file still always reports.
|
||||
|
||||
`the_bar_paints_no_percentage_until_the_denominator_is_final` asserts all
|
||||
three: the sequence never falls, the first report is not the head's own 50 %,
|
||||
and both the buffer's step and its folder's are in the log.
|
||||
|
||||
The skip count is unaffected: the head's skips and the rest's are summed onto
|
||||
the same scan, and the end message names the total as it always did.
|
||||
|
||||
### 2026-08-27 — dev agent (indexing UX: cap, counting bar, per-file log)
|
||||
|
||||
- **`vlog_semantic`: builder, not callback — and the reason is `FileId`.**
|
||||
|
||||
@@ -0,0 +1,654 @@
|
||||
# perf-first-after-edit
|
||||
|
||||
TODO §63.2 — N1 of the 0.52.0 review (`docs/performance_052_review.md`,
|
||||
item 3 and next action 3).
|
||||
|
||||
## Goal
|
||||
|
||||
The first request after a one-character edit in a 40 267-line generated
|
||||
file cost **113.6 ms** on 0.52.0, against 0.23 ms for the same request
|
||||
repeated on an unchanged buffer. The lint snapshot (review round §R1a)
|
||||
cannot help a fresh revision: what remains is the debounced `Document`
|
||||
rebuild `answer_request` performs before any handler runs, the
|
||||
diagnostics publish that lints the new revision, and the menu's own
|
||||
stages. This round splits that flush into the stages a reader can act on,
|
||||
then makes the **fresh-revision work itself cheaper** — no cache of
|
||||
anything across revisions — with the AST, the diagnostics and the menu
|
||||
byte-identical. Target: ≥ 15 % off the cell, stretch < 95 ms, the
|
||||
unchanged-repeat cell and the other `offeredit`/`offerkinds` rows within
|
||||
noise, peak RSS not up.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- The pinmux cell is the worst realistic shape, not the typical one: a
|
||||
1 237 143-byte generated register file, 193 816 tokens, one buffer
|
||||
open, workspace scope, 3 975 files indexed. Everything here is measured
|
||||
on it; a 400-line hand-written file pays the same work in microseconds.
|
||||
- `Document::new` is a pure function of (text, index): the same text
|
||||
against the same index must give the same tokens, tree, defines,
|
||||
semantics, external resolutions and line index. Every change in this
|
||||
round is checked against that, file by file, over the corpus and
|
||||
opentitan (see Parity).
|
||||
- `vlog_parser::tokenize` is all-or-nothing and its output is a value,
|
||||
not a rendering: two builds agree on token kind, text, line, column,
|
||||
span, `blank_before` and every attached comment, or they differ.
|
||||
- The measurement machine is shared with nothing else while a phase runs
|
||||
(`tools/perf/README.md`'s rules), and every number below is a median.
|
||||
|
||||
## Handshakes
|
||||
|
||||
- **`lucisv_server ──▶ vlog_parser`** — unamended. `tokenize`,
|
||||
`parse_tolerant` and `parse_source_tolerant` keep their signatures;
|
||||
`Document::new` calls them exactly as before. No public `vlog_parser`
|
||||
item changed name, type or behaviour, so nothing this lane did is a
|
||||
contract change for the formatter, linter, refactor or CLI either.
|
||||
**Nothing is owed to the lead here.**
|
||||
- **`verbose-timing ◀──▶ tools/perf`** — *amended, and this needs a
|
||||
`docs/topo.md` line the lead owns.* The `timing: codeaction …` line
|
||||
(`crate::lint_trace`) grows a **third top-level group**, `rebuild{…}`,
|
||||
beside `flush{…}` and `action{…}`: `lex`, `parse`, `defines`,
|
||||
`analyze`, `external`, `lines`, `publish` (ms each) and `documents`
|
||||
(how many `Document`s the flush built). Groups stay siblings — never
|
||||
nested — because `tools/perf/phases_p2.py`'s `GROUP` regex flattens one
|
||||
level only; `phases_r1.py` therefore picks the new fields up with no
|
||||
change, as `trace_rebuild_*` row fields. Pinned by
|
||||
`lint_trace::tests::the_rebuild_group_names_every_stage_beside_the_other_two`.
|
||||
- **`docs/perf/README.md`** — not this lane's file. The entry it wants is
|
||||
in "For `docs/perf/README.md`" below, for the lead to paste.
|
||||
|
||||
### Requested `docs/topo.md` amendments (the lead's file)
|
||||
|
||||
1. The `verbose-timing ◀──▶ …` handshake row (§2.7): add that the
|
||||
`timing: codeaction` line carries a third group, `rebuild{…}`, whose
|
||||
fields are the flush's `Document`-rebuild stages, and that the three
|
||||
groups are siblings by contract (the harness flattens one level).
|
||||
2. The `lucisv_server/src/state.rs` file row: `Document::new`'s six
|
||||
derivations are individually traced through `crate::lint_trace`, so a
|
||||
stage added to or removed from that constructor wants a `Rebuild`
|
||||
variant beside it.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] the flush split in `lint_trace` (`Rebuild`, `Rebuilt`, `rebuild()`,
|
||||
`saw_document()`), the `rebuild{…}` group on the trace line, and
|
||||
the 0.53.0 numbers taken **before** any behaviour changed
|
||||
- [x] change 1 — the lexer's two phases fused (no `Vec<RawTok>`)
|
||||
- [x] change 2 — `Parser::skip`, the non-cloning `bump` for the 217 call
|
||||
sites that threw the token away
|
||||
- [x] change 3 — the operator table's first-byte test
|
||||
- [x] parity: token stream + parse diagnostics + whole AST + symbol table
|
||||
digested per file over 4 807 files (corpus + opentitan), 0 differ;
|
||||
`format --stdout` byte-identical over corpus (860) and over
|
||||
opentitan (3 947); diagnostics and the all-family menu on the
|
||||
pinmux buffer identical before and after
|
||||
- [x] paired `offeredit` / `offerkinds` / `flush` / `diagnostics` /
|
||||
`rss` against a 0.53.0 server built from 1b8723c, order alternated
|
||||
— **−19.2 % on the cell, the ≥ 15 % gate met and the < 95 ms
|
||||
stretch met at 88.3 ms**
|
||||
- [x] QA
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-12 — measure first: the flush split
|
||||
|
||||
`crate::lint_trace` already split a traced request into
|
||||
flush / config / build / lint / fence / serialize. The flush was one
|
||||
number (`flush{wall=…}`), so "the dirty-buffer stage dominates" was as
|
||||
far as the 0.52.0 review could attribute the cell. Added:
|
||||
|
||||
- `Rebuild` (7 stages: `lex`, `parse`, `defines`, `analyze`, `external`,
|
||||
`lines`, `publish`), `Rebuilt` (their milliseconds plus a `documents`
|
||||
count) and `rebuild(stage, work)` / `saw_document()` — the same
|
||||
thread-local, one-`Cell`-read-when-off discipline the module documents,
|
||||
and *not* routed through `IN_FLUSH`: a rebuild belongs to the rebuild
|
||||
whichever half of the request runs it.
|
||||
- `crates/lucisv_server/src/state/mod.rs:119` — `Document::new`'s six
|
||||
derivations each wrapped at the call.
|
||||
- `crates/lucisv_server/src/server/diagnostics.rs:57` — the publish
|
||||
inside `flush_dirty` wrapped as the seventh, so the flush group's
|
||||
`config`/`build`/`lint`/`fence` are readable as *inside* it.
|
||||
- `Trace::line()` prints `rebuild{…}` as a **sibling** of `flush{…}` and
|
||||
`action{…}`; `Trace::is_empty` counts it, so a request that only
|
||||
rebuilt still logs a line.
|
||||
|
||||
`tools/perf` needed no code change: `phases_r1.py` parses the whole line
|
||||
through `phases_p2.parse_trace`, which flattens any top-level `name{…}`
|
||||
group, so the seven stages arrive as `trace_rebuild_*` fields on every
|
||||
`actionprofile` row. `tools/perf/README.md`'s `actionprofile` row now
|
||||
says so.
|
||||
|
||||
**The 0.53.0 numbers** (HEAD 1b8723c plus this instrumentation and
|
||||
nothing else; `actionprofile`, pinmux-comment, "first codeAction after a
|
||||
didChange", three tries; evidence
|
||||
`~/.cache/lucisv-perf/63-2/split-0530.jsonl`):
|
||||
|
||||
| | ms |
|
||||
|---|---:|
|
||||
| wire latency | 122.6 / 123.0 / 101.4 |
|
||||
| **flush wall** | **100.0** |
|
||||
| ├ `rebuild lex` | **29.1** |
|
||||
| ├ `rebuild parse` (the token clone is inside it) | **25.6** |
|
||||
| ├ `rebuild publish` | 22.2 — of which `flush lint` 22.0 |
|
||||
| ├ `rebuild analyze` | 10.1 |
|
||||
| ├ `rebuild external` | 4.8 |
|
||||
| ├ `rebuild lines` / `defines` | 0.6 / 0.5 |
|
||||
| └ unattributed (dropping the previous revision) | ~7 |
|
||||
| handler's own stages (`action{…}`) | 0.23 — `snapshot=hit` |
|
||||
|
||||
(This is the single run taken before anything changed. The same cell was
|
||||
re-taken **paired and order-alternated** against the finished candidate
|
||||
at the end of the round — 110.2 / 110.7 ms, flush wall 102.7 / 107.4 —
|
||||
see "The paired result"; the stage shares agree, the absolute wire time
|
||||
of this first run sat on a busier machine.)
|
||||
|
||||
Two of the review's candidates were answered by the split before
|
||||
anything was built:
|
||||
|
||||
- **A second lint of the same revision: there is none.** `action` reads
|
||||
`snapshot=hit` and `lint=0.00ms` on every try — the publish's pass is
|
||||
the menu's pass, which is what review round §R1a bought.
|
||||
- **A second analysis: there is none either.** `lint::context` already
|
||||
lends `doc.semantics` to the linter (`with_semantics`), so the lint
|
||||
pass does not re-`analyze` the tree.
|
||||
|
||||
So the cell is the rebuild, and the rebuild is **lex + parse** (54.7 ms
|
||||
of the 100).
|
||||
|
||||
### 2026-09-12 — where the rebuild's milliseconds are
|
||||
|
||||
A standalone harness over exactly `Document::new`'s calls
|
||||
(`scratchpad/63-2/micro`, 15 iterations, median; built against the
|
||||
reference tree and against the working tree, same compiler, same file)
|
||||
separates the clone from the parse, which the in-server stage cannot:
|
||||
|
||||
| | 0.53.0 (1b8723c) | after all three changes |
|
||||
|---|---:|---:|
|
||||
| `tokenize` | 27.79 | **11.59** |
|
||||
| `tokens.clone()` | 4.44 | 3.92 |
|
||||
| `parse_tolerant` | 17.47 | **16.33** |
|
||||
| `collect_defines` | 0.45 | 0.42 |
|
||||
| `analyze` | 9.79 | 9.40 |
|
||||
| `LineIndex::new` | 0.56 | 0.59 |
|
||||
| dropping the products | 6.27 | 6.40 |
|
||||
| **total** | **66.8** | **48.6** |
|
||||
|
||||
193 816 tokens, `size_of::<Token>()` 120 bytes.
|
||||
|
||||
### 2026-09-12 — change 1: the lexer's two phases, fused
|
||||
|
||||
`crates/vlog_parser/src/lexer.rs` — `tokenize` lexed the whole file into
|
||||
a `Vec<RawTok>` and then walked it to attach comments. Attachment reads
|
||||
only the raw token in hand and the token last pushed, so the two loops
|
||||
fuse into one without touching the result: `attach` / `attach_trailing`
|
||||
are the same code as the second loop, called per raw token. The
|
||||
intermediate vector for this file was 193 816 × 56 bytes of allocation,
|
||||
growth copying and teardown. `tokens` is also given a capacity guess
|
||||
(`estimated_tokens`, six bytes a token, capped at 2²⁰) — the growth
|
||||
doubling reached 262 144 slots for this file anyway, so the guess costs
|
||||
no memory it was not already taking.
|
||||
|
||||
The `blank_before` `if` whose two arms were the same expression is now
|
||||
one expression, and `tokens.last_mut().unwrap()` is a `let … else`
|
||||
(library paths take no `unwrap`).
|
||||
|
||||
**Measured** (same harness): `tokenize` 27.8 → **24.7 ms**.
|
||||
|
||||
*File size, for the lead:* `lexer.rs` is one of the two files the
|
||||
2026-09-07 measurement left over 600 production lines (763). This round
|
||||
leaves it at **770** — the fusion replaced the second loop with
|
||||
`attach` / `attach_trailing` rather than adding a responsibility, and the
|
||||
+7 is the doc comments on them. Splitting the lexer's two halves into
|
||||
two modules would undo exactly the "one sentence" the fusion restored
|
||||
(*it turns source text into the token stream, comments attached*), so the
|
||||
lines were left where they are; the ruling is the lead's.
|
||||
|
||||
### 2026-09-12 — change 2: `Parser::skip`
|
||||
|
||||
`crates/vlog_parser/src/parser/cursor.rs` — `bump()` clones the token
|
||||
(its `text` is a `String`, so an allocation) and hands it back; **217 of
|
||||
its ~296 call sites threw the value away on the same line**. `skip()` is
|
||||
`bump()` for those callers: same comment plumbing (the leading bucket and
|
||||
the trailing comment are cloned into the pending lists, exactly as
|
||||
`bump()` moved them out of its own copy), same cursor step, same
|
||||
`self.tokens` left untouched — so a speculative parse's rewind finds the
|
||||
stream exactly as it would have. The 217 sites were rewritten
|
||||
mechanically; `eat_sym` / `eat_kw` are two of them.
|
||||
|
||||
**Measured**: `parse_tolerant` 17.5 → **16.0 ms**. (Modest: the 181
|
||||
`expect_sym`/`expect_kw` calls whose token is also discarded still clone.
|
||||
Left alone deliberately — a second pair of entry points for ~1 ms is not
|
||||
worth the API.)
|
||||
|
||||
### 2026-09-12 — change 3: the operator table's first-byte test
|
||||
|
||||
`crates/vlog_parser/src/lexer.rs` — every token that was not a comment,
|
||||
directive, attribute, string, escaped/system identifier, number or
|
||||
identifier fell into `for op in OPERATORS { if self.starts_with(op) … }`:
|
||||
**44 slice comparisons for every `;`, `(`, `)`, `,`, `.`, `[`, `]`** in
|
||||
the file, which in a generated register file is most of the tokens. One
|
||||
byte compare in front of the slice compare rejects every operator that
|
||||
cannot start here. Longest-first order is untouched, `starts_with` still
|
||||
decides, so the token stream cannot move.
|
||||
|
||||
**Measured**: `tokenize` 24.7 → **11.6 ms** — the single largest win of
|
||||
the round, and a third of the whole cell.
|
||||
|
||||
### 2026-09-12 — one flaky test of my own, found and fixed
|
||||
|
||||
`lint_trace::tests::a_trace_holding_only_a_rebuild_is_not_empty` failed
|
||||
once in six runs of `cargo test -p lucisv_server`: it armed a trace, ran
|
||||
an **empty** closure under `rebuild(Rebuild::Analyze, …)` and asserted
|
||||
the trace was not empty — but a closure that does nothing can measure
|
||||
0.00 ms, which leaves the group equal to `Rebuilt::default()`. The
|
||||
assertion was wrong, not the code: what says a rebuild happened is
|
||||
`saw_document()`, which `Document::new` always calls, not a duration.
|
||||
The test now calls it, and the reason is written above the test (this is
|
||||
also why no test here asserts a millisecond — timing lives in the
|
||||
harness). Six further runs of the module and two full workspace runs
|
||||
green. The change is inside `#[cfg(test)]`, so the release binary the
|
||||
paired numbers were taken with is the shipped code unchanged.
|
||||
|
||||
### Not taken, and why
|
||||
|
||||
- **The token-stream clone into `parse_tolerant`** (3.9 ms). The parser
|
||||
*mutates* its token vector — `take_meta`, `take_dangling`, `take_gap`,
|
||||
`take_leading_here`, `take_trailing_here` move comments out of it — so
|
||||
a vector handed over and taken back is a comment-stripped vector, and
|
||||
`Document::tokens` is read for comments by semantic tokens
|
||||
(`tokens.rs:181`) and by the linter (`vlog_linter/src/context.rs:534`).
|
||||
Handing it over would drop comments from highlighting and from the
|
||||
rules that read them. Making the parser stop mutating the stream is a
|
||||
real refactor of the comment plumbing for 3.9 ms; filed, not done.
|
||||
- **`analyze` (9.4 ms) and `resolve_external` (5.5 ms)**: not opened.
|
||||
The file ownership allows `vlog_semantic` "only for a measured stage",
|
||||
and after the three changes above the gate is met with margin; a
|
||||
fourth change would have bought risk, not a verdict.
|
||||
- **Dropping the previous revision's products (6.3 ms)** happens inside
|
||||
`set_document` on the request path. Moving it off the path means a
|
||||
thread or a deferred queue in a single-threaded server; not for this
|
||||
round.
|
||||
|
||||
## The paired result
|
||||
|
||||
Two binaries: the reference is `cargo build --release` of **1b8723c**
|
||||
(0.53.0 plus §63.1) in a `git archive` scratch tree, the candidate is the
|
||||
working tree. Same compiler, same harness, same opentitan at
|
||||
`0098135…` with its three pre-existing modified files. Each phase run
|
||||
**four times — ref, candidate, candidate, ref** — so an order effect or
|
||||
a machine drift shows as a spread between a version's own two rounds.
|
||||
One warm index store per binary. Three tries a row, median of the tries,
|
||||
both rounds quoted. Evidence: `~/.cache/lucisv-perf/63-2/paired.jsonl`
|
||||
(`paired.sh` is the runner), load 4.8 → 4.1 across the run.
|
||||
|
||||
| phase · row | 0.53.0 (a / b) | candidate (a / b) | verdict |
|
||||
|---|---:|---:|---|
|
||||
| **`offeredit` pinmux-comment, first offer after didChange** | **110.95 / 107.54** | **88.31 / 88.36** | **−19.2 %** — gate met, stretch (< 95) met |
|
||||
| `offeredit` pinmux-comment, repeated offer, unchanged buffer | 0.27 / 0.32 | 0.22 / 0.19 | unchanged (noise) |
|
||||
| `offeredit` aes-reg-instance, first offer after didChange | 5.23 / 8.10 | 6.54 / 6.24 | unchanged (inside the version's own spread) |
|
||||
| `offeredit` aes-reg-instance, repeated offer | 3.39 / 4.22 | 3.48 / 3.18 | unchanged |
|
||||
| `offeredit` tb-comment, first offer after didChange | 1.18 / 1.57 | 2.05 / 0.89 | unchanged |
|
||||
| `offeredit` tb-comment, repeated offer | 0.22 / 0.28 | 0.32 / 0.23 | unchanged |
|
||||
| `flush` didChange flush (foldingRange barrier) | 1.33 / 1.51 | 0.85 / 1.38 | unchanged |
|
||||
| `diagnostics` publish after didChange (≈150 ms debounce) | 162.16 / 157.20 | 160.88 / 159.66 | unchanged |
|
||||
| `offerkinds` — all 35 rows (5 cursors × 7 families) | 0.03 – 6.00 | 0.04 – 4.95 | every row inside its own version's a/b spread; the two rows above 1 ms (`aes-reg-instance` all-family 3.42/6.00 → 4.95/4.57 and `…ports` 2.99/3.73 → 2.92/2.83) do not move |
|
||||
|
||||
**Memory** (`rss`, three fresh processes a cell, KiB):
|
||||
|
||||
| cell | 0.53.0 | candidate |
|
||||
|---|---:|---:|
|
||||
| RSS after the workspace scan, cold cache | 505 968 / 508 048 / 505 824 · 501 200 / 501 232 / 505 312 | **478 992 / 479 584 / 480 720 · 480 848 / 479 344 / 479 488** |
|
||||
| RSS after the workspace scan, warm cache | 428 480 / 429 104 / 425 312 · 427 392 / 430 720 / 427 968 | 427 872 / 428 160 / 426 928 · 427 056 / 427 888 / 427 632 |
|
||||
| index store on disk | 45 468 | 45 468 |
|
||||
|
||||
Peak RSS is **not up**: warm is flat, and the cold scan — 3 975 files
|
||||
lexed and parsed — is **~25 MiB lower**, which is the `Vec<RawTok>` the
|
||||
fused lexer no longer builds.
|
||||
|
||||
**The flush split, paired** (`actionprofile`, pinmux-comment, first
|
||||
codeAction after a didChange; the same four-run order; the trace is the
|
||||
last try's, evidence `split-paired.jsonl`):
|
||||
|
||||
| | 0.53.0 + trace (a / b) | candidate (a / b) |
|
||||
|---|---:|---:|
|
||||
| wire latency, median of 3 | 110.2 / 110.7 | **89.1 / 89.1** |
|
||||
| flush wall | 102.7 / 107.4 | **82.2 / 87.5** |
|
||||
| ├ `lex` | 29.3 / 29.9 | **11.6 / 14.1** |
|
||||
| ├ `parse` (clone inside) | 25.8 / 30.3 | 23.3 / 26.3 |
|
||||
| ├ `publish` (of which `lint`) | 23.6 (23.4) / 23.2 (23.0) | 23.9 (23.7) / 23.3 (23.1) |
|
||||
| ├ `analyze` | 10.7 / 11.3 | 10.4 / 10.7 |
|
||||
| ├ `external` | 4.8 / 4.7 | 4.7 / 4.7 |
|
||||
| └ `lines` / `defines` | 0.6 / 0.4 | 0.7 / 0.4 |
|
||||
| handler (`action`) | `snapshot=hit` | `snapshot=hit` |
|
||||
|
||||
## Parity
|
||||
|
||||
Nothing below is an assertion about intent; each is a comparison of two
|
||||
builds' outputs over real files.
|
||||
|
||||
1. **The token stream, the parse diagnostics, the whole AST and the
|
||||
symbol table, file by file.** A digest per file over every token's
|
||||
kind, text, line, column, span start/end, `blank_before` and every
|
||||
leading/trailing comment, then over `{:?}` of the diagnostics, of the
|
||||
`SourceFile` and of `analyze`'s symbols. Run with the same tool built
|
||||
against the reference tree and against the working tree, over
|
||||
**4 807 files** (860 corpus + 3 947 opentitan): **0 lines differ**
|
||||
(`digest-ref.txt` / `digest-new.txt`, `digest.diff` empty).
|
||||
2. **`format --stdout`, corpus.** 860 files, sha256 per file, reference
|
||||
binary vs candidate: **0 differ** (`fmt-ref.txt` / `fmt-new.txt`).
|
||||
3. **`format --stdout`, opentitan.** The whole tree in one run, both
|
||||
binaries: the same sha256 over the concatenated output
|
||||
(`2c363ec2eb8395…`) and byte-identical stderr.
|
||||
4. **Diagnostics and the menu, on the buffer this round is about.**
|
||||
`parity_menu.py` opens each of the three cursors' files, asks for the
|
||||
all-family menu and each of the seven `context.only` families —
|
||||
recording every action's **title, kind and edit payload** — collects
|
||||
the published diagnostics, then does it twice more after a
|
||||
`didChange`: once with a harmless comment appended and once with a
|
||||
revision that deliberately introduces lint findings (a tab, a 140-
|
||||
character line, a trailing space), so the comparison is not two empty
|
||||
lists. 87 lines including 12 diagnostics and the fix-all edits:
|
||||
**identical** (`parity-ref.txt` / `parity-new.txt`).
|
||||
5. **Suites.** `cargo test --workspace --locked` through the guard:
|
||||
reference **4 403 passed, 0 failed, 46 ignored**; candidate **4 406
|
||||
passed, 0 failed, 46 ignored** — +3, the new `lint_trace` tests. The
|
||||
parser snapshot and idempotency suites are inside that run
|
||||
(`vlog_parser` 380 + 22 span tests, `vlog_formatter` 226 + fixtures),
|
||||
green on their own too. `cargo fmt --all -- --check` and
|
||||
`cargo clippy --all-targets --locked` clean. No guard kill anywhere in
|
||||
the round.
|
||||
6. **opentitan untouched.** `git -C ~/repo/opentitan status --porcelain`
|
||||
before and after every phase lists exactly the three pre-existing
|
||||
modified files (`hw/ip/aes/dv/tb/tb.sv`,
|
||||
`hw/top_darjeeling/ip/ast/rtl/ast.sv`,
|
||||
`hw/top_earlgrey/ip/ast/rtl/ast.sv`) and nothing else.
|
||||
|
||||
### Re-deriving it
|
||||
|
||||
Everything is under `~/.cache/lucisv-perf/63-2/`: both server binaries
|
||||
(`server-ref-0.53.0`, `server-step1-trace` — the reference plus the
|
||||
instrumentation only —, `server-step2-lexparse`), both CLIs
|
||||
(`lucisv-ref`, `lucisv-new`), the reference tree (`ref-1b8723c/`), the
|
||||
runners (`run.sh`, `paired.sh`, `split.sh`, `fmtgate.sh`,
|
||||
`parity_menu.py`), the file lists and every `.jsonl` / `.txt` named
|
||||
above, plus the stage micro-harness's sources — `micro/` (path
|
||||
dependencies on the working tree) and `micro-ref/` (on `ref-1b8723c/`).
|
||||
Both are plain `cargo` crates with no third-party code; `micro`'s
|
||||
`main.rs` is the per-stage median table and its `bin/digest.rs` is the
|
||||
per-file digest of parity check 1.
|
||||
|
||||
## For `docs/perf/README.md` (the lead's file)
|
||||
|
||||
> **2026-09-12 — the first request after an edit (TODO §63.2, N1 of the
|
||||
> 0.52.0 review).** The 40 267-line pinmux cell — one-character
|
||||
> `didChange`, then the all-family `codeAction` menu — **109 → 88 ms
|
||||
> paired (−19.2 %)**, the unchanged-repeat cell and every other
|
||||
> `offeredit`/`offerkinds`/`flush`/`diagnostics` row within noise, cold
|
||||
> scan RSS ~25 MiB lower and warm RSS flat. The flush is now split in
|
||||
> the `timing: codeaction` line (`rebuild{lex parse defines analyze
|
||||
> external lines publish documents}`), which is what named the cost:
|
||||
> **lex 29 ms and parse 26 ms of a 100 ms flush**, and *no* second lint
|
||||
> and *no* second analysis of the revision (the snapshot and
|
||||
> `with_semantics` already had those). Three changes, all in
|
||||
> `vlog_parser`: the lexer's two phases fused (the intermediate
|
||||
> `Vec<RawTok>` is gone; 27.8 → 24.7 ms), `Parser::skip` for the 217
|
||||
> `bump()` sites that discarded the token (17.5 → 16.0 ms), and a
|
||||
> first-byte test in front of the 44-entry operator table (24.7 →
|
||||
> **11.6 ms** — the single largest win). Token stream, parse
|
||||
> diagnostics, AST and symbol table digested per file over 4 807 files:
|
||||
> 0 differ; `format --stdout` byte-identical over corpus and opentitan;
|
||||
> diagnostics and menus identical on the edited buffer.
|
||||
> **Filed, not fixed:** the token clone into `parse_tolerant` (3.9 ms —
|
||||
> the parser mutates the stream it is given, so it cannot be handed
|
||||
> over while `Document::tokens` is read for comments), `analyze`
|
||||
> (9.4 ms), `resolve_external` (4.7 ms), and the ~6 ms spent dropping
|
||||
> the previous revision's products on the request path.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-09-12 — TODO §63.2 verified: PASS
|
||||
|
||||
Verified the flush split, the three lexer/parser changes, and the lead's
|
||||
`attach_trailing` edit. Everything below was re-derived independently
|
||||
(own tools, own binaries, own re-run of the dev's evidence), not read off
|
||||
the dev's numbers. Scratch work: `/private/tmp/.../scratchpad/63-2-qa/`
|
||||
(a fresh clone of 1b8723c at `old_lucisv/`, a paired-QA benchmark run at
|
||||
`paired-qa/`).
|
||||
|
||||
**Gates** (all through `tools/guard.sh -m 8 -t 1800`, no guard kill
|
||||
anywhere):
|
||||
- `cargo test --workspace`: **4 422 passed, 0 failed** (run alone, no
|
||||
concurrent cargo invocation — an earlier attempt run *concurrently*
|
||||
with another `cargo test`/`cargo build` in the same tree hit a stale
|
||||
doctest rlib once; that is a target-dir race from running two cargo
|
||||
processes at once, not a code defect, and does not reproduce solo).
|
||||
4 406 (the dev's count) + 16 tests this round added (13 in
|
||||
`vlog_parser::lexer::tests`, 2 in `lucisv_server::state::tests`, 1 in
|
||||
`lucisv_server::lint_trace::tests`) = 4 422.
|
||||
- `cargo clippy --all-targets --workspace`: clean, 0 warnings.
|
||||
- `cargo fmt --all -- --check`: clean.
|
||||
|
||||
**Fuzzers** (`docs/topo.md`'s `comment-slots` row names four; the SVA
|
||||
fuzzer is `sva-bodies`'s): `cargo test -p vlog_formatter --test
|
||||
verification a_comment_in_every_` — covergroup, fragment, constraint,
|
||||
RTL, SVA, **5/5 pass, still at their pinned gap counts** (329/153/395/
|
||||
419-class/705). No formatter or comment-slot code was touched by this
|
||||
round, so this is a regression check, not new coverage — it stayed at
|
||||
zero.
|
||||
|
||||
**`skip` vs `bump`, mechanically, not by reading the diff**: a script
|
||||
diffed old and new `crates/vlog_parser/src/parser/*.rs` and asserted
|
||||
every hunk is `bump()` → `skip()` and nothing else (line-for-line, same
|
||||
whitespace). Result: **every one of 178 hunks matches that shape**, and
|
||||
every removed line is a bare `self.bump();` statement (verified
|
||||
separately — `grep '^-' | grep -v 'self\.bump();'` on the parser diff
|
||||
returns nothing but the lexer's unrelated deleted lines and the two
|
||||
`eat_sym`/`eat_kw` bodies, both bare-statement too). Cross-checked: 252
|
||||
`Parser::bump()` call sites existed in `parser/` at 1b8723c, 74 remain
|
||||
(all `.bump().text` or similar — value used, correctly untouched),
|
||||
252 − 74 = 178, matching exactly.
|
||||
|
||||
- **Finding (non-blocking, doc-only): the "217 call sites" claim in the
|
||||
Work log and TODO.md §63.2 does not match the diff.** The diff converts
|
||||
**178** call sites (176 direct + the 2 inside `eat_sym`/`eat_kw`), not
|
||||
217. `~296` (Work log) is real — it is the *textual* `.bump()` count
|
||||
across all of `vlog_parser/src` including `RawLexer::bump` (a
|
||||
different, unrelated function) — but 217 does not correspond to any
|
||||
count I could reproduce from the tree at 1b8723c or from the diff. Not
|
||||
a safety issue (every conversion that *did* happen is a verified-safe
|
||||
shape, and no unused-result `self.bump();` statement remains anywhere
|
||||
in `parser/`), but the number should read 178 wherever it is quoted
|
||||
again (the Work log, TODO.md §63.2, and the `docs/perf/README.md` paste
|
||||
in this file all repeat it). Left the dated Work log entries as the
|
||||
historical record; not editing them.
|
||||
- **Finding (fixed directly, typo-class): the operator table has 42
|
||||
entries, not 44.** Counted `OPERATORS` in `lexer.rs` by hand and by
|
||||
script: 42. The inline code comment said "44 spellings" — fixed to 42
|
||||
(`crates/vlog_parser/src/lexer.rs`, the comment above the first-byte
|
||||
test). The Work log prose and TODO.md still say 44; same disposition as
|
||||
above — noted, not rewritten.
|
||||
|
||||
**Comment-attachment attacks on the fused lexer** (item 4): built
|
||||
`tokenize` from 1b8723c in a fresh clone (`old_lucisv/`) and from the
|
||||
working tree as two throwaway `examples/qa_token_digest.rs` /
|
||||
`qa_dump_one.rs` binaries (removed after use — not part of this diff).
|
||||
- **Whole corpus + opentitan, re-derived independently**: token stream +
|
||||
parse-tree + diagnostics digest (a hash of `{:?}` output, not read from
|
||||
the dev's cached digest files) over the same **4 807-file list** the
|
||||
dev used (`~/.cache/lucisv-perf/63-2/files-all.txt`): **0 lines
|
||||
differ**.
|
||||
- **The ten named attack shapes** (comment first in file; two comments
|
||||
before any token; trailing comment at EOF; two block comments merging
|
||||
on one line; a blank line between a comment and its token; CRLF; a
|
||||
block comment spanning lines before a same-line token; a comment
|
||||
between a macro invocation and its arguments; a file that is only
|
||||
comments; an empty file): dumped full `Debug` token streams for all
|
||||
ten from both builds — byte-identical hashes and, for the trickier
|
||||
three (merge, macro-comment, multi-line block), eyeballed the raw
|
||||
`Debug` output for sanity. Pinned as **ten new tests** in
|
||||
`crates/vlog_parser/src/lexer.rs`'s `mod tests` (search
|
||||
`TODO §63.2 QA`), all passing.
|
||||
- The lead's `attach_trailing` edit (returns the comment instead of
|
||||
dropping it when there is no previous token): confirmed the branch is
|
||||
unreachable through `tokenize` today (`attach` only calls
|
||||
`attach_trailing` when `same_line_as_prev` is true, which already
|
||||
requires `!tokens.is_empty()`), so it changes nothing observable yet
|
||||
and is a correct hardening of invariant 3 for whichever future caller
|
||||
removes that guard. Compiles clean, no test regressed.
|
||||
|
||||
**Operator table** (item 5): three new tests in `lexer.rs`.
|
||||
- `every_operator_s_first_byte_is_a_single_ascii_byte` — all 42 entries.
|
||||
- `the_operator_table_has_no_duplicate_or_empty_entries`.
|
||||
- `every_operator_followed_by_every_other_operator_still_lexes_without_a_gap`
|
||||
— all 42×42 = 1 764 concatenations, asserted to round-trip with no gap.
|
||||
Cross-checked the same 1 764 pairs against 1b8723c with the throwaway
|
||||
digest tool: **0 differ**.
|
||||
|
||||
**Idempotency and snapshots** (item 6): `cargo test -p vlog_formatter`
|
||||
green as part of the full workspace run above (`fixtures_match_snapshots
|
||||
_and_are_idempotent` passes). `tools/corpus_check.sh corpus -b
|
||||
target/release/lucisv`: 814/820 parse & format, 0 verification errors, 0
|
||||
crashes, and the outcome column is **byte-for-byte identical to the
|
||||
tracked `corpus-check-results.tsv`** for all 820 files. `format --stdout`
|
||||
byte-identity: **corpus, 0 differ** (stdout and stderr both, against
|
||||
`~/.cache/lucisv-baselines/lucisv-0.53.0`); **opentitan `hw/ip`
|
||||
(1 807 files), 0 differ**, same 4 parse errors both binaries, run through
|
||||
the guard. `git -C ~/repo/opentitan status --porcelain` before and after:
|
||||
only the three pre-existing files, every time.
|
||||
|
||||
**sha256 / rebuild check** (item 7 precondition): a fresh
|
||||
`cargo build --release` of the working tree's `lucisv` CLI matches
|
||||
`~/.cache/lucisv-perf/63-2/lucisv-new` byte for byte
|
||||
(`fabd3432…bdfcfaf`) — the lead's edit landed before that binary was
|
||||
built. **`lucisv-server` does *not* match**: `server-step2-lexparse`
|
||||
(built 01:23) is `b0b09544…`, a fresh build of the current tree is
|
||||
`694287ea…`. The lead's edit landed between the two builds (01:23 →
|
||||
01:25), so the server binary used for the dev's own paired run predates
|
||||
it. Per the brief, rebuilt the candidate and re-ran the paired benchmark
|
||||
against the fresh binary rather than trusting the cached one.
|
||||
|
||||
**Paired re-take** (item 7), `paired-qa.sh` (same shape as the dev's
|
||||
`paired.sh`, ref/new alternated, 3 tries, one warm store per binary),
|
||||
against the freshly built candidate `lucisv-server` (694287ea…) and the
|
||||
reference rebuilt from 1b8723c and hash-verified against
|
||||
`server-ref-0.53.0` (6b1b5245…, matches):
|
||||
|
||||
| cell | ref (a/b) | candidate (a/b) | change |
|
||||
|---|---:|---:|---|
|
||||
| `offeredit` pinmux-comment, first after didChange (median of 3) | 112.31 / 110.63 | 90.35 / 92.57 | **−19.6% / −16.3%**, gate (≥15%) met both rounds, stretch (<95ms) met |
|
||||
| `offeredit` aes-reg-instance, first after didChange | 6.32–7.82 | 2.94–8.05 | inside noise, matches dev's characterization |
|
||||
| `offeredit` tb-comment, first after didChange | 0.56–3.94 | 0.56–3.08 | inside noise |
|
||||
| `offerkinds`, 35 rows | 0.03–6.0 ms | 0.03–5.0 ms | no row moved out of range |
|
||||
| RSS cold | 502.7–505.2 MiB | 478.6–483.1 MiB | lower, matches "cold ~25 MiB lower" |
|
||||
| RSS warm | 427.4–429.4 MiB | 426.9–429.3 MiB | flat |
|
||||
|
||||
This run was **not** on an idle machine (a `cargo test --workspace` was
|
||||
running concurrently in the background for part of it), which is why the
|
||||
absolute ms are a little higher than the dev's own quieter-machine
|
||||
numbers — the percentage reduction and every qualitative claim
|
||||
(noise-level `offerkinds`/other cursors, RSS direction) hold anyway, so
|
||||
the gate is met with margin either way.
|
||||
|
||||
Also re-ran `parity_menu.py` (item covering TODO.md's "an edit that
|
||||
moves a fence" attack, plus the lex-failure and `define`-table attacks
|
||||
below) against the freshly built ref/candidate pair: **87 lines, 0
|
||||
differ**, same as the dev's own run — the LINTY edit's fence/lint-finding
|
||||
path is unaffected.
|
||||
|
||||
**TODO.md's three named parity attacks** — a buffer that fails to lex, a
|
||||
`` `define `` edit that changes the macro table, an edit that moves a
|
||||
fence:
|
||||
1. **Lex failure**: new test
|
||||
`a_buffer_that_fails_to_lex_still_records_every_rebuild_stage`
|
||||
(`state/mod.rs`) — an unterminated string literal, confirms `tokens`
|
||||
stays empty, a diagnostic is produced, `Rebuild::Lex` is still
|
||||
recorded (the failed attempt is real work), and every other stage
|
||||
(`defines`/`analyze`/`external`/`lines`/`publish`) still runs over the
|
||||
empty tree exactly as the un-instrumented code always did.
|
||||
2. **`define` edit**: new test
|
||||
`a_define_edit_changes_the_macro_table_the_rebuild_reports_on` —
|
||||
two `Document::new` calls with different macros, confirms the second
|
||||
document's table has no trace of the first's macro (no cross-document
|
||||
staleness introduced by wrapping `collect_defines` in `rebuild`).
|
||||
3. **Fence-moving edit**: covered by the `parity_menu.py` re-run above
|
||||
(the LINTY revision is exactly this — a new lint finding changes what
|
||||
the fence/diagnostics path reports for the revision).
|
||||
|
||||
**`lint_trace` arithmetic — sabotaged, as asked** (item 8): nested
|
||||
`rebuild{…}` inside `flush{…}` in `Trace::line()` and reran the dev's
|
||||
pinning test, `the_rebuild_group_names_every_stage_beside_the_other_two`.
|
||||
**It did not fail.** That test extracts the rebuild body by splitting on
|
||||
the literal string `"rebuild{"` and the *next* `}`, which finds a clean
|
||||
body whether or not another `}` follows — the extra brace the nesting
|
||||
adds sits outside the slice the test inspects. Checked what actually
|
||||
happens to a consumer against `tools/perf/phases_p2.py`'s real regex
|
||||
(`([a-z_]+)\{([^{}]*)\}`, which cannot cross an inner `{`): run against
|
||||
the sabotaged line, `GROUP.findall` matched only `rebuild` and `action`
|
||||
— **the whole `flush` group silently fails to match**, and
|
||||
`flush_wall`/`flush_buffers`/`flush_parses` and every `flush.fields()`
|
||||
key vanish from that row with no error anywhere. So the existing pin
|
||||
does not actually enforce the sibling-group contract it documents.
|
||||
Added `the_three_top_level_groups_are_flat_never_nested` to
|
||||
`lint_trace.rs`'s test module, which reads the line the way the regex
|
||||
does (each group must reach its own `}` before another `{` opens) —
|
||||
confirmed it **fails** against the sabotaged code and **passes** after
|
||||
reverting the sabotage; the sabotage itself is reverted (`git diff` of
|
||||
`lint_trace.rs` no longer shows it). This is the one finding I'd call a
|
||||
real gap rather than a documentation slip, though it is a `tools/perf`
|
||||
tooling-correctness issue, not a formatter-invariant one (no corpus/
|
||||
opentitan output is affected), so it does not block this round; filed as
|
||||
a fix-directly-and-note per CLAUDE.md's QA rule since the fix is a test
|
||||
addition, not a redesign.
|
||||
|
||||
**Not independently re-verified**: the dev's own `flush`/`diagnostics`
|
||||
paired cells (only `offeredit`/`offerkinds`/`rss` were named in my brief
|
||||
for item 7); the micro-harness per-stage table (`tokenize` 27.79→11.59ms
|
||||
etc.) — trusted as reported, since the stage split itself is exercised
|
||||
by the corpus-wide digest and the paired re-take above.
|
||||
|
||||
**Verdict: PASS.** No corpus, opentitan, snapshot, idempotency or
|
||||
comment-preservation regression found anywhere; the two real findings
|
||||
are a documentation/count inaccuracy (217→178, 44→42, the latter fixed)
|
||||
and a test-strength gap in the sibling-group pin (fixed with a new test
|
||||
that actually catches the nesting failure mode). Gate met with an
|
||||
independently-measured margin on a busier machine than the dev's own
|
||||
run.
|
||||
|
||||
## Review
|
||||
|
||||
**Lead review, 2026-09-12 — accepted.** The lane did what the brief
|
||||
asked in the order it asked: the flush split came first and it settled
|
||||
two of the review's candidates without code (no second lint, no second
|
||||
analysis), then named the two stages that mattered — lex and parse, 55 of
|
||||
a 100 ms flush. The three changes are all in `vlog_parser` and all
|
||||
behaviour-preserving by construction: the lexer fusion is a reordering of
|
||||
the same attachment loop (the fused `attach` reads only the raw token in
|
||||
hand and the token last pushed, which is all the old loop ever read),
|
||||
`Parser::skip` is `bump` minus the clone with the same comment plumbing,
|
||||
and the first-byte test in front of the operator table is a filter in
|
||||
front of an unchanged `starts_with`. The proof is the one that matters for
|
||||
a lexer change: token stream, diagnostics, AST and symbols digested per
|
||||
file over 4 807 files with 0 differing, re-derived by QA from a rebuilt
|
||||
1b8723c, plus the five gap fuzzers at their pinned counts and every
|
||||
byte-identity gate. Gate met at −19.2 % (dev) and −19.6 % / −16.3 % (QA's
|
||||
re-take on a busier machine), stretch met.
|
||||
|
||||
One edit is the lead's, and QA covered it: `attach_trailing` now hands an
|
||||
orphan comment back to `pending` instead of returning silently — the
|
||||
branch is unreachable while `same_line_as_prev` requires a token, and it
|
||||
stays a rule rather than a hope (invariant 3).
|
||||
|
||||
Rulings on QA's findings:
|
||||
|
||||
- **Counts** (217 call sites and 44 operators in the Work log; 178 and
|
||||
42 in the tree): the Work log stands as a dated record; the lead's own
|
||||
entry in `docs/perf/README.md`, TODO §63.2 and the topo row carry the
|
||||
verified numbers.
|
||||
- **The nesting guard**: the dev's pin string-split the line and missed a
|
||||
nested group; QA's `the_three_top_level_groups_are_flat_never_nested`
|
||||
runs the real regex and catches the sabotage. Accepted as the pin.
|
||||
|
||||
Deferred with the dev's reasons and filed in TODO's loop-3 list: the
|
||||
token clone into `parse_tolerant` (the parser mutates the stream it is
|
||||
given), `analyze`, `resolve_external`, and dropping the previous revision
|
||||
on the request path. `lexer.rs` at 770 production lines is noted: the
|
||||
fusion removed a responsibility rather than adding one.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,602 @@
|
||||
# perf5r-lint-snapshot — the code-action path on a large file
|
||||
|
||||
Take 5 **review** round (`docs/performance_take5_review.md` §1), TODO §61.2,
|
||||
tracker rows **R1b** (the stage trace) and **R1a** (the lint-result snapshot).
|
||||
Baseline is 0.51.0; the paired reference for this lane is trunk at `51cbfd2`,
|
||||
which is 0.51.0 plus §61.1's rename preflight — a change on the rename path
|
||||
that this lane does not touch.
|
||||
|
||||
## Goal
|
||||
|
||||
A `textDocument/codeAction` on a comment in `pinmux_reg_top.sv` (42 192 lines,
|
||||
1.3 MB, generated) costs **25 ms**, of which **23 ms is the quickfix family**,
|
||||
and the first request after a one-character edit costs **136 ms**. The review's
|
||||
own reading is that `lint.rs::fixable` calls `lint_with` on every request and
|
||||
nothing memoizes the result; take 5 §P1's lane deferred that memo because "its
|
||||
key is a different shape from anything else in this lane" and its failure mode
|
||||
is a **stale fix offer**.
|
||||
|
||||
This lane does the two halves the review asks for, in its order:
|
||||
|
||||
* **R1b, first: measure.** One `timing: codeaction …` line per request behind
|
||||
`--verbose`, splitting the request into config discovery, `LintRun` build,
|
||||
lint pass, fence filter and action serialization — and, separately, the
|
||||
**flush**: the debounced `Document` rebuild that `answer_request` performs
|
||||
before any handler runs, with the diagnostics pass that publishes inside it
|
||||
split the same five ways. No behaviour change.
|
||||
* **R1a, then: reuse.** One lint-result snapshot per open `Document`, keyed by
|
||||
every input the result depends on, read by the **diagnostics** pass and by
|
||||
**quick-fix discovery** alike, recomputed whenever the key does not match.
|
||||
The fence authority and execute-time validation are untouched.
|
||||
|
||||
**What must not move:** which diagnostics are published, which fixes are
|
||||
offered, and their bytes. A menu that is fast because it is stale is a
|
||||
failure, and so is a fix offered for a finding the current buffer no longer
|
||||
has.
|
||||
|
||||
## What the measurement said (R1b)
|
||||
|
||||
`tools/perf/phases_r1.py::actionprofile`, three cursors, four request shapes,
|
||||
`--verbose`, one warm session each. Milliseconds, `--tries 3`, repeat median
|
||||
of the wire time and the trace of the last request.
|
||||
|
||||
| pinmux comment | wire | flush wall | flush parses | flush lint | action config | action build | action lint | fence | serialize |
|
||||
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
||||
| first request of the session | 25.10 | 0.00 | 0 | 0.00 | 0.20 | 0.06 | **22.43** | 0.00 | 0.05 |
|
||||
| repeated, unchanged buffer | 21.97 | 0.00 | 0 | 0.00 | 0.04 | 0.01 | **20.87** | 0.00 | 0.03 |
|
||||
| definition queued behind it | 22.33 | 0.00 | 0 | 0.00 | 0.04 | 0.02 | **20.96** | 0.00 | 0.03 |
|
||||
| first request after a `didChange` | 127.54 | **99.72** | 1 | **21.08** | 0.03 | 0.01 | **20.22** | 0.00 | 0.03 |
|
||||
|
||||
Read off those numbers:
|
||||
|
||||
* **The 23 ms is the rules.** Config discovery — the `lucisv.toml` walk,
|
||||
`ProjectLint::read` and the waiver reads — is **0.04 ms** on a repeat
|
||||
(0.20 ms on the first request of a session, which is the OS cache warming).
|
||||
The `LintRun` build is 0.01–0.06 ms. The fence filter costs **nothing**:
|
||||
this buffer has **zero** violations, so §P1a's "no fix, no fence parse" gate
|
||||
answers before the memo is asked. Serialization is 0.03 ms. **99% of the
|
||||
quickfix menu is `lint_with`.**
|
||||
* **Which rules.** `tools/perf/phases_r1.py::ruleablation` pushes
|
||||
`lucisv.lint.select` one rule at a time through `didChangeConfiguration`
|
||||
and times the same quickfix-only menu under each. The floor — one cheap
|
||||
rule, so context construction and transport alone — is **1.3–1.4 ms**.
|
||||
Three rules stand out, and they are the three **semantic** ones that read
|
||||
the buffer's `Semantics` and the workspace census:
|
||||
|
||||
| rule | repeat median | over the floor |
|
||||
|---|---:|---:|
|
||||
| `unused-signal` | 9.52 | **+8.2** |
|
||||
| `undriven-net` | 8.69 | **+7.4** |
|
||||
| `multiply-driven` | 8.88 | **+7.5** |
|
||||
| every other default rule (55 of them) | 1.24–3.51 | ≤ +2.2 |
|
||||
| control, all 57 default rules | 20.19 | +18.9 |
|
||||
|
||||
The three semantic rules are effectively the whole of it; the remaining 55
|
||||
rules together account for about 2 ms. (Single-rule rows each pay the
|
||||
shared context setup once, so the three do not add up to 18.9 exactly —
|
||||
the ranking is what this row set establishes, not an exact partition.)
|
||||
* **The 136 ms first-after-edit is mostly *not* the lint pass.** Of 127.5 ms:
|
||||
**99.7 ms is the flush** (one whole-file parse and the analysis of 1.3 MB,
|
||||
plus the diagnostics publish it triggers) and **20.2 ms is the handler's own
|
||||
lint pass**. Inside the flush, the diagnostics pass is **21.1 ms** of the
|
||||
99.7 — so the `Document` rebuild itself is about **78.6 ms**, and the
|
||||
request runs **`lint_with` twice on the same revision**: once to publish
|
||||
diagnostics, once to discover quick fixes.
|
||||
|
||||
That is the review's item 4 answered with a number: **a lint cache alone
|
||||
cannot fix the 136 ms**, because 79 ms of it is `Document::new`. What a
|
||||
snapshot can take out of it is one of the two 21 ms passes.
|
||||
|
||||
The small-file controls behave as expected and are recorded in full:
|
||||
`tb.sv` 0.52 ms unchanged / 0.98 ms after a change (flush 0.49 ms), the
|
||||
`aes.sv` `aes_reg_top` cursor 3.2 ms / 4.19 ms (flush 1.10 ms).
|
||||
|
||||
## The dependency / invalidation table
|
||||
|
||||
Written **before** any cache, as the review requires. One row per input that
|
||||
can change a lint result or a fix. "How the key observes it" is the mechanism,
|
||||
not a hope; "test" is the test that flips that row and asserts a fresh result.
|
||||
|
||||
`lint_with(ctx, rules, external)` is a pure function of its three arguments,
|
||||
and `ctx = LintContext::from_parse(text, tokens, tree, line_index, path)
|
||||
.with_semantics(&doc.semantics).with_options(options).with_line_length(w)
|
||||
.with_tab_width(t)` plus the oracle. So the table below is complete by
|
||||
construction: every argument of that expression is a row.
|
||||
|
||||
| # | input | how it can change | how the key observes it | test |
|
||||
|---|---|---|---|---|
|
||||
| 1 | document text, tokens, tree, `semantics`, line index, path | `didOpen`, `didChange`, a text-carrying `didSave`, `willRenameFiles` | **identity.** The snapshot is a field on the `Document`, and `Workspace::set_document` builds a **new** `Document` for every flushed change and drops the old one. There is no revision number to compare because there is no way to hold the wrong one — the same argument `crate::fences` already rests on | `an_edited_buffer_is_relinted` |
|
||||
| 2 | `doc.large` | a buffer crossing `lucisv.largeFile.threshold` in either direction | identity (row 1: the mode is re-taken in `set_document`, which builds a new `Document`). A large buffer never reaches the pass at all: `codeAction` is answered `[]` by `large_file.rs` before any handler, and `diagnostics::all_in` returns empty | `a_large_buffer_lints_nothing_and_stores_nothing` |
|
||||
| 3 | the enabled rule set | `lucisv.lint.select` / `ignore` / `severity.<class>` / `rules.<name>` pushed by `didChangeConfiguration`; `[lint] select` / `ignore` in the buffer's `lucisv.toml` | `Key.rules`: the `&'static str` names the ladder produced, in registry order, compared **exactly** (not hashed) | `a_pushed_rule_selection_is_relinted`, `a_rewritten_toml_is_relinted` |
|
||||
| 4 | merged rule options | `[lint.<rule>]` tables in `lucisv.toml`; `lucisv.lint.options` from the editor | `Key.options`: the merged `RuleOptions`, compared exactly (`PartialEq`) | `a_rewritten_toml_is_relinted` |
|
||||
| 5 | line width | `line-length` in `lucisv.toml`; `lucisv.lineLength` | `Key.line_length` | `a_rewritten_toml_is_relinted` |
|
||||
| 6 | tab width (fix **text** only) | `indent` in `lucisv.toml`; `lucisv.indent` | `Key.tab_width`. Since this lane the width lives on the `LintRun` — read there through `format::indent_width`, which used to be called by the dispatcher — so the diagnostics pass and the quick-fix pass build the *same* context and share one snapshot. Only `no-tabs`' fix string reads it, and the diagnostics path never reads a fix, so no published diagnostic moves | `a_tab_width_change_rewrites_the_fix` |
|
||||
| 7 | external waiver file **contents** | any edit of a file named by `[lint] waivers` or by `lucisv.lint.waivers` | `Key.waivers`: `(path, text)` per file, in the order they are read — the **exact text** `ExternalWaivers::parse` was handed, not a hash and not an mtime. One read, not two: `lint.rs` now reads the bytes itself and parses them, reproducing `ExternalWaivers::read`'s error sentence byte for byte | `a_rewritten_waiver_file_is_relinted` |
|
||||
| 8 | the `lucisv.toml` itself | any edit of the discovered config file; a new config file appearing in a parent directory | **through rows 3–7.** Nothing in a `lucisv.toml` reaches a lint result except the selection, the options, the width, the indent and the waiver paths, and all five are in the key. `LintRun::for_document` re-runs `Discovery::for_file` on **every** request (0.04 ms, measured above), so a rewritten file is in the key at the next request | `a_rewritten_toml_is_relinted` |
|
||||
| 9 | the workspace index the census oracle reads | `publish_scan`, both `finish_scan` paths, `update_one` — i.e. a scan step, a scan finishing, a `didSave` or a watcher event in **another** file | **not a key field: an explicit drop.** All four of those call sites end with `for doc in self.docs.values_mut() { doc.refresh_overlay(&self.index) }`, and `refresh_overlay` — the one place a `Document` is told the index moved — clears the snapshot. Verified by exhaustion: `self.index.{absorb,remove_file,update_facts,update_file}` occurs nowhere else in `state/` | `a_change_in_another_file_relints_this_one` |
|
||||
| 10 | whether there is an oracle at all | the first scan of a session that began with an empty index | `Key.has_oracle`, **and** row 9's drop | `a_workspace_appearing_turns_the_semantic_rules_on` |
|
||||
| 11 | client settings generation | `workspace/didChangeConfiguration`, or the reply to `workspace/configuration` | through rows 3–7; `apply_settings` also republishes every open buffer, which recomputes under the new key immediately | `a_pushed_rule_selection_is_relinted` |
|
||||
| 12 | file-watcher events on the `lucisv.toml` / the waiver files | **there are none.** `watch::SOURCE_GLOB` is `**/*.{v,vh,sv,svh}` and the only other watcher is the configured filelist's own path | rows 7 and 8 are what make this safe: both files are re-read per request, so no watcher is needed and none is added | `a_rewritten_toml_is_relinted` (no watcher event is sent) |
|
||||
| 13 | close and reopen | `didClose` then `didOpen` | identity: `close_document` removes the `Document`, and with it the snapshot | `a_closed_and_reopened_buffer_is_relinted` |
|
||||
| 14 | UTF-16 ranges | — | **not an input.** `Positions` is built from `doc.text` per request in `code_action.rs` and `lint::diagnostics_in`; nothing positional is stored in the snapshot, which holds byte spans exactly as `lint_with` returned them | `a_snapshot_fix_keeps_its_utf16_range` |
|
||||
|
||||
Two things are deliberately **not** in the key:
|
||||
|
||||
* **A hash of anything.** Every field is compared by value. A 64-bit digest
|
||||
would have been smaller and would have made "no stale fix" an argument
|
||||
about collision probability instead of a fact.
|
||||
* **A time or a generation number for the config files.** An mtime is a
|
||||
weaker statement than the contents and is wrong across a same-second
|
||||
rewrite; the contents are already in hand because the pass reads them.
|
||||
|
||||
|
||||
## What R1a bought (paired)
|
||||
|
||||
Reference `51cbfd2` (`5d2a7aa2a4fd…`) against the same tree plus this lane's
|
||||
diff (`827c7ac222c8…`), both `--release --locked`, the same schema-2 harness,
|
||||
phase order alternating which binary went first, no build during any timed
|
||||
run, `--tries 3`, repeat medians. Load 2.5–5.9 one-minute, inside the review's
|
||||
own 2.8–6.0 band; zero guard kills; opentitan `git status --porcelain` = the
|
||||
same three pre-existing files after every phase.
|
||||
|
||||
| workload | `51cbfd2` | this lane | change |
|
||||
|---|---:|---:|---|
|
||||
| pinmux comment, **all** action families, unchanged | 22.61 | **0.98** | **−95.6%** |
|
||||
| pinmux comment, **quickfix only**, unchanged | 24.51 | **0.11** | **−99.5%** |
|
||||
| pinmux comment, empty family filter | 0.05 | 0.05 | unchanged |
|
||||
| pinmux menu, repeated on the unchanged buffer (`offeredit`) | 23.44 | **0.18** | **−99.2%** |
|
||||
| **definition queued** behind the pinmux menu (leader / follower, pipeline 3) | 22.39 / 22.38 | **0.78 / 0.76** | **−96.5%** |
|
||||
| pinmux comment, **first offer after a `didChange`** | 125.65 | **106.89** | **−14.9%** |
|
||||
| `tb.sv` comment, unchanged / after a change | 0.19 / 1.26 | 0.23 / 1.45 | +0.04 / +0.19 ms |
|
||||
| `aes.sv` `aes_reg_top`, unchanged / after a change | 2.86 / 3.83 | 2.58 / 3.62 | −9.7% / −5.5% |
|
||||
| diagnostics publish after `didChange` (≈150 ms of it is the debounce) | 162.29 | 162.75 | **+0.3%** |
|
||||
| `didOpen pinmux_reg_top.sv` → definition | 120.45 | 110.42 | −8.3% |
|
||||
| `didOpen aes.sv` / `aes_core.sv` / `spi_device.sv` → definition | 4.53 / 5.72 / 8.68 | 3.49 / 5.56 / 8.15 | −23% / −3% / −6% |
|
||||
| take-3 `codeaction` cells (eager, fan-out 1 / 6 / comment) | 21.37 / 88.44 / 1.67 | 21.60 / 89.74 / 1.56 | +1.1% / +1.5% / −6.7% |
|
||||
| idle RSS, 100 open buffers each asked for quick fixes (MiB) | 574.0 | **574.6** | **+0.1%** |
|
||||
| idle RSS, 10 / 1 buffers (MiB) | 429.4 / 420.9 | 428.4 / 422.2 | ±0.3% |
|
||||
|
||||
**Gates.**
|
||||
|
||||
* *unchanged pinmux menu ≤ 16 ms* — **met, 0.98 ms** (quickfix-only 0.11 ms).
|
||||
* *queued definition ≤ 16 ms* — **met, 0.76 ms**.
|
||||
* *first-after-edit improved, reported separately with its stage split* —
|
||||
**125.65 → 106.89 ms, −14.9%**, and the split says exactly why that is the
|
||||
whole of what a lint cache can do here: of the candidate's 109 ms, **106 ms
|
||||
is the flush**, of which **21.9 ms is the diagnostics pass** and the
|
||||
remaining ~84 ms is `Document::new` on 1.3 MB. The handler's own lint pass
|
||||
is **0.00 ms — it does not run**. The remaining stage is named and is not
|
||||
this lane's: the parse and analysis of a 1.3 MB buffer.
|
||||
* *diagnostics publish unchanged* — **met, +0.3%** (inside the run-to-run
|
||||
spread of a 150 ms debounce).
|
||||
* *no higher retained memory* — **met, +0.1% at 100 open buffers**, all of
|
||||
them holding a snapshot.
|
||||
* *no stale diagnostic or fix under any invalidation row* — 11 server tests
|
||||
and 10 unit tests, one per row plus the attack; see below.
|
||||
|
||||
The candidate's own trace, at the same three cursors:
|
||||
|
||||
| pinmux comment | wire | flush wall | flush lint | flush snapshot | action lint | action snapshot |
|
||||
|---|---:|---:|---:|---|---:|---|
|
||||
| first request of the session | 2.07 | 0.00 | 0.00 | — | **0.01** | **hit** |
|
||||
| repeated, unchanged | 0.72 | 0.00 | 0.00 | — | **0.00** | **hit** |
|
||||
| definition queued behind it | 0.23 | 0.00 | 0.00 | — | **0.00** | **hit** |
|
||||
| first after a `didChange` | 109.39 | 106.09 | **21.87** | miss | **0.00** | **hit** |
|
||||
|
||||
The first request of a *session* already hits: the `didOpen` published
|
||||
diagnostics, and that pass is the one the menu reads. A queued definition logs
|
||||
no trace line of its own at all — it lints nothing — which is what the
|
||||
`result_count` of those rows says.
|
||||
|
||||
**The config-discovery decision: leave it.** The review allows memoizing the
|
||||
`FileConfig` read "if the trace says that I/O is material". It does not:
|
||||
0.04–0.16 ms on a repeat, against a 21 ms pass. Memoizing it would have added
|
||||
a second key (path, mtime, length) whose failure mode is a *stale rule
|
||||
selection* — and the `lucisv.toml` and the waiver files are not watched
|
||||
(table row 12), so that per-request read is the only thing that ever notices
|
||||
one of them changing. It stays.
|
||||
|
||||
The one thing that did move is where the **indent width** is read. It used to
|
||||
be `format::indent_width`, called by the dispatcher; it is now the same
|
||||
function, called by `LintRun::for_document`, because the two doors must build
|
||||
the same context to share one snapshot. A code-action request therefore does
|
||||
the same two `Discovery` walks it always did (one in `configured`, one in
|
||||
`indent_width`); the **diagnostics publish now does two where it did one**.
|
||||
Measured, that moved the config stage from about **0.04 to 0.15 ms** on a
|
||||
repeat and left the publish row at **+0.3%**, inside the spread of a 150 ms
|
||||
debounce. It is stated rather than hidden, and the fix is a handshake request
|
||||
below, not a second spelling of the indent ladder here.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **`lint_with` is deterministic and side-effect-free** given `(ctx, rules,
|
||||
external)`. Not enforced by a type; it is what makes a snapshot legitimate
|
||||
at all. Pinned by `a_recomputed_snapshot_equals_a_fresh_pass`, which lints
|
||||
the same document twice through the two doors and compares every violation.
|
||||
- **A `Document`'s derived fields are a pure function of its text.** The same
|
||||
assumption `crate::fences` (§P1b) already ships on, and the reason identity
|
||||
can stand in for a revision number in row 1.
|
||||
- **`refresh_overlay` is called for every open buffer at every index
|
||||
mutation.** Established by exhaustion over `state/mod.rs` (row 9) rather
|
||||
than by a type. A new index mutation that skipped it would be a stale
|
||||
oracle for `external` resolution too, which is a pre-existing contract this
|
||||
lane now also depends on — stated in Handshakes.
|
||||
- **`format::indent_width` stays the one authority on the indent ladder.**
|
||||
`LintRun::for_document` calls it rather than re-deriving the width from the
|
||||
`FileConfig` it already read, which costs a second `Discovery` walk — worth
|
||||
hundredths of a millisecond against a 21 ms pass, and worth not having two
|
||||
spellings of a rule that decides a fix's bytes. Pinned rung by rung by
|
||||
`the_runs_tab_width_is_the_formatters_own_ladder`. The dispatcher's own call
|
||||
to it is gone, so the request as a whole does not walk more often than
|
||||
before.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**Consumed**
|
||||
|
||||
- `vlog_linter::{lint_with, ExternalWaivers::parse, RuleOptions}` — unchanged.
|
||||
`ExternalWaivers::parse` (already public) is now called directly instead of
|
||||
`ExternalWaivers::read`, so the file's text is in hand for the key; the
|
||||
error sentence for an unreadable file is reproduced verbatim
|
||||
(`format!("{}: {e}", path.display())`).
|
||||
- `vlog_formatter::fence::protected_regions` through `crate::fences` — the
|
||||
shared-fence-filter contract (`docs/features/shared-fence-filter/`) is
|
||||
**not** amended. `fences.rs` gains one read-only predicate, `held`, which
|
||||
the trace uses to say whether a request paid the parse; it decides nothing.
|
||||
- `crate::state::Document::refresh_overlay` — the existing "the index moved"
|
||||
hook. This lane makes it also drop the lint snapshot.
|
||||
- `vlog_parser::stats::parses` — the flush's parse count in the trace.
|
||||
|
||||
**Promised**
|
||||
|
||||
- `crate::lint::violations_in` and `crate::lint::fixable` now return
|
||||
`Arc<[Violation]>` instead of `Vec<Violation>`, and `fixable` no longer
|
||||
takes a `tab_width` — the width comes from the `LintRun`. In-crate callers
|
||||
only (`lucisv_server` is a binary crate): `diagnostics.rs`, `code_action.rs`
|
||||
and their tests.
|
||||
- `crate::lint_trace` is new and is written to from `lint.rs`,
|
||||
`code_action.rs` and `server/dispatch.rs`. It is a thread-local
|
||||
accumulator, armed per request; nothing outside `--verbose` observes it.
|
||||
|
||||
**Requested of another module**
|
||||
|
||||
- `crate::format` (not this lane's file): `indent_width(path, client)` runs its
|
||||
own `Discovery` walk, and `LintRun::for_document` has already discovered the
|
||||
same `FileConfig` a line earlier. A form taking that `FileConfig`
|
||||
— `indent_width_of(&FileConfig, &ClientSettings)`, with today's function as a
|
||||
one-line wrapper — would let the lint pass pay one walk instead of two. The
|
||||
cost of not having it is measured above (about **+0.11 ms** on the config
|
||||
stage, publish row +0.3%), which is why this lane did not spell the ladder a
|
||||
second time to avoid it: one authority on a fix's bytes is worth more than
|
||||
0.11 ms. Nothing else is needed in `vlog_linter`, `vlog_formatter`,
|
||||
`fence.rs` or `state/scan.rs`.
|
||||
|
||||
**`docs/topo.md`** — this lane adds one edge (`lint.rs ──▶ lint_snapshot.rs`,
|
||||
`lint.rs ──▶ lint_trace.rs`, `state/mod.rs ──▶ lint_snapshot.rs` for the
|
||||
field) and amends the `server-lint ◀──▶ diagnostics` edge to say the two now
|
||||
share one computed result. `topo.md` is not this lane's file: the amendment is
|
||||
requested here for the lead to apply at merge.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] R1b — the `timing: codeaction …` stage trace (`lint_trace.rs`), with the
|
||||
flush group and its parse count; `fences::held` for the memo hit
|
||||
- [x] R1b — the harness: `tools/perf/phases_r1.py`, phases `actionprofile`
|
||||
(three cursors × four request shapes) and `ruleablation` (one row per
|
||||
default-on rule)
|
||||
- [x] R1b — measured, and the 23 ms / 136 ms attributed (above)
|
||||
- [x] the dependency/invalidation table, written before the cache
|
||||
- [x] R1a — `lint_snapshot.rs`, the `Document` field, both consumers
|
||||
- [x] R1a — one invalidation test per table row, plus the stale-fix attack
|
||||
- [x] R1a — measured paired against `51cbfd2`; the 100-buffer RSS cell
|
||||
- [x] tracker cells R1a/R1b and both experiment records; TODO §61.2
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-09-08 — dev (Opus), R1b.**
|
||||
|
||||
- `crates/lucisv_server/src/lint_trace.rs` (new): a thread-local stage
|
||||
accumulator in `vlog_parser::stats`' shape — per thread because a request is
|
||||
answered on one thread, and armed only by the request wrapper when
|
||||
`--verbose` asked. Off costs one `Cell<bool>` read per traced site: no clock,
|
||||
no allocation, no line. Two groups per request, `flush` and `action`,
|
||||
divided by `close_flush`, so the diagnostics pass that publishes during the
|
||||
debounced flush is readable beside the handler's own pass.
|
||||
- `lint.rs`: `LintRun::for_document`'s body split into `Discovered::read`
|
||||
(everything read from disk) and `Discovered::into_run` (the oracle and the
|
||||
rule ladder), so the I/O has a stage of its own. The calls, their order and
|
||||
the order the config problems are collected in are unchanged. One place now
|
||||
calls `lint_with` (`found`), which is what makes one trace site enough.
|
||||
- `dispatch.rs`: `flush_dirty_traced` wraps the flush with a clock and a
|
||||
`vlog_parser::stats::parses()` delta, but only when a trace is armed;
|
||||
`Server::request` arms one and logs `timing: codeaction method=… total=… ` +
|
||||
the two groups, for any request that linted anything — which is the code
|
||||
actions and any request whose flush published diagnostics, so the queued
|
||||
definition gets its own line.
|
||||
- Deviation, stated: the flush is traced as **one** stage plus its parse
|
||||
count, not split into parse / analysis / overlay-refresh. Those three live
|
||||
inside `Document::new` and `Workspace::set_document` in `state/mod.rs`,
|
||||
which this lane owns only for the snapshot field and its initializers;
|
||||
splitting them means threading a trace through `set_document`'s signature.
|
||||
The number the review asks for — dirty-buffer stage versus lint pass — is
|
||||
fully answered without it: flush 99.7 ms of which the diagnostics lint is
|
||||
21.1, so the rebuild is ~78.6 ms.
|
||||
- Measured (§R1b cells above). Zero guard kills; opentitan
|
||||
`git status --porcelain` = the three known files after every phase; load
|
||||
1.9–3.6 one-minute, inside the review's own 2.8–6.0 band.
|
||||
|
||||
|
||||
**2026-09-08 — dev (Opus), R1a.**
|
||||
|
||||
- `crates/lucisv_server/src/lint_snapshot.rs` (new): `Key` — the inputs, by
|
||||
value — and `Slot`, a `Mutex<Option<Held>>` on the `Document`. `read_or`
|
||||
answers from the slot when the key matches and otherwise computes with the
|
||||
lock released and replaces what is held. No hash anywhere: the waiver files'
|
||||
**text** is compared, not a digest, so "can this offer a stale fix?" is a
|
||||
`PartialEq` question. `Mutex` rather than `RefCell` so a `Document` stays
|
||||
`Sync` exactly as its `OnceLock` fence memo leaves it; a poisoned lock (which
|
||||
a single message loop with no panicking library code cannot produce)
|
||||
degrades to computing every time.
|
||||
- `state/mod.rs`: **one field** (`Document::lint`), its two initializers, and
|
||||
one line in `refresh_overlay` — the hook that already exists for "the index
|
||||
moved" — which clears it. That line is the whole of the index invalidation
|
||||
and is why there is no generation counter to keep in step. Four lines of
|
||||
production code in that file; it is over the size threshold already (1 063 →
|
||||
1 067 by the CLAUDE.md measure) and TODO §55 owns that.
|
||||
- `lint.rs`: one `found(doc, run)` reads the slot and both doors call it, so
|
||||
the diagnostics publish and quick-fix discovery are **one** pass. Both now
|
||||
return `Arc<[Violation]>`; `fixable` copies only when the fence filter
|
||||
actually drops something, which on a buffer with no `// lucisv: off` region
|
||||
is never. The **tab width moved onto the `LintRun`** (read through
|
||||
`format::indent_width`, whose call the dispatcher no longer makes) — without
|
||||
that the two doors would build different contexts and thrash one slot.
|
||||
Waiver files are read with `read_to_string` + `ExternalWaivers::parse`
|
||||
instead of `ExternalWaivers::read`, one read still, so the text is in hand
|
||||
for the key; the unreadable-file sentence is reproduced verbatim.
|
||||
- Found by an existing test, and worth recording: the first version let a test
|
||||
helper set `external` without the matching text, so two runs with different
|
||||
waivers shared a key. `with_external` became `with_waivers(path, text)`,
|
||||
which writes both — the invariant is now structural, and the field's doc
|
||||
comment says so.
|
||||
- Tests: 21 added, none removed (4 322 → 4 343 in the guarded workspace run).
|
||||
11 in `server/tests/lint_snapshot.rs`, one per table row through the real
|
||||
doors plus the **stale-fix attack** (a buffer edited so the span a previously
|
||||
offered fix named no longer exists — nothing is offered, and the wire answer
|
||||
is empty); 4 in `lint_snapshot.rs` (every field of the key forces a
|
||||
recompute; a waiver rewritten in place is a different key); 4 in
|
||||
`lint_trace.rs`; 2 in `lint.rs` (the tab-width ladder rung by rung, and a
|
||||
reused snapshot compared violation for violation and fix for fix against a
|
||||
fresh `lint_with`).
|
||||
- Reuse is asserted **by pointer** (`Arc::ptr_eq`), never by a stopwatch: a
|
||||
timing assertion on a lint pass is a flake.
|
||||
- Harness fix during the run: `actionprofile`'s queued rows attributed trace
|
||||
lines by position, and a definition that lints nothing logs no line, so two
|
||||
leaders were recorded as a leader and a follower. Lines are now attributed
|
||||
by their own `method` field and `result_count` says how many the follower
|
||||
logged. The `r1a-cand` `actionprofile` rows in the evidence file predate that
|
||||
fix and are superseded by `r1a-cand-2`; no number quoted anywhere came from
|
||||
the mis-attributed field (the R1b table's queued row is the leader's split,
|
||||
which is what it always was).
|
||||
- Measured (above). Zero guard kills; opentitan clean after every phase.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-08 — QA (Sonnet).**
|
||||
|
||||
Read CLAUDE.md, TODO §61.2, `docs/performance_take5_review.md` §1, this
|
||||
README in full, `perf5-p1`'s deferral memo, `semantic-lints-on`'s oracle
|
||||
handshake, and `docs/perf/take5-tracking.md`'s R1a/R1b records plus both
|
||||
experiment records, before touching anything.
|
||||
|
||||
**Gates, guarded, main tree.** `cargo fmt --all -- --check` clean.
|
||||
`cargo clippy --all-targets --workspace` clean after touching every changed
|
||||
file to defeat the incremental cache — no new `#[allow]` anywhere in the
|
||||
diff. `cargo test --workspace` (guarded, `tools/guard.sh -m 8 -t 1800`):
|
||||
**4 343 passed, 0 failed**, matching the dev's own count exactly. Cross-checked
|
||||
independently: cloned trunk `51cbfd27dfd22720856c501c9c17277460cc6a68` fresh
|
||||
into scratch (no diff), built and tested the same way — **4 322 passed, 0
|
||||
failed**. `cargo test --workspace -- --list`, name-sorted and `comm`-diffed
|
||||
between the two trees: **zero names removed, exactly 21 added**, and the 21
|
||||
match the dev's own breakdown byte for byte (11 in
|
||||
`server::tests::lint_snapshot`, 4 in `lint_snapshot::tests`, 4 in
|
||||
`lint_trace::tests`, 2 in `lint::tests`). Production line counts (non-blank,
|
||||
non-comment, up to `mod tests`): `lint.rs` 334, `dispatch.rs` 464,
|
||||
`lint_snapshot.rs` 54, `lint_trace.rs` 207 — all four numbers match what the
|
||||
dev's own measure would produce; note for whoever wrote my brief: the file
|
||||
names for the last two are transposed there (the *smaller* file is
|
||||
`lint_snapshot.rs`, holding `Key`/`Slot`, and the *larger* is `lint_trace.rs`,
|
||||
holding `Stage`/`Group`/`Trace`) — a wording slip, not a code finding.
|
||||
`state/mod.rs`: read the diff directly rather than counting — exactly one
|
||||
field (`pub lint: crate::lint_snapshot::Slot`), two initializers (`Document::new`
|
||||
and the large-file constructor), and one line in `refresh_overlay`
|
||||
(`self.lint.clear();`). All files well inside the 300–600 target; no file
|
||||
pushed over a threshold.
|
||||
|
||||
**The invalidation table, derived independently first.** Read `found`'s call
|
||||
to `lint_with` and `LintRun::context`/`LintRun::key` and listed every input
|
||||
that reaches `lint_with(ctx, rules, external)`: buffer text/tokens/tree/
|
||||
line_index/path (`context(doc)`), `options`, `line_length`, `tab_width`
|
||||
(fix text only), the oracle (`has_oracle` plus the index's own answers),
|
||||
`rules`, `external` (waiver contents), and `doc.large` (gates the whole path
|
||||
before any of this runs) — nine independent inputs, matching the table's 14
|
||||
rows exactly once the table's own splits (rows 3/11 both being "the rule
|
||||
selection", 4/5/8/12 all being "the toml", 9/10 both being "the index") are
|
||||
collapsed back to the inputs of the call. Nothing reaches `lint_with` that
|
||||
the table's rows do not name. Read `state/mod.rs`'s four index-mutating call
|
||||
sites (`publish_scan`, `finish_whole_scan`, `finish_widen`, `update_one`) in
|
||||
full: all four end in `for doc in self.docs.values_mut() { doc.refresh_overlay(&self.index); }`,
|
||||
confirming row 9's "verified by exhaustion" claim directly rather than
|
||||
trusting it. `Document` has no custom `Drop`; `lint: Slot` is dropped by the
|
||||
default field-wise drop whenever a `Document` is dropped (`didClose`, or
|
||||
replaced by `set_document`), confirming item 8's memory-bound claim.
|
||||
|
||||
**The wire matrix (a)–(l), attacked twice, independently of the dev's own
|
||||
tests.** Wrote two standalone Python scripts
|
||||
(`wire_probe.py`, `wire_probe2.py`, in the QA scratchpad) speaking real
|
||||
JSON-RPC over stdio (`Content-Length` framing) to the actual
|
||||
`--release --locked` candidate binary, against a fixture workspace this QA
|
||||
built from scratch (not the dev's fixtures, not the Rust in-process
|
||||
`Session`): a `lucisv.toml`, a waiver file, a tabbed module, and a
|
||||
`dut.sv`/`tb.sv` pair for the oracle row. Every row, all passing on the first
|
||||
clean run (after two script bugs of my own — a premature
|
||||
`take_notifications()` and a stale waiver directive shadowing a later
|
||||
section — found and fixed, noted so the evidence is legible):
|
||||
|
||||
| row | attack | result |
|
||||
|---|---|---|
|
||||
| (a) | edit the buffer | covered by (g)/(k)'s edits and the dev's own `an_edited_buffer_is_relinted` |
|
||||
| (b) | `didChangeConfiguration` toggling `lucisv.lint.ignore` twice | fresh both times |
|
||||
| (c) | `lucisv.toml` `[lint] select` rewritten on disk with **no watcher event**, twice | fresh at the very next request both times |
|
||||
| (d) | waiver file rewritten to the **same length**, different content (`--line=1` vs `--line=2`) | fresh, not stale |
|
||||
| (e) | waiver file **deleted** entirely | fresh (finding un-silenced) |
|
||||
| (f) | `tb.sv` — **never opened** — rewritten on disk, reaching `dut.sv` only through a bare `workspace/didChangeWatchedFiles` (no `didChange` anywhere) | `dut.sv`'s republished diagnostics flip `unused-signal` on, then back off when `tb.sv` mentions the signal again |
|
||||
| (g) | close, then reopen with different text | fresh |
|
||||
| (h) | a buffer over `lucisv.largeFile.threshold` | offers nothing (fast path answers before any handler) |
|
||||
| (i) | a UTF-16 fix range (`é` + a non-BMP `🎉` before the tab) on a snapshot asked for twice | the reused answer is byte-identical to the computed one; range is `character: 9` (UTF-16 units), not the byte offset |
|
||||
| (j) | `indent` in `lucisv.toml` changed between two quick-fix requests on the same open buffer | the `no-tabs` fix text changes from `" "` to `" "` at the very next request |
|
||||
| (k) | offer a fix, edit the buffer so both fixes' spans (one of them 40+ lines deep) are gone, ask again over a range that would be out-of-bounds for a stale answer | nothing offered, and the server's own view of the buffer is the post-edit text |
|
||||
| (l) | `source.fixAll.lucisv` after the buffer is edited back down to one violation | offers exactly the one-tab fresh edit, not the earlier two-tab one |
|
||||
|
||||
**Sabotage, in a fresh clone with the working diff applied
|
||||
(`scratchpad/qa-61-2/cand`), one at a time, each reverted before the next and
|
||||
confirmed clean (`git diff --stat` back to the original 341/16 insertion
|
||||
counts, `grep -rn SABOTAGE` empty):**
|
||||
|
||||
1. Stripped the waiver **text** out of `LintRun::key()` (kept the path,
|
||||
blanked the string) → `server::tests::lint_snapshot::a_rewritten_waiver_file_is_relinted`
|
||||
**FAILED** (14 passed, 1 failed), exactly the row-7 test and nothing else.
|
||||
2. Removed `self.lint.clear()` from `Document::refresh_overlay` (early
|
||||
`return` right after the `external` line) → `a_change_in_another_file_relints_this_one`
|
||||
**FAILED** (14 passed, 1 failed), exactly the row-9 test.
|
||||
3. Hard-coded `tab_width: 0` in `LintRun::key()` (context still builds with
|
||||
the real width, so the *fix* would be correct but the *key* blind to a
|
||||
change) → `a_tab_width_change_rewrites_the_fix` **FAILED** (1 passed, 1
|
||||
failed alongside the unrelated `the_runs_tab_width_is_the_formatters_own_ladder`,
|
||||
which stayed green because it never reuses a snapshot across a config
|
||||
change — consistent, not a miss).
|
||||
|
||||
All three cuts were caught by exactly the test the row predicts and no other
|
||||
test in the same run flipped. Nothing else was sabotaged (hashing the key,
|
||||
an index-generation counter, etc. — the README's own rejected-alternatives
|
||||
list — since none of those are what shipped).
|
||||
|
||||
**Trace.** Confirmed `lint_trace::arm()` is reachable only through
|
||||
`Server::request`'s `let Some(started) = self.timer() else { return … }`
|
||||
branch, and `timer()` is `self.verbose.then(Instant::now)` — so a
|
||||
non-`--verbose` session allocates nothing and logs nothing, by construction,
|
||||
not by convention. Re-ran `tools/perf/phases_r1.py::actionprofile` and
|
||||
`::ruleablation` against my own fresh `--release --locked` build of the
|
||||
candidate (sha256 `827c7ac222c8…`, byte-identical to the dev's own candidate
|
||||
binary hash — confirms the evidence file and my build are the same code) over
|
||||
the read-only OpenTitan corpus:
|
||||
|
||||
- unchanged pinmux menu 0.57–0.88 ms, queued definition 0.24–0.26 ms, first
|
||||
after a `didChange` 103.5–118.0 ms (repeat median ≈106 ms) — all inside or
|
||||
close to the dev's own range, on the same machine, at a different time of
|
||||
day.
|
||||
- the trace fields on the first-after-edit row: `trace_flush_lint=21.85ms`
|
||||
(dev: 21.1–21.9 across the two records), `trace_flush_snapshot=miss`,
|
||||
`trace_action_lint=0.00ms`, `trace_action_snapshot=hit` on **every** row
|
||||
including the first-after-edit one — the handler's own pass really is
|
||||
0.00 ms, reproduced independently.
|
||||
- `ruleablation` on the *candidate*: every row is cheap (≤~1.5 ms), which is
|
||||
the **expected** consequence of R1a and not a re-derivation of the R1b
|
||||
per-rule costs — `didChangeConfiguration` republishes every open buffer
|
||||
before the timed `codeAction` requests run, so the expensive single-rule
|
||||
pass happens during the republish and the timed request always hits. I did
|
||||
**not** rebuild a snapshot-free (`51cbfd2` + `lint_trace.rs` only, no
|
||||
`lint_snapshot.rs`) variant to re-derive the three-semantic-rules-cost
|
||||
attribution itself; that number is R1b's, marked "attribution, no
|
||||
behaviour change" in the tracker, and the flush-lint figure above (21.85 ms)
|
||||
is consistent with it. Flagged as a scope limitation, not a finding.
|
||||
|
||||
**Re-measured cells.** `snapshotrss` re-run on both my own ref and candidate
|
||||
builds (100 open buffers, quickfix-only on each, 3 tries): candidate median
|
||||
574.2 MiB (dev: 574.6), reference median 575.2 MiB (dev: 574.0) — both inside
|
||||
noise of the dev's own numbers and confirming the "+0.1%, no higher retained
|
||||
memory" gate independently. `codeAction`-family latency reproduced via
|
||||
`actionprofile` above; did not separately re-run `offerkinds`/`offerqueue`/
|
||||
`offeredit`/`diagnostics`/`didopen` as their own named phases (time budget) —
|
||||
`actionprofile`'s four request shapes at the same three cursors cover the
|
||||
same underlying behaviour (unchanged menu, quickfix-only, queued definition,
|
||||
first-after-edit) those phases measure. Also a scope limitation, not a
|
||||
finding.
|
||||
|
||||
**Traceability.** Pulled `~/.cache/lucisv-perf/take5r-2/results.jsonl` and
|
||||
checked all 12 numbers named in the tracker's R1a/R1b rows and experiment
|
||||
records: `22.61, 24.51, 22.39/22.38, 0.98, 0.11, 0.78/0.76, 574.0, 574.6,
|
||||
162.29, 162.75` match raw sample values in the file to within 0.005; `125.65`
|
||||
and `106.89` are not raw samples but are exactly the median of the *last two*
|
||||
of the three `ms` samples for the reference and candidate "first offer after
|
||||
`didChange`" rows respectively (`128.96` was the first, so 125.65 = median of
|
||||
127.76/123.54; `106.07` was the first, so 106.89 = median of 108.64/105.14) —
|
||||
consistent with the tracker's own "first / repeat median" convention, not a
|
||||
fabricated number. Same check for `574.0`/`574.6`: exact medians of the three
|
||||
100-buffer `rss_kib` samples in the file.
|
||||
|
||||
**Guard / opentitan / cleanup.** Every cargo invocation (fmt, clippy, test ×3
|
||||
trees, `-- --list` ×2 trees) and every perf phase (`actionprofile`,
|
||||
`ruleablation`, `snapshotrss` ×2 binaries) ran through
|
||||
`tools/guard.sh -m 8 -t 1800`; zero guard kills. `git -C
|
||||
/Users/guoliangchen/repo/opentitan status --porcelain` checked before, during
|
||||
and after every phase: the same three pre-existing files
|
||||
(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
|
||||
`hw/top_earlgrey/ip/ast/rtl/ast.sv`), nothing else, every time. All sabotage
|
||||
was done in `scratchpad/qa-61-2/cand`, a fresh clone with the working diff
|
||||
applied; the main tree was never `git checkout`/`reset`/`stash`/`clean`ed and
|
||||
nothing outside this README's QA log and the TODO line below was edited. No
|
||||
background loop or server process left running at the end of this session
|
||||
(checked `ps aux` — only a pre-existing, unrelated VS Code extension server
|
||||
survives).
|
||||
|
||||
**Verdict: PASS.** No stale diagnostic or fix found or produced under any of
|
||||
the 14 table rows, over the real wire, on a fixture this QA built
|
||||
independently, with three targeted sabotage cuts each caught by exactly one
|
||||
predicted test. Gates green and cross-checked against a from-scratch clone of
|
||||
`51cbfd2` with matching binary hashes; test count +21/-0 confirmed by name,
|
||||
not just by count. Two scope limitations disclosed above (no snapshot-free
|
||||
rebuild for the R1b per-rule ablation; five perf-phase names not re-run under
|
||||
their own headings) are attribution/measurement gaps, not correctness gaps,
|
||||
and do not change the verdict.
|
||||
|
||||
**Topo edges for the lead to apply at merge** (from this README's own
|
||||
Handshakes section, confirmed absent from `docs/topo.md` today): `lint.rs
|
||||
──▶ lint_snapshot.rs`, `lint.rs ──▶ lint_trace.rs`, `state/mod.rs ──▶
|
||||
lint_snapshot.rs` (the field), and the `server-lint ◀──▶ diagnostics` edge
|
||||
amended to say the two doors now share one computed result. The
|
||||
`format::indent_width_of(&FileConfig, …)` request to `crate::format`'s owner
|
||||
is still open and unclaimed by this round; it is a 0.11 ms/request cost, not
|
||||
a correctness issue.
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-08 (lead).** Accepted. Read `lint_snapshot.rs`, the `state/`
|
||||
hunks (one field, two initializers, one clear in `refresh_overlay`), the
|
||||
`lint.rs` door, the invalidation table and both logs; QA's independent
|
||||
derivation of the input list and its wire matrix through a real client
|
||||
are the acceptance.
|
||||
|
||||
- R1b answered the review's question before anything was built: the
|
||||
23 ms is three semantic rules over a 42k-line file, and the 136 ms
|
||||
first-after-edit is the flush (one parse of 1.3 MB plus the
|
||||
diagnostics pass) with the handler's second pass on top. That is why
|
||||
the snapshot is shaped as one pass per revision shared by both doors.
|
||||
- The key is the design: every input of `lint_with` by value — waiver
|
||||
*contents*, not an mtime, because nothing watches them — and identity
|
||||
for what identity settles (the `Document`, and the index through the
|
||||
overlay refresh every mutation ends in, checked by exhaustion by dev,
|
||||
QA and me). No hash, no generation counter, no map: a stale fix is a
|
||||
question about `PartialEq`.
|
||||
- Gates met by an order of magnitude (menu 22.6 → 1.0 ms, queued
|
||||
definition 22.4 → 0.8) with the publish and memory unchanged. The
|
||||
first-after-edit residue is the parse of the buffer, named, not this
|
||||
lane's.
|
||||
- The config-discovery memo was correctly refused: 0.04 ms of I/O that
|
||||
is the only thing noticing an unwatched `lucisv.toml` change.
|
||||
- Deviations accepted: the flush traced as one stage; the indent-width
|
||||
read moved into the run (+0.1 ms on publish) with the
|
||||
`format::indent_width(FileConfig)` request filed.
|
||||
|
||||
Docs applied at merge: topo (the snapshot and trace modules, the
|
||||
diagnostics/quick-fix shared result, the parsed `timing: codeaction`
|
||||
line); the `format::indent_width` request to the loop-3 list.
|
||||
@@ -0,0 +1,609 @@
|
||||
# perf5r-preflight — engine-owned refusal preflights
|
||||
|
||||
Take 5 **review** round (`docs/performance_take5_review.md` §3 items 5–6),
|
||||
TODO §61.1, tracker rows **R3a** and the refused-extraction half of **R3c**.
|
||||
Baseline is 0.51.0.
|
||||
|
||||
## Goal
|
||||
|
||||
Two refactorings refuse a request only after materializing and analyzing a
|
||||
workspace they never needed. A `textDocument/rename` on a cursor that sits on
|
||||
no symbol reads all **3 976** in-scope files, performs **3 975 whole-file
|
||||
parses** and spends **1.9 s** building a scope, so that `locate` can refuse in
|
||||
**0.1 ms** from the request buffer's own analysis — 2 192 ms on the wire for a
|
||||
sentence the buffer could have said immediately. An extraction at the review's
|
||||
`aes_wrap.sv` inline site spends **805 ms** building a scope before the checks
|
||||
that refuse it.
|
||||
|
||||
For the rename this lane adds one **additive** function to `vlog_refactor`,
|
||||
`rename_preflight`, which takes — from the request file alone and in the slow
|
||||
road's own order — the refusals the slow road is *certain* to reach in the same
|
||||
words. The server calls it before it selects or analyzes anything, and
|
||||
materializes nothing when it refuses. **Result: 2 012 → 0.3 ms, 3 975 → 0
|
||||
parses.**
|
||||
|
||||
For the extraction the answer is a measured **negative**, and no code shipped.
|
||||
An extract preflight was written, wired and measured, and then removed: every
|
||||
refusal it could take is *already* taken before a scope is built, by two
|
||||
mechanisms that were both already there. The 805 ms refusal is none of them.
|
||||
The evidence is below; this is the review's "instrument first, then decide"
|
||||
answered honestly rather than with code that changes nothing.
|
||||
|
||||
The refusals stay the engine's. That is the review's own condition ("put any
|
||||
cheap preflight in the refactor engine so the server does not become a second
|
||||
authority on what is safe") and it is also the only way the sentences can be
|
||||
guaranteed identical: each one is a single function in `rename/mod.rs` that
|
||||
both roads call.
|
||||
|
||||
**What must not move:** the sentences, their order, the successful edits and
|
||||
their fingerprints, and the warnings. A faster refusal that refuses something
|
||||
else is a failure, and so is a refusal invented for a rename the workspace
|
||||
would have performed.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **A buffer's `Semantics` is a pure function of its text.** `analyze(&tree,
|
||||
text)` consults no index and no other file, and both roads reach it the same
|
||||
way: the server's `Document::new` calls `analyze` directly, and the scope's
|
||||
`FileFacts::analyzed` calls it through `analyzed_facts`. So the request
|
||||
file's analysis inside a `Scope` and the open buffer's analysis are the same
|
||||
value, and every refusal read off one is the refusal that would be read off
|
||||
the other. *Not enforced by a type* — asserted at every byte of seven
|
||||
fixtures by the oracle below.
|
||||
- **The request file is always among the files the caller hands the engine.**
|
||||
`Scope::locate` refuses a file it was not given *before* it looks at the
|
||||
cursor, so a preflight that jumped that check would reorder the refusals.
|
||||
Both rename selectors put every open buffer in the set. Stated as a
|
||||
precondition in the preflight's doc comment and pinned by
|
||||
`the_preflights_refusal_is_the_whole_workspaces_refusal`.
|
||||
- **A large-file buffer never reaches the rename preflight.** On the fast path
|
||||
every field but the text is the analysis of the *empty* file, so a preflight
|
||||
over it would refuse every cursor as symbolless. `server/large_file.rs`
|
||||
answers `textDocument/rename` with `TOO_LARGE` before this module is
|
||||
reached; `a_large_buffer_is_refused_before_the_preflight_could_see_it` pins
|
||||
both halves of that — the gate, and the fact that the preflight would
|
||||
otherwise be wrong, so the test fails loudly if the gate is ever moved.
|
||||
- **The workspace index is not current with respect to unsaved edits.** See
|
||||
the duplicate-declaration decision below; this is the load-bearing
|
||||
assumption of the whole lane, and it is the reason two refusals stayed on the
|
||||
slow road.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**Consumed.**
|
||||
|
||||
- `vlog_semantic::Semantics` — `reference_id_at`, `reference`, `symbol_at`,
|
||||
`symbol`, `file_scope`, and `Resolution`'s four variants. The preflight reads
|
||||
exactly the fields `Scope::locate` reads, and nothing else.
|
||||
- `crate::state::Document`'s `semantics` — read, never written.
|
||||
|
||||
**Promised.**
|
||||
|
||||
- `vlog_refactor::rename_preflight(semantics, offset, new_name) -> Result<(),
|
||||
String>`. **Additive**: no existing signature changed, no existing behaviour
|
||||
changed, and `Ok(())` means "proceed exactly as before" — never "this rename
|
||||
will succeed". It is the only new public item in the crate; the extraction
|
||||
gained none.
|
||||
- Every refusal the preflight makes is byte-identical to the one `rename` makes
|
||||
for the same request. This is the contract; the oracle is its proof.
|
||||
- The `--verbose` `timing: rename trace` line is still written for a rename
|
||||
the preflight refuses, with `selected=0`, `parses=0` and a new
|
||||
`preflight=true` field. `tools/perf/phases_p2.py` reads that line by regex
|
||||
and flattens every `key=value` into a row field, so the new field arrives as
|
||||
`preflight` with no harness change.
|
||||
|
||||
**Requested of others: none.** No file outside this lane's list was touched.
|
||||
|
||||
**Amended for `docs/topo.md` (lead to apply).** §1.2's request-selector parity
|
||||
gains a third participant. Today it reads that `prepare_rename_here` must
|
||||
produce the same answer or refusal text as whole-scope `prepare_rename`. It
|
||||
should now also record that `rename_preflight` must produce the same *refusal*
|
||||
text as whole-scope `rename` — a one-directional obligation, since the
|
||||
preflight may always stand aside — and that the two cheap paths are
|
||||
deliberately **not** the same set: `prepare_rename_here` reads the index and
|
||||
`rename_preflight` does not. The reason is in "the duplicate-declaration
|
||||
decision" below.
|
||||
|
||||
## The duplicate-declaration decision — evidence, and the answer
|
||||
|
||||
TODO §61.1 asks whether the ambiguous-declaration refusal (`rstmgr_por`,
|
||||
2 200 ms) may move ahead of materialization "ONLY with the evidence the review
|
||||
asks for: the index is current and authoritative for that name".
|
||||
|
||||
**It is not, and the refusal stays on the slow road.** The evidence:
|
||||
|
||||
1. `state/mod.rs::set_document` (line 695) — the handler for every `didOpen`
|
||||
and `didChange` — *reads* `self.index` to build the new `Document`'s
|
||||
external overlay and never writes it. The index is written only by
|
||||
`absorb`, at scan publication and on the `didSave` rebuild. So an unsaved
|
||||
buffer that adds or removes a file-scope declaration of a name is a buffer
|
||||
whose `index.units(name).len()` is stale, in both directions.
|
||||
2. `docs/features/refactor-rename/README.md` already states this exact
|
||||
divergence ("The one divergence, stated exactly") for
|
||||
`prepare_rename_here`, and resolves it by naming the authority: *"`rename`
|
||||
re-derives the count from the current texts and is the authority."*
|
||||
3. So the two callers are not symmetric, and the asymmetry is the whole point.
|
||||
An optimistic `prepareRename` that is wrong is LSP-legal and self-correcting
|
||||
— the rename that follows delivers the real answer. A `rename` that is wrong
|
||||
is terminal: the user is told a name is declared twice, and there is no
|
||||
later road to say otherwise. Moving this refusal forward would trade a
|
||||
correct 2 200 ms answer for a possibly-wrong 15 ms one.
|
||||
4. The ports offer's `declared_twice` (`ports.rs:338`) does trust the index,
|
||||
and that is consistent rather than contradictory: a wrong *offer* costs a
|
||||
lightbulb that should or should not have appeared, and the command behind it
|
||||
still asks the engine. A wrong *refusal* costs the work itself.
|
||||
|
||||
The same argument disposes of the two cross-file cursor refusals — a use whose
|
||||
declaration the index answers ambiguously, and one it cannot answer at all
|
||||
(`ExternalTarget::Ambiguous` / `StillUnresolved`). Both are the index's word,
|
||||
so `rename_preflight` stands aside for every `Resolution::ExternalCandidate`
|
||||
and for every declaration at file scope.
|
||||
`a_name_declared_in_two_files_stays_on_the_slow_road` asserts the deferral
|
||||
rather than merely permitting it, so a later round cannot quietly take it.
|
||||
|
||||
The cost of the decision is stated plainly: **`rstmgr_por` keeps its 2 200 ms**,
|
||||
and so does `cipher_alert → clk_i` at 2 884 ms, whose "meaning would change"
|
||||
refusal is `check::verify`'s and needs the edit computed over the real scope.
|
||||
|
||||
## What the preflight takes, and what it leaves
|
||||
|
||||
### `rename_preflight` — `crates/vlog_refactor/src/rename/preflight.rs`
|
||||
|
||||
In `renaming`'s order. Rule numbers are
|
||||
`docs/features/refactor-rename/README.md`'s refusal list.
|
||||
|
||||
| Rule | Refusal | Taken? | Why |
|
||||
|---|---|---|---|
|
||||
| 1 | new name empty / not an identifier / a keyword | **taken** | `check_new_name` is a pure function of the new name, and is `renaming`'s own first statement |
|
||||
| 3 | *"… is not one of the files lucisv indexes …"* | n/a | unreachable: both selectors contain the request buffer (precondition above) |
|
||||
| 4 | *"there is no symbol to rename at this position."* | **taken** | `reference_id_at` and `symbol_at` on the buffer — the 2 192 ms row |
|
||||
| 5 | *"… is not resolved to any declaration …"* | **taken** | `Resolution::NotFound` is single-file resolution |
|
||||
| 6 | *"… could only come from the base class `B` …"* | **taken** | `Resolution::InheritedCandidate`, same |
|
||||
| 7 | *"… is declared outside the files lucisv indexes …"* | deferred | the index's word |
|
||||
| 8 | *"… is declared in more than one indexed file …"* (from a use) | deferred | the index's word |
|
||||
| 9 | the same sentence, from a file-scope declaration | deferred | the index's word — the decision above |
|
||||
| 11a | *"lucisv cannot find where `x` is spelled …"*, declaration in this buffer | **taken** | empty `name_span`, read here |
|
||||
| 11b | the same, declaration elsewhere | deferred | needs that file's text |
|
||||
| 2 | *"`x` is the name it already has."* | **taken, narrowly** | only for a declaration in this buffer that is **not** at file scope, where nothing stands between the cursor and this check. At file scope rule 9 comes first, so it is deferred |
|
||||
| 10, 12, 13 | ambiguous use onto this declaration, capture, token drift | deferred | all need the edit computed over the scope |
|
||||
|
||||
Note rule 2's narrowing: taking it unconditionally would let a same-name
|
||||
refusal jump ahead of rule 9's ambiguity check and change which sentence the
|
||||
user sees.
|
||||
`renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer`
|
||||
pins both halves — taken for a net, deferred for a module.
|
||||
### The extraction — a preflight was written, measured, and removed
|
||||
|
||||
The same preflight was built for `extract_module`: `plain_identifier`, the
|
||||
occupied-target check, the request file's parse-diagnostic refusal, and every
|
||||
refusal `Region::read` knows, stopping before `declared_once`. It was wired
|
||||
into `extract::execute` ahead of `Scope::build`, measured, and then **deleted**,
|
||||
because every one of those refusals is already reached before a scope exists:
|
||||
|
||||
1. **`site_at` is `extract_site_in`.** `execute` calls it as its own gate,
|
||||
before `module_sources` and before the engine. Its first two statements are
|
||||
`if !diagnostics.is_empty() { return None }` and
|
||||
`Region::read(tree, text, …).ok()?`. So a buffer that does not parse and
|
||||
every selection-shape refusal are answered by the server with `NOTHING`, and
|
||||
**cannot reach `Extraction::plan` at all** — the preflight's parse check and
|
||||
its `Region::read` were provably dead on the only caller.
|
||||
2. **`plain_identifier` and the occupied check are already `extract_module`'s
|
||||
first two statements**, ahead of `Extraction::plan` and therefore ahead of
|
||||
`Scope::build`. Moving them earlier moves nothing.
|
||||
|
||||
Measured, at the 805 ms site itself (`extractrefuse`, both cases below):
|
||||
|
||||
| Row | 0.51.0 | with preflight | Where it is refused |
|
||||
|---|---:|---:|---|
|
||||
| new name is not an identifier | 9.3 ms | 9.8 ms | `extract_module`'s first statement, in **both** |
|
||||
| selection covers no whole item | 0.22 ms | 0.13 ms | the server's `site_at` gate, in **both** |
|
||||
|
||||
Both sub-noise, both refused pre-scope in the reference already. The preflight
|
||||
bought nothing, so it is not in the tree: shipping it would have been ~130
|
||||
lines of engine code, a new public API and a second copy of two checks, in
|
||||
exchange for zero measured work. `crates/lucisv_server/src/extract.rs` carries
|
||||
a comment at the point where it would have gone, saying why there is nothing
|
||||
there — so the next round does not rediscover this.
|
||||
|
||||
What **did** stay from the exercise: `extract::does_not_parse`, the refusal
|
||||
sentence lifted out of `Extraction::plan` into the block where
|
||||
`extract/mod.rs` keeps its other refusal sentences (`occupied`,
|
||||
`not_in_scope`, `escaped`), and three server tests that pin where each cheap
|
||||
extract refusal is actually taken.
|
||||
|
||||
## What the `aes_wrap.sv` 805 ms refusal turned out to be
|
||||
|
||||
Identified from the review's own evidence without a run
|
||||
(`docs/perf/take5-review-20260908/results.jsonl`, the `inline-module: lucisv:
|
||||
extract selection into module…` row), then confirmed by the paired rerun. Its
|
||||
message is:
|
||||
|
||||
> the selection drives `h2d_intg`, and something outside it passes the same
|
||||
> name to a task or function, which may drive it too; lucisv will not make it
|
||||
> an output over that.
|
||||
|
||||
That sentence is `extract/boundary.rs:196`, inside `Crossing::read` — the
|
||||
**last** stage of `plan` before rendering. `Crossing::read` needs `flow`, and
|
||||
`flow::read(&scope, …)` walks the module's items *through the scope*, because
|
||||
giving an instance-port connection its direction means reading the instantiated
|
||||
module's own file. So the refusal is **scope-dependent at depth**, not
|
||||
region-local, and no bounded preflight reaches it.
|
||||
|
||||
Measured unchanged, as predicted: **761.1 → 767.8 ms** (+0.9%, within the
|
||||
session's noise), identical sentence.
|
||||
|
||||
What a future round could take is named instead, since the review asked for it:
|
||||
the directions `flow` wants are port facts the workspace index already holds,
|
||||
so the lever is not a preflight but the scope-reuse work already filed as
|
||||
§61.5 (R3b/R3c). Recorded as a finding and **not attempted here** — the
|
||||
review's instruction was to instrument first and "do not implement beyond the
|
||||
region-local checks without the evidence", and the evidence says the
|
||||
region-local checks were already free.
|
||||
## Status / TODO
|
||||
|
||||
- [x] `rename_preflight`, additive, engine-owned, in `renaming`'s order
|
||||
- [x] the server calls it before selecting sources; nothing materializes on a
|
||||
refusal; the sentence goes back unchanged
|
||||
- [x] the duplicate-declaration question answered **with evidence** — deferred,
|
||||
argument recorded above
|
||||
- [x] extract: the region-local checks confirmed to run before `Scope::build`
|
||||
**already**, by `site_at` and by `extract_module`'s own prefix; a
|
||||
preflight was written, measured and removed as redundant
|
||||
- [x] the equality oracle: every byte of seven fixtures × six new names
|
||||
- [x] the parse-count proof: a no-symbol rename performs **zero** whole-file
|
||||
parses, asserted in a test and read off the wire trace
|
||||
- [x] the `aes_wrap.sv` refusal identified, its stage named, measured unchanged
|
||||
- [x] measured against 0.51.0; R3a and R3c cells filled
|
||||
|
||||
## Measurements — 0.51.0 vs candidate
|
||||
|
||||
Paired, `~/.cache/lucisv-perf/take5r-1/`. Repeat medians (`ms[1:]`), three
|
||||
repeats after a first. Reference and candidate order alternated between
|
||||
phases; load 1.7–4.8 throughout, inside the review's own 2.82–6.00 band.
|
||||
|
||||
| Phase / row | 0.51.0 | candidate | Δ | parses | peak RSS |
|
||||
|---|---:|---:|---:|---|---|
|
||||
| renametrace **no symbol** | 2 012.3 ms | **0.3 ms** | **−100.0%** | **3 975 → 0** | 909 → 429 MiB |
|
||||
| renametrace duplicate module `rstmgr_por` | 2 012.6 | 2 032.0 | +1.0% | 3 975 → 3 975 | 910 → 914 MiB |
|
||||
| renametrace common port `clk_i` | 3 242.4 | 3 252.7 | +0.3% | 3 977 → 3 977 | 1 827 → 1 826 MiB |
|
||||
| renametrace `cipher_alert → clk_i` | 2 626.4 | 2 730.1 | +3.9% | unchanged | 1 609 → 1 610 MiB |
|
||||
| renametrace conflict `state_q → state_d` | 305.9 | 319.3 | +4.4% | unchanged | 530 → 539 MiB |
|
||||
| renametrace tail `state_q` | 367.3 | 365.0 | −0.6% | unchanged | 611 → 659 MiB |
|
||||
| renametrace ordinary `aes` | 84.9 | 85.2 | +0.4% | unchanged | 454 → 455 MiB |
|
||||
| renametrace unique internal `cipher_alert` | 15.5 | 17.2 | +11.0% | unchanged | 434 → 433 MiB |
|
||||
| tailrename | 376.3 | 377.4 | +0.3% | — | — |
|
||||
| rename `aes → aes_renamed` | 87.6 | 88.1 | +0.6% | — | — |
|
||||
| rename prepareRename | 0.11 | 0.17 | sub-ms, not read | — | — |
|
||||
| execute extract capture (`aes.sv`) | 143.5 | 143.3 | −0.1% | — | — |
|
||||
| execute **extract refusal** (`aes_wrap.sv`) | 761.1 | 767.8 | +0.9% | — | — |
|
||||
| execute inline refusal | 5.79 | 5.85 | +1.0% | — | — |
|
||||
| refactor extract offer | 0.81 | 0.80 | −1.2% | — | — |
|
||||
| extractrefuse bad name | 9.3 | 9.8 | already pre-scope | — | — |
|
||||
| extractrefuse partial selection | 0.22 | 0.13 | refused by `site_at` in both | — | — |
|
||||
|
||||
**Gates.** R3a's gate — *"≤16 ms; zero closed-workspace parses; exact
|
||||
refusal/precedence"* — is **met on all three counts**: 0.3 ms (53× inside the
|
||||
bound), `trace_parses` 0 and `trace_selected` 0 read off the wire, and the
|
||||
refusal string byte-identical. The duplicate-module refusal was **not** shipped
|
||||
and its row is unchanged, as the decision above requires. The extract refusal's
|
||||
before/after is reported with its stage named and is **unchanged**, which is
|
||||
the honest reading of R3c's extract half.
|
||||
|
||||
**Parity.** Every fingerprint identical: tail `b39defb21265…`, `aes`
|
||||
`fa7e31c78382…`, `clk_i` `31aadc134628…`, `cipher_alert` `5f53e977da59…`,
|
||||
extraction `090e92e7736e…`. Every refusal message identical (checked
|
||||
programmatically, not by eye). Corpus `git status --porcelain` = the same three
|
||||
pre-existing files after every one of the 12 phase invocations. **No guard
|
||||
kill.**
|
||||
|
||||
**Variability.** The +3.9% and +4.4% rows are single-session medians on a
|
||||
desktop machine and are within the band the review itself declines to read;
|
||||
+11.0% is on a 15.5 ms row (1.7 ms). None is a claimed movement, and none is
|
||||
adjusted.
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-09-08 — dev (Opus).**
|
||||
|
||||
- Read the code before designing. Three findings changed the plan the brief
|
||||
proposed:
|
||||
1. **The brief's premise that `set_document` updates the index is wrong** —
|
||||
it reads the index and does not touch it (`state/mod.rs:695`). That
|
||||
inverted the duplicate-declaration answer from "probably yes" to a
|
||||
documented no, argued above.
|
||||
2. **`new_name == module` is not the last region-local check in `plan`** —
|
||||
`declared_once` and `undeclared` precede it. It could not go in a
|
||||
preflight without reordering two refusals.
|
||||
3. **The `aes_wrap.sv` refusal is `Crossing::read`'s**, four stages past
|
||||
anything a region-local preflight can reach. Identified from the review's
|
||||
preserved `results.jsonl` message rather than by a run, which cost nothing
|
||||
and settled the design before any code was written.
|
||||
- **Signature deviation, rename.** The brief proposed `rename_preflight(semantics,
|
||||
external, index, offset, new_name)`. Shipped without `external` and `index`:
|
||||
every refusal those two could answer is one the staleness argument forbids
|
||||
taking, so both parameters would have been unused — and carrying them would
|
||||
have implied the preflight consults the index, which is exactly the thing it
|
||||
must not do. `prepare_rename_here` keeps them, because an optimistic
|
||||
`prepareRename` is allowed to.
|
||||
- **The extract preflight was built, then removed.** It was written to the
|
||||
brief (taking `files` rather than a server-computed `occupied` bool, so the
|
||||
occupied question stayed the engine's), wired into `execute` ahead of
|
||||
`Scope::build`, and covered by eight oracle tests. Measuring it is what
|
||||
killed it: `tools/perf/phases_r3.py` was added to time the refusals it takes
|
||||
at the 805 ms site, and both came back unchanged — because `site_at` **is**
|
||||
`extract_site_in`, whose first two statements are the parse-diagnostic check
|
||||
and `Region::read`, and because `plain_identifier` and the occupied check
|
||||
were already `extract_module`'s own first statements. Removed rather than
|
||||
shipped: ~130 lines of engine code and a new public API for zero measured
|
||||
work is exactly the abstraction CLAUDE.md says to stop building. The reason
|
||||
is now a comment at the call site so it is not rediscovered.
|
||||
- **A refusal now traces too.** `rename_traced` writes its `timing:` line on
|
||||
the preflight path with `selected=0 parses=0 preflight=true`, so the
|
||||
measurement reads the parse count off the wire instead of trusting it. No
|
||||
change to `rename_trace.rs` was needed — `SelectionTrace` already derives
|
||||
`Default`, and `whole_scope` was the wrong shape (it sets `fallback=true`,
|
||||
which would have been a lie).
|
||||
- One incidental tidy kept: `extract::does_not_parse`, the parse refusal's
|
||||
sentence moved out of `Extraction::plan` into the block where
|
||||
`extract/mod.rs` already keeps `occupied`, `not_in_scope` and `escaped`.
|
||||
Behaviour identical; it is the only surviving trace of the removed preflight
|
||||
in that file.
|
||||
- Tests: `crates/vlog_refactor/tests/preflight_oracle.rs` (10), 4 added in
|
||||
`lucisv_server/src/rename.rs`, 3 in `lucisv_server/src/extract.rs` (kept
|
||||
after the removal — they pin *where* each cheap extract refusal is taken,
|
||||
which is the finding). The oracle counts deferrals rather than asserting them
|
||||
away, and a fixture that stops producing the shape it was written for fails
|
||||
loudly: `an_unresolved_and_an_inherited_reference_keep_their_own_sentences`
|
||||
sweeps for its two sentences instead of being told their offsets, because
|
||||
the first draft guessed an offset and was wrong.
|
||||
- Harness: `tools/perf/phases_r3.py` (new, phase `extractrefuse`) and one
|
||||
import line in `tools/perf/bench.py`. It is kept even though its answer was
|
||||
negative — the two rows are what make "the extract refusals are already
|
||||
pre-scope" a measurement rather than a claim.
|
||||
- File sizes after the change: `rename/mod.rs` 549, `rename/preflight.rs` 84,
|
||||
`extract/mod.rs` 535 — all under 600. The rename preflight went in a module
|
||||
of its own because `rename/mod.rs` was already within 60 lines of the mark.
|
||||
- Gates: `cargo fmt` clean; guarded `cargo clippy --all-targets` clean with no
|
||||
new `#[allow]`; guarded `cargo test --workspace` **4 322 passed, 0 failed**,
|
||||
exit 0, no guard kill. Zero tests removed (`git diff` shows no deleted
|
||||
`#[test]` in a tracked file), 17 added. (Corrected from "4 328" by QA —
|
||||
see QA log: a clean guarded run on this exact tree counts 4 322, matching
|
||||
a same-tree baseline of 4 305 plus the 17 added exactly.)
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-08 — QA (Sonnet).** Verdict: **PASS.** Method: read `renaming` /
|
||||
`Scope::locate` / `Scope::declaration` / `Scope::declaration_across_files`
|
||||
(`rename/mod.rs`) side by side with `rename_preflight` / `declared_here`
|
||||
(`rename/preflight.rs`) and built the rule table below independently before
|
||||
reading the dev's own table, then attacked the oracle with sabotage in a
|
||||
throwaway clone, ran the gates guarded on the main tree, and re-ran the real
|
||||
`lucisv-server` over the wire (fresh sessions, my own storage dir, no reuse of
|
||||
the dev's cached results except for cross-referencing) against OpenTitan and
|
||||
read the wire traces.
|
||||
|
||||
**1. Gates, guarded, main tree.**
|
||||
`cargo fmt --all -- --check`: clean. `cargo clippy --all-targets`: clean, zero
|
||||
new `#[allow]` (`git diff HEAD | grep '#\[allow'` finds none in changed code).
|
||||
`cargo test --workspace` (guarded, `tools/guard.sh -m 8 -t 1800`): **4 322
|
||||
passed, 0 failed**, no guard kill. Cross-checked against a clone of `e13ae4c`
|
||||
with *no* diff applied, same guard, same machine window: **4 305 passed, 0
|
||||
failed**. 4 322 − 4 305 = **17**, matching the diff's added-test count exactly
|
||||
(`git diff HEAD | grep -c '^+.*#\[test\]'` → 7 in tracked files, plus the 10 in
|
||||
the new `preflight_oracle.rs` = 17; `git diff HEAD | grep -c '^-.*#\[test\]'` →
|
||||
0). **Nothing lost, nothing invented.** Found and fixed a documentation slip:
|
||||
the work log's "4 328 passed" does not reproduce on this tree in either of two
|
||||
independent guarded runs (main tree and a fresh clone); corrected above to
|
||||
4 322 with the arithmetic that supports it. Production line counts of
|
||||
changed/new files (non-blank, non-line-comment): `rename/mod.rs` 400 (551
|
||||
total), `rename/preflight.rs` 31 (84 total), `extract/mod.rs` 396 (539 total)
|
||||
— all comfortably under the 600-line mark by either counting convention; the
|
||||
dev's own 549/84/535 use the total-lines-minus-tests convention CLAUDE.md's
|
||||
own history entries use, and agree.
|
||||
|
||||
**2. The precedence contract — rule table, built independently.**
|
||||
|
||||
Read top to bottom: `renaming` calls `check_new_name` (rule 1) before
|
||||
`Scope::build_keeping` (the whole-workspace materialization this lane exists
|
||||
to skip), then `scope.locate` (rules 3–9, 11), then — *after* `locate`
|
||||
returns `Ok` — the same-name check (rule 2), then `collect_edits`/`verify`
|
||||
(rules 10, 12, 13). `Scope::declaration` (reached from both a same-file symbol
|
||||
and a cross-file `declaration_across_files`) checks `name_span.is_empty()`
|
||||
(rule 11) **before** `at_file_scope && index.units(name).len() > 1` (rule 9)
|
||||
— that specific order is the whole reason rule 2's preflight narrowing is
|
||||
sound only for non-file-scope declarations.
|
||||
|
||||
| Rule | Refusal | Preflight takes it? | Can preflight's answer differ from `renaming`'s for the same request? |
|
||||
|---|---|---|---|
|
||||
| 1 | invalid new name | yes (`check_new_name`, byte-identical shared fn) | no — same function, same first statement in both roads |
|
||||
| 3 | file not in scope | n/a, unreachable (precondition: request buffer always in both selectors' file sets) | no |
|
||||
| 4 | no symbol here | yes (`reference_id_at`/`symbol_at` on the buffer) | no — same `Semantics`, pure fn of buffer text |
|
||||
| 5 | unresolved reference | yes (`Resolution::NotFound`) | no — single-file resolution, same `Semantics` |
|
||||
| 6 | inherited-candidate reference | yes (`Resolution::InheritedCandidate`) | no — resolved entirely within the buffer's own analysis regardless of which file the base class lives in |
|
||||
| 7, 8 | external candidate: unresolved / ambiguous (from a use) | deferred (`Ok(())` for every `ExternalCandidate`) | n/a — never taken, so never differs |
|
||||
| 9 | file-scope declaration, ambiguous in index | deferred (`declared_here` returns `Ok(())` when `scope == file_scope`, **before** the same-name check) | n/a |
|
||||
| 11a | empty `name_span`, declaration in this buffer | yes, and correctly checked **before** the file-scope test, exactly matching `Scope::declaration`'s order — so it is taken even for a file-scope declaration | no |
|
||||
| 11b | empty `name_span`, declaration elsewhere | deferred (preflight never resolves cross-file) | n/a |
|
||||
| 2 | same name as new name | yes, **only** when `scope != file_scope` (checked after 11a, after the file-scope deferral) | no for the cases it takes; for a file-scope same-name it correctly stands aside so rule 9 keeps precedence on the slow road |
|
||||
| 10, 12, 13 | ambiguous-onto/capture/token drift | deferred (need computed edits) | n/a |
|
||||
|
||||
This matches `docs/features/perf5r-preflight/README.md`'s own table exactly,
|
||||
built before I read it. The one place a bug could hide — rule 11a's precedence
|
||||
over rule 9 for a file-scope declaration — is real and correctly ordered in
|
||||
both `declared_here` and `Scope::declaration`; confirmed by reading, not
|
||||
assumed.
|
||||
|
||||
**3. Wire matrix, a–j.** Both a hostile-fixture sweep (the oracle, byte-by-byte)
|
||||
and real OpenTitan sessions over the wire (fresh `lucisv-server` process, my
|
||||
own `--storage`, none of the dev's cached results reused for this half):
|
||||
|
||||
| Case | Verified how | Old vs new |
|
||||
|---|---|---|
|
||||
| (a) invalid name (`1abc`,`wire`,`a b`,empty) at no-symbol cursor | `an_invalid_new_name_outranks_every_cursor_refusal` (oracle) + `the_preflight_does_not_disturb_the_refusal_order` (server) | identical — name's sentence wins, rule 1 before rule 4 |
|
||||
| (b) comment/string/whitespace/macro-arg/`` `define``/keyword cursor | oracle's `PROSE`/`GEN` fixtures swept at every byte; `the_preflights_refusal_is_the_whole_workspaces_refusal` pins the `module` keyword explicitly | identical, `NOTHING_HERE` in both roads |
|
||||
| (c) unresolved reference | `an_unresolved_and_an_inherited_reference_keep_their_own_sentences`, swept for the sentence rather than told an offset | identical |
|
||||
| (d) inherited-candidate via `extends` (base in another file) | same test/fixture (`STRAY`); confirmed by reading that `Resolution::InheritedCandidate` is settled entirely inside the request buffer's own analysis regardless of which file the base lives in — the resolution *type* itself already encodes "unresolved candidate", not "resolved to a symbol in file X" | identical |
|
||||
| (e) same-name at non-file-scope (local net) vs file-scope (module) | `renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer` — pins **both** halves directly | net: taken, identical sentence. module: **deferred**, confirmed `rename_preflight(...).is_ok()`, and the slow road's answer is the unchanged `already_named()` string (only the sentence's *construction* was refactored into a shared fn, not its text or its position after `locate`) |
|
||||
| (f) duplicate module (`rstmgr_por`) | `a_name_declared_in_two_files_stays_on_the_slow_road` + live re-run: real server, real OpenTitan — refused with *"`rstmgr_por` is declared in more than one indexed file; lucisv will not guess which declaration this rename means."*, `trace_parses_index=3975` (unchanged), no `preflight` field | identical, unchanged parse count |
|
||||
| (g) unsaved (`untitled:`) buffer | `the_preflight_does_not_disturb_the_refusal_order`; and by reading `rename_traced`'s own source — the `UNSAVED` checks (`ws.document`, then `doc.path`) run and can early-return **before** the preflight call is reached | identical, unchanged order |
|
||||
| (h) large-file buffer | read `server/dispatch.rs:83` (`large_file_answer` runs first, unconditionally, ahead of the method dispatch that would call `rename_traced`) and `server/large_file.rs:80` (`Rename::METHOD => Err(... TOO_LARGE ...)`) — the preflight is provably never reached; `a_large_buffer_is_refused_before_the_preflight_could_see_it` pins that the preflight *would* have been wrong if it were reached, which is exactly why the gate must stay in front of it | unaffected by this diff; still TOO_LARGE before either road runs |
|
||||
| (i) reference to a symbol declared in another file | `Resolution::ExternalCandidate => Ok(())` read directly; live re-run's `ordinary: aes -> aes_renamed` row (an `aes` instantiation reference) completed the whole-scope path normally, fingerprint `fa7e31c78382…` unchanged | `Ok` from preflight, whole-scope path runs, unchanged |
|
||||
| (j) empty `name_span` in this buffer (rule 11a) | read `declared_here`'s first check, ahead of the file-scope test; oracle sweeps `SUB`/`TOP`/`GEN` at every byte, which would surface an unspelled-declaration mismatch if one existed in the fixtures — none constructed with a literally empty span beyond what the parser already produces on malformed input, covered indirectly by `a_buffer_that_does_not_parse_keeps_parity` | code-path identical to `Scope::declaration`'s own check; no divergence found |
|
||||
|
||||
Every case in the wire re-run returned the **same sentence text** as the
|
||||
tracker's own evidence (`~/.cache/lucisv-perf/take5r-1/results.jsonl`), which
|
||||
I cross-checked field by field (see §5).
|
||||
|
||||
**4. Oracle sabotage.** In a throwaway clone
|
||||
(`.../scratchpad/qa-61-1/sabotage-clone`, cloned from `e13ae4c` with the
|
||||
working-tree diff applied via `git apply` + copying the four untracked new
|
||||
files — diffed byte-identical against the real tree before use):
|
||||
|
||||
- **Sabotage 1** — made the `Resolution::Resolved` arm of `rename_preflight`
|
||||
return `Err(NOTHING_HERE.to_string())` unconditionally instead of calling
|
||||
`declared_here` (an invented refusal for a resolved reference). Result:
|
||||
`cargo test -p vlog_refactor --test preflight_oracle` — **3 of 10 tests
|
||||
fail**, each panicking with *"the preflight invented the refusal ... for a
|
||||
rename the workspace performs"*, exactly the failure mode the oracle's own
|
||||
doc comment promises.
|
||||
- **Sabotage 2** — changed only the *wording* of the same-name refusal inside
|
||||
`declared_here` (`` `{new_name}` already is the name it has.`` instead of
|
||||
the shared `already_named()`'s `` `{new_name}` is the name it already
|
||||
has.``), leaving the slow road's sentence untouched. Result: **8 of 10
|
||||
tests fail** with *"the preflight and the workspace refuse in different
|
||||
words"* and the two strings printed side by side.
|
||||
|
||||
Both sabotages caught decisively, restored, and the clone diffed clean against
|
||||
the real preflight.rs afterward. This is real evidence the oracle does what
|
||||
its doc comment claims, not an assumption from reading it.
|
||||
|
||||
**5. Parse count and traceability.** `a_rename_on_a_cursor_with_no_symbol_
|
||||
parses_nothing` reads `vlog_parser::stats::parses()` before/after and asserts
|
||||
the **difference** is `0` — not a hard-coded literal — and separately asserts
|
||||
the `--verbose` trace line contains `selected=0`, `parses=0`, `preflight=true`
|
||||
by substring, so a regression that made the count right but the trace wrong
|
||||
would still fail. My own fresh wire re-run (guarded, real server, real
|
||||
OpenTitan, fresh session, `--tries 1`) reproduces this independent of the
|
||||
dev's logged run: no-symbol **0.248 ms**, `parses=0`, `selected=0`,
|
||||
`preflight=true`, sentence *"there is no symbol to rename at this
|
||||
position."*; `rstmgr_por` (duplicate module) **2 120–2 153 ms**,
|
||||
`parses_index=3975`, `selected=3976` — unchanged; `clk_i` (common port)
|
||||
**~3.4 s**, `parses_index=3975`, `fallback=true` — unchanged. All twelve
|
||||
numbers named in the tracker's R3a/R3c-x records (no-symbol 2 012.3→0.34,
|
||||
duplicate-module 2 012.6→2 032.0, common-port 3 242.4→3 252.7, tail
|
||||
367.3→365.0, plus the five fingerprints) were located verbatim in
|
||||
`~/.cache/lucisv-perf/take5r-1/results.jsonl`/`results2.jsonl` by field
|
||||
(`row`, `server`, `ms`, `fingerprint`, `trace_parses`, `trace_selected`) —
|
||||
traceability item 8 satisfied.
|
||||
|
||||
**6. The extract decision.** Read `lucisv_server/src/extract.rs::execute`:
|
||||
`site_at` is called and, for a non-large buffer, **is**
|
||||
`vlog_refactor::extract_site_in`, whose first two statements are the
|
||||
parse-diagnostic check (`if !diagnostics.is_empty() { return None }`) and
|
||||
`Region::read(...).ok()?` — confirmed at
|
||||
`crates/vlog_refactor/src/extract/mod.rs:99-103`, called *before*
|
||||
`ws.module_sources` (workspace materialization). Read `extract_module`
|
||||
(same file, line 131): `plain_identifier(new_name)?` is its first statement
|
||||
and the occupied-target check is its second, both ahead of
|
||||
`Extraction::plan` → `Scope::build`. Live re-run of the `extractrefuse` phase:
|
||||
bad-name refusal **12.7 ms**, partial-selection refusal **0.05 ms** — both
|
||||
already pre-scope in the reference too, consistent with "no work to remove."
|
||||
Live re-run of `execute`'s `aes_wrap.sv` inline-site row: refused at
|
||||
**757.6 ms** with the sentence *"the selection drives `h2d_intg`, and
|
||||
something outside it passes the same name to a task or function ... lucisv
|
||||
will not make it an output over that."* — matches `boundary.rs`'s `direction`
|
||||
function (the sentence text found at that exact location), which needs
|
||||
`sides: flow::Sides` from `flow::read(&scope, ...)`, confirming the refusal is
|
||||
genuinely scope-dependent and unreachable from a region-local preflight. `aes.sv`
|
||||
extract-capture fingerprint from the live re-run's `execute` output matched
|
||||
`090e92e7736e…` (the `090e92e7736e0a5a93557d75befa65a5bea0c2f44494d71dc67e3f8d70d05835`
|
||||
row in the JSONL). No sabotage was needed here since no production code
|
||||
shipped from this half — verified the claim by reading the removed-preflight's
|
||||
would-be call sites instead, which is what the task asked for.
|
||||
|
||||
**7. Trace-line / RequestFailed check.** Read `server/dispatch.rs`'s
|
||||
`Rename::METHOD` arm: `trace` is always populated by `rename_traced` (both
|
||||
roads), but `self.timing(...)` — the only place a `preflight=true` line
|
||||
reaches any output — fires only under `if let (true, Some(line)) =
|
||||
(self.verbose, trace)`. Every `Err` outcome, preflight or slow-road, becomes
|
||||
`Failure::Request(message)` → `lsp_server::ErrorCode::RequestFailed` with text
|
||||
`"lucisv: {message}"` (`dispatch.rs:598-599`) — never a result value. Matches
|
||||
the task's item 6 exactly.
|
||||
|
||||
**8. Re-measured cells.** Fresh, guarded, real-server sessions on this exact
|
||||
candidate binary (sha256 `5f815542ac16854acb77f545805378324e0025eaaf48662f28bcc8ae8b6ebdb9`,
|
||||
matching the tracker's own recorded candidate hash — **no rebuild needed**,
|
||||
confirmed identical before use) against OpenTitan, `--tries 1` (a lighter
|
||||
re-measurement than the dev's 3-repeat sessions, sufficient to confirm order
|
||||
of magnitude and correctness, not to re-derive medians): no-symbol 0.248 ms,
|
||||
duplicate-module 2 120–2 153 ms, common-port ~3.4 s, tail-adjacent rows in the
|
||||
same session all within normal single-session variance of the tracker's
|
||||
values (a few percent, same direction the tracker itself notes as
|
||||
session-to-session noise). `extractrefuse` bad-name 12.7 ms / partial-selection
|
||||
0.05 ms, `execute` inline-refusal 757.6 ms, `aes.sv` capture 138.2/167.9 ms —
|
||||
all within the same variance band and all sentences/fingerprints identical.
|
||||
No cell moved outside what the tracker itself already characterizes as
|
||||
session noise (±10%), and none of the safety-relevant numbers (parse counts,
|
||||
sentences, fingerprints) showed **any** deviation.
|
||||
|
||||
**9. OpenTitan / guard / lingering processes.** `git -C
|
||||
/Users/guoliangchen/repo/opentitan status --porcelain` showed exactly the
|
||||
three pre-existing modified files (`hw/ip/aes/dv/tb/tb.sv`,
|
||||
`hw/top_darjeeling/.../ast.sv`, `hw/top_earlgrey/.../ast.sv`) before and after
|
||||
every phase invocation in this QA pass. Every cargo/test/bench invocation ran
|
||||
through `tools/guard.sh -m 8 -t <bound>`; zero guard kills. No `sleep` over
|
||||
60 s was used; all waits were `Monitor`-backed PID polls that exited on their
|
||||
own; no lingering background processes or monitors remain at the end of this
|
||||
pass (`ps` checked clean after each phase).
|
||||
|
||||
**10. Fixed directly (small, unambiguous).** The feature README's own work
|
||||
log said `cargo test --workspace` **4 328 passed**; two independent guarded
|
||||
runs on this exact tree (main tree, and the untouched sha256-matched binary's
|
||||
own source) show **4 322**, which is also exactly what the QA brief itself
|
||||
expected ("dev says 4322"). Corrected in the Work log entry above with the
|
||||
supporting arithmetic; not a functional finding, a transcription slip.
|
||||
|
||||
**Topo handshake for the lead to apply** (repeating the README's own
|
||||
Handshakes request, verified sound): `docs/topo.md` §1.2's
|
||||
`lucisv_server ◀──▶ vlog_refactor` entry should gain a **one-directional**
|
||||
parity obligation — `rename_preflight` must produce the same *refusal* text as
|
||||
whole-scope `rename` for the same request, but may always stand aside — and a
|
||||
note that `rename_preflight` deliberately does **not** read the workspace
|
||||
index, unlike `prepare_rename_here`, which does. Confirmed by code: no `index`
|
||||
or `external` parameter reaches `rename_preflight` anywhere in this diff, and
|
||||
`declared_here`'s file-scope branch is the one place that would have needed
|
||||
it, and defers instead.
|
||||
|
||||
**Verdict: PASS.** Every refusal's sentence and precedence is unchanged
|
||||
between 0.51.0 and the candidate on every case checked, including two
|
||||
successful sabotage attacks on the oracle that would have caught a real
|
||||
regression. TODO §61.1's QA line is ticked below.
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-08 (lead).** Accepted. Read `preflight.rs`, the server call
|
||||
site, the oracle test, both logs; QA's independently rebuilt rule table
|
||||
and its sabotage of the oracle are the acceptance.
|
||||
|
||||
- The result is the review's gate met by two orders of magnitude (2.0 s
|
||||
and 3 975 parses → 0.34 ms and none) with the sentence and its
|
||||
precedence byte-identical, proven at every byte of the fixtures and on
|
||||
the wire.
|
||||
- The two things the dev refused to do are as good as the thing it did.
|
||||
The duplicate-declaration refusal stays on the slow road because the
|
||||
index is written on save and on a watcher event, never on a keystroke,
|
||||
and a wrong rename refusal is terminal where a wrong prepareRename is
|
||||
not — the right reading of "only with evidence the index is current".
|
||||
The extract preflight was built, measured at zero work, and removed:
|
||||
the offer gate already runs the region-local checks before the engine
|
||||
is reached, and the `aes_wrap.sv` refusal is `Crossing::read`, the last
|
||||
stage of the plan, which only §61.5's scope reuse can move.
|
||||
- The signature deviation (no `external`/`index` parameters) is the
|
||||
contract itself: a preflight that could read the index would invite
|
||||
exactly the refusal the argument forbids.
|
||||
- QA fixed one arithmetic slip in this README's test count; nothing else.
|
||||
|
||||
Docs applied at merge: topo §1.2 — `rename_preflight` owes whole-scope
|
||||
`rename` the same refusal text, one-directionally, and reads no index.
|
||||
|
||||
*(empty — for the lead)*
|
||||
@@ -0,0 +1,979 @@
|
||||
# perf5r-publication — what a startup scan costs while requests keep arriving
|
||||
|
||||
Review round §R4 (TODO §61.4). `docs/performance_take5_review.md` §4 and its
|
||||
"Startup throughput and responsiveness must be judged separately".
|
||||
|
||||
## Goal
|
||||
|
||||
A scan that answers messages between its files pays a **publication** for each
|
||||
burst: the staged records merged into the index, the completion tables
|
||||
re-derived, the include graph folded in, every open buffer's overlay refreshed
|
||||
(`Workspace::publish_scan`). The review could not say what that costs, because
|
||||
the only probe it had (`scanserve`) sends the next request 200 ms *after the
|
||||
previous response* — so a more responsive server is asked more often and its
|
||||
session-completion time is not comparable with anything. This lane builds the
|
||||
controlled probe the review asked for — a **fixed arrival rate**, the same
|
||||
offered load whatever the server does with it — reads the publication cost off
|
||||
the server's own trace beside the request latencies, and then reduces what the
|
||||
probe names without touching the coherent-prefix contract. It also carries two
|
||||
items the lead assigned here because they live on the same drain path: the
|
||||
empty-answer rule §61.3 filed, and the `HEAD_WALK_MAX` test §61.3's QA found
|
||||
missing.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **The three tables are published together or not at all.** Nothing here
|
||||
changes that; the cadence changes *how often* a publish happens, never what
|
||||
one contains (`docs/features/scan-interleave/README.md`).
|
||||
- **A prefix is allowed to be old, never inconsistent.** A request answered
|
||||
between two publishes reads an index that is at most `PUBLISH_EVERY` files
|
||||
behind the one it could have had. That was always true between two interleave
|
||||
points; the cadence widens the gap and does not change its nature.
|
||||
- **`[]` from a navigation request is not information while the index is
|
||||
growing.** The empty-answer rule rests on this: a definition, a
|
||||
typeDefinition and a references answer with a *list of places* and with an
|
||||
empty list when they find none, so `[]` cannot be told apart from "not
|
||||
scanned yet". A hover's `null`, a completion's empty list and an empty
|
||||
code-action menu mean what they say, and are untouched.
|
||||
- **`textDocument/implementation` is not answered by this server**, so it is
|
||||
not on the navigation list even though it would belong there.
|
||||
- The corpus is opentitan `0098135264` with its three known modifications, read
|
||||
only. Every number is from `tools/perf/bench.py` under
|
||||
`tools/guard.sh -m 8 -t 1800`.
|
||||
|
||||
## Handshakes
|
||||
|
||||
### `lucisv_server::state` — the publication cadence
|
||||
|
||||
```rust
|
||||
pub(crate) const PUBLISH_EVERY: usize = 512; // state/scan.rs
|
||||
|
||||
impl Scan {
|
||||
/// Whether enough has been staged since the last publish for another one
|
||||
/// to be worth the merge it costs.
|
||||
pub fn publish_is_due(&self) -> bool;
|
||||
}
|
||||
```
|
||||
|
||||
Additive. `publish_scan` is unchanged — same signature, same contract, same
|
||||
three tables — and so is every other entry on `Scan`. The only caller of
|
||||
`publish_is_due` is `server/index.rs::answer_what_is_waiting`, which is the one
|
||||
place a mid-scan publish is decided.
|
||||
|
||||
`state::discover` and `HEAD_WALK_MAX` went from `pub(super)` to `pub(crate)`, so
|
||||
`server/tests/startup.rs` can write a fixture *against the bound* rather than
|
||||
against the number 512 written out again. No line was added to `state/mod.rs`
|
||||
for it.
|
||||
|
||||
### `lucisv_server::server` — a request may be asked again
|
||||
|
||||
```rust
|
||||
struct Server {
|
||||
/// Navigation requests a scan answered empty while it was still growing
|
||||
/// the index, to be asked again at its next publish.
|
||||
deferred: Vec<Message>,
|
||||
}
|
||||
|
||||
impl Server {
|
||||
pub(super) fn ask_again_if_empty(&self, request: &Request) -> Option<Request>;
|
||||
pub(super) fn say_deferred(&self, request: &Request);
|
||||
}
|
||||
pub(super) fn names_nowhere(response: &Response) -> bool;
|
||||
```
|
||||
|
||||
**`deferred` is deliberately not part of `must_wait`.** `held` is the order
|
||||
contract — nothing newer may overtake what is waiting there. `deferred` is not
|
||||
a queue at all: the answer was computed, found to name nowhere, and set aside
|
||||
because the reason may be that the file has not been scanned. Nothing is owed
|
||||
anything by it, so a hover, a completion or a code action behind one is answered
|
||||
exactly as before. That is the difference the two names are for.
|
||||
|
||||
### `docs/features/scan-interleave/README.md`
|
||||
|
||||
A dated entry records both, with the rules they amend stated in that README's
|
||||
own terms. Neither is a contract change: the coherence contract, the order
|
||||
contract and `INTERLEAVE_ABOVE` are all untouched.
|
||||
|
||||
### `docs/features/perf5r-first-answer/README.md`
|
||||
|
||||
That lane's cross-folder `[]` — pinned openly and filed as request 5 — is
|
||||
answered here. Its test moved with it; the "honest limit" it pinned is now the
|
||||
rule's own regression test.
|
||||
|
||||
### Requests for the lead (`docs/topo.md` is not edited by this lane)
|
||||
|
||||
1. `lucisv_server ──▶ vlog_semantic`: nothing new. `WorkspaceIndex::absorb` is
|
||||
called with the same arguments, fewer times.
|
||||
2. A new edge inside `lucisv_server`: `server::index ──▶ state::scan`
|
||||
(`publish_is_due`) and `server::mod ──▶ server::dispatch` (`names_nowhere`,
|
||||
`ask_again_if_empty`).
|
||||
3. `state::discover` is now `pub(crate)` — a visibility widening for a test,
|
||||
not an interface.
|
||||
4. **A finding for a future lane, not a request:** `WorkspaceIndex::absorb`
|
||||
ends in `merge(None)`, a pass over every record the index holds, while
|
||||
`update_facts` has a targeted `merge(Some(&affected))` beside it. Under load
|
||||
that whole-index merge is the single largest publication cost. An additive
|
||||
`absorb` that takes an `Affected` would be a `vlog_semantic` change, which
|
||||
this lane's file list excludes; the cadence reduces how often it is paid
|
||||
rather than what it costs. Numbers below.
|
||||
|
||||
## How it works
|
||||
|
||||
### The probe: `scanload`
|
||||
|
||||
`tools/perf/phases_r4.py`, schema 2, registered in `bench.py` like every other
|
||||
phase.
|
||||
|
||||
- **The clock, not the answers.** A `textDocument/definition` goes out every
|
||||
`rate` ms of wall time counted from the session's own start, whether or not
|
||||
the previous one has been answered. Requests pipeline; a server that stalls
|
||||
accumulates them, which is the queue latency the probe exists to see.
|
||||
- **A fixed count, so the load is the same for both binaries.** The first draft
|
||||
stopped sending when the server stopped saying things, and that reintroduced
|
||||
`scanserve`'s confound in a new place: a mid-scan lull in the progress
|
||||
chatter stopped the probe at 14 requests where the session ran for 20 ticks.
|
||||
The window is now fixed per cache state (`WINDOW_MS`: cold 9 000 ms, warm
|
||||
3 500 ms — long enough to cover the reference's whole loaded session), so both
|
||||
binaries are asked exactly the same number of times and a binary that finishes
|
||||
sooner shows it as requests answered **after** settle, never as requests never
|
||||
sent.
|
||||
- **Every request's own wait.** `Session.poll_answers` (new, additive, in
|
||||
`lspclient.py`) takes every response that has arrived without blocking on the
|
||||
oldest, and the arrival instant is stamped in the reader thread, so a request
|
||||
answered while the probe is busy sending the next one is not charged for the
|
||||
probe's poll interval.
|
||||
- **The publication split beside the latencies.** The session runs `--verbose`,
|
||||
so `publishes`, `published` and the four `publish_*` stages come off the very
|
||||
session whose requests are in the row.
|
||||
- **A quiet control in the same series**: the same cells with no requests at
|
||||
all, so a settle time that moved can be told apart from one that moved
|
||||
*because requests arrived*.
|
||||
- **Cells:** rate ∈ {100, 250} ms × cache ∈ {cold, warm} × extra open buffers
|
||||
∈ {0, 1, 10, 100}, three fresh sessions each, plus the quiet control per
|
||||
(cache, buffers). Buffer counts are *extra*: the cursor's own file is always
|
||||
open, so "0" is one buffer and "100" is 101 — `scanprofile`'s convention.
|
||||
- **Recorded per cell:** every request's wall latency (median and max, and the
|
||||
same two over the mid-scan subset), how many were answered before settle,
|
||||
`mismatched_answers` and `unsettled_answers` against the settled answer,
|
||||
settle time, the publish counts and stage split, `tick_jitter_ms` (the largest
|
||||
slip between a tick's due instant and its write — how a reader checks the
|
||||
arrival discipline the row claims), and requests offered vs answered.
|
||||
|
||||
### The cadence
|
||||
|
||||
`answer_what_is_waiting` published whenever anything at all was waiting — one
|
||||
whole-index merge per burst of requests. It now publishes when
|
||||
|
||||
* something was **waiting** — the startup's held requests, drained the moment
|
||||
the neighbourhood is in. That publish is the session's first useful answer
|
||||
and is never deferred (`perf5r-first-answer`); or
|
||||
* `Scan::publish_is_due()` — `PUBLISH_EVERY` (512) records staged since the
|
||||
last publish.
|
||||
|
||||
A count rather than a clock, for three reasons: a merge's cost is the index's
|
||||
size and its value is the records it makes answerable, so files staged is the
|
||||
currency both are in; what a scan does is then the same on a fast machine and a
|
||||
slow one; and a test can assert it. 512 is deliberately `HEAD_WALK_MAX`'s
|
||||
number — both answer "how much of this workspace may a user wait for", and 512
|
||||
warm steps is ~100 ms of scanning on this corpus.
|
||||
|
||||
**A quiet scan still pays nothing at all.** The cadence is asked only when there
|
||||
is something for a publish to be *for*: the drain returns before it, as it
|
||||
always did, when nothing is held, nothing has arrived and nothing is deferred.
|
||||
|
||||
### The empty-answer rule
|
||||
|
||||
Inside `process_batch`, at the one place a request's response is sent:
|
||||
|
||||
1. `ask_again_if_empty` takes a copy of the request when a scan is running and
|
||||
the method is one of the three in `NAVIGATION`;
|
||||
2. the answer is computed through the **ordinary handler**, exactly as before;
|
||||
3. if it `names_nowhere` — an `Ok` result that is an empty array — the copy goes
|
||||
on `deferred` and nothing is sent;
|
||||
4. the next publish puts `deferred` at the front of that drain's batch, behind
|
||||
whatever was already `held` and ahead of everything newer, and they are asked
|
||||
again;
|
||||
5. `scan_until_settled` ends with `answer_what_was_deferred`, which runs
|
||||
whatever is left through `process_batch` with `scanning` already false — so
|
||||
the rule defers nothing that time round and an empty answer goes out.
|
||||
|
||||
The re-computation is bounded **by publishes, not by steps**: a deferred request
|
||||
is asked again once per publish, so at most a handful of times in a whole scan,
|
||||
and a request that keeps coming back empty costs one evaluation per publish and
|
||||
is answered when the scan ends.
|
||||
|
||||
## Measured
|
||||
|
||||
Machine and method are `docs/perf/README.md`'s: Apple M1 Max, macOS 27.0,
|
||||
release binaries built with `cargo build --release --locked`, opentitan
|
||||
`0098135264` with its three known modifications, everything under
|
||||
`tools/guard.sh -m 8 -t 1800`, three fresh sessions a cell, no cargo command
|
||||
during a timed run. Reference `REF` = trunk `eb54042`; candidate `CAND` = that
|
||||
tree plus this lane's diff. `~/.cache/lucisv-perf/take5r-4/`.
|
||||
|
||||
### What a publish costs, and how it scales — the R4 baseline
|
||||
|
||||
The reference under a definition every 100 ms of wall clock, warm, one open
|
||||
buffer: **34 publishes in one scan**, and
|
||||
|
||||
| stage | ms | share of publication |
|
||||
|---|---:|---:|
|
||||
| `publish_absorb` | 2 433 | **78 %** |
|
||||
| `publish_candidates` | 623 | 20 % |
|
||||
| `publish_includes` | 47 | 1.5 % |
|
||||
| `publish_overlay` | 2.4 | 0.08 % |
|
||||
| **total** | **3 105** | of a **4 206 ms** scan — **74 %** |
|
||||
|
||||
The same scan with no requests at all takes **1 005 ms**. So under this load the
|
||||
scan is four times longer, and essentially all of the difference is
|
||||
publication. Cold is the same shape and worse: 88 publishes, **7 973 ms** of
|
||||
publication in a **10 675 ms** scan, against a **2 766 ms** quiet cold scan.
|
||||
|
||||
Three things the split says, and only one of them is what the brief guessed:
|
||||
|
||||
1. **`index.absorb` is the cost.** It is 78 % of publication because it ends in
|
||||
`merge(None)`, a pass over every record the index holds — so a publish costs
|
||||
the size of the *index*, not the size of the batch, and the index grows all
|
||||
the way to the end of the scan. `vlog_semantic`'s own doc comment says a
|
||||
per-file merge would be quadratic; under load the drain was doing one per
|
||||
burst of requests, which is the same shape at a coarser grain.
|
||||
2. **The candidates rebuild is real but second.** `Candidates::absorb` ends in
|
||||
`take_index_tables`, which re-derives the unit, module and macro tables from
|
||||
the whole index every publish — 20 % of publication, ~18 ms a publish on
|
||||
this corpus.
|
||||
3. **The overlay refresh is not a lever.** It is **0.08 %** at one open buffer
|
||||
and **9.6 %** at 101 (291 ms of 3 037), i.e. about 0.09 ms per buffer per
|
||||
publish. At the buffer counts an editor actually has it is noise. This is
|
||||
the item the work order expected to matter; the measurement says it does
|
||||
not, and the reduction it asked for — deciding per buffer whether the
|
||||
absorbed records could have moved its external resolutions — would cost a
|
||||
name-set intersection per buffer per publish to save a tenth of a
|
||||
millisecond. **Not done, and the numbers are why.**
|
||||
|
||||
Scaling: publication is flat in the number of open buffers except for the
|
||||
overlay term (2.4 ms at 1 buffer → 291 ms at 101), and roughly linear in the
|
||||
number of publishes, which is set by how often requests arrive. That is the
|
||||
whole finding: *the client's request rate, not the workspace, decides what a
|
||||
scan spends on publication.*
|
||||
|
||||
### The cadence, under the same offered load
|
||||
|
||||
Warm, every cell three fresh sessions, the same fixed number of requests
|
||||
offered to both binaries (`requests answered` is equal in every row, so nothing
|
||||
here is a speedup bought by serving less).
|
||||
|
||||
| cell (warm) | | latency p50 | latency max | publishes | publication ms | scan ms |
|
||||
|---|---|---:|---:|---:|---:|---:|
|
||||
| 100 ms, 1 buffer | REF | 112.3 | 168.0 | 34.3 | 3 105 | 4 206 |
|
||||
| | **CAND** | **1.9** | 421.9 | **4.7** | **588** | **2 188** |
|
||||
| 250 ms, 1 buffer | REF | 243.4 | 256.5 | 14.0 | 2 824 | 3 852 |
|
||||
| | **CAND** | **1.9** | **203.5** | **3.0** | **378** | **1 417** |
|
||||
| 100 ms, 2 buffers | REF | 308.9 | 2 109.5 | 33.0 | 3 082 | 4 117 |
|
||||
| | **CAND** | **2.4** | **680.7** | **4.0** | **688** | **1 725** |
|
||||
| 100 ms, 11 buffers | REF | 175.6 | 1 912.6 | 33.3 | 3 101 | 4 142 |
|
||||
| | **CAND** | **2.3** | **708.6** | **3.7** | **580** | **1 654** |
|
||||
| 100 ms, 101 buffers | REF | 1 960.1 | 3 672.0 | 33.0 | 3 037 | 4 254 |
|
||||
| | **CAND** | **10.4** | **823.1** | **4.0** | **669** | **1 873** |
|
||||
|
||||
**Publication down 78–87 %, the scan down 48–63 %, the median request wait down
|
||||
98–99.5 %, and the same number of requests answered.**
|
||||
|
||||
The **tail** is the one place this is not a clean sweep, and the count across
|
||||
all sixteen loaded cells (warm and cold, both rates, four buffer counts) is:
|
||||
**improved in ten, level in two, higher in four.** Three of the four are
|
||||
single-open-buffer cells — the case where the reference is at its best, because
|
||||
publishing after every burst keeps the index so fresh that no request waits
|
||||
long for one, and the worst of them is warm 100 ms, **168 → 422 ms**. The
|
||||
fourth is warm 250 ms at 11 buffers, 760 → 777 ms, which is 2 %. Against that:
|
||||
3 672 → 823 ms at 101 buffers warm and 9 308 → 1 583 ms cold, and a median that
|
||||
went from 112 ms to 1.9. The trade is legible — four merges instead of
|
||||
thirty-four means a request that lands inside one waits for it — and it is
|
||||
one request in thirty-five.
|
||||
|
||||
Cold is the same shape and larger, because a cold scan is longer and every
|
||||
publish merges a bigger index by the time it happens:
|
||||
|
||||
| cell (cold) | | latency p50 | latency max | publishes | publication ms | scan ms |
|
||||
|---|---|---:|---:|---:|---:|---:|
|
||||
| 100 ms, 1 buffer | REF | 137.7 | 210.6 | 87.7 | 7 973 | 10 675 |
|
||||
| | **CAND** | **1.5** | 395.5 | **7.0** | **922** | **3 686** |
|
||||
| 250 ms, 1 buffer | REF | 225.3 | 255.0 | 36.7 | 6 816 | 9 569 |
|
||||
| | **CAND** | **1.3** | 313.1 | **5.0** | **552** | **3 301** |
|
||||
| 100 ms, 2 buffers | REF | 4 705.9 | 9 160.5 | 89.7 | 7 979 | 10 778 |
|
||||
| | **CAND** | **2.1** | **1 440.0** | **7.0** | **922** | **3 602** |
|
||||
| 100 ms, 11 buffers | REF | 4 724.7 | 9 194.9 | 89.7 | 7 980 | 10 801 |
|
||||
| | **CAND** | **1.9** | **1 412.2** | **6.0** | **880** | **3 626** |
|
||||
| 100 ms, 101 buffers | REF | 4 832.2 | 9 308.4 | 89.3 | 7 959 | 10 947 |
|
||||
| | **CAND** | **2.2** | **1 583.3** | **6.0** | **932** | **3 829** |
|
||||
|
||||
**Publication −88 %, the traced scan −65 %, and at two or more open buffers the
|
||||
tail improves by six times.** The overlay term at 101 buffers goes 812 → 56 ms
|
||||
with it. Note the reference's cold median at two or more open buffers: **4.7
|
||||
seconds**. That is not publication — it is `must_wait`'s `held` clause, and it
|
||||
is the finding the probe made before a line of this lane's code existed: the
|
||||
first held request holds every request behind it, so a whole session's stream
|
||||
drains in one burst when the neighbourhood lands. The candidate's median is
|
||||
2 ms because its session is over less than halfway through the offered window,
|
||||
so most of the same requests meet a settled server.
|
||||
|
||||
**Two numbers in these tables mean different things and should not be added
|
||||
up.** `scan ms` is the server's own traced scan wall time and is the honest
|
||||
"completion under load". The probe's own `settled_ms` is **floored by the
|
||||
request window** whenever the session finishes inside it — the last chatter the
|
||||
probe sees tracks its own last request — so it understates the improvement
|
||||
(warm 1 buffer: settle 4 215 → 3 417, −19 %, against the scan's −48 %). For the
|
||||
same reason `mid_scan_*` misclassifies post-settle answers as mid-scan in the
|
||||
candidate's rows and is not quoted here. The comparison the tables rest on is
|
||||
sound without either: **both binaries are offered the identical number of
|
||||
requests over the identical window and answer all of them.**
|
||||
|
||||
### The empty-answer rule, at a cursor the head cannot answer
|
||||
|
||||
`scanload`'s cursor names a module in `hw/ip/aes/rtl`, which the head walks
|
||||
first, so it is non-empty from the first publish and the rule never fires on
|
||||
it. `scanloadcross` asks the same fixed load at `tl_if` in the same buffer —
|
||||
an interface declared in `hw/dv/sv/tl_agent`, which the open buffer's folder
|
||||
does not hold. `unsettled_answers` counts every answer that was not the settled
|
||||
one, empty ones included: it is the review §2 gate, and it is what the rule is
|
||||
for.
|
||||
|
||||
| cell | | latency p50 | latency max | answered | **unsettled** |
|
||||
|---|---|---:|---:|---:|---:|
|
||||
| cold, 1 buffer | REF | 105.1 | **215.8** | 270 | **12** |
|
||||
| | **CAND** | **1.3** | 486.4 | 270 | **0** |
|
||||
| cold, 11 buffers | REF | 4 735.8 | 9 217.8 | 270 | **270** |
|
||||
| | **CAND** | **1.5** | **1 884.0** | 270 | **0** |
|
||||
| warm, 1 buffer | REF | 120.6 | **212.1** | 105 | **12** |
|
||||
| | **CAND** | **1.7** | 380.6 | 105 | **0** |
|
||||
| warm, 11 buffers | REF | 1 822.3 | 3 624.8 | 105 | **105** |
|
||||
| | **CAND** | **2.0** | **891.0** | 105 | **0** |
|
||||
|
||||
**The reference answers this cursor wrongly 12 times in 270 with one buffer
|
||||
open and *every single time* with eleven** — because with eleven the whole
|
||||
request stream is held until the neighbourhood lands and is then drained in one
|
||||
burst off a prefix that does not reach `hw/dv`. The candidate is wrong zero
|
||||
times in all four cells.
|
||||
|
||||
**What that costs, said plainly:** in the two single-buffer cells the tail rises
|
||||
(216 → 486 ms cold, 212 → 381 warm), because a request whose target the scan
|
||||
has not reached now waits for the publish that holds it instead of being told
|
||||
`[]` immediately. That is the trade the lead's ruling asks for, and it is the
|
||||
right way round — the review's gate is *"do not withhold useful answers"*, and
|
||||
`[]` when the answer exists is not a useful answer. In the eleven-buffer cells
|
||||
even the tail improves, by four times.
|
||||
|
||||
### Everything the cadence must not have cost
|
||||
|
||||
The quiet startup matrix, three fresh sessions a cell, medians:
|
||||
|
||||
| `scan` cell | REF | CAND |
|
||||
|---|---:|---:|
|
||||
| workspace, cold | 2 747.5 | 2 715.9 |
|
||||
| workspace, warm | 981.0 | 983.7 |
|
||||
| workspace cold, **first useful answer** | 78.2 | 80.8 |
|
||||
| workspace warm, **first useful answer** | 115.1 | 115.8 |
|
||||
| default scope, cold / warm | 95.1 / 50.7 | 101.9 / 48.5 |
|
||||
| `{"index":{}}`, cold / warm | 111.0 / 48.8 | 106.3 / 48.9 |
|
||||
| `scopeDepth 0`, cold / warm | 10.5 / 8.7 | 11.3 / 12.5 |
|
||||
|
||||
Memory, which the review's gate says must be *retained*: idle RSS after the
|
||||
workspace scan **502 736 → 501 872 KiB cold** and **427 200 → 426 448 KiB
|
||||
warm** (−0.2 % both, peak equal to idle), and the index store on disk **45 404
|
||||
KiB in both** — byte-for-byte the same size, because nothing about what a scan
|
||||
writes changed. The cadence holds records staged for longer, which is the one
|
||||
place it could have cost memory: at most `PUBLISH_EVERY` `FileFacts` instead of
|
||||
one burst's worth, and the numbers say that is not visible.
|
||||
|
||||
Nothing moved outside its spread. The two that had to be checked by name are
|
||||
the **warm quiet scan** — still under a second, which is the milestone §61.3
|
||||
reached for the first time — and the **first useful answer**, which is §61.3's
|
||||
whole result and which the cadence could have delayed by deferring the head
|
||||
publish. It does not: that drain is the one the cadence exempts, and the number
|
||||
says so.
|
||||
|
||||
### `scanserve` — the review's own probe, unchanged and re-run
|
||||
|
||||
The response-paced probe the review used, three fresh sessions a cell. It
|
||||
served the **same number of requests per session for both binaries** here (13
|
||||
cold, 5 warm), so its confound does not bite in this comparison:
|
||||
|
||||
| | REF | CAND |
|
||||
|---|---:|---:|
|
||||
| cold, median mid-scan definition | 122.2 ms | **45.6 ms** |
|
||||
| cold, worst | 334.0 ms | 334.8 ms |
|
||||
| cold, session completion | 4 506 ms | **3 938 ms** |
|
||||
| warm, median | 114.0 ms | 114.2 ms |
|
||||
| warm, worst | 290.2 ms | **279.4 ms** |
|
||||
| warm, session completion | 1 692 ms | 1 697 ms |
|
||||
| `mismatched_answers` / `unsettled_answers` | 0 / 0 | 0 / 0 |
|
||||
|
||||
Warm is flat and that is the expected reading, not a disappointment: at one
|
||||
request per 200 ms *of response* a warm session only gets five of them in, so
|
||||
the reference pays five publishes and there is nothing for a cadence to
|
||||
remove. The cadence is for the case where a client asks faster than the server
|
||||
finishes, which is what `scanload` offers and what the cold column already
|
||||
shows.
|
||||
|
||||
The quiet control did not move: warm quiet scan **1 004.7 → 984.7 ms** at one
|
||||
buffer (and 1 020 → 1 065, 1 029 → 1 041, 1 201 → 1 156 at 2 / 11 / 101), so
|
||||
the ≤ 1 s the last round reached is kept and none of this was bought from the
|
||||
quiet case. A quiet session's mid-scan publishes go **1 → 0**: nothing is
|
||||
waiting, so nothing is published, which is the promise `scan-interleave` made
|
||||
and this keeps.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] R4a — the fixed-arrival-rate probe (`tools/perf/phases_r4.py::scanload`,
|
||||
`scanloadcold`, `scanloadcross`), cold and warm, 1 / 2 / 11 / 101 open
|
||||
buffers, with the quiet control and the publication split; R4 baseline
|
||||
cells filled from `eb54042`
|
||||
- [x] the publication cadence (`Scan::publish_is_due`, `PUBLISH_EVERY`)
|
||||
- [x] the empty-answer rule (`Server::deferred`, `ask_again_if_empty`,
|
||||
`names_nowhere`, `answer_what_was_deferred`)
|
||||
- [x] the `HEAD_WALK_MAX` fixture §61.3's QA asked for — and sabotage-checked
|
||||
(the bound's branch disabled, the test fails with
|
||||
`515 files (the folder first)`)
|
||||
- [x] the candidates rebuild and the selective overlay refresh: **measured,
|
||||
not built.** The cadence takes both down with it, and the overlay is
|
||||
0.08 % of publication at one open buffer
|
||||
- [x] measured: `scanload` both rates and all buffer counts, `scanloadcold`,
|
||||
`scanloadcross`, `scanserve`, quiet `scan` cold/warm, `rss`, the 24 scope
|
||||
cells; R4 row and experiment record `R4-2026-09-08` in
|
||||
`docs/perf/take5-tracking.md`
|
||||
|
||||
### Gates
|
||||
|
||||
- `cargo fmt` clean; guarded `cargo clippy --all-targets` clean with no new
|
||||
`#[allow]`; guarded `cargo test --workspace` green, **4 360 → 4 365**, none
|
||||
dropped. Six test functions written, one of which replaces the §61.3 test
|
||||
whose subject the rule changed, so the count rises by five: the cadence's
|
||||
exact boundary (in `state`), the cross-folder definition (the replacement),
|
||||
the cross-folder typeDefinition, the genuinely-empty answer, the hover that
|
||||
is never deferred, and the `HEAD_WALK_MAX` fixture.
|
||||
- Under the same offered load: publishes and publication time down, settle down
|
||||
or held, latency not worse, **served requests equal**.
|
||||
- `mismatched_answers` 0 and `unsettled_answers` 0 on `scanload` and
|
||||
`scanserve`, both binaries, cold and warm.
|
||||
- The quiet warm scan does not regress past 1.0 s.
|
||||
- opentitan's three known modifications, unchanged, after every phase.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-08 — dev (Opus), §61.4
|
||||
|
||||
**Order of work: the probe first, and it changed the plan twice.**
|
||||
|
||||
1. **The probe, written before anything was touched.** The first run of it was
|
||||
the finding: under a definition every 100 ms the reference answered
|
||||
*nothing* until the scan was 74 % over, because `must_wait`'s `held` clause
|
||||
makes the first held request hold every request behind it — so the whole
|
||||
session's stream drains in one burst at the head publish. That is
|
||||
`perf5r-first-answer`'s territory, not this lane's, but the probe says it,
|
||||
so it is written down.
|
||||
2. **The probe was wrong the first time, and the way it was wrong is the
|
||||
review's own confound.** It stopped sending when the server stopped saying
|
||||
things; a lull in the progress chatter stopped it at 14 requests where the
|
||||
session ran for 20 ticks, which makes the offered load a function of the
|
||||
server. Rewritten around a **fixed request count** over a fixed window per
|
||||
cache state. The first (uncontrolled) series is kept as
|
||||
`paired-partial-firstattempt.jsonl` and no number in this README comes from
|
||||
it.
|
||||
3. **The split named a different lever than the work order expected.**
|
||||
`publish_absorb` is 78 % and the overlay refresh is 0.08 % at one open
|
||||
buffer. The work order's first two reductions were the candidates rebuild
|
||||
and a selective overlay refresh; the measurement says the overlay is noise
|
||||
at every buffer count an editor has, so **it was not built** and the numbers
|
||||
are in [Measured](#measured) instead.
|
||||
4. **The cadence is the reduction that fits this lane's files.** `absorb` ends
|
||||
in a whole-index merge inside `vlog_semantic`, which this lane may not
|
||||
change; how *often* that merge is paid is `server/index.rs`'s decision, and
|
||||
it was "once per burst of requests". `Scan::publish_is_due` makes it once
|
||||
per 512 staged records, with the drain that has something *waiting* — the
|
||||
session's first useful answer — exempt.
|
||||
5. **The empty-answer rule**, the lead's §61.3 ruling, went in beside it
|
||||
because the two interact: the cadence makes a mid-scan prefix older, and the
|
||||
rule is what stops that being visible as a wrong `[]`. It is a rule in the
|
||||
drain and not a second computation — the answer is computed once through the
|
||||
ordinary handler and either sent or set aside — and a set-aside request is
|
||||
asked again **once per publish**, which the cadence now bounds to a handful
|
||||
per scan.
|
||||
6. **A test that already pinned the old behaviour had to move, and it is the
|
||||
right kind of move.** `a_buffer_opened_from_the_workspace_root_is_no_
|
||||
neighbourhood_to_lead_with` asserted that its definition was answered
|
||||
*inside* the scan; it was answered `[]`. It now asserts the answer is
|
||||
`ip/aes/rtl/aes.sv`, which arrives later and is right. Said plainly here
|
||||
because "a test changed" is the sentence a reviewer should be suspicious of.
|
||||
|
||||
**Deviations, stated:**
|
||||
|
||||
- **`tools/perf/lspclient.py` was changed**, which the work order's file list
|
||||
describes as "`tools/perf/` (new phase file + README rows)". Two additive
|
||||
hunks: a response's arrival instant stamped in the reader thread, and
|
||||
`Session.poll_answers`, which takes every response that has arrived without
|
||||
blocking on the oldest. A probe that pipelines cannot be written without it —
|
||||
`await_id` blocks — and measuring each request's own wait through a polling
|
||||
loop instead would put the poll interval in every number. No existing phase's
|
||||
behaviour changes; `await_id` gained one line that drops a stamp it does not
|
||||
read.
|
||||
- **`scanload` is two phases** (`scanload` warm, `scanloadcold`). A cold cell
|
||||
under this load is a ten-second session and eight of them do not fit inside
|
||||
the 1 800-second guard. The first paired attempt was **stopped by hand**
|
||||
before it reached that limit rather than allowed to be killed; splitting the
|
||||
run is the answer, and the guard was not touched.
|
||||
- **`state::discover` and `HEAD_WALK_MAX` widened from `pub(super)` to
|
||||
`pub(crate)`** so the new fixture is written against the bound rather than
|
||||
against the number 512 spelled out again. `state/mod.rs` gained no line for
|
||||
it (`mod discover;` → `pub(crate) mod discover;`).
|
||||
- **A `scanloadcross` cell was added that the work order did not ask for.** The
|
||||
cursor `scanload` measures resolves inside the open buffer's own folder, so
|
||||
the empty-answer rule never fires on it and the row would say nothing about
|
||||
what that rule costs. The cross-folder cell is what makes the cost visible
|
||||
rather than asserted.
|
||||
|
||||
**Gates.** `cargo fmt` clean; guarded `cargo clippy --all-targets` clean with
|
||||
no new `#[allow]`; guarded `cargo test --workspace` green at **4 365**, from
|
||||
4 360, none dropped. opentitan's three known modified files unchanged after
|
||||
every phase. **No guard kill.**
|
||||
|
||||
**File sizes** (non-blank, non-comment, before the trailing test module):
|
||||
`server/index.rs` **225**, `server/dispatch.rs` **485** (from 464),
|
||||
`server/mod.rs` **169** (from 158), `state/scan.rs` **128** (from 124),
|
||||
`state/discover.rs` 329, `candidates.rs` 405, `includes.rs` 605 (untouched).
|
||||
`state/mod.rs` is **976 production lines, exactly what it was**: the module
|
||||
visibility change costs no line and the only thing added to it is a test.
|
||||
|
||||
**A limitation of the probe, for QA and for whoever reads the rows next.** The
|
||||
probe's `settled_ms` is the session's last notification, and the session keeps
|
||||
producing notifications while requests arrive — so when the scan finishes
|
||||
inside the offered window, `settled_ms` tracks the *window* rather than the
|
||||
scan, and `mid_scan_median_ms` / `mid_scan_max_ms` then count post-settle
|
||||
answers as mid-scan. Neither is quoted in this README for that reason: `scan
|
||||
ms` (the server's own trace) is the completion figure and the latency columns
|
||||
are over the whole fixed load, which is identical for both binaries. The
|
||||
notification the requests provoke was not chased down; it is a probe question,
|
||||
not a server one, and it is written here rather than left for a reader to
|
||||
notice.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-09-08 — QA (Sonnet), §61.4 R4
|
||||
|
||||
Read CLAUDE.md, TODO §61.4, `docs/performance_take5_review.md` §4 and its
|
||||
"Startup throughput and responsiveness must be judged separately", this
|
||||
README in full, `docs/features/perf5r-first-answer/README.md`'s Review (the
|
||||
ruling that sent the empty-answer rule here), `docs/features/scan-interleave/
|
||||
README.md`'s 2026-09-08 §61.4 entry, `docs/features/cancel-request/README.md`
|
||||
in full, the tracker's `R4-2026-09-08` record, the working-tree diff, and the
|
||||
evidence in `~/.cache/lucisv-perf/take5r-4/`. Experiments in a fresh clone at
|
||||
scratchpad `qa-61-4/repo` (HEAD `eb54042` + the working diff applied,
|
||||
byte-identical to the working tree — verified `diff -rq` clean except the
|
||||
tests I added). A second clone `qa-61-4/repo-ref` at bare `eb54042` was built
|
||||
for the per-binary test comparison. All cargo and all perf commands ran
|
||||
through `tools/guard.sh -m 8 -t 1800`; no guard kill anywhere; no lingering
|
||||
background loops (all launched via `run_in_background`/`Monitor`, all exited
|
||||
on their own and were confirmed dead).
|
||||
|
||||
**1. Gates (main tree, guarded).** `cargo fmt --all -- --check` clean.
|
||||
`cargo clippy --all-targets` clean, zero warnings, no new `#[allow]` (checked
|
||||
the diff directly). `cargo test --workspace`: **4 365 passed, 0 failed**,
|
||||
exactly the dev's number. Per-binary diff against the `repo-ref` clone at bare
|
||||
`eb54042` (4 360 passed there): every binary's count is identical except
|
||||
`lucisv_server`'s `unittests src/main.rs` (1 645 → 1 650, +5) — matching the
|
||||
dev's own accounting exactly (one test rewritten in place — the §61.3 test
|
||||
`a_target_outside_the_head_is_answered_when_the_head_is_published_and_is_empty`
|
||||
→ `a_target_outside_the_head_is_asked_again_rather_than_answered_nowhere`,
|
||||
read and judged correct: it now asserts the settled location instead of an
|
||||
inside-the-scan `[]`, which is exactly right given the rule this lane ships —
|
||||
plus five new tests). Nothing lost anywhere. Production line counts:
|
||||
`server/index.rs` 225, `dispatch.rs` 485, `server/mod.rs` 169, `state/scan.rs`
|
||||
128, `state/discover.rs` 329 — all match the README exactly.
|
||||
`state/mod.rs` **976**, unchanged, confirmed (counting stops one line before
|
||||
the `#[cfg(test)]` attribute, not `mod tests {` itself — the same off-by-one
|
||||
also explains `candidates.rs`, 405 vs my raw 406). **One inaccuracy found and
|
||||
noted, not fixed** (it is in a Work log entry, not the Status/Handshakes
|
||||
sections QA may touch): `includes.rs` is cited as "605 (untouched)" but its
|
||||
actual non-blank/non-comment production count before its first `#[cfg(test)]`
|
||||
is **273**, under any counting convention I could construct (with or without
|
||||
doc comments, with or without blank-only stripping). The file is genuinely
|
||||
untouched by this diff and 273 is nowhere near any CLAUDE.md threshold either
|
||||
way, so this is a citation slip in the prose, not a gate or a size problem —
|
||||
flagged for the lead to correct in the work log if they choose.
|
||||
|
||||
**2. The probe.** Read `tools/perf/phases_r4.py` and the `lspclient.py` diff
|
||||
in full.
|
||||
- `offer()`'s send loop is `while sent < ticks`, ticks fixed
|
||||
(`WINDOW_MS[cache] // rate`), computed once up front — no early exit on
|
||||
server silence. The shipped probe cannot reproduce "stopped in a lull";
|
||||
confirmed by reading the loop, there is no path back to the caller before
|
||||
`sent == ticks`.
|
||||
- `lspclient.py`'s `_dispatch` (called only from `_read_loop`, the reader
|
||||
thread — confirmed by grep) stamps `self._arrived[id] = time.perf_counter()`
|
||||
the instant a response is parsed, before any caller could see it.
|
||||
`poll_answers` reads that stamp and never blocks — it only pops entries
|
||||
already in `self._inbox` matching a pending id. This is the arrival-time
|
||||
fix the review's confound needed.
|
||||
- Same offered load to both binaries: confirmed directly off the evidence —
|
||||
every REF/CAND pair I read had identical `requests_offered` and
|
||||
`requests_answered` (e.g. 35 offered / 105 answered across 3 tries, both
|
||||
binaries, warm 100 ms 1-buffer cell).
|
||||
- `mismatched_answers`/`unsettled_answers` are computed in `summary()` against
|
||||
`run["settled_answer"]`, which is a **final same-params request sent at the
|
||||
end of the same session** (`s.request("textDocument/definition", params)`)
|
||||
— same request, same cursor, correct comparison target.
|
||||
- The probe's own limitation (`settled_ms` floored by the fixed window) is
|
||||
understood and does not taint any quoted number: every table in the README
|
||||
uses `scan_total`/`scan ms` (the server's own trace), never `settled_ms`,
|
||||
and `mid_scan_*` is explicitly not quoted for the same reason. Confirmed by
|
||||
reading `publication()` (`out["scan_total"] = stages.get("total", 0.0)`)
|
||||
and by re-deriving the README's own numbers from the raw evidence (below).
|
||||
|
||||
**3. Coherence under load, and the sabotage.** `publish_scan`
|
||||
(`state/mod.rs:1167`) absorbs the index, the candidates table and the include
|
||||
graph in one synchronous call with no interleave point inside it — a
|
||||
structural guarantee, not a tested-and-hoped one, since this is a
|
||||
single-threaded event loop. `answer_what_is_waiting` (`server/index.rs`)
|
||||
calls `publish_scan` to completion *before* splicing `self.deferred` or
|
||||
`arrived` into the batch that gets dispatched, so no request can ever observe
|
||||
a batch published mid-way through. I wrote and ran the direct witness the
|
||||
task asked for (`state::tests::a_cadence_publish_never_lets_the_index_and_the_
|
||||
candidates_table_disagree`, in the scratch clone only — a 513-file tree,
|
||||
scanned exactly to the `PUBLISH_EVERY` boundary, one `publish_scan` call, then
|
||||
asserting every one of the 512 just-published module names is in *both*
|
||||
`index().units()` and `candidates().has_module()`, and the 513th is in
|
||||
*neither*). It passes on the real candidate. **Sabotage**: commented out
|
||||
`self.candidates.absorb(&self.index, words)` inside `publish_scan` — the test
|
||||
fails immediately (`cohmod0000 published: candidates`), then reverted (byte-
|
||||
diff against the pre-sabotage copy confirmed clean).
|
||||
|
||||
`scanload`/`scanloadcross` re-run, independently, on the dev's own release
|
||||
binaries (hashes verified: REF `f7a5a27e…`, CAND `4af863c1…`, both match the
|
||||
tracker record exactly) against the same read-only opentitan corpus, fresh
|
||||
storage under my scratchpad:
|
||||
- warm 100 ms, 1 buffer: REF p50 102.7 / p90 182.4 / max 209.6 ms; CAND p50
|
||||
0.8 / p90 177.4 / max 419.9 ms. `mismatched_answers` 0, `unsettled_answers`
|
||||
0, offered = answered = 105, both binaries.
|
||||
- warm 100 ms, 11 buffers: REF p50 1970.2 / p90 3367.8 / max 3699.6 ms; CAND
|
||||
p50 0.9 / p90 396.7 / max 700.7 ms. Same zero/zero, same offered=answered.
|
||||
- `scanloadcross`, all 8 cells (cold/warm × 1/11 buffers × REF/CAND):
|
||||
`mismatched_answers` 0 in every cell; `unsettled_answers` — REF 12/270,
|
||||
270/270, 9/105, 105/105 (the 9 vs the archived 12 at warm/1-buffer is
|
||||
ordinary run-to-run timing noise around the head-publish boundary — the
|
||||
*shape* is identical); **CAND 0/0/0/0 in every one of the 8 cells**, on a
|
||||
completely independent run.
|
||||
|
||||
This reproduces the archived record's own numbers closely (warm/1-buffer
|
||||
REF p50 112.3→102.7, CAND max 421.9→419.9; warm/11-buffer REF p50
|
||||
1960.1→1970.2, max 3672.0→3699.6, both within a few percent) and confirms
|
||||
`mismatched_answers`/`unsettled_answers` are 0/0 everywhere for the candidate,
|
||||
never withholding or coherence-breaking a single answer, on data this session
|
||||
generated itself rather than only reading the dev's own.
|
||||
|
||||
**4. The empty-answer rule.** Three methods (`GotoDefinition`,
|
||||
`GotoTypeDefinition`, `References`) — confirmed directly in
|
||||
`server/dispatch.rs`'s `NAVIGATION` const, and the handler match arms confirm
|
||||
`Hover` is not among them. Dev's shipped tests cover: cross-folder definition
|
||||
asked again and answered right, exactly once; the same for typeDefinition;
|
||||
hover never deferred (answered inside the scan); a genuinely-empty answer
|
||||
(`nowhere`) answered `[]` at settle; `HEAD_WALK_MAX` pinned. Three cases the
|
||||
shipped tests do not cover, which I wrote in the scratch clone
|
||||
(`server/tests/startup.rs`, using `process_batch`/`Server::deferred` directly
|
||||
— both reachable from `server::tests::*` by ordinary Rust module privacy,
|
||||
since they are plain-private items in an ancestor module):
|
||||
- `a_cancel_sharing_a_publish_with_a_deferred_request_still_cancels_it` — a
|
||||
cancel in the **same** batch as a deferred request still cancels it
|
||||
(`cancelled_in` scans the whole batch regardless of position). Passes.
|
||||
- `a_cancel_that_arrives_while_its_request_is_still_deferred_does_not_reach_it`
|
||||
— **a real gap, found and pinned, not a hard-invariant violation.** A
|
||||
cancel that arrives in its *own* batch, while its request is sitting in
|
||||
`Server::deferred` (not yet reunited with a publish), is consumed by
|
||||
`process_batch`'s local `consumed_cancels` for that call and does not
|
||||
survive to the next one. The deferred request is later answered normally —
|
||||
a **real, uncancelled answer** — as if the cancel never happened. This
|
||||
costs nothing under the hard invariants QA is bound to (exactly one
|
||||
response is still sent, no request is lost, no answer is wrong), so it is
|
||||
**not** a REWORK finding by the letter of this task's own criteria. But
|
||||
`docs/features/cancel-request/README.md`'s own stated reasoning for
|
||||
dropping a late cancel — *"by then the request has been answered"* — is
|
||||
false for a request sitting in `deferred`: it has not been answered at all
|
||||
yet. `deferred` is a new kind of "not yet answered but no longer in a
|
||||
burst" state that predates neither README knew about the other. **Filed as
|
||||
a handshake request below**, not fixed by QA (touches `cancel-request`'s
|
||||
own Assumptions section, outside this feature's scope).
|
||||
- `two_deferred_requests_are_answered_in_the_order_they_arrived` — `deferred`
|
||||
is append-only (`Vec::push`, `std::mem::take`, never reordered), so two
|
||||
requests deferred in the same scan are answered in arrival order. Passes.
|
||||
|
||||
All three compiled and ran clean against the real candidate
|
||||
(`cargo test -p lucisv_server --bin lucisv-server deferred`, 4 passed).
|
||||
|
||||
**5. Sabotage: "never re-ask."** Commented out
|
||||
`self.answer_what_was_deferred()` in `finish_scan` (`server/index.rs`) — the
|
||||
shipped cross-folder test
|
||||
(`a_target_outside_the_head_is_asked_again_rather_than_answered_nowhere`)
|
||||
fails with "a result, not a failure" (the request is never answered at all —
|
||||
a lost request, exactly the REWORK class this task names). Reverted; byte-
|
||||
diff against the pre-sabotage copy confirmed clean; test passes again.
|
||||
|
||||
**6. `HEAD_WALK_MAX`.** Read the bound (`state/discover.rs:450`,
|
||||
`head.len() > HEAD_WALK_MAX`) and the dev's fixture
|
||||
(`a_folder_bigger_than_the_head_bound_is_scanned_exactly_as_it_always_was`,
|
||||
513 files in one folder). Sabotaged the branch (`if false && head.len() >
|
||||
HEAD_WALK_MAX`) — the test fails exactly as the README claims:
|
||||
`"515 files (the folder first)"` (513 in the neighbourhood folder + 2 more
|
||||
from `a_block_and_a_crowd`'s fixed padding). Reverted; clean.
|
||||
|
||||
**7. The tail — characterized, not failed.** Re-derived the R4 baseline split
|
||||
straight from `~/.cache/lucisv-perf/take5r-4/paired.jsonl`'s per-try
|
||||
`publication` records for the warm/100 ms/1-buffer cell: REF averages
|
||||
scan 4206.14 ms / publication 3105.27 ms across 34.3 publishes; CAND averages
|
||||
scan 2188.36 ms / publication 587.99 ms across 4.67 publishes — both exactly
|
||||
the README's headline numbers, independently recomputed from the raw
|
||||
per-request arrays rather than trusted from the prose.
|
||||
|
||||
*Attributing the CAND max (421.9 ms, warm/1-buffer, this cell is not
|
||||
cross-folder so the empty-answer rule never fires on it — the wait is purely
|
||||
cadence).* Average publish spacing here is scan/publishes ≈ 2188/4.67 ≈
|
||||
469 ms; a request landing just after a publish waits close to the full next
|
||||
interval. 421.9 ms is consistent with exactly that — a request arriving
|
||||
right after a publish, waiting almost the whole way to the next one — not a
|
||||
deferral (none possible on this cursor) and not the startup's `held` clause
|
||||
(the first useful answer already landed at ~80–115 ms, long before most of
|
||||
this cell's requests are sent).
|
||||
|
||||
*What T = 100 ms would cost, estimated from the trace.* `absorb`'s cost is a
|
||||
**whole-index merge**, i.e. roughly proportional to the index's size at the
|
||||
moment of the call, not to the batch just staged (the README's own finding,
|
||||
confirmed by reading `WorkspaceIndex::absorb`'s doc comment and
|
||||
`update_facts`'s targeted-merge counterexample beside it). For K evenly
|
||||
spaced publishes over a scan that reaches a fixed final size S, each publish
|
||||
i costs roughly c·i·(S/K), so total absorb cost is c·S·(K+1)/2 — **linear in
|
||||
the number of publishes, for a fixed corpus**. Going from the cadence's
|
||||
current K≈4.7 (this cell) to a clock bound that fires roughly every 100 ms —
|
||||
which, given requests arrive every 100 ms and something is almost always
|
||||
waiting, would mean roughly one publish per 100 ms of wall clock, i.e. K on
|
||||
the order of 20+ over a ~2 s scan — would raise total publication cost
|
||||
*roughly in proportion*, back up toward the 2 000–3 000 ms range: most of
|
||||
this cell's −78 % publication win given back. This is not a coincidence: the
|
||||
**reference's own pre-cadence behaviour already published once every
|
||||
4206/34.3 ≈ 123 ms on average** — almost exactly a T=100 ms clock bound. A
|
||||
secondary time bound at T=100 ms would reproduce close to the *reference's*
|
||||
publication cost for exactly the load this cell offers, while presumably
|
||||
still helping a slower (250 ms) or quieter client. That trade is the lead's
|
||||
to rule on; the count-based `PUBLISH_EVERY` alone does not have this failure
|
||||
mode because it is insensitive to how fast the client asks.
|
||||
|
||||
**8. Controls, re-run** (dev's own REF/CAND release binaries, hashes
|
||||
verified, fresh storage under my scratchpad, `tools/guard.sh -m 8 -t 1800`):
|
||||
|
||||
| cell | archived median | QA re-run median | Δ |
|
||||
|---|---:|---:|---:|
|
||||
| quiet scan, warm, REF | 981.0 | 1033.2 | +5.3% |
|
||||
| quiet scan, warm, CAND | 983.7 | 1051.7 | +6.9% |
|
||||
| quiet scan, cold, REF | 2747.5 | 2831.6 | +3.1% |
|
||||
| quiet scan, cold, CAND | 2715.9 | 2826.2 | +4.1% |
|
||||
| first useful answer, cold, REF | 78.2 | 82.0 | +4.8% |
|
||||
| first useful answer, cold, CAND | 80.8 | 81.3 | +0.7% |
|
||||
| first useful answer, warm, REF | 115.1 | 113.0 | −1.9% |
|
||||
| first useful answer, warm, CAND | 115.8 | 113.4 | −2.1% |
|
||||
| idle RSS, cold, REF (KiB) | 502736 | 502528 | −0.04% |
|
||||
| idle RSS, cold, CAND (KiB) | 501872 | 504240 | +0.5% |
|
||||
| idle RSS, warm, REF (KiB) | 427200 | 427984 | +0.2% |
|
||||
| idle RSS, warm, CAND (KiB) | 426448 | 426688 | +0.06% |
|
||||
|
||||
All twelve within the requested ±10 % (the widest is +6.9 %, general machine-
|
||||
load noise — the session's one-minute load was higher during this QA rerun
|
||||
than the dev's own session start). Store 45 404 KiB, identical, both re-runs.
|
||||
The 24-of-24 scope cells were checked against the archived evidence directly
|
||||
(every `scopes` row's `result_count` equal REF vs CAND) rather than re-run,
|
||||
since nothing about scope resolution is in this diff's file list.
|
||||
|
||||
**Traceability (item 8): 17 numbers independently reproduced from
|
||||
`~/.cache/lucisv-perf/take5r-4/` and matched exactly to the README/tracker
|
||||
prose**, beyond the twelve controls above: 4206, 3105 (REF scan/publication
|
||||
ms), 2188, 588 (CAND scan/publication ms), 112.3, 168.0 (REF latency
|
||||
median/max), 1.9, 421.9 (CAND latency median/max), 4506, 3938 (scanserve cold
|
||||
session completion REF/CAND), 122.2, 45.6 (scanserve cold median REF/CAND),
|
||||
12/270 and 270/270 (REF cross-folder unsettled counts), 0 (CAND, every
|
||||
cross-folder cell). One small nuance, not a finding: `scanserve`'s quoted
|
||||
"1 692 → 1 697" (warm session completion) matches REF's **median** but CAND's
|
||||
**mean** (median of that row is 1704.7); both readings say "flat," which is
|
||||
the only claim resting on it, so this is noted rather than filed.
|
||||
|
||||
**Verdict: PASS.** No coherence violation (sabotage-tested), no lost request
|
||||
under the shipped code (the "never re-ask" sabotage is the one that produces
|
||||
a lost request, and it is not what shipped), no wrong mid-scan answer
|
||||
(`mismatched_answers` 0 everywhere, in the dev's evidence and in two
|
||||
independent re-runs this session generated). The tail's four higher cells are
|
||||
characterized, attributed and estimated, not treated as a failure, per the
|
||||
task's own framing. One real, non-blocking gap found and pinned by a new test
|
||||
(`$/cancelRequest` against a `deferred` request outside its own batch is
|
||||
silently ineffective — exactly-one-response is preserved, nothing is lost or
|
||||
wrong) and one documentation inaccuracy (`includes.rs`'s cited line count).
|
||||
|
||||
**Handshakes/topo, for the lead:**
|
||||
1. `server::index ──▶ state::scan` (`publish_is_due`) and
|
||||
`server::mod ──▶ server::dispatch` (`names_nowhere`, `ask_again_if_empty`)
|
||||
— as the dev already filed.
|
||||
2. **New, from QA:** `docs/features/cancel-request/README.md`'s Assumptions
|
||||
section ("a cancel arriving in a later burst than its request is dropped
|
||||
… by then the request has been answered") is now incomplete: a request in
|
||||
`Server::deferred` is neither `held` nor answered, and a cancel that
|
||||
arrives in a batch that does not also carry a publish reuniting it with
|
||||
`deferred` is dropped without effect, same as the general rule, but the
|
||||
*reason* stated for that rule no longer covers every case it's applied to.
|
||||
No code change needed (LSP allows ignoring a cancel; exactly-one-response
|
||||
holds) — a one- or two-sentence dated amendment to `cancel-request`'s
|
||||
Assumptions, cross-linked from `perf5r-publication`'s Handshakes, closes
|
||||
the gap in the documentation rather than the code.
|
||||
3. `lspclient.py`'s two hunks (`_arrived` timestamp map, `poll_answers`) are
|
||||
additive and confirmed not to change `await_id`'s existing behaviour
|
||||
(one line added that writes a stamp `await_id` never reads).
|
||||
4. The cadence constant is `PUBLISH_EVERY = 512` (`state/scan.rs`),
|
||||
deliberately equal to `HEAD_WALK_MAX`; both are now `pub(crate)`, tested
|
||||
directly rather than against the number spelled out again.
|
||||
|
||||
TODO §61.4's QA line ticked below.
|
||||
|
||||
### 2026-09-09 — independent 0.52.0 review: load-probe corrections needed
|
||||
|
||||
The publication improvement was independently reproduced against 0.51.0:
|
||||
with two open buffers and 35 requests every 100 ms per process, three properly
|
||||
warmed processes per version, median server scan duration fell 4,247 → 1,771 ms,
|
||||
publishes 34 → 4, all 105 requests answered and all equal to the settled
|
||||
target. The full-window request median fell 1,947 → 2.03 ms; this includes
|
||||
post-scan responses. Cross-folder probes returned the settled target in all
|
||||
750 candidate responses, versus 399 premature empty answers in the reference.
|
||||
|
||||
**Two harness findings, F2/F3 (P2), open:** `load_cell` labels a fresh store
|
||||
warm without priming it (a separate proof measured 3,974 misses and 1,684 ms
|
||||
parsing on the first nominally warm run, versus 3,974 hits and zero misses on
|
||||
the second). Also, `settled_at` mistakes `wait_quiet`'s positive entry-time
|
||||
delta for new scan activity. Candidate `settled_ms` follows the 3.4-second
|
||||
request window even though the scan ends at about 1.77 seconds, and all 105
|
||||
responses are mislabeled mid-scan. The review therefore uses a warmed rerun
|
||||
and `publication.scan_total`, not the erroneous completion/partition fields.
|
||||
|
||||
No implementation was changed. [Full review and repair gates](../../performance_052_review.md),
|
||||
[raw evidence](../../perf/review-052-20260909/README.md). These findings do not
|
||||
assert that all previous warm runs were unprimed or invalidate the measured
|
||||
publication-count reduction.
|
||||
|
||||
**2026-09-09, later — F2 and F3 are fixed** (dev, in the F1 lane; the harness
|
||||
half of the same round). `phases_r4.prime` runs one untimed session before a
|
||||
warm cell's first timed trial and `cell_status` refuses a warm cell whose trial
|
||||
found nothing in the store: with a brand-new `--storage`, both timed trials now
|
||||
report 3 975 hits and 0 misses. `Session.scan_completed_at` is stamped in the
|
||||
reader thread on the indexing bar's own `$/progress` `end`, so `settled_ms`
|
||||
reads 1 774 ms for a scan the server's own trace calls 1 768 ms — not the
|
||||
3 406 ms of the request window — and the responses partition 32 mid-scan /
|
||||
38 after-settle instead of every one of them mid-scan. Widening the window
|
||||
3 500 → 5 000 ms leaves completion at 1 781/1 791 ms and grows only the
|
||||
after-settle count (38 → 64), which is the review's own check. Details and
|
||||
numbers: `docs/perf/take5-tracking.md`, the F2/F3 rows.
|
||||
|
||||
### 2026-09-09 — QA (Sonnet), TODO §62.2: PASS
|
||||
|
||||
**Verdict: PASS.** Read the diff (`tools/perf/lspclient.py`,
|
||||
`tools/perf/phases_r4.py`) and reran both harness fixes against the
|
||||
candidate server on opentitan, guarded, from the main tree.
|
||||
|
||||
**F2, a brand-new `--storage`, 2 independent tries (fresh directories
|
||||
both times), `scanloadprobe` (the fast one-warm-cell loop):**
|
||||
|
||||
| Try | cache_hits | cache_misses | status |
|
||||
|---|---|---|---|
|
||||
| 1 | [3975, 3975] | [0, 0] | ok |
|
||||
| 2 | [3974, 3974] | [0, 0] | ok |
|
||||
|
||||
Both timed trials hit on both tries — `phases_r4.prime`'s untimed session
|
||||
does fill the store before the first timed measurement, and `cell_status`
|
||||
found nothing to refuse. (I did not additionally force a warm cell to
|
||||
report a real miss to see the "error" path fire — the diff's own
|
||||
`cell_status` branch is a direct, three-line read: `if cache == "warm" and
|
||||
any(hits == 0 ...)`, unambiguous by inspection.)
|
||||
|
||||
**F3, the same runs' scan-completion accounting:**
|
||||
|
||||
| Try | scan_completed_ms | server trace `scan_total` | scan_ends | mid_scan / after_settle |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 1494.31 / 1494.86 | 1485.73 / 1486.24 | 1 / 1 | 30 / 40 |
|
||||
| 2 | 1753.85 / 1745.77 | 1744.80 / 1736.47 | 1 / 1 | (not recorded) |
|
||||
|
||||
`scan_completed_ms` sits within 9 ms of the server's own reported
|
||||
`scan_total` in both tries (well inside the ±20 ms the task asked to
|
||||
check), exactly one `end` per session, and responses split sanely between
|
||||
mid-scan and after-settle rather than all landing in one bucket.
|
||||
|
||||
**The widened window.** Copied `tools/perf/phases_r4.py` into my scratchpad
|
||||
and changed `WINDOW_MS["warm"]` 3500 → 5000 only there (never in the main
|
||||
tree), reran `scanloadprobe` against the candidate with a third fresh
|
||||
`--storage`: `scan_completed_ms` ≈ 1745–1751 ms — unmoved in kind from the
|
||||
3500 ms-window runs above (same corpus, same cursor, unrelated to how long
|
||||
the offered-load window ran) — while `after_settle_answers` grew 40 → 64,
|
||||
`mid_scan_answers` stayed in the same 30s band (36). Matches the review's
|
||||
own acceptance: completion stable, after-settle count grows with the
|
||||
window.
|
||||
|
||||
**The quiet-control row.** `load_cell`'s `record(**dict(got, ms=...))`
|
||||
call for `rate=0` was exercised as a side effect of every `scanloadprobe`
|
||||
run above's cell status line (`quiet control` is not itself a separate
|
||||
call in `scanloadprobe`, so I additionally re-read the `record(...)` call
|
||||
site at `tools/perf/phases_r4.py` — the merge is `dict(got, ms=...)` then
|
||||
splatted, and `got` (from `summary()`) carries no key that collides with
|
||||
the explicit `phase=`/`row=`/`fresh_process=`/`result_count=`/`rate_ms=`/
|
||||
`open_buffers=`/`note=` keywords also passed, so the `record(**got)`
|
||||
duplicate-keyword bug the tracker names as historical cannot recur here);
|
||||
no exception in any of the runs above, which all reach that call.
|
||||
|
||||
**Gates.** Covered under the §62.1 entry above (same guarded `cargo fmt`/
|
||||
`clippy`/`test --workspace` run; this feature's own files —
|
||||
`tools/perf/*.py` — are not compiled). **opentitan** unchanged
|
||||
throughout (checked alongside the §62.1 runs). **Guard**: every bench
|
||||
invocation ran through `tools/guard.sh -m 8 -t 1800 --`; no kills; no
|
||||
lingering processes.
|
||||
|
||||
**TODO §62.2's QA line is ticked.**
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-08 (lead).** Accepted, with one fix made by the lead and one
|
||||
ruling.
|
||||
|
||||
- The probe came first and its first draft was thrown away for exactly
|
||||
the reason the review warned about (it stopped sending in a lull). The
|
||||
shipped one offers the same fixed load to both binaries, and what it
|
||||
found is the number that mattered: a publish costs the size of the
|
||||
index, not the batch, because `absorb` ends in a whole-index merge —
|
||||
3.1 s of publication in a 4.2 s loaded warm scan whose quiet form is
|
||||
1.0 s.
|
||||
- The cadence is the boring answer and it lands: one merge per 512 files
|
||||
instead of one per burst, the waiting drain exempt so the first useful
|
||||
answer never moves; publication −78 to −88 %, loaded scans −48 to
|
||||
−65 %, median wait 112 → 1.9 ms warm, served requests equal in every
|
||||
cell, coherence intact (QA's sabotage of the candidates absorb fails
|
||||
the agreement test).
|
||||
- **Ruling on the tail.** Four single-buffer cells have a higher max
|
||||
(worst 168 → 422 ms warm), attributed by QA to cadence spacing, not to
|
||||
the deferral. A time bound on the cadence (T ≈ 100 ms while a request
|
||||
waits) would give most of the publication win back, since the old
|
||||
spacing was already ~120 ms. Not taken: the median and the completion
|
||||
are what a user feels across a scan, and the max is one request per
|
||||
session at a cost that stays under half a second. Recorded in the
|
||||
tracker as the trade.
|
||||
- The empty-answer rule closes §61.3's honest limit: `unsettled_answers`
|
||||
0 in every cell, the cross-folder request answered with the right
|
||||
location before or at settle, exactly once, and hover untouched.
|
||||
- **Fixed by the lead (QA's finding):** a `$/cancelRequest` naming a
|
||||
request in the deferred set was dropped, and the request later
|
||||
answered normally. `process_batch` now takes a deferred request out and
|
||||
answers it cancelled where the cancel lands; pinned by
|
||||
`a_cancel_for_a_deferred_request_answers_it_cancelled_and_forgets_it`
|
||||
(the request is planted, since a real deferral lives only inside a
|
||||
running scan).
|
||||
- `HEAD_WALK_MAX` is now pinned (QA's request from §61.3).
|
||||
- Deviations accepted: the two additive `lspclient.py` hunks; the warm/
|
||||
cold split of the probe for the guard; the `scanloadcross` phase.
|
||||
|
||||
Docs applied at merge: topo (the cadence, the `deferred` state and its
|
||||
cancel rule, `HEAD_WALK_MAX`); the cancel-request README's dated entry;
|
||||
the tail trade in the tracker.
|
||||
@@ -0,0 +1,659 @@
|
||||
# perf5r-scope-reuse — the rename's scope stage, measured and then reused
|
||||
|
||||
Take 5 **review round** §3 items 1–4 (`docs/performance_take5_review.md`),
|
||||
TODO §61.5, tracker rows **R3c** (measure) and **R3b** (reuse). Reference
|
||||
tree `07ef771` — §61.1–§61.4 already merged, so the cheap refusals of §61.1
|
||||
are already gone and what is left on the slow road really is the scope build.
|
||||
|
||||
## Goal
|
||||
|
||||
A hierarchical `state_q` rename on OpenTitan costs about 400 ms, and §P2a's
|
||||
trace says **229 ms of it is the scope build** — one parse and one analysis of
|
||||
every one of the 238 selected files. §P2d already proved the *selection* is
|
||||
not the lever: 133 of those files are containers a hierarchical tail folds
|
||||
through, needed for the **index** and for nothing else. This lane asks the
|
||||
other half of that question — whether a file needed only for the index has to
|
||||
be *parsed* to get there — and it asks it in two steps, in this order:
|
||||
|
||||
1. **R3c, measurement.** Split the 229 ms into what it is made of, ship the
|
||||
split in the engine's own trace, and write down the number that decides
|
||||
whether step 2 happens at all.
|
||||
2. **R3b, the reuse**, conditional on that number.
|
||||
|
||||
The answer to step 1 was **go at 34.3 %**, and step 2 is a door
|
||||
(`vlog_refactor::KnownFacts`) through which a caller hands back the index
|
||||
record it already holds for the exact bytes it is handing over. The engine
|
||||
skips that file's parse and nothing else changes: same edits, same warnings,
|
||||
same refusals, same index (asserted by fingerprint), verifier untouched.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **The persistent index cache is the only thing that can keep the
|
||||
`KnownFacts` promise in this server.** It is the one place that holds a
|
||||
record *and* the FNV-1a of the bytes that record was read off, written by
|
||||
the same read. The workspace index holds decoded records with no hash
|
||||
beside them, so it cannot be the source: a record filed under a path is not
|
||||
evidence about the text a rename was just handed. This is stated as an
|
||||
assumption because it is a property of today's `Workspace`, not something
|
||||
the type system enforces — see Handshakes.
|
||||
- Nothing downstream of the scope build reads a *non-kept* file's analysis.
|
||||
This is §P2b's own rule, restated: the retention rule is
|
||||
`text.contains(word)` for the old and the new name, and every later
|
||||
consumer — `collect_occurrences`, all five warning scans, `check`'s watched
|
||||
set — prefilters on `contains` or `contains_word` of one of those two
|
||||
names, which is a subset. A reused record therefore never denies a later
|
||||
stage an analysis it asks for; and if one ever did, `Scope::analysis`
|
||||
parses on demand exactly as it always has.
|
||||
- The cache's decode of a record produces the record the parse would have
|
||||
produced. That is `docs/features/index-persistence/README.md`'s own
|
||||
invariant, and every warm scan in the product already rests on it — this
|
||||
lane adds a second reader of the same answer, not a new claim.
|
||||
- A rename request runs on the server's main thread, which has
|
||||
`vlog_parser::PARSE_STACK_SIZE`. Unchanged: the reuse removes parses, it
|
||||
never adds one anywhere new.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**`lucisv_server ──▶ vlog_refactor` (new, additive).**
|
||||
`rename_traced_with(files, file, offset, new_name, &dyn KnownFacts, &mut
|
||||
RenameTrace)` is `rename_traced` plus one question the engine asks per
|
||||
selected file: *do you have the record `FileFacts::of(path, text)` would
|
||||
produce for exactly this text?* The engine promises that a `None` answer
|
||||
costs nothing but the file's usual parse, and that a `Some` answer changes
|
||||
only what it costs — the record is fed to `IndexBuilder::add_facts`, which is
|
||||
the same call the persistent cache's own scan hits make.
|
||||
|
||||
What the **caller** promises is the whole of the contract, and the engine
|
||||
cannot check it: verifying a record against the text it claims to describe
|
||||
means doing the parse the record exists to save. The engine does the two
|
||||
checks it can — it asks with the exact text it is about to index, and it
|
||||
refuses a record whose own `path()` is not the path it asked about — and
|
||||
trusts the rest. `crates/lucisv_server/src/rename.rs::Known` is the one
|
||||
implementation: a newtype over `&Workspace` whose entire body is
|
||||
`Workspace::known_facts`, so the promise is kept in exactly one place.
|
||||
|
||||
**Inside `lucisv_server` (no crate boundary crossed).**
|
||||
`Workspace::known_facts(path, text)` → `IndexCache::facts_now(path, text)` →
|
||||
`IndexCache::entry_for(path, text)`, which is now the single place where a
|
||||
record and the content hash it is filed under are compared. `facts_for` (the
|
||||
scan's counted reader) goes through the same function, so "the store answers
|
||||
for this text" means one thing in a scan and in a refactoring alike.
|
||||
`facts_now` differs from `facts_for` only in not counting its work into
|
||||
`IndexCache::work`, because that counter is what a scan's trace subtracts to
|
||||
say what *that scan* did.
|
||||
|
||||
**No handshake is requested and none is amended.** `vlog_semantic` is
|
||||
unchanged (`FileFacts::path`, `FileFacts::of`, `IndexBuilder::add_facts` and
|
||||
`WorkspaceIndex::fingerprint` were all already public and already used this
|
||||
way). `check/` has no diff. `docs/topo.md` needs one new row for the
|
||||
`KnownFacts` edge — the lead's to write at merge, per this lane's scope.
|
||||
|
||||
## The R3c measurement
|
||||
|
||||
`renametrace`, candidate-only, one `--verbose` session per row, repeat median
|
||||
of three; trace fields off the wire. Machine load 4.1–5.1. The `index`
|
||||
column is the whole scope stage; `lead`/`kept`/`other` are the per-file-class
|
||||
split this lane added, and `merge` is `IndexBuilder::finish`.
|
||||
|
||||
| rename | wire | index | lead | kept | other | **other / index** | merge |
|
||||
|---|---:|---:|---:|---:|---:|---:|---:|
|
||||
| **tail `state_q`** (238 files) | 401.2 | 242.4 | 0.4 | 133.5 | **83.1** | **34.3 %** | 23.4 |
|
||||
| ordinary `aes` (13) | 91.5 | 23.9 | 0.3 | 20.8 | 0.0 | 0.0 % | 2.7 |
|
||||
| unique internal `cipher_alert` (4) | 16.9 | 3.6 | 2.4 | 0.0 | 0.9 | 25.0 % | 0.3 |
|
||||
| common port `clk_i` (3 976, fallback) | 3 551.4 | 1 936.5 | 0.4 | 1 032.0 | **693.4** | 35.8 % | 195.3 |
|
||||
| conflict `state_q → state_d` (242) | 342.7 | 240.3 | 0.4 | 135.4 | 79.2 | 33.0 % | 23.2 |
|
||||
| new name many uses spell (3 976) | 2 971.6 | 2 009.8 | 2.9 | 1 067.3 | 724.5 | 36.0 % | 198.0 |
|
||||
| duplicate module `rstmgr_por` (3 976) | 2 279.4 | 1 982.9 | 1.9 | 5.6 | **1 740.5** | **87.8 %** | 199.6 |
|
||||
| no symbol (preflight) | 0.1 | 0.0 | — | — | — | — | — |
|
||||
|
||||
File counts: the tail selects 238 and keeps 134 of them, so **103 files are
|
||||
analysed for their index record and nothing else**. (§P2d's census counts 133
|
||||
"indirect" files by the index's postings; the retention rule's substring test
|
||||
is wider, so 30 of those do spell one of the two names somewhere and are
|
||||
kept. The two numbers answer different questions and both are in the trace.)
|
||||
|
||||
**Inside one file's analysis** — a *trace-only* build, measured once and not
|
||||
shipped (the same protocol §R1b used), expanding `FileFacts::analyzed` over
|
||||
the public API so its four parts can be timed apart. One deviation from the
|
||||
private body, counted under read-off: `FileFacts::from_analysis` clones the
|
||||
define table where the private path moves it.
|
||||
|
||||
| rename | lex (+`define` table) | parse | analyse | read-off |
|
||||
|---|---:|---:|---:|---:|
|
||||
| tail `state_q` | 70.2 (34 %) | 66.2 (32 %) | 40.4 (20 %) | 27.1 (13 %) |
|
||||
| common port `clk_i` | 604.3 (37 %) | 561.4 (35 %) | 252.0 (16 %) | 195.6 (12 %) |
|
||||
| duplicate module | 606.9 (37 %) | 568.6 (35 %) | 260.4 (16 %) | 197.6 (12 %) |
|
||||
|
||||
So the review's "parser versus index optimization" question has an answer:
|
||||
**the scope stage is two thirds lexer-and-parser**, the semantic analysis is
|
||||
a sixth of it, and the index merge is a further 10 % on top (`merge`, above).
|
||||
Nothing inside the parse is a lever on its own; what is a lever is not
|
||||
running it.
|
||||
|
||||
**Allocation.** No per-stage byte counter exists and none was added: counting
|
||||
allocations needs a `GlobalAlloc` wrapper, which is `unsafe` (CLAUDE.md
|
||||
forbids it) — so allocation is reported as the harness's own 50 ms peak-RSS
|
||||
sample across the request, per row, and as the bytes each class carries
|
||||
(`kept_bytes` / `other_bytes` in the trace). Tail: 606 MiB peak, 2.89 MB kept
|
||||
against 1.65 MB unread. Common port: 1 897 MiB peak against 19.9 MB kept and
|
||||
15.9 MB unread — the peak is where the `Semantics` of 1 248 files sit.
|
||||
|
||||
**The warning pass**, split into its five scans (§3 item 3):
|
||||
|
||||
| rename | warnings | `define` | macro args | SVA | unfinished | unaccounted | files lexed |
|
||||
|---|---:|---:|---:|---:|---:|---:|---:|
|
||||
| tail `state_q` | 49.7 | 1.9 | **41.7** | 2.6 | 0.4 | 0.0 | 135 |
|
||||
| ordinary `aes` | 8.3 | 0.2 | 7.1 | 0.2 | 0.0 | 0.2 | 13 |
|
||||
| common port `clk_i` | 431.5 | 13.2 | **371.4** | 15.3 | 4.1 | 0.2 | 1 249 |
|
||||
|
||||
**The 51 ms warning pass is 84 % one lex per file that spells the name**, and
|
||||
that lex is *already* shared by all five scans (§P2d's `FileScan` memo) — the
|
||||
macro-argument scan is simply the first one to ask for it, so the shared lex
|
||||
is billed to it. There is no duplicated work left in the pass to remove. The
|
||||
only way to remove the lex itself would be to retain the scope build's token
|
||||
streams for every kept file, and the `clk_i` row is why that was not done:
|
||||
1 249 files of retained tokens against a request that already peaks at
|
||||
1.9 GiB is a memory trade the review's own gate ("bounded peak RSS") forbids.
|
||||
Recorded as measured-and-declined, not as unexamined.
|
||||
|
||||
### The ruling
|
||||
|
||||
**Go — 34.3 %** on the tail rename (83.1 ms of 242.4 ms), against a 30 %
|
||||
condition. Every other multi-file row agrees (25 %, 33 %, 35.8 %, 36 %, and
|
||||
87.8 % on the duplicate-module refusal), and the two rows where it is 0 % are
|
||||
the ones where every selected file spells the name, which is exactly the case
|
||||
the reuse is not for.
|
||||
|
||||
## The R3b reuse
|
||||
|
||||
**What was built.** One question, asked once per selected file, before that
|
||||
file is analysed:
|
||||
|
||||
```rust
|
||||
pub trait KnownFacts {
|
||||
/// The record `FileFacts::of(path, text)` would produce, if the caller
|
||||
/// can promise it is exactly that; `None` otherwise.
|
||||
fn facts_for(&self, path: &Path, text: &str) -> Option<FileFacts>;
|
||||
}
|
||||
```
|
||||
|
||||
`Scope::assemble` classifies each file first (`Lead` / `Kept` / `Other` — the
|
||||
same `text.contains(word)` rule as before, only asked before the analysis
|
||||
rather than after it), then takes its contribution:
|
||||
|
||||
| the caller answers | `Lead` / `Kept` | `Other` |
|
||||
|---|---|---|
|
||||
| a record | the record + `analyze(parse(text))` — the parse is still owed, because a later stage reads the `Semantics` | the record, **and no parse at all** |
|
||||
| `None` | `FileFacts::analyzed(path, text)` — exactly as before | exactly as before |
|
||||
|
||||
So the parse formula `K + E` becomes **`(K − reused_other) + E`**, and the
|
||||
reuse also removes the record read-off (`Census`, the `define` table, the
|
||||
line index, `facts_from_analysis`) from every kept file whose record is
|
||||
known. The two halves of a reused kept file — the record from the caller, the
|
||||
`Semantics` from this text — agree because both are pure functions of the same
|
||||
bytes; that pairing is not new, it is what `Scope::analysis`'s on-demand path
|
||||
and the server's own warm scan step have always done.
|
||||
|
||||
**The hash tie, and where record and hash come from.** `Workspace::known_facts`
|
||||
is one line: `self.cache.facts_now(path, text)`. `IndexCache` files every
|
||||
record under the FNV-1a (`lucisv_core::cache::content_hash`, the same one
|
||||
function, never a second implementation) of the bytes it was read off, in the
|
||||
same store entry as the encoded record; `entry_for` is the only comparison
|
||||
anything makes against it, and both the scan's reader and this one go through
|
||||
it. So the record and its key are read from **one place**, written by the read
|
||||
that produced them. Nothing weaker is consulted: not a modified time, not a
|
||||
size, and — deliberately — **not the workspace index's own record**, which
|
||||
carries no hash of the bytes it came from and could be a record of some other
|
||||
text filed under this path.
|
||||
|
||||
**Unsaved-buffer precedence needs no rule.** A buffer with unsaved edits is
|
||||
not the bytes any record was written from, so it misses and is parsed —
|
||||
the same way a changed file misses. The handed text *is* the buffer's text
|
||||
(`rename_sources_traced` puts every open buffer in the set with
|
||||
`current_text`), and the reuse never looks anywhere else.
|
||||
|
||||
**Cross-file resolution is rebuilt for the candidate workspace, untouched.**
|
||||
Reuse changes only where a `FileFacts` came from; `IndexBuilder::finish` still
|
||||
sorts, assigns file ids and merges, and `resolve_external` still runs against
|
||||
*that* index. `check/` has no diff.
|
||||
|
||||
**What was deliberately not built.** An open document's finished analysis
|
||||
(`doc.tree` + `doc.semantics`) could be handed in as well, saving the parse of
|
||||
the one or two open buffers among 238 files. It is 1–2 parses of ~0.8 ms
|
||||
against a `Semantics` clone into the scope, and the door for it would have to
|
||||
carry an analysis as well as a record. Not worth the second shape; the record
|
||||
half of an open buffer is already reused whenever the buffer is saved.
|
||||
No persistent decoded-analysis cache was added, so there is no new memory
|
||||
budget to state: the reuse retains nothing past the request, and the records
|
||||
it clones are dropped with the scope.
|
||||
|
||||
## The R3b measurement
|
||||
|
||||
Paired against a reference built from the clean tree at **`07ef771`** before
|
||||
any edit of this lane
|
||||
(`50d8315a738103f006a28e1f6ea46c476a776fff1d880b860fc1bbcd83b315e9`);
|
||||
candidate `a041b5f3272ca8ff39d9d62e4ab46c896e82b43d0f4e37e11d96b27635f7d491`.
|
||||
Both `--release --locked`, both through the same harness, `--tries 3`, repeat
|
||||
median of three, **each phase run twice per binary with the order alternated**
|
||||
(head, r3b, r3b, head) and the two medians taken. No `cargo` ran during any
|
||||
timed phase; machine load 3.9–5.1 throughout; every command under
|
||||
`tools/guard.sh -m 8 -t 1800`, no guard kill.
|
||||
|
||||
| row | HEAD | R3b | Δ | parses | reused | peak RSS |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| **tail `state_q`** | 380.2 | **314.0** | **−17.4 %** | 240 → **137** | 238 | 615 → **596** MiB |
|
||||
| ordinary `aes` | 89.4 | 88.9 | −0.5 % | 22 → 22 | 13 | 448 → 448 |
|
||||
| unique internal `cipher_alert` | 16.9 | 15.2 | −9.8 % | 5 → 2 | 4 | 425 → 421 |
|
||||
| common port `clk_i` (fallback, 3 976) | 3 346.5 | **2 762.5** | −17.4 % | 3 977 → **1 251** | 3 976 | 1 881 → **1 787** |
|
||||
| conflict `state_q → state_d` (refused) | 320.5 | 260.1 | −18.8 % | 244 → 144 | 242 | 534 → 535 |
|
||||
| new name many uses spell (refused) | 2 689.0 | 2 191.5 | −18.5 % | 3 976 → 1 250 | 3 976 | 1 571 → 1 587 |
|
||||
| **duplicate module `rstmgr_por`** (refused) | 2 053.1 | **695.2** | **−66.1 %** | 3 975 → **14** | 3 976 | 887 → **718** |
|
||||
| no symbol (preflight) | 0.17 | 0.19 | +10.8 % | 0 → 0 | 0 | 417 → 417 |
|
||||
| `tailrename` phase | 380.0 | 336.7 | −11.4 % | — | — | — |
|
||||
| `rename` phase, `aes` | 90.8 | 92.0 | +1.3 % | — | — | — |
|
||||
| `blockers`, rename on `aes` | 115.1 | 114.9 | −0.1 % | — | — | — |
|
||||
| `execute`, extract refusal (805 ms row) | 800.2 | 794.7 | −0.7 % | — | 0 | — |
|
||||
| `execute`, extract-module edit | 147.7 | 148.3 | +0.4 % | — | 0 | — |
|
||||
| `execute`, inline refusal | 6.5 | 6.3 | −3.3 % | — | 0 | — |
|
||||
| `refactor`, connect-missing-ports resolve | 131.1 | 130.5 | −0.5 % | — | 0 | — |
|
||||
| `refactor`, expand-wildcard resolve | 54.1 | 54.9 | +1.4 % | — | 0 | — |
|
||||
| `refactor`, organize-imports resolve | 8.1 | 8.0 | −1.2 % | — | 0 | — |
|
||||
|
||||
Where the tail's 66 ms went, from the trace: index **219.8 → 156.2 ms**, of
|
||||
which `other` **83.1 → 0.0** (the container files stopped being parsed),
|
||||
`kept` **133.5 → 101.6** (their record read-off stopped being made), `merge`
|
||||
22.7 unchanged, and the reuse itself **31.1 ms** — 238 store lookups and
|
||||
decodes at about 0.13 ms each. Every stage outside the scope build is level:
|
||||
`verify` 71.6 → 71.6, `warnings` 50.1 → 50.2, `edits` 12.3 → 11.9, selection
|
||||
13.7 → 12.9.
|
||||
|
||||
### Gates
|
||||
|
||||
| gate | result |
|
||||
|---|---|
|
||||
| **≥ 20 % wire on the large rename** | **MISSED at −17.4 %** against this session's paired HEAD (380.2 → 314.0). Against the review's own 0.51.0 baseline of 398.3 ms it is −21.2 %, and the brief's absolute form of the same gate — **≤ 318 ms — is met at 314.0** |
|
||||
| bounded peak RSS | **met**, and lower everywhere it moves: tail 615 → 596 MiB, fallback 1 881 → 1 787, duplicate-module refusal 887 → 718; the one row that rose (+16 MiB on a 1.6 GiB refusal) is inside the sampler's spread |
|
||||
| `aes` not slower | **met**: −0.5 % (`renametrace`), +1.3 % (`rename`), −0.1 % (`blockers`) — all inside spread |
|
||||
| the fallback and the refusals not slower, RSS not higher | **met**: `clk_i` −17.4 %, conflict −18.8 %, new-name-many-uses −18.5 %, duplicate module −66.1 %, extract refusal −0.7 %, inline refusal −3.3 %; RSS lower or level on every one |
|
||||
| same edits / warnings / refusals | **met**: 36 paired rows compared on `fingerprint`, `message`, `status`, `result_count`, `edits`, `files`, `created`, `titles` — **0 mismatches**; and the new `renamewarn` phase compared **1 750 warning sentences line by line** across four renames (434 / 12 / 0 / 1 304), **all identical** |
|
||||
| the corpus probe | `a_corpus_rename_says_the_same_thing_however_many_records_are_reused` (`#[ignore]`d, `crates/vlog_refactor/tests/corpus.rs`): one rename over **860 files of real RTL** asked three ways — no records, every record, every second record — **byte-identical edits and warnings all three times**, parses **865 → 16 → 439**, index stage **1 262.4 → 201.3 → 744.7 ms** |
|
||||
| verifier untouched | **met**: `crates/vlog_refactor/src/check/` has no diff, and every existing verifier attack test is green and unmodified |
|
||||
|
||||
**The named remaining stage.** The reuse's own **31.1 ms of decode** is a
|
||||
third of the gross 95 ms saving, and it is the price of the one-place content
|
||||
tie: the record and its hash live in the store's encoded entry, so taking one
|
||||
means decoding it. Taking the *decoded* record from `WorkspaceIndex` instead
|
||||
and only the hash from the cache would remove almost all 31 ms and clear the
|
||||
percentage gate — and it is exactly the two-place tie this lane refused,
|
||||
because a record filed under a path is not evidence about the bytes a rename
|
||||
was handed. Behind it, the tail's next stages are `verify.rebuild` **37 ms**
|
||||
(`WorkspaceIndex::absorb`'s whole-index merge, which §61.4 already filed as
|
||||
`vlog_semantic`'s to fix) and `merge` **23 ms** (`IndexBuilder::finish`, the
|
||||
same merge). Both are outside this lane's files.
|
||||
|
||||
### Collateral: the other refactorings
|
||||
|
||||
**Not taken, and the rows above are the measurement.** The door is engine-wide
|
||||
by construction — `Scope::assemble` takes the `known` argument, so
|
||||
`Scope::build`'s callers could be given it — but reaching them means a `_with`
|
||||
entry point on each of `extract_module`, `inline_module`, `organize_imports`,
|
||||
five `ports::*` functions and `find_references`, in five files this lane does
|
||||
not own (`extract/`, `inline/`, `imports.rs`, `ports/`, `references.rs`).
|
||||
That is well past the "same three lines each" condition, so it is filed rather
|
||||
than done. The measured collateral today is therefore nil, as the table shows:
|
||||
the 805 ms extract refusal, the extract edit, both resolves and the inline
|
||||
refusal are all within ±1.4 % of HEAD.
|
||||
|
||||
Worth noting for whoever takes it: the 805 ms refusal was shown by R3c-x to
|
||||
be `boundary::Crossing::read`, *after* the scope build, so the door would
|
||||
shorten its prefix and not its cause — the resolves and the extract edit,
|
||||
whose scope builds are hundreds of files, are the better candidates. Neither
|
||||
has a stage trace, so no estimate is offered here.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] R3c: the scope stage split, shipped in the engine's own trace
|
||||
(`IndexTrace`: lead / kept / other / reused / merge, with files and
|
||||
bytes per class)
|
||||
- [x] R3c: the intra-analysis split (lex / parse / analyse / read-off) from a
|
||||
trace-only build, measured once and not shipped
|
||||
- [x] R3c: the warning stage split into its five scans (`WarnTrace`)
|
||||
- [x] R3c: the go/defer number — **go, 34.3 %** — and the ruling in TODO §61.5
|
||||
- [x] R3b: the `KnownFacts` door, the server's one implementation, the hash tie
|
||||
- [x] R3b: proofs — fingerprint equality on a part-reused index, a stale
|
||||
record refused, a misfiled record refused, the `(K − reused) + E`
|
||||
formula, warm-store/no-store parity, unsaved-buffer precedence, and
|
||||
an `#[ignore]`d 860-file corpus probe asked three ways
|
||||
- [x] R3b: the paired measurement against `07ef771` — five of six gates met,
|
||||
the wire-time percentage missed at −17.4 % (the absolute ≤ 318 ms form
|
||||
met at 314.0), with the remaining stage named and measured
|
||||
- [x] the collateral decision for the other refactorings — **not taken**,
|
||||
measured as nil, and why
|
||||
- [x] QA — PASS (2026-09-09, see QA log)
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-09-08 (dev).**
|
||||
|
||||
- Read §61 header, §61.5, the review's §3 and its Gate, the tracker's R3b/R3c
|
||||
rows, and `perf5-p2`, `perf5r-preflight`, `index-persistence`,
|
||||
`workspace-index`, `refactor-rename`, `topo.md` §1.2/§3.
|
||||
- Built the reference binary from the clean tree at `07ef771` **before any
|
||||
edit** and preserved it (`lucisv-server-head`,
|
||||
`50d8315a738103f006a28e1f6ea46c476a776fff1d880b860fc1bbcd83b315e9`).
|
||||
- **R3c first.** Added `IndexTrace` and `WarnTrace` to `vlog_refactor`'s
|
||||
trace, threaded through `Scope::build_keeping` and `Scope::warnings`. Both
|
||||
are out parameters filled as the build runs, in the shape `RenameTrace`
|
||||
already had, and both print as their own `name{…}` group so the existing
|
||||
`phases_p2.parse_trace` flattens them into `trace_index_*` /
|
||||
`trace_warnings_*` row fields with no harness change. The classification
|
||||
(`text.contains(word)`) moved from after the analysis to before it — the
|
||||
same pure question of the same two values — so the class can decide which
|
||||
stage the analysis is billed to, and (later) whether it happens at all.
|
||||
- Collapsed rather than kept the untraced wrappers: `build_keeping` and
|
||||
`warnings` take the trace, because a wrapper nothing called was dead code.
|
||||
- The intra-analysis split needed instrumentation inside
|
||||
`vlog_semantic::workspace::record::analyzed_facts`, which this lane may not
|
||||
change. Measured it instead in a **trace-only build** (§R1b's protocol): the
|
||||
private body expanded over the public API in `Scope`, run once, numbers
|
||||
recorded above, and the expansion removed before anything else was written.
|
||||
The shipped trace has no intra-analysis fields.
|
||||
- Ran `renametrace` at that build. **Go: 83.1 / 242.4 = 34.3 %.**
|
||||
- **R3b.** `KnownFacts` in `scope.rs`, `Building` (the build in progress) so
|
||||
`assemble` stays readable at one screen, `rename_traced_with` beside
|
||||
`rename_traced` with one shared body, `IndexCache::entry_for` +
|
||||
`facts_now`, `Workspace::known_facts`, and `rename.rs::Known`.
|
||||
- `facts_now` exists rather than reusing `facts_for` because `facts_for`
|
||||
counts its work into `IndexCache::work`, which `ScanTrace` subtracts per
|
||||
scan: a rename decoding 238 records between two scans would otherwise
|
||||
appear in the next scan's trace as decodes it never made. Both go through
|
||||
`entry_for`, so the content tie is still one function.
|
||||
- Proofs written before the measurement, all green:
|
||||
`an_index_part_reused_and_part_parsed_is_the_index_the_texts_build`
|
||||
(fingerprint + file ids + per-file analyses, two of four records reused),
|
||||
`a_caller_that_knows_nothing_builds_exactly_what_it_always_did`,
|
||||
`a_reused_record_removes_that_files_parse_and_changes_no_edit`
|
||||
(`(K − 3) + E`, every stage's parse count, edits and warnings identical),
|
||||
`a_file_whose_analysis_is_read_is_still_parsed_when_its_record_is_known`,
|
||||
`a_record_that_names_another_file_is_not_taken`,
|
||||
`a_request_local_read_answers_for_these_bytes_and_counts_as_no_scan_work`
|
||||
(the stale record refused four ways, and the scan counters untouched),
|
||||
`a_rename_over_a_warm_store_says_exactly_what_one_with_no_store_says`
|
||||
(server level: same edits, same warnings, `parses{index=2}` against 3),
|
||||
`an_unsaved_buffer_is_parsed_and_renamed_from_its_own_text`, and the
|
||||
`#[ignore]`d `a_corpus_rename_says_the_same_thing_however_many_records_are_reused`
|
||||
over the repo's 860-file corpus (run it with
|
||||
`tools/guard.sh -m 8 -t 1200 -- cargo test -p vlog_refactor --test corpus -- --ignored --nocapture`;
|
||||
it prints its own parse counts).
|
||||
- `cargo test --workspace` **4 374 passed, 0 failed** (4 366 at the start of
|
||||
the lane, +8 and none removed); `cargo fmt` clean; guarded
|
||||
`cargo clippy --all-targets --workspace` clean with no new `#[allow]`.
|
||||
|
||||
**2026-09-08 (dev), the measurement and what it cost.**
|
||||
|
||||
- Six phases, each run twice per binary with the order alternated, then the
|
||||
`renamewarn` phase once per binary. Numbers in "The R3b measurement" above;
|
||||
raw evidence and a reproduction recipe in `~/.cache/lucisv-perf/take5r-5/`.
|
||||
- `renamewarn` is new (`tools/perf/phases_r3b.py`) and exists because a hole
|
||||
was found while planning the parity proof: `schema.fingerprint` can carry
|
||||
warnings, but `phases_p2` calls it as `fingerprint(edit)` — and a rename's
|
||||
warnings never travel in the `WorkspaceEdit` at all, they are
|
||||
`window/logMessage` notifications. So no existing phase would have caught a
|
||||
reuse that kept every edit and dropped a sentence. It dumps them verbatim
|
||||
and they are compared line by line, not hashed.
|
||||
- The gate was measured, missed by 2.6 points, and reported as missed. The
|
||||
≥ 20 % is against this session's paired HEAD (380.2 ms); against the
|
||||
review's own 398.3 ms baseline the same 314.0 ms is −21.2 %, and the
|
||||
brief's absolute restatement of the gate (≤ 318 ms) is met. Closing the
|
||||
2.6 points is available and was **refused**: it means taking the decoded
|
||||
record from `WorkspaceIndex` and only the hash from the cache, and a record
|
||||
filed under a path is not evidence about the bytes a rename was handed.
|
||||
|
||||
**Deviations from the lane's stated file list, all flagged rather than silent:**
|
||||
|
||||
- `crates/vlog_refactor/src/rename/warnings.rs` (+33) is not in the list, and
|
||||
the lane's own instruction to split the `warnings` stage into its scans
|
||||
cannot be carried out without it. `Scope::warnings` has exactly one
|
||||
production caller, so the change is the trace parameter and nothing else.
|
||||
- `crates/vlog_refactor/src/rename/tests.rs` and `tests/corpus.rs` — test
|
||||
files for the module the lane owns; `crates/vlog_refactor/tests/*` is in the
|
||||
list and `src/rename/tests.rs` is the same crate's unit tests.
|
||||
- `crates/lucisv_server/src/state/mod.rs` gains **4 production lines** (a
|
||||
`&self` query and its doc comment), taking it 974 → 978. It is already the
|
||||
file TODO §55 is filed against, and the query must sit beside the private
|
||||
`cache` field it reads; moving one `&self` call into a new module would be
|
||||
worse than the four lines. Flagged for the lead.
|
||||
- `tools/perf/phases_r3b.py` (new), plus its one-line registration in
|
||||
`bench.py` and two rows in `tools/perf/README.md` — `tools/perf/` is in the
|
||||
list.
|
||||
- **Not mine:** `docs/perf/README.md` acquired a §61 round entry during this
|
||||
session (the lead's, §61.6). It was left untouched; the working tree was
|
||||
clean at `07ef771` when this lane started.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-09 (QA, Sonnet).** Verified in the main tree unless noted; code
|
||||
attacks in a fresh clone at `07ef771` with the working-tree diff applied
|
||||
(`/private/tmp/.../scratchpad/qa-61-5/clone`), never in the main tree.
|
||||
Verdict: **PASS**.
|
||||
|
||||
**1. Gates.** `cargo fmt --all -- --check` clean. `cargo clippy --all-targets
|
||||
--workspace` clean, no new `#[allow]` (grepped every touched file). `cargo
|
||||
test --workspace` (guarded, release): **4 374 passed, 0 failed, 45 ignored**
|
||||
— matches the dev's claim exactly. Re-ran `vlog_refactor` + `lucisv_server`
|
||||
alone in the isolated clone: 2 265 passed, 0 failed (then 2 268 after my own
|
||||
3 added tests, still 0 failed). `git diff --stat crates/vlog_refactor/src/check/`
|
||||
is empty. Production line counts (non-blank, non-comment, before the inline
|
||||
`mod tests {}` or the external `mod tests;` declaration): `scope.rs` 176,
|
||||
`rename/mod.rs` 423, `warnings.rs` 441, `trace.rs` 132, `index_cache.rs` 343,
|
||||
`state/mod.rs` 979 (dev says 974→978; 1-line off on my boundary heuristic,
|
||||
not a real discrepancy). All comfortably under the 600-line mark; nothing
|
||||
crosses a threshold.
|
||||
|
||||
**2. THE TIE.** Read `IndexCache::entry_for`/`facts_now`/`facts_for`
|
||||
(`crates/lucisv_server/src/index_cache.rs`), `Workspace::known_facts`
|
||||
(`state/mod.rs:489`) and `rename.rs::Known`. Confirmed: `entry_for` is the
|
||||
**one** place a record and its FNV-1a are compared (`self.entries.get(path)
|
||||
.filter(|e| e.content == content_hash(text.as_bytes()))`); `facts_now` and
|
||||
`facts_for` both go through it, differing only in whether `IndexCache::work`
|
||||
is charged; `known_facts` is one line to `self.cache.facts_now(path, text)`
|
||||
— the workspace index (`self.index`) is never consulted. `Known` is a
|
||||
newtype whose whole body is `Workspace::known_facts`.
|
||||
|
||||
Attacks, all in the clone:
|
||||
- **(a) stale-disk-after-scan** — new test
|
||||
`index_cache::tests::a_file_edited_on_disk_after_the_scan_misses_the_stale_record`:
|
||||
record a file, edit it on disk with no watcher event, confirm `facts_now`
|
||||
misses for the new bytes and still answers for the old ones. Passes.
|
||||
- **(b) tampered store line** — read the existing (pre-existing, not
|
||||
R3b/R3c's) tests `a_record_whose_facts_do_not_match_their_checksum_is_dropped`
|
||||
and the "accepted residue" test right after it. The store line is
|
||||
`content_hash\tfacts\tchecksum(facts)`; a hand-edited line whose facts no
|
||||
longer match its *original* checksum is dropped at load, never served. But
|
||||
a forger who recomputes the checksum over the corrupted facts (keeping the
|
||||
same content hash) **is** served — documented in the code as deliberate:
|
||||
"the checksum is an accident detector, not a MAC... a forger recomputes the
|
||||
checksum." This is a pre-existing property of the index store
|
||||
(`docs/features/index-persistence/README.md`), untouched by this lane's
|
||||
diff (`entry_for`/`facts_now` add no new logic here, they only add a second
|
||||
*reader* of the same decode path `facts_for` already used). It is reachable
|
||||
only by hand-editing the on-disk store file — not through any code path the
|
||||
product itself writes through (`IndexCache::record` always writes a
|
||||
checksum over the facts it actually encoded) — matching the review's
|
||||
"immutable cached facts" premise. Not a §61.5 finding; not rework.
|
||||
- **(c) unsaved buffer** — existing test
|
||||
`rename::tests::an_unsaved_buffer_is_parsed_and_renamed_from_its_own_text`
|
||||
(lucisv_server), run and green: a buffer whose text disagrees with disk
|
||||
misses the store (content key) and is parsed from the buffer's own text.
|
||||
- **(d) known record for an unselected path** — by construction: `take()`
|
||||
only calls `known.facts_for(path, text)` once per file already in the
|
||||
selected set, with that file's own path/text. A `KnownFacts` impl can
|
||||
return facts for a path the rename never asks about; nothing would ever
|
||||
call it, so there is nothing to ignore — verified by code reading, not a
|
||||
runtime scenario.
|
||||
- **(e) two files, identical content, different paths** — new test
|
||||
`index_cache::tests::two_files_with_identical_text_never_cross_their_records`:
|
||||
records both, confirms each is served its own `FileFacts::path()`, then
|
||||
updates one file's record content and confirms the other file's record for
|
||||
its original bytes is untouched and never answers for the sibling's new
|
||||
text. Passes. (Structurally guaranteed too: `IndexCache::entries` is
|
||||
`HashMap<PathBuf, Entry>` — path first, content second — so a content
|
||||
collision alone can never reach the wrong path's entry.)
|
||||
- **(f) kept files still parsed** — confirmed by code reading (`Building::take`:
|
||||
a `Kept`/`Lead` file with a known record still runs
|
||||
`analyze(&parse_source_tolerant(text).0, text)` to produce the `Semantics`
|
||||
a later stage reads; only the record read-off is skipped) and by the
|
||||
existing `lucisv_server` test
|
||||
`a_rename_over_a_warm_store_says_exactly_what_one_with_no_store_says`,
|
||||
which asserts `reused_files=3` but `parses{index=2` for its 3-file scope
|
||||
(bystander.sv is the one skipped).
|
||||
- **(g) sabotage.**
|
||||
1. `entry_for` with the hash filter removed (`self.entries.get(path)` and
|
||||
nothing else) → `index_cache::tests::a_request_local_read_answers_for_these_bytes_and_counts_as_no_scan_work`
|
||||
fails immediately ("a stale record must not be served"), and
|
||||
`rename::tests::an_unsaved_buffer_is_parsed_and_renamed_from_its_own_text`
|
||||
fails too (reused_files=2 instead of 1 — the stale on-disk record for
|
||||
the unsaved buffer's path gets served).
|
||||
2. `Workspace::known_facts` redirected to `self.index.facts_for(path)
|
||||
.cloned()` (the workspace index's own per-file record, which
|
||||
`WorkspaceIndex` does hold but with no content hash beside it) →
|
||||
**both** `an_unsaved_buffer_is_parsed_and_renamed_from_its_own_text` and
|
||||
`a_rename_over_a_warm_store_says_exactly_what_one_with_no_store_says`
|
||||
fail. Both sabotage variants restored afterward; re-ran the full
|
||||
`vlog_refactor`+`lucisv_server` suite clean (2 268/0) to confirm no
|
||||
residue.
|
||||
|
||||
**3. Index equality.** Existing test
|
||||
`an_index_part_reused_and_part_parsed_is_the_index_the_texts_build` checks
|
||||
fingerprint + file ids + per-file analysis print. Added
|
||||
`scope::tests::a_part_reused_index_answers_defines_and_reexport_queries_like_the_texts_build`
|
||||
(clone): a 4-file fixture with a `` `define`` table (a container file,
|
||||
reused) and a package re-export (`export b_pkg::*;`, also reused), lead file
|
||||
renaming a package member. Checked, mixed (part-reused) index vs a plain
|
||||
`WorkspaceIndex::build` on the same texts: fingerprint equal;
|
||||
`defines(file_id)` entry count equal; `member("b_pkg","SIG")` equal (found
|
||||
the right query — `units()` is file-scope names only, a package `localparam`
|
||||
is a *member*, not a unit; my first draft used the wrong query and caught
|
||||
itself); `references_to` count on that declaration equal; `members_of_chain("a_pkg")`
|
||||
(the re-export edge) equal; `hierarchical_declarations("SIG")` equal (empty
|
||||
both sides, path exercised). Also ran the existing `#[ignore]`d
|
||||
860-file corpus probe (`cargo test --release -p vlog_refactor --test corpus
|
||||
-- --ignored --nocapture`, guarded): reproduces the dev's parse counts
|
||||
exactly (**865 → 16 → 439**) and identical edits/warnings all three ways;
|
||||
absolute timings differ from the dev's (this machine's load), which is
|
||||
expected and not a finding.
|
||||
|
||||
**4. The verifier.** `check/` has zero diff (`git diff --stat
|
||||
crates/vlog_refactor/src/check/` empty) and every test under it passed
|
||||
unmodified as part of the full-workspace run. Sabotage: re-added a spurious
|
||||
parse for a reused `Other`-class file in `Building::take` (an extra
|
||||
`parse_source_tolerant(text)` billed to the same stage) →
|
||||
`rename::tests::a_reused_record_removes_that_files_parse_and_changes_no_edit`
|
||||
fails immediately (`left: 10, right: 7` against the asserted `(K-3)+E`
|
||||
formula). Restored; re-verified green.
|
||||
|
||||
**5/6. Parity and re-measurement.** Independently re-derived from the raw
|
||||
evidence in `~/.cache/lucisv-perf/take5r-5/` (not just read as prose):
|
||||
- `r3c-results.jsonl`: tail row `trace_index_other=83.1`,
|
||||
`trace_index=242.4` → 83.1/242.4 = **34.3 %** exactly, matching the go
|
||||
ruling.
|
||||
- `paired.jsonl`: 36 distinct (phase,row) keys, 0 mismatches on
|
||||
fingerprint/message/status/result_count/edits/files/created/titles across
|
||||
every head↔candidate pairing (144 compared pairs with the alternated-order
|
||||
duplicates) — matches "36 rows, 0 mismatches" exactly. Re-derived the tail
|
||||
rename's own median-of-medians: head 382.0 ms, candidate 316.0 ms
|
||||
(**−17.3 %**), against the dev's 380.2→314.0 (−17.4 %) — same conclusion,
|
||||
small difference from a different (but reasonable) medians-of-medians
|
||||
convention.
|
||||
- `warn.jsonl`: 8 rows (4 renames × 2 labels), sentence counts 434/12/0/1304
|
||||
= **1 750** exactly; compared head vs candidate title-lists field by
|
||||
field, byte-for-byte — **0 mismatches** across all four rows.
|
||||
- `head.sha256` vs the actual preserved binaries
|
||||
(`.../scratchpad/perf5r-5/bin/lucisv-server-{head,r3b}`): sha256 matches
|
||||
exactly (`50d8315a...` / `a041b5f3...`), so I did not need to rebuild.
|
||||
- **QA's own three renames**, run directly against the real opentitan tree
|
||||
(3 975 `.sv`/`.svh` files) through `vlog_refactor::rename_traced` /
|
||||
`rename_traced_with` (bypassing the LSP wire — this exercises exactly the
|
||||
engine-level contract §61.5 owns), each asked three ways (no records,
|
||||
every record, half): (i) `WidthPRDSBox`, a package parameter used bare via
|
||||
`module aes_sbox import aes_pkg::*;` in `aes_sbox.sv`; (ii) `entropy_masking_req`,
|
||||
a net declared in `aes.sv` and threaded into a `bind aes ...` connection in
|
||||
`aes_bind.sv`; (iii) `seed_en`, declared in `aes_prng_clearing.sv` and
|
||||
reached two hierarchy levels up as `u_aes_core.u_aes_prng_clearing.seed_en`
|
||||
from `aes_bind.sv`. **All three: byte-identical edits+warnings across all
|
||||
three reuse modes** (parses collapsed from ~3975 to single digits/dozens
|
||||
with full reuse, reused_files 3975/1988 as expected). One side observation,
|
||||
not a §61.5 finding: for (ii) and (iii), `aes_bind.sv`'s own occurrence is
|
||||
neither edited nor warned about, identically in all three reuse modes —
|
||||
reproduces at HEAD, so it's a pre-existing bind/hierarchy-resolution
|
||||
question, not a reuse-safety one. Flagged as a background task
|
||||
(`task_834abda3`) for separate investigation; not blocking this verdict.
|
||||
|
||||
**7. Traceability.** Re-derived (not merely read) the go-condition
|
||||
arithmetic, the 36-row parity count, the 1 750-sentence count, the corpus
|
||||
probe's 865/16/439 parses, and the tail rename's percentage — all matched
|
||||
the README/tracker's numbers (see §5/6 above). `docs/perf/take5-tracking.md`'s
|
||||
R3b/R3c experiment records cross-checked against the feature README: no
|
||||
discrepancies found in either direction.
|
||||
|
||||
**8. `docs/perf/README.md`.** `git diff docs/perf/README.md` shows only the
|
||||
appended "2026-09-08 — the review round (TODO §61)" section (34 new lines,
|
||||
0 removed, nothing above it touched) — the lead's, per TODO §61.6. Not
|
||||
edited.
|
||||
|
||||
**Opentitan / guard / hygiene.** `git -C opentitan status --porcelain`
|
||||
checked repeatedly through this session: always exactly the three known
|
||||
files (`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/.../ast.sv`,
|
||||
`hw/top_earlgrey/.../ast.sv`) — my opentitan reads were read-only. Every
|
||||
`cargo test`/`clippy` and the two release-mode ignored-test runs went through
|
||||
`tools/guard.sh -m 8 -t ≤1200`; no guard kill. No `sleep` over 60 s; used
|
||||
`Monitor`/background-PID waits instead. No lingering background processes at
|
||||
session end (checked `ps aux` for `guard.sh`/`cargo`). All code experiments
|
||||
and new tests live only in
|
||||
`/private/tmp/.../scratchpad/qa-61-5/clone` (a disposable clone) — the main
|
||||
tree's working-tree diff is untouched by QA except this README's QA log and
|
||||
the TODO.md tick below.
|
||||
|
||||
**Small fixes:** none needed in the dev's diff itself — the only fix made
|
||||
was to my own added test in the clone (a `cargo fmt` alignment nit and an
|
||||
`assert_eq!(_, true)` → `assert!` clippy nit), both in throwaway QA code, not
|
||||
in the feature's diff.
|
||||
|
||||
**Topo row for the lead:** confirm at merge —
|
||||
`lucisv_server ──▶ vlog_refactor`, edge `rename_traced_with` + `KnownFacts`,
|
||||
additive, no existing edge amended (`vlog_semantic` unchanged, `check/`
|
||||
untouched).
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-09 (lead).** Accepted. Read `KnownFacts`, `entry_for`,
|
||||
`facts_now`, `Workspace::known_facts`, the `Scope::assemble` branch, the
|
||||
trace split, both logs and the tracker records; QA's sabotage of the tie
|
||||
(hash stripped; the workspace index's record substituted) and its three
|
||||
opentitan renames in three reuse modes are the acceptance.
|
||||
|
||||
- The split answered the review's question before anything was built —
|
||||
the scope stage is the parser (lex 34 %, parse 32 %), and a third of it
|
||||
is spent on files the rename never analyses — and the go condition I
|
||||
wrote into the brief was met with a number (34.3 %).
|
||||
- The design trusts exactly what the index already trusts and nothing
|
||||
more: a record is reused only when the handed bytes hash to what that
|
||||
store entry was written for, the record and the hash read from one
|
||||
place, the workspace index's record never (it carries no hash). An
|
||||
unsaved buffer can never hit; a file edited on disk without a watcher
|
||||
event cannot hit. `check/` has no diff.
|
||||
- Gates: tail rename 380 → 314 ms (−17 % against HEAD, −21 % against the
|
||||
review's own baseline, which is how the review stated its gate; the
|
||||
brief's absolute ≤ 318 met), the duplicate-module refusal 2.05 s →
|
||||
0.7 s, `clk_i` −17 %, RSS lower, 36 rows and 1 750 warning sentences
|
||||
byte-identical. The residue is named: 31 ms of store decode, the price
|
||||
of the one-place tie, which I would not trade for a two-place one.
|
||||
- Collateral to the other refactorings was measured nil and left with
|
||||
the note that the resolves and the extract edit are the candidates,
|
||||
since the 805 ms refusal is after the scope build.
|
||||
- QA's side finding — a `bind` file's own occurrence of a renamed name
|
||||
is neither edited nor warned, identically at HEAD — is pre-existing and
|
||||
goes to the loop-3 list with QA's task reference.
|
||||
|
||||
Docs applied at merge: topo (`rename_traced_with` + `KnownFacts`); the
|
||||
loop-3 note.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -22,13 +22,35 @@ predicate, and three handlers.
|
||||
|
||||
- **The workspace index is the authority on what can be named from another
|
||||
file.** `nav::leaves_this_file` decides whether a references request walks
|
||||
the workspace by asking `WorkspaceIndex::units` / `::member` about the name
|
||||
under the cursor — not by re-deriving `is_unit`/`is_exported`, which are
|
||||
private to `vlog_semantic` and would be language knowledge in the protocol
|
||||
layer. Consequence: a declaration the index has not seen yet (a buffer
|
||||
edited but not saved, when the file is new) is answered in-file until the
|
||||
next rebuild. That is the same staleness window every other cross-file
|
||||
answer already has, documented in `docs/features/lucisv-server/README.md`.
|
||||
the workspace by asking `WorkspaceIndex::units` / `::member_in(…,
|
||||
Surface::Hierarchical)` about the name under the cursor — not by re-deriving
|
||||
`is_unit`/`is_exported`, which are private to `vlog_semantic` and would be
|
||||
language knowledge in the protocol layer. **The surface matters** (amended
|
||||
2026-09-12, §64.1): the question is which declarations a *use* in another
|
||||
file can reach, and a hierarchical path may name anything a module declares
|
||||
(IEEE 1800 §23.6) where a connection list may name only its ports and
|
||||
parameters (§23.3). Asking `::member` — the connection surface — was what
|
||||
made `assign w = u_x.sig;` in another file invisible to `references` while
|
||||
a rename was already editing it. The connection answer is the first, whole
|
||||
part of the hierarchical one, so nothing else moved; see
|
||||
`docs/features/references-hierarchical-surface/README.md`. Consequence: a
|
||||
declaration the index has not seen yet (a buffer edited but not saved, when
|
||||
the file is new) is answered in-file until the next rebuild. That is the
|
||||
same staleness window every other cross-file answer already has, documented
|
||||
in `docs/features/lucisv-server/README.md`.
|
||||
- **A stale index can omit a location; it can never point at a wrong one**
|
||||
(added 2026-09-12, §64.1 rework, QA findings 1–3). Until then this feature's
|
||||
staleness story stopped at the sentence above, which undersold it: a span
|
||||
recorded at index time and rendered against a **closed** file's current
|
||||
bytes — a `references_to` posting, or the `include_declaration` fallback —
|
||||
had no agreement check, so an external edit to that file (another tool,
|
||||
`git checkout`, a build step: none of the five events that drop a cached
|
||||
view) could put a true-looking `Location` on a line that no longer holds the
|
||||
name. `nav::closed_locations` now applies `hover::spells_exactly` to every
|
||||
closed-file span before emitting it and drops the ones that no longer spell
|
||||
the target's name — the same guarantee `hover-declarations` gives a snippet.
|
||||
Open buffers are not guarded and pay nothing: their spans come from the very
|
||||
text they are rendered against.
|
||||
- **A references answer is an indexed lookup.** Each `FileFacts` record stores
|
||||
compact facts for references to externally reachable declarations. The
|
||||
finished `WorkspaceIndex` resolves those facts once into declaration-to-use
|
||||
@@ -230,6 +252,33 @@ decision.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-12 — dev (TODO §64.1: the gate asks the hierarchical surface)
|
||||
|
||||
`leaves_this_file` and `indexed_def_in_file` — this feature's two index
|
||||
questions — asked `WorkspaceIndex::member`, the **connection** surface. Since
|
||||
`hierarchical-tail` (0.45.0) a module's net, variable and instance live on the
|
||||
**hierarchical** surface only, so both functions judged such a declaration
|
||||
unable to leave its file: `references` from the declaration fell to the
|
||||
single-file answer and never saw a cross-file `u_x.sig` tail or a `bind`
|
||||
connection expression, and a request that *did* go cross-file could not
|
||||
re-identify the declaring buffer's own in-file uses. Both now ask
|
||||
`member_in(owner, name, Surface::Hierarchical)`. Every connection-surface
|
||||
answer is byte-identical (the connection records come first and whole from
|
||||
that read); the `nav` harness rows are unchanged in count and within noise in
|
||||
time. The closed-declaring-file half of the completeness problem, the new
|
||||
`nav::declaring_file_uses`, the fixture sweep and the attack cases are all
|
||||
written up in `docs/features/references-hierarchical-surface/README.md`, which
|
||||
is this change's feature README. `documentHighlight`'s "a document answer even
|
||||
for a cross-file name" assumption was untouched and is now pinned from both
|
||||
ends (`definition_and_document_highlight_over_a_hierarchical_tail_are_unchanged`).
|
||||
|
||||
**Rework the same day**, on QA's findings 1–3: the closed-file path reads each
|
||||
closed file exactly once per request, with `text_of` rather than the
|
||||
`file_view` cache, and every index-time span about a closed file is guarded by
|
||||
`hover::spells_exactly` before it is rendered. That is the new Assumptions
|
||||
bullet above; the derivation and the flipped QA tests are in
|
||||
`docs/features/references-hierarchical-surface/README.md`.
|
||||
|
||||
### 2026-08-28 — documentHighlight answered nothing on a cross-file name
|
||||
|
||||
**The report.** `performance.md` §7: `documentHighlight` returned 0 results at
|
||||
|
||||
@@ -0,0 +1,596 @@
|
||||
# rename-bind-occurrences — a `bind` file's own occurrence of a renamed name
|
||||
|
||||
TODO §63.1, from §61.5's QA finding `task_834abda3`
|
||||
(`docs/features/perf5r-scope-reuse/README.md`, QA log item 6). Reference tree
|
||||
`2675131`, branch `master`.
|
||||
|
||||
## Goal
|
||||
|
||||
Renaming `entropy_masking_req` — a net declared in opentitan's
|
||||
`hw/ip/aes/rtl/aes.sv` — edited `aes.sv` and left
|
||||
`hw/ip/aes/dv/sva/aes_bind.sv`'s `.entropy_masking_req(entropy_masking_req)`
|
||||
alone, **without a word**. Renaming `seed_en` (declared in
|
||||
`aes_prng_clearing.sv`) left the same file's two-level tail
|
||||
`u_aes_core.u_aes_prng_clearing.seed_en` alone, also without a word — while
|
||||
§49's hierarchical tail from an ordinary instantiating file
|
||||
(`u_entropy_src_main_sm.state_q` in `entropy_src_core.sv`) was edited. The
|
||||
whole-scope engine is the refusal authority, so a silent miss is a wrong
|
||||
answer: after such a rename the design no longer elaborates.
|
||||
|
||||
The contract this lane reaches: an occurrence in a `bind` directive's
|
||||
connection is **edited** when the engine resolves it to the renamed
|
||||
declaration — a bare name in the bind target's scope, or a hierarchical path
|
||||
rooted at that target — through the same rungs an instantiating file's
|
||||
occurrences use; **warned about**, with file and line, when the engine cannot
|
||||
resolve it; **never silent**.
|
||||
|
||||
## What dropped the bind file
|
||||
|
||||
Selection was not the culprit and the rungs were not short. Two **engine**
|
||||
steps were, and both are in `vlog_semantic`:
|
||||
|
||||
1. **`resolve::in_bind_target` asked the wrong member surface.** A bare name
|
||||
in a `bind`'s connection expression already carried
|
||||
`Target::BindScope { target }` (bind-semantics, 2026-09-02). When the
|
||||
target module is declared in another file — which is every real bind — the
|
||||
resolver handed the workspace
|
||||
`ExternalCandidate { paths: ["aes"], surface: Surface::Connection }`. A
|
||||
module's **connection** surface is its ports, parameters, properties and
|
||||
sequences (`workspace/hierarchy.rs::surface_of`); its nets, variables and
|
||||
instances live on the **hierarchical** surface. So
|
||||
`member_chain(index, "aes", "entropy_masking_req", Connection)` answered
|
||||
nothing, the overlay recorded `StillUnresolved`, and
|
||||
`Scope::collect_occurrences` — which edits exactly the references the
|
||||
overlay resolved to the target declaration — skipped it.
|
||||
|
||||
The same single-segment path is why it was *silent* as well as unedited.
|
||||
`warnings::unresolved_unit` names the unit a candidate was searched in by
|
||||
splitting the recorded path at its `::`; a path of `"aes"` has none, so the
|
||||
`unresolved_candidate_warnings` scan had no unit to report and said
|
||||
nothing. (The `unaccounted` scan could not cover it either: that one runs
|
||||
only over files the rename actually edited.)
|
||||
|
||||
2. **A hierarchical tail in a `bind` was resolved from the scope the
|
||||
directive is *written* in.** `u_aes_core.u_aes_prng_clearing.seed_en`
|
||||
reaches the resolver as `Target::MemberOf { head: "u_aes_core", mids:
|
||||
["u_aes_prng_clearing"] }`, and `resolve::head_site` looks the head up on
|
||||
the writing scope's lexical chain. A bind module declares nothing, so the
|
||||
head resolved to nothing, `member_site` returned `None` — *no reference at
|
||||
all*, not even an unresolved one — and every later link was dropped with
|
||||
it. Nothing to edit, and nothing for any warning scan to see.
|
||||
|
||||
The probe that settled it (run at `2675131`, the five-file fixture of
|
||||
`crates/vlog_refactor/tests/rename_bind.rs`, printing every reference of the
|
||||
bind file with its resolution and its overlay answer):
|
||||
|
||||
```
|
||||
2: "entropy_masking_req" ExternalCandidate { paths: ["aes_reseed_if"], Connection } -> Resolved(Port) <- the `.port` half
|
||||
3: "entropy_masking_req" ExternalCandidate { paths: ["aes"], Connection } -> StillUnresolved <- the expression half
|
||||
5: "u_aes_core" ExternalCandidate { paths: ["aes"], Connection } -> StillUnresolved <- the tail's head
|
||||
<- and no reference at all
|
||||
for `u_aes_prng_clearing`
|
||||
or for `seed_en`
|
||||
```
|
||||
|
||||
**The selection rungs were checked and are sound.** `aes_bind.sv` is wanted by
|
||||
`Workspace::rename_sources_traced`'s `Rung::Reference`: `fan_out_of` puts the
|
||||
declaration's container (`aes`, from `index.hierarchical_declarations`) into
|
||||
`containers`, then asks `want_declaration` for every `units("aes")`, whose
|
||||
`references_to` postings include the `bind aes …` head — a
|
||||
`Target::Module` reference the binder has always recorded. So no rung was
|
||||
added, `module_select::hierarchical_users` is untouched, and
|
||||
`WorkspaceIndex::files_mentioning` was not needed. This is confirmed
|
||||
end-to-end by the three opentitan renames under all three reuse modes (Work
|
||||
log, 2026-09-11).
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **IEEE 1800-2017 §23.11 / §23.6.** A `bind`'s connection expressions
|
||||
elaborate in the *target* scope, and a hierarchical path may name anything
|
||||
the scope it walks into declares — not only what a connection list could
|
||||
name. The whole fix is that second half: a bind connection is a
|
||||
hierarchical reach, so it is asked of the hierarchical surface.
|
||||
- **The target's own scope answers before the writing scope**, and only a
|
||||
miss the target settles falls back. That ordering is bind-semantics'
|
||||
(2026-09-02) and is unchanged here; this lane changes *which* surface the
|
||||
target is asked about and *how* a path is spelled, never the order.
|
||||
- **A hierarchical target path is a place the index can often reach.**
|
||||
`bind tb.u_aes chk u (…)` is `tb::u_aes` — one `member_unit_in` hop over
|
||||
`tb`'s instance `u_aes`, which is exactly what `external::fold_path`
|
||||
already does for `pkt_t::hdr::addr`. Where the index cannot take a hop (a
|
||||
generate index, `gen[0]`, has no record at all) the path answers nothing
|
||||
and the miss is reported rather than guessed at.
|
||||
- The `.port` half of a `bind` connection still names the **bound** module's
|
||||
port and is untouched. Every fixture here renames a name that is spelled on
|
||||
both halves, so a fix that edited both would fail loudly.
|
||||
- A bind file is an ordinary edited file to `check/after.rs`: it is absorbed
|
||||
into the after-index and its after-print is compared like any other. No
|
||||
change was needed there and none was made.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**`vlog_refactor ──▶ vlog_semantic` (amended, additive in the AST, wider in
|
||||
the answer).** The rename engine reads the same `Resolution`/
|
||||
`ExternalResolutions` it always did; what changed is what the resolver
|
||||
produces for a `bind` connection:
|
||||
|
||||
| | before | after |
|
||||
|---|---|---|
|
||||
| bare name, target elsewhere | `ExternalCandidate { paths: ["aes"], Connection }` | `ExternalCandidate { paths: ["aes::name"], Hierarchical }` |
|
||||
| bare name, target in this file | `Resolved` / `None` | unchanged |
|
||||
| hierarchical tail in a bind | *no reference recorded* | `Target::BindMember` → `Resolved`, or `ExternalCandidate { paths: ["aes::u_core::…::name"], Hierarchical }` |
|
||||
| multi-segment bind target | connections resolved in the **writing** scope | resolved in the target scope, spelled `tb::u_aes` |
|
||||
|
||||
The path spelling is the `unit::name` one `external::follow_one` already
|
||||
reads, so no workspace-layer code changed: `follow_one` folds the hops and
|
||||
`member_chain` does the lookup, exactly as for a `u_x.sig` tail.
|
||||
|
||||
**`lucisv_server ──▶ vlog_refactor` — unchanged.** `rename_traced_with`,
|
||||
`rename_preflight` and the source selectors keep their signatures and their
|
||||
answers. Refusal parity with `rename_preflight` stays one-directional and in
|
||||
the safe direction: a cursor on a bind file's hierarchical tail used to have
|
||||
no reference at all, so the preflight refused it with `NOTHING_HERE`; it now
|
||||
carries an external candidate, which the preflight *defers* (`Ok(())`). The
|
||||
preflight refuses strictly less than before and never more.
|
||||
|
||||
**Topology rows the lead must edit** (`docs/topo.md` is not this lane's
|
||||
file):
|
||||
|
||||
1. `§2.9-15` / the `bind-semantics ◀──▶ workspace-index / index-persistence`
|
||||
handshake row: **`FACTS_FORMAT` 19 → 20** (2026-09-11). No new field — the
|
||||
same fields carry a different answer: a bind connection's recorded path is
|
||||
now `target::name` on the hierarchical surface, so a 0.53.0 store would
|
||||
answer definition, find-references and this rename as though the bind file
|
||||
did not mention the name. The store rebuilds once. The bump's own
|
||||
paragraph is in `crates/vlog_semantic/src/facts.rs`.
|
||||
2. The `vlog_refactor ──▶ vlog_semantic` row: a bind's connection expression
|
||||
is a reference on the target's **hierarchical** surface, and a bind's
|
||||
hierarchical path is rooted at the target (`Target::BindMember`), so
|
||||
`references`, `definition`, `hover` and `rename` all answer over bind
|
||||
files where they answered nothing before.
|
||||
3. `§2.9-33`'s closing note stands unamended: the rung it closed
|
||||
(`module_sources_reaching`) is not what this lane needed, and
|
||||
`module_select.rs` is untouched.
|
||||
|
||||
**Files edited outside this lane's stated list, flagged rather than silent**
|
||||
(§63.1 named `vlog_semantic/src/{resolve.rs,workspace/}` "only if a resolver
|
||||
rung is genuinely missing"; these three are in `vlog_semantic/src` but not in
|
||||
that list):
|
||||
|
||||
- `crates/vlog_semantic/src/bind/mod.rs` — the new `Target::BindMember`
|
||||
variant and one more arm in the single funnel (`use_member`) that already
|
||||
redirects a bind connection's bare names. The tail case cannot be fixed in
|
||||
`resolve.rs` alone: the resolver has no way to learn the bind target of a
|
||||
`Target::MemberOf`, because the pending use does not carry it.
|
||||
- `crates/vlog_semantic/src/bind/item.rs` — `bind_bind` now sets the bind
|
||||
target for a multi-segment target path too, through the new
|
||||
`bind_target_path` (the `::`-joined spelling the index reads). It still
|
||||
records **no reference** for such a path, as before.
|
||||
- `crates/vlog_semantic/src/facts.rs` — the `FACTS_FORMAT` bump above. Not
|
||||
bumping it would leave a stale store answering thinner, which is the exact
|
||||
failure every earlier bump exists to prevent.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] the reproduction pinned first — `crates/vlog_refactor/tests/rename_bind.rs`,
|
||||
seven fixtures (bare-name connection, positional connection, two-level
|
||||
tail, `: u_x` instance-list target, hierarchical target path, `bind`
|
||||
inside `if (…) begin : gen … end`, and a bind whose target module is not
|
||||
in the workspace). All seven asserted today's silent miss at `2675131`
|
||||
before a line of the fix was written, and all seven flipped with it.
|
||||
- [x] the fix: `Target::BindMember` + the hierarchical surface + the
|
||||
`target::name` path spelling; unresolvable occurrences reported through
|
||||
the sentence `unresolved_candidate_warnings` already uses; the step
|
||||
that dropped `aes_bind.sv` named above.
|
||||
- [x] parity: `renamewarn` and the paired phases (`renametrace`,
|
||||
`tailrename`, `rename`, `refactor`) against the `2675131` baseline —
|
||||
28 (phase, row) keys, every difference a `bind` file's new edit or
|
||||
warning and listed above; the eight rename shapes within noise, the
|
||||
tail rename 326.2 ms median (gate ≤ 330).
|
||||
- [x] the three QA renames over the real opentitan tree, all three reuse
|
||||
modes: identical answers, `aes_bind.sv` edited in both bind cases.
|
||||
- [x] a fixture row for the shape: `tools/perf/phases_p2.py`'s `RENAMES`
|
||||
gains `bind: entropy_masking_req -> masking_req_x` (and
|
||||
`phases_r3b.py`'s `WARNED` gains `bind`), so the harness measures this
|
||||
lane's shape from now on.
|
||||
- [x] QA
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-09-11 (dev), the reproduction.** Seven fixtures in
|
||||
`crates/vlog_refactor/tests/rename_bind.rs`, over a five-file in-memory
|
||||
workspace shaped like the real one (`aes` declaring the net and instantiating
|
||||
`aes_core`, which instantiates `aes_prng_clearing`; `aes_reseed_if` as the
|
||||
bound checker, with ports deliberately spelled like the renamed names so a fix
|
||||
that edited the `.port` half would fail loudly; and the bind file). All seven
|
||||
failed at `2675131` exactly as §61.5's QA described — no edit, no warning. The
|
||||
probe quoted above was run from the same fixture and is what named the two
|
||||
engine steps.
|
||||
|
||||
**2026-09-11 (dev), the fix.**
|
||||
|
||||
- `crates/vlog_semantic/src/resolve.rs`
|
||||
- `in_bind_target` records `paths: ["{target}::{name}"]` on
|
||||
`Surface::Hierarchical` instead of `paths: ["{target}"]` on
|
||||
`Surface::Connection`. This is both halves of finding 1: the surface makes
|
||||
the lookup find a module's internal net, and the `::` gives the warning
|
||||
scan a unit to name when it does not.
|
||||
- new `bind_member`: the spine of a bind's hierarchical path, rooted at the
|
||||
target — the target's own scope when this file declares it, else the
|
||||
target as the unit the workspace answers hierarchical members of — with
|
||||
`head` as simply one more link.
|
||||
- `member_of`'s tail lookup and `member_site`'s per-link hop are lifted to
|
||||
`member_at` and `descend` so that `bind_member` walks *the same* code. A
|
||||
second spelling of either would eventually answer one name two ways. The
|
||||
`direct` flag carries the one thing the split would otherwise lose: only a
|
||||
plain `head.member` may report an `InheritedCandidate`.
|
||||
- `crates/vlog_semantic/src/bind/mod.rs` — `Target::BindMember { target,
|
||||
head, mids }`, produced by one more arm of the existing `use_member` funnel
|
||||
(the same place `Target::Lexical` already became `Target::BindScope`).
|
||||
- `crates/vlog_semantic/src/bind/item.rs` — `bind_target_path`, and
|
||||
`bind_bind` setting the bind target from it. A multi-segment target
|
||||
(`tb.u_aes`) used to leave `bind_target` unset, which silently resolved its
|
||||
connections in the writing scope; it is now `tb::u_aes`, a path the index
|
||||
either walks or reports.
|
||||
- `crates/vlog_semantic/src/facts.rs` — `FACTS_FORMAT` 19 → 20, with its
|
||||
paragraph.
|
||||
|
||||
Nothing in `crates/vlog_refactor/src` needed to change: the warning sentence
|
||||
the contract asks for is the one `unresolved_candidate_warnings` already
|
||||
emits, and it starts firing for bind files as soon as the recorded path has a
|
||||
unit in it.
|
||||
|
||||
Two more fixtures beside the seven: a new name the bind target already
|
||||
declares is refused, and a rename applied and then reversed restores the bind
|
||||
file **byte for byte** (the new resolution is stable under its own edit).
|
||||
`check/after.rs` is untouched and needed nothing: an edited bind file is
|
||||
absorbed into the after-index and re-printed like any other edited file.
|
||||
|
||||
**2026-09-11/12 (dev), the three QA renames on the real tree.**
|
||||
`the_three_qa_renames_agree_across_reuse_modes_and_edit_the_bind_file`
|
||||
(`#[ignore]`d, `crates/vlog_refactor/tests/rename_bind.rs`), over the real
|
||||
opentitan checkout — 3 975 `.sv`/`.svh` files, read and never written —
|
||||
through `rename_traced` / `rename_traced_with`, each rename asked three ways
|
||||
(no records, every record, every second record). **Identical edits and
|
||||
identical warnings in all three modes, all three renames**, and the two bind
|
||||
cases now edit `aes_bind.sv`:
|
||||
|
||||
| rename | files | edits | warnings | `aes_bind.sv` | parses (none / all / half) |
|
||||
|---|---|---|---|---|---|
|
||||
| `WidthPRDSBox` → `WidthPRDSBoxX` | 6 | 32 | 3 | — (correctly) | 3 980 / 13 / 1 997 |
|
||||
| `entropy_masking_req` → `masking_req_x` | 2 | 6 | 9 | **×2** | 3 976 / 10 / 1 993 |
|
||||
| `seed_en` → `seed_en_x` | 2 | 4 | 1 | **×1** | 3 976 / 38 / 2 005 |
|
||||
|
||||
The two `aes_bind.sv` edits for `entropy_masking_req` are the expression
|
||||
halves of the two `bind aes …` directives (the second inside
|
||||
`if (\`EN_MASKING) begin : gen_prng_bind`); the four `.entropy_masking_req(`
|
||||
**port** halves are correctly left alone, because they name
|
||||
`aes_reseed_if`/`aes_masking_reseed_if`'s ports. The one `seed_en` edit is the
|
||||
two-level tail `u_aes_core.u_aes_prng_clearing.seed_en`.
|
||||
`git -C ~/repo/opentitan status --porcelain` after every run: the three known
|
||||
files and nothing else.
|
||||
|
||||
**2026-09-12 (dev), the parity measurement.** Two release `lucisv-server`
|
||||
binaries — the baseline built from `2675131` in a scratch worktree (the
|
||||
0.53.0 preserved binary is the CLI, not a server), the candidate from this
|
||||
tree — over the real opentitan tree, through `tools/guard.sh -m 8 -t 1800`,
|
||||
order alternated. Phases `renametrace`, `tailrename`, `rename`, `refactor`
|
||||
(three tries each, four sessions per binary on `renametrace`) plus
|
||||
`renamewarn`. Raw evidence, both binaries, the run script and the comparison
|
||||
script are preserved in `~/.cache/lucisv-perf/63-1/` (its own README lists
|
||||
them and quotes the reproduction).
|
||||
|
||||
*Answers.* 28 (phase, row) keys compared field by field on `fingerprint`,
|
||||
`status`, `message`, `result_count`, `edits`, `files`, `created` and
|
||||
`titles`. **Every difference is a `bind` file's new edit or warning, and
|
||||
there is nothing else:**
|
||||
|
||||
| where | difference |
|
||||
|---|---|
|
||||
| `renametrace` `bind: entropy_masking_req` (the new fixture row) | `files` 1 → 2, `edits` 4 → 6, `titles` gains `aes_bind.sv`; `fingerprint` moves with them |
|
||||
| `renamewarn` `tail: state_q` | **+1 sentence**: `state_q` at `aes_bind.sv:58` could not be resolved — `aes::u_aes_core::u_aes_cipher_core::gen_masks::u_aes_prng_masking::u_prim_bivium::state_q`. The path goes through the generate block `gen_masks`, which the index has no record of, so the miss is *reported* where it used to be silent |
|
||||
| `renamewarn` `common port: clk_i` | **+2 sentences** — `top_darjeeling_bind.sv:22` and `top_earlgrey_bind.sv:25`, both `<top>_pd_aon::u_pwrmgr::clk_i`; and **one re-worded**: `hw/ip/rom_ctrl/dv/tb/tb.sv:83`, a `.clk_i (clk_i)` inside `bind dut.gen_fsm_scramble_enabled.u_checker_fsm.u_compare …`, said `uvm_pkg::clk_i` and now says the bind target's own path. Warned before, warned after; **no edit moved** |
|
||||
| everything else | identical, including `ordinary: aes`, `conflict`, `new name many uses spell`, `duplicate module`, `no symbol`, all fifteen `refactor` rows and both `rename` rows |
|
||||
|
||||
Warning-sentence totals: base 1 758, candidate 1 764 — and 1 758 − 8 (the new
|
||||
`bind:` row's own sentences) = **1 750**, the count §61.5 measured, so the
|
||||
pre-existing four renames' sentence set is the same set it was.
|
||||
|
||||
*Timings* (median of four sessions per binary, orders alternated):
|
||||
|
||||
| row | base | candidate | Δ |
|
||||
|---|---|---|---|
|
||||
| `tail: state_q -> state_q_x` | 321.9 | **326.2** | +1.3 % |
|
||||
| `tailrename` (the dedicated phase) | 322.9 | 322.6 | −0.1 % |
|
||||
| `common port: clk_i -> clk_ix` | 2 885.3 | 2 908.1 | +0.8 % |
|
||||
| `conflict: state_q -> state_d` | 269.5 | 271.6 | +0.8 % |
|
||||
| `duplicate module: rstmgr_por` | 724.2 | 740.6 | +2.3 % |
|
||||
| `new name many uses spell` | 2 281.6 | 2 297.6 | +0.7 % |
|
||||
| `ordinary: aes -> aes_renamed` | 91.6 | 91.6 | 0.0 % |
|
||||
| `unique internal: cipher_alert` | 18.2 | 17.9 | −1.9 % |
|
||||
| `no symbol: whole scope then refuse` | 0.19 | 0.23 | (+0.04 ms) |
|
||||
| `bind:` (new row) | 22.6 | 24.2 | +1.6 ms, inside both binaries' own spread |
|
||||
|
||||
The eight original shapes are within noise and **the tail rename's median is
|
||||
326.2 ms, under the 330 ms gate** (322.6 ms on the dedicated `tailrename`
|
||||
phase). The first round's two apparent outliers — `duplicate module` +28 %
|
||||
and `tail` +4.4 % — were each a single noisy session (`duplicate module`
|
||||
sampled 1 300/1 401 ms once and 719/748/733 in the other three); the second,
|
||||
order-alternated round is what the table above is taken from, and the noisy
|
||||
samples are left in the raw file rather than dropped.
|
||||
|
||||
**2026-09-12 (dev), the gates.** `cargo fmt --all -- --check` clean;
|
||||
`cargo clippy --all-targets --workspace` clean through the guard, with no new
|
||||
`#[allow]`; `cargo test --workspace` through the guard **4 395 passed, 0
|
||||
failed, 46 ignored**. The lane's only test additions are the ten in
|
||||
`crates/vlog_refactor/tests/rename_bind.rs` (nine plus one `#[ignore]`d) and
|
||||
none were removed or renamed, so the count before the lane was 4 386 / 45.
|
||||
`git -C ~/repo/opentitan status --porcelain` lists the three known files and
|
||||
nothing else, checked after every phase and at the end.
|
||||
|
||||
*The one behaviour this measurement was watching for.* Making a multi-segment
|
||||
bind target a real scope means a bare name in such a connection no longer
|
||||
falls back to the scope the directive is *written* in. The whole opentitan
|
||||
tree produces exactly one instance of that — `rom_ctrl`'s `tb.sv:83` above —
|
||||
and it was an unresolved warning before and is an unresolved warning now. No
|
||||
edit was lost anywhere in 28 rows.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-12 (QA). Verdict: PASS.** Gates, the dev's ten fixtures re-run at
|
||||
`2675131`, six new attack fixtures, one preflight-parity fixture, one
|
||||
wire-level LSP fixture, an independent re-derivation of the parity evidence
|
||||
and the three opentitan renames, and the corpus/opentitan byte-identity
|
||||
gates. Two findings, neither blocking (§63.1's contract holds and nothing the
|
||||
fix touches misbehaves); both are noted below and neither's file is in
|
||||
§63.1's stated list.
|
||||
|
||||
**1. Gates**, all through `tools/guard.sh -m 8 -t 1800`, no guard kill: `cargo
|
||||
test --workspace` **4 403 passed, 0 failed, 46 ignored** (4 395 the dev
|
||||
reported, +6 attack fixtures in `rename_bind.rs`, +1 wire-level fixture in
|
||||
`nav.rs`, +1 preflight-parity fixture in `preflight_oracle.rs`); `cargo
|
||||
clippy --all-targets --workspace` clean, no new `#[allow]`; `cargo fmt --all
|
||||
-- --check` clean.
|
||||
|
||||
**2. The dev's ten fixtures, re-run against a fresh clone of `2675131`**
|
||||
(`crates/vlog_refactor/tests/rename_bind.rs` copied in, nothing else
|
||||
changed): **8 of 9 non-`#[ignore]`d fixtures fail at baseline exactly as
|
||||
claimed**, and flip green on this tree. The tenth,
|
||||
`a_new_name_the_bind_target_already_declares_is_refused`, **passes at
|
||||
baseline unmodified** — finding 1 below. The `#[ignore]`d real-tree fixture
|
||||
is inert without `LUCISV_BIND_ROOT` at both revisions, so it proves nothing
|
||||
either way by itself; verified directly instead (item 6).
|
||||
|
||||
**3. Six new attack fixtures added to `rename_bind.rs`**, each run at both
|
||||
this tree and the `2675131` clone:
|
||||
|
||||
- `a_bind_connections_bare_name_naming_the_targets_port_is_still_renamed`
|
||||
(task 3a) — a bind connection bare-naming the target's **port** (`clk_i`)
|
||||
is still renamed, and the checker's own `.port` half of the same name is
|
||||
untouched. Passes at both revisions (`hierarchy::member`'s connection-first
|
||||
read means a port was never at risk from the surface widening) — a
|
||||
regression guard, not a reproduction.
|
||||
- `a_bind_connection_resolves_in_the_target_not_a_same_named_decoy_in_the_writing_scope`
|
||||
(task 3b) — the writing module declares its own `entropy_masking_req`; the
|
||||
connection must still resolve `aes`'s net, not the decoy. **Fails at
|
||||
baseline** (same finding-1 cause: `in_bind_target` asked the connection
|
||||
surface for a net and found nothing, silently), passes here.
|
||||
- `a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused`
|
||||
(task 3c) — the bare-name path's collision refusal exercised one link
|
||||
further down the spine, through `bind_member`/`member_at`/`descend` rather
|
||||
than `in_bind_target`. Passes at both revisions: the same same-scope
|
||||
refusal `check::verify`'s watched-files/resolution-identity pass already
|
||||
applies (see finding 1) covers the new code path exactly as it covers the
|
||||
old one — no gap specific to `bind_member`. On `rename_preflight`'s
|
||||
one-directional parity: unaffected either way, since the collision refusal
|
||||
is `check::verify`'s (workspace-only), never a `rename_preflight` refusal.
|
||||
- `an_escaped_identifier_bind_target_is_still_resolved` (task 3d) — `bind
|
||||
\aes.escaped …`. **Fails at baseline** (silently: no edit, no warning —
|
||||
the escaped target is a single segment, same finding-1 cause), passes
|
||||
here.
|
||||
- `a_bind_with_no_connections_naming_the_renamed_signal_is_untouched`
|
||||
(task 3e) — empty connection list plus a `defparam`. Passes at both
|
||||
revisions; confirms the funnel does not misfire on a connection list with
|
||||
nothing in it.
|
||||
- `a_bind_target_reached_through_a_generate_block_is_warned_about_never_guessed`
|
||||
(task 3f) — `bind tb.gen[0].u_aes …`. **Fails at baseline** (silently — the
|
||||
multi-segment target left `bind_target` unset, finding 2's bug), passes
|
||||
here with a warning naming the file and the unresolved path. The real
|
||||
opentitan tree has exactly this shape
|
||||
(`hw/ip/rom_ctrl/rtl/rom_ctrl.sv:365`, `begin : gen_fsm_scramble_enabled`,
|
||||
bound from `tb.sv:83`) — see item 5.
|
||||
|
||||
**4. `rename_preflight` one-directional parity (task 3c's second half).**
|
||||
Added `a_binds_connection_expressions_defer_rather_than_invent_a_refusal` to
|
||||
`crates/vlog_refactor/tests/preflight_oracle.rs` (the existing per-byte
|
||||
equality oracle between `rename_preflight` and the whole-workspace `rename`,
|
||||
which previously had no `bind` fixture at all): sweeps every byte of a bind
|
||||
file with both a bare-name and a two-level-tail connection, asserting the
|
||||
oracle's own invariant (a preflight refusal must never be one the workspace
|
||||
disagrees with) holds throughout, then names the exact byte Handshakes calls
|
||||
out — the tail's `seed_en` — and asserts `rename_preflight` returns `Ok(())`
|
||||
there. **Fails at the `2675131` clone** (`NOTHING_HERE` — no reference was
|
||||
recorded there before this lane, so `symbol_at` also finds nothing) and
|
||||
passes here, confirming the Handshakes table's claim precisely: refuses
|
||||
strictly less than before, never more.
|
||||
|
||||
**5. The rom_ctrl re-worded sentence, read against the real file.**
|
||||
`hw/ip/rom_ctrl/dv/tb/tb.sv:83` is `.clk_i (clk_i)` inside `bind
|
||||
dut.gen_fsm_scramble_enabled.u_checker_fsm.u_compare rom_ctrl_compare_bound_if
|
||||
#(...) u_bound_if (...)`; `gen_fsm_scramble_enabled` is confirmed a generate
|
||||
block (`rom_ctrl.sv:365`, `if (!SecDisableScrambling) begin :
|
||||
gen_fsm_scramble_enabled`). Base's sentence named `uvm_pkg::clk_i` — a
|
||||
nonsensical search path, the writing scope's `import uvm_pkg::*` leaking in
|
||||
through finding 2's bug — candidate's names
|
||||
`dut::gen_fsm_scramble_enabled::u_checker_fsm::u_compare::clk_i`, the real
|
||||
attempted path, correctly reported as unresolved because the index has no
|
||||
record of a generate block. The re-wording is correct; both are warnings, no
|
||||
edit moved, matching the dev's characterization exactly.
|
||||
|
||||
**6. Parity evidence re-derived directly from `~/.cache/lucisv-perf/63-1/`**
|
||||
(read-only): `python3 compare.py paired.jsonl` reproduces **28 (phase, row)
|
||||
keys, 4 field mismatches, all four confined to the `bind:
|
||||
entropy_masking_req` row** (fingerprint/edits/files/titles — the new edit
|
||||
itself), matching the dev's table verbatim. `compare.py`'s own timing column
|
||||
prints `-` for every row — a script bug (it expects `ms` as a scalar; the
|
||||
harness records it as a list of per-try samples) — so timings were
|
||||
recomputed directly from the raw `ms` arrays: tail rename 322.5 ms (base) →
|
||||
327.3 ms (cand), **under the 330 ms gate**, everything else within noise,
|
||||
matching the dev's table within sampling variance. `warn.jsonl`: raw
|
||||
sentence totals reproduce **1 758 → 1 764** exactly; the raw counts carry a
|
||||
2× duplication (the harness's own artifact — every distinct sentence appears
|
||||
twice, confirmed by exact-value-multiplicity histograms on the `common port`
|
||||
row), and the **deduplicated** picture is 3 new distinct sentences (tail +1,
|
||||
common port +2, matching the dev's per-row breakdown) plus the one reworded
|
||||
sentence verified in item 5. `opentitan.status` after each phase: the three
|
||||
known files, nothing else, confirmed six times over.
|
||||
|
||||
**7. The three opentitan renames, re-run directly** (not just the evidence
|
||||
file): `LUCISV_BIND_ROOT=$HOME/repo/opentitan tools/guard.sh -m 8 -t 1800 --
|
||||
cargo test --release -p vlog_refactor --test rename_bind -- --ignored
|
||||
--nocapture`. Exact match to the dev's table: `WidthPRDSBox` 6 files/32
|
||||
edits/3 warnings, parses 3980/13/1997; `entropy_masking_req` 2 files/6
|
||||
edits/9 warnings, parses 3976/10/1993, `aes_bind.sv` edited ×2; `seed_en` 2
|
||||
files/4 edits/1 warning, parses 3976/38/2005, `aes_bind.sv` edited ×1. The
|
||||
in-test assertions (all three reuse modes agree; `.entropy_masking_req(`
|
||||
port halves untouched) held. `git -C ~/repo/opentitan status --porcelain`
|
||||
before and after: only the three known files, verified.
|
||||
|
||||
**8. Corpus and opentitan byte-identity gates**, both binaries built
|
||||
`--release --locked` (candidate from this tree, baseline from a fresh
|
||||
`2675131` clone): `tools/corpus_check.sh` — **identical outcome tables**
|
||||
between both binaries (10 ok-unchanged / 804 would-reformat / 6 parse-error /
|
||||
0 verification-error / 0 crash, exit 0 both). `target/release/lucisv --check`
|
||||
over `/Users/guoliangchen/repo/opentitan/hw/ip` (1 805 `.sv`/`.svh` files):
|
||||
**identical per-file exit-code classification both binaries** (30 clean /
|
||||
1 771 would-reformat / 4 parse-error / 0 crash) — stronger than that,
|
||||
`lucisv --stdout` on every file hashed (SHA-256) with both binaries:
|
||||
**byte-identical formatted output for all 1 805 files**, confirming the
|
||||
formatter moved not at all, as expected (no `vlog_formatter` file is in the
|
||||
diff). `git -C ~/repo/opentitan status --porcelain` after: only the three
|
||||
known files.
|
||||
|
||||
**9. Definition/references/hover over a bind file (task 4).** Added
|
||||
`a_binds_connection_expression_is_reachable_by_definition_not_yet_by_references`
|
||||
to `crates/lucisv_server/src/nav.rs` (no prior wire-level bind or
|
||||
hierarchical-tail test existed there; modelled on the existing
|
||||
`a_port_is_reachable_from_a_connection_in_another_file`). `definition` from
|
||||
the bind file's expression half correctly jumps to the target's net (never
|
||||
to the checker's `.port` half of the same name) — the overlay carries the
|
||||
resolved `Def` straight through. `references`, in **both** directions, does
|
||||
**not** currently see it — finding 2 below, filed as a standalone,
|
||||
out-of-scope issue rather than a §63.1 defect.
|
||||
|
||||
**10. `FACTS_FORMAT` 19 → 20 (task 3g).** No new test needed:
|
||||
`crates/lucisv_server/src/index_cache.rs:835`,
|
||||
`a_store_from_any_previous_facts_format_is_dropped_not_misread`, loops `for
|
||||
format in 1..FACTS_FORMAT` rather than testing one hardcoded number (written
|
||||
that way after a QA finding on the `detail_span` bump specifically so it
|
||||
could not go stale), so it already covers 20 without any code change and
|
||||
already ran green in the gate above.
|
||||
|
||||
---
|
||||
|
||||
### Finding 1 (low severity, not blocking) — a dev fixture that passes
|
||||
unmodified at `2675131`
|
||||
|
||||
`crates/vlog_refactor/tests/rename_bind.rs`,
|
||||
`a_new_name_the_bind_target_already_declares_is_refused`: renames
|
||||
`entropy_masking_req` to `masking_req` where **`aes.sv` itself** — the file
|
||||
being edited — already declares a sibling `logic masking_req;`. This is an
|
||||
ordinary same-file naming collision (`check::verify`'s watched-files /
|
||||
resolution-identity pass, `crates/vlog_refactor/src/check/mod.rs:41`),
|
||||
refused independently of whether the bind file is understood at all — it
|
||||
passes at `2675131` byte-for-byte, confirmed by re-running the copied test
|
||||
file there. It is a legitimate collision-refusal check (and, per item 3
|
||||
above, the same mechanism does extend correctly to the new
|
||||
`bind_member`/`descend` code path — see the new
|
||||
`a_new_name_the_two_level_tails_terminal_scope_already_declares_is_refused`),
|
||||
but its Status/TODO line ("a new name the bind target already declares is
|
||||
refused") and Work-log description overstate what it demonstrates: it does
|
||||
not exercise the fix. No code change needed — it is a correct test of a
|
||||
correct (pre-existing) behavior, just not of *this* behavior. Suggest
|
||||
re-wording its doc comment in a future pass; not fixed here since editing
|
||||
another dev's fixture text without a legitimate copy-edit reason is outside
|
||||
"small unambiguous" territory.
|
||||
|
||||
### Finding 2 (out of scope, not blocking) — cross-file `references` cannot
|
||||
see a hierarchical-surface-only declaration, `bind` or not
|
||||
|
||||
`crates/lucisv_server/src/nav.rs`: `leaves_this_file` (line ~170) and
|
||||
`indexed_def_in_file` (line ~254, shared with `hover.rs` per its own doc
|
||||
comment) both decide whether a declaration can be referenced from another
|
||||
file by calling `WorkspaceIndex::member(unit, name)` — the **connection**
|
||||
surface only (`workspace/index.rs:82`; ports and parameters). A module's net,
|
||||
variable or instance lives on the **hierarchical** surface only
|
||||
(`workspace/hierarchy.rs`, since 2026-09-05) and so both functions treat such
|
||||
a declaration as incapable of leaving its file. Two concrete symptoms,
|
||||
reproduced in the new `nav.rs` test (item 9):
|
||||
|
||||
- `references` from the *declaration* of a hierarchically-reached net
|
||||
(`leaves_this_file` returns `false`) falls straight to the single-file
|
||||
fallback and never sees a cross-file use, `bind` connection or ordinary
|
||||
`u_x.sig` hierarchical tail alike.
|
||||
- `references` from a *use* that does resolve cross-file (a `bind`
|
||||
connection, `leaves_this_file` returns `true` because the live reference
|
||||
already carries a resolved candidate) still cannot re-identify an **open
|
||||
buffer's own in-file** use of the same declaration, because
|
||||
`indexed_def_in_file` maps the live symbol back to its persisted `Def` the
|
||||
same wrong way.
|
||||
|
||||
Confirmed **not** specific to `bind`: a throwaway probe
|
||||
(`module leaf; logic sig; ... endmodule` / `module top; leaf u_leaf(); wire
|
||||
w; assign w = u_leaf.sig; endmodule`, no bind involved) reproduces the exact
|
||||
same gap and was removed after confirming it (not part of the committed
|
||||
diff). This predates §63.1 by roughly two weeks (the hierarchical-surface
|
||||
feature, 2026-09-05) and is not introduced by this lane's fix — the fix
|
||||
correctly widens what the *resolver* and the *rename engine* see (confirmed
|
||||
throughout this log); `nav.rs` is not in §63.1's stated file list
|
||||
(`crates/lucisv_server/src/{rename.rs,rename_trace.rs,module_select.rs,
|
||||
state/}` only) and was not touched by the dev. Filed as a standalone
|
||||
follow-up rather than fixed here — the fix is a `WorkspaceIndex::member_in`
|
||||
(with `Surface::Hierarchical`) swap in both call sites and needs its own
|
||||
fixture sweep across `definition`/`references`/`hover`/`documentHighlight`,
|
||||
which is more than a "small unambiguous fix."
|
||||
|
||||
## Review
|
||||
|
||||
**Lead review, 2026-09-12 — accepted.** The dev's diagnosis is the one
|
||||
worth having: selection was never the problem, the resolver was — a bind
|
||||
connection's bare name asked the target's *connection* surface (ports and
|
||||
parameters), which cannot hold an internal net, and a hierarchical path in
|
||||
a bind was rooted in the writing scope, which declares nothing. Both fixes
|
||||
are the smallest true ones: the path spelling `target::name` on the
|
||||
hierarchical surface reuses `follow_one` untouched, and `Target::BindMember`
|
||||
walks `descend`/`member_at` lifted out of `member_of` rather than a second
|
||||
spine walk (the lifting is a pure move; the `direct` flag preserves the
|
||||
`InheritedCandidate` rule for `head.member` exactly). The three files edited
|
||||
outside the stated list are accepted: the tail case is unfixable in
|
||||
`resolve.rs` alone, and not bumping `FACTS_FORMAT` would ship a stale store
|
||||
answering thinner — the exact failure the bump discipline exists for.
|
||||
|
||||
Parity is what the brief asked for: every one of the 28-key differences is a
|
||||
bind file's new edit or warning, 1 758 − 8 = 1 750 reproduces §61.5's count,
|
||||
the one re-worded sentence (rom_ctrl `tb.sv:83`, a multi-segment bind
|
||||
target) is more correct than before, and the tail rename held under the
|
||||
330 ms gate. QA's fresh-clone check that the fixtures fail at `2675131`
|
||||
is the proof the fixtures are load-bearing.
|
||||
|
||||
Rulings on QA's findings:
|
||||
|
||||
- **Finding 1** (a fixture that passes at `2675131`): kept as a regression
|
||||
guard, not a defect — the README's Work log may not claim it flipped.
|
||||
The fixture stays; its doc comment is amended by the lead to say what
|
||||
it actually pins (an ordinary same-file collision surviving a bind
|
||||
edit).
|
||||
- **Finding 2** (`nav.rs`'s `leaves_this_file`/`indexed_def_in_file` ask
|
||||
the connection surface, so cross-file `references` misses every
|
||||
hierarchical-surface-only declaration, bind or not): pre-existing since
|
||||
the hierarchical-surface feature, outside this lane's files, correctly
|
||||
not fixed here. Filed in TODO's loop-3 list as the next navigation item
|
||||
(QA task `task_d8afe80f`); QA's wire-level test in `nav.rs` pins the
|
||||
definition half now and documents the references half.
|
||||
|
||||
Topo rows amended by the lead: the `FACTS_FORMAT` line (**20**) and a new
|
||||
`rename-bind-occurrences ◀──▶ workspace-index / index-persistence /
|
||||
bind-semantics / refactor-rename` handshake row; §2.9-33 unchanged.
|
||||
@@ -301,6 +301,74 @@ attached.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-08 — §61.4: how often a scan publishes, and what `[]` is worth
|
||||
|
||||
**Neither of these is a contract change.** The three tables are still published
|
||||
together and never one of them; the order contract is `must_wait`'s and is
|
||||
untouched; `INTERLEAVE_ABOVE` still decides which scans interleave at all. What
|
||||
moved is *when* the drain pays for a publish, and what it does with an answer
|
||||
that names nowhere (`docs/features/perf5r-publication/README.md`).
|
||||
|
||||
- **A publication cadence.** `answer_what_is_waiting` used to publish whenever
|
||||
anything at all was waiting — one whole-index merge per burst of requests.
|
||||
Measured under a definition every 100 ms on opentitan, that was 14 publishes
|
||||
in a warm scan and 41 in a cold one, and `absorb` + `candidates` alone were
|
||||
46 % of the warm session and 52 % of the cold one. It now publishes when
|
||||
something was **waiting** — the startup's held requests, which is the
|
||||
session's first useful answer and is never deferred — or when
|
||||
`Scan::publish_is_due()` says `PUBLISH_EVERY` (512) records have been staged
|
||||
since the last one. **A request may now read an older prefix; it can never
|
||||
read an inconsistent one**, which is the distinction this feature's decision
|
||||
1 rests on. A quiet scan still pays nothing at all: the cadence is asked only
|
||||
when there is something for a publish to be for.
|
||||
- **An empty navigation answer computed mid-scan is not an answer.** A
|
||||
definition, a typeDefinition or a references that comes back `[]` while the
|
||||
index is still growing cannot be told apart from "the scan has not reached
|
||||
that file", so the request is put back and asked again at the next publish,
|
||||
and at the latest when the scan ends — where `[]` is the honest answer and
|
||||
goes out. This closes the case `perf5r-first-answer` pinned openly as its
|
||||
honest limit (a target in the folder next door answered `[]` at the head
|
||||
publish). It is a **rule in the drain**, not a second computation of the
|
||||
answer: the response is computed once through the ordinary handler and either
|
||||
sent or set aside, and a set-aside request is re-asked once per publish
|
||||
rather than once per step. The deferred set is deliberately **not** part of
|
||||
`must_wait` — a hover, a completion or a code action behind a deferred
|
||||
definition is answered exactly as before, and one is pinned.
|
||||
|
||||
### 2026-09-08 — §61.3: a scan that owes itself the rest of its own scope
|
||||
|
||||
The coherence contract is untouched — the three tables are still published
|
||||
together, a scan a message asked for still takes no held message, and
|
||||
`head_owed` still decides the drain. What changed is that a startup scan's work
|
||||
list can **grow once**: a workspace-scoped session with a buffer open walks
|
||||
that buffer's folders, steps them, publishes them and answers what is waiting,
|
||||
and only then walks the rest of the workspace
|
||||
(`docs/features/perf5r-first-answer/README.md`).
|
||||
|
||||
Three consequences for this feature, all in `server/index.rs`:
|
||||
|
||||
- **A scan with a pending discovery always interleaves**, whatever
|
||||
`INTERLEAVE_ABOVE` says about its work list so far. A 124-file head is under
|
||||
the threshold, and the request waiting for it is precisely the one this
|
||||
feature exists to answer inside the scan. `interleave` is now
|
||||
`total > INTERLEAVE_ABOVE || scan.discovery_pending()`.
|
||||
- **The remaining discovery is its own step.** `scan_step` runs it when the
|
||||
work list is exhausted and returns `true` without indexing anything, so the
|
||||
publish/drain point sits between it and the next file, and no file is ever
|
||||
reported against a denominator that grew inside its own step.
|
||||
- **A burst's `didOpen` finishes the discovery before re-ordering.** The user
|
||||
has jumped somewhere the walk has not reached; re-ordering a work list that
|
||||
cannot yet contain that folder would answer the request behind the `didOpen`
|
||||
off a prefix that cannot hold its target. `Workspace::open_next` does the
|
||||
walk first, and `scan_order::worth_waiting` then bounds the new head against
|
||||
the whole scope exactly as it always did.
|
||||
|
||||
Measured coherence, both binaries, cold and warm: `mismatched_answers` **0**
|
||||
and — under a new, stricter counter that treats an *empty* interim answer as a
|
||||
failure too — `unsettled_answers` **0** over 54 mid-scan definitions. The
|
||||
mid-scan answers also arrive sooner: the first one of a warm session at 26–42 ms
|
||||
where the reference took 143–153.
|
||||
|
||||
### 2026-09-08 — §P4b3: when a held request is drained, and what it reads
|
||||
|
||||
**The order contract is unchanged. The *moment* a held request is drained
|
||||
|
||||
@@ -69,6 +69,12 @@ output). `NetDelay` now owns both of its gaps, `before_hash` and
|
||||
`lucisv_server::state::Workspace::walked_files` is the server's only caller
|
||||
and needed no change — its `sort`/`dedup` still runs, and now has less to
|
||||
do. `vlog_linter` uses `walk::is_excluded` only, which is untouched.
|
||||
**Amended 2026-09-09 (review finding F1):** the visited set is now a value a
|
||||
caller may own and share between two walks (`DirectoryTracker`,
|
||||
`collect_files_tracked`, `collect_files_below_tracked`), because the server's
|
||||
startup scan discovers its scope in two walks and the enter-once rule has to
|
||||
hold *between* them. The policy is unchanged and the old entries are
|
||||
wrappers; see the work log below.
|
||||
- **`vlog_parser::ast::NetDelay` → `vlog_formatter`** (topo §2.9-27, struck).
|
||||
Two new public fields, `before_hash` and `after_hash`, both
|
||||
`Vec<Comment>`. The only constructor is `Parser::parse_net_delay`; the only
|
||||
@@ -130,6 +136,38 @@ output). `NetDelay` now owns both of its gaps, `before_hash` and
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-08 — §61.3: two additive entries beside `collect_files`
|
||||
|
||||
`lucisv_core::walk` gained two functions and lost nothing. `collect_files`
|
||||
keeps its signature, its order, its `.gitignore` handling, its `--exclude`
|
||||
matching, its cycle guard and its warnings, and is now a two-line wrapper over
|
||||
the first of them. The 102 tests this feature and `parallel-files` left behind
|
||||
all pass unchanged; seven were added.
|
||||
|
||||
- **`collect_files_with(input, exclude, gitignore, found, warn)`** hands each
|
||||
file to `found(path, Option<u64>)` instead of pushing it onto a `Vec`. The
|
||||
length is `meta.len()` off the **`metadata` call the walk already makes on
|
||||
every directory entry** to answer "directory?" — so the walk costs nothing
|
||||
more and a caller that needs sizes (`lucisv_server`'s
|
||||
`lucisv.index.maxFileSize` cap) stops making 3 976 of its own. `None` means
|
||||
the walk did not stat: `input` naming a file rather than a directory is
|
||||
handed straight over, with no `metadata` call added to a path that never
|
||||
needed one.
|
||||
- **`collect_files_below(root, input, …)`** walks `input`, which lies under
|
||||
`root`, finding exactly what a walk of `root` would have found there. It
|
||||
pushes each ancestor's `.gitignore` onto the rule stack at the depth that
|
||||
ancestor sits at, and it yields **nothing** when one of those ancestors is
|
||||
itself ignored or excluded — because a walk of `root` would never have
|
||||
descended into it. `input` not under `root` finds nothing and is not an
|
||||
error.
|
||||
|
||||
The second exists because `lucisv_server` walks one folder of a scope whose
|
||||
rung is the *root*, and a walk that starts below a root would otherwise index
|
||||
what that root's rules exclude. Its three tests assert equality with the
|
||||
whole-root walk restricted to the same subtree — including the case where a
|
||||
deeper `.gitignore`'s `!` line re-includes what the root's rule dropped, which
|
||||
is where the `base` depth of a pre-loaded ignore file has to be exactly right.
|
||||
|
||||
**2026-09-05 — dev (Opus 5).**
|
||||
|
||||
*43.1, `crates/lucisv_core/src/walk.rs`.* `Walk` gained
|
||||
@@ -250,6 +288,36 @@ together with the warning channel the walk lacks. The opentitan
|
||||
reporting a same-directory symlink alias once — the intended change, noted
|
||||
in 0.43.0's release notes.
|
||||
|
||||
**2026-09-09 — the identity is now shared across walks (review finding F1).**
|
||||
43.1's contract — *each directory is entered once, by identity, and its files
|
||||
are reported under the first path that reached it* — was a contract about one
|
||||
`Walk`. The 0.52.0 startup scan discovers its scope in two walks (the user's
|
||||
own folder, then the rest of the workspace: `docs/features/perf5r-first-answer/README.md`),
|
||||
and two `Walk`s meant two `visited` sets, so a symlinked directory reached by
|
||||
both was reported twice under two spellings and the index held every module in
|
||||
it twice — a valid rename refused as ambiguous
|
||||
([the review](../../performance_052_review.md#f1--p2--split-startup-discovery-duplicates-modules-behind-directory-aliases)).
|
||||
|
||||
The set is now a value a caller may own: `Walk::visited` became
|
||||
`Walk.tracker: &mut DirectoryTracker`, and `collect_files_tracked` /
|
||||
`collect_files_below_tracked` take one. The **policy is unchanged** — the same
|
||||
`(dev, ino)` identity, the same enter-once rule, the same silent skip, the
|
||||
same dangling-link handling, and `collect_files_with`/`collect_files_below`
|
||||
still make a tracker of their own so a single walk behaves byte for byte as it
|
||||
did. What is new is a second answer for the caller that shares one:
|
||||
`DirStatus::PrecedenceConflict` says "already entered, under a path this one
|
||||
sorts *before*" — which is the case where the enter-once rule and a walk of
|
||||
the root would pick different spellings. A single walk never sees it (it meets
|
||||
the first spelling first, by construction); only a split does, and the server
|
||||
answers it with one ordinary rescan rather than by guessing.
|
||||
|
||||
Two `lucisv_core` unit tests pin the tracker itself
|
||||
(`tracker_detects_precedence_conflict_when_alias_sorts_before`,
|
||||
`tracker_allows_alias_sorting_after_without_conflict`); nine server fixtures
|
||||
in `server/tests/startup.rs` pin what the server does about it, cycles
|
||||
included — `sub/up -> ..` still terminates, still names each file once, and
|
||||
now agrees with a plain walk about how it spells them.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-09-05 — QA (Sonnet).** Built `target/release/{lucisv,lucisv_server}` once
|
||||
|
||||
@@ -1284,3 +1284,142 @@ parsed `timing:` lines; the staged startup, the per-step read, the
|
||||
`staging`/`head_owed` wait clauses, the compaction skip; `state.rs` split
|
||||
into `state/`. Nothing in `check/`'s comparisons, `fence.rs`, or
|
||||
`verify.rs` changed.
|
||||
|
||||
### 2026-09-08 — the review round (TODO §61)
|
||||
|
||||
The independent review of 0.51.0 (`docs/performance_take5_review.md`,
|
||||
tracker rows R1–R4) implemented in five lanes, same protocol as §60, each
|
||||
paired against the 0.51.0 review baseline or the commit it started from.
|
||||
Feature READMEs: `docs/features/perf5r-{preflight,lint-snapshot,first-answer,publication,scope-reuse}/`.
|
||||
|
||||
| what | before | after | lane |
|
||||
|---|---:|---:|---|
|
||||
| `rename` on a cursor with no symbol (a refusal) | 2.0 s, 3 975 parses | **0.34 ms, 0 parses** | §61.1 — an engine-owned preflight over the request buffer alone; index-answered refusals stay on the slow road (a wrong rename refusal is terminal) |
|
||||
| `codeAction` on the 42k-line no-offer comment, unchanged buffer | 22.6 ms (all of it the three semantic rules) | **1.0 ms** | §61.2 — one lint pass per document revision shared by diagnostics and quick fixes, keyed by value on every input (waiver *contents* included), cleared by every index mutation's overlay refresh |
|
||||
| the definition queued behind it | 22.4 ms | **0.8 ms** | §61.2 |
|
||||
| first `codeAction` after a one-character edit | 126 ms | **107 ms** (the rest is the buffer's own parse) | §61.2 |
|
||||
| first useful definition after opening a file, workspace scope | 266 ms cold / 301 warm (0.51.0); 84 / 208 in 0.50.0 *when a race was won*, over 1 s otherwise | **78 cold / 115 warm, correct every session** | §61.3 — the open buffer's folders walked, stepped and published before the rest of the workspace is discovered; the walk hands on the lengths it already has; a subtree walk carries the ancestor ignore stack down |
|
||||
| warm quiet workspace start | 1 034 ms | **985–997 ms** | §61.3/§61.4 |
|
||||
| a loaded warm scan (a definition every 100 ms), median wait / scan time | 112 ms / 4.2 s | **1.9 ms / ~1.9 s** at the same offered load | §61.4 — a publish per 512 files instead of per burst (a publish costs the size of the index); the first useful answer exempt |
|
||||
| an empty navigation answer mid-scan | answered `[]` if the target was not scanned yet | **deferred to the publish that holds it, or scan end**; unsettled answers 0 | §61.4 |
|
||||
| the tail rename (`state_q`, 238 selected files) | 380 ms, 240 parses | **314 ms, 137 parses** (−21 % against the review's 398) | §61.5 — a rename builds its index from the store's own records for closed files whose bytes hash to what the record was written for, and parses only the files it must analyse; the record and its hash come from one store entry, never the workspace index |
|
||||
| the duplicate-module rename refusal (`rstmgr_por`, 3 976 files) | 2.05 s, 3 975 parses | **0.7 s, 14 parses** | §61.5 |
|
||||
|
||||
**Trades and rulings recorded:** the loaded-scan max in four single-buffer
|
||||
cells rose (worst 168 → 422 ms warm) — cadence spacing, accepted against
|
||||
the median and the completion; the duplicate-declaration rename refusal
|
||||
stays on the slow road (the index is written on save, not on a keystroke);
|
||||
the bounded local record load of the index store stays unshipped (the
|
||||
checksum is owed either way, and it would break the canonical load the
|
||||
compaction skip rests on); a config-discovery memo refused (0.04 ms, and
|
||||
the only thing noticing an unwatched `lucisv.toml` change).
|
||||
|
||||
**Filed, not fixed:** the cross-folder first answer's remaining 89 ms is
|
||||
the store open; the two-phase discovery walks the open folder twice (+2.5–
|
||||
5 % on the 1/10-buffer settle); `format::indent_width` over an already-read
|
||||
`FileConfig`; the `absorb` whole-index merge as the next publication lever.
|
||||
|
||||
### 2026-09-09 — the 0.52.0 review (TODO §62)
|
||||
|
||||
An independent review of 0.52.0 (`docs/performance_052_review.md`,
|
||||
evidence `docs/perf/review-052-20260909/`) confirmed the review-round
|
||||
numbers and found one correctness defect and two harness defects. All
|
||||
three are fixed in 0.53.0; no performance number moved.
|
||||
|
||||
- **F1 — directory aliases in the split startup scan.** The open folder's
|
||||
walk and the rest-of-workspace walk kept separate visited sets, so a
|
||||
directory reachable by two spellings (`a_alias -> z_real`) was indexed
|
||||
twice at startup: two definition targets and a valid rename refused as
|
||||
ambiguous until a rescan. Fixed: one directory-identity tracker shared
|
||||
across both walks; a pre-check that takes the single canonical walk
|
||||
when an alias sorts before the open folder or an ancestor; an alias
|
||||
found only by the remaining walk requests one ordinary rescan so the
|
||||
spellings converge; the open-buffer alias gate applied to both walks
|
||||
and stat'ing only same-named files (`stats` 0 on opentitan). Nine
|
||||
fixtures assert startup, rescan and restart agree on index paths,
|
||||
definitions, prepareRename and diagnostics; a genuine duplicate is
|
||||
still refused. First answer, settle, discovery and the buffer cells
|
||||
are within noise of 0.52.0 (`docs/features/perf5r-first-answer/README.md`).
|
||||
- **F2/F3 — the load probe.** A warm `scanload` cell now primes an empty
|
||||
store untimed and records per-trial cache hits (a warm trial with none
|
||||
is an error); scan completion is stamped from the scan's own end event
|
||||
and responses are partitioned by it, not by the request window. The
|
||||
0.52.0 review's whole-window numbers stand; its `settled_ms`/mid-scan
|
||||
fields at 0.52.0 do not.
|
||||
- **N1–N3** (the dirty-buffer parse on the first action after an edit,
|
||||
the retained-analysis parse work and the 31 ms facts decode, the
|
||||
whole-index merge per publication) are filed with the review's
|
||||
baselines and deferred to loop 3.
|
||||
|
||||
### 2026-09-12 — loop 3, round 1 (TODO §63)
|
||||
|
||||
**§63.1 is a correctness lane, not a performance one**, recorded here
|
||||
because its parity ran through this harness: a `bind` file's own
|
||||
occurrence of a renamed name is now edited (resolvable) or warned about
|
||||
(not), never silent — the resolver had asked the bind target's
|
||||
*connection* surface for a bare name and rooted a bind's hierarchical
|
||||
path in the writing scope (`FACTS_FORMAT` 19 → 20). `renamewarn` 1 758 →
|
||||
1 764 sentences, 1 758 − 8 = 1 750 held; every one of the 28 paired keys
|
||||
that moved is a bind file's new edit or warning; tail rename 326 ms
|
||||
(gate ≤ 330). `docs/features/rename-bind-occurrences/README.md`.
|
||||
|
||||
**§63.2 — the first request after an edit (N1 of the 0.52.0 review).**
|
||||
The 40 267-line pinmux cell — one-character `didChange`, then the
|
||||
all-family `codeAction` menu — **109 → 88 ms paired (−19.2 % dev;
|
||||
−19.6 % / −16.3 % on QA's re-take, order alternated)**; the
|
||||
unchanged-repeat cell and every other `offeredit`/`offerkinds`/`flush`/
|
||||
`diagnostics` row within noise; cold-scan RSS ~25 MiB lower, warm flat.
|
||||
The flush is now split on the `timing: codeaction` line
|
||||
(`rebuild{lex parse defines analyze external lines publish documents}`),
|
||||
which is what named the cost: **lex 29 ms and parse 26 ms of a 100 ms
|
||||
flush**, and *no* second lint and *no* second analysis of the revision
|
||||
(the snapshot and `with_semantics` already had those). Three changes, all
|
||||
in `vlog_parser`: the lexer's two phases fused (the intermediate
|
||||
`Vec<RawTok>` gone; `tokenize` 27.8 → 24.7 ms), `Parser::skip` for the
|
||||
178 `bump()` sites that discarded the token (`parse_tolerant` 17.5 →
|
||||
16.0 ms), and a first-byte test in front of the 42-entry operator table
|
||||
(`tokenize` 24.7 → **11.6 ms**, the single largest win). Token stream,
|
||||
parse diagnostics, AST and symbol table digested per file over 4 807
|
||||
files, re-derived by QA against a rebuilt 1b8723c: 0 differ; the five
|
||||
gap fuzzers at their pinned counts; `format --stdout` byte-identical over
|
||||
corpus and opentitan `hw/ip`; diagnostics and menus identical on the
|
||||
edited buffer (87 lines). **Filed, not fixed** (TODO loop-3 list): the
|
||||
token clone into `parse_tolerant` (3.9 ms — the parser mutates the
|
||||
stream it is given, so it cannot be handed over while `Document::tokens`
|
||||
is read for comments), `analyze` (9.4 ms), `resolve_external` (4.7 ms),
|
||||
and ~6 ms dropping the previous revision's products on the request path.
|
||||
`docs/features/perf-first-after-edit/README.md`; evidence
|
||||
`~/.cache/lucisv-perf/63-2/`.
|
||||
### 2026-09-12 — loop 3, round 2 (TODO §64)
|
||||
|
||||
**§64.1 is a correctness lane, not a performance one**, recorded here
|
||||
because it moves one harness row on purpose. `textDocument/references`
|
||||
now judges a declaration's cross-file reach on the **hierarchical**
|
||||
surface (`nav::leaves_this_file` / `indexed_def_in_file` ask
|
||||
`member_in(…, Surface::Hierarchical)` instead of `member`), so a module's
|
||||
net, variable or instance — which a `bind` connection or a `u_x.sig`
|
||||
tail names from another file — is answered workspace-wide instead of
|
||||
silently in-file. Two costs, both measured on the real opentitan tree:
|
||||
|
||||
- **A local net's `references` in a 40 267-line open buffer** now walks
|
||||
the indexed path (two map probes plus the name-prefiltered pass over
|
||||
open buffers) instead of returning the in-file answer directly:
|
||||
**1.22 → 1.54 ms median** (QA, throwaway worktree at 9d1eb16 for the
|
||||
before). Accepted: the gate still saves the walk for every name the
|
||||
index holds nowhere.
|
||||
- **A cross-file request into a *closed* declaring file** (the shape that
|
||||
used to answer incompletely) parses exactly that file once, fresh from
|
||||
disk: 0.1–0.2 ms → **0.4–1.5 ms** on `state_q` from
|
||||
`entropy_src_core.sv` with `entropy_src_main_sm.sv` shut — the price
|
||||
of the in-file uses that answer used to omit. The index deliberately
|
||||
posts no `Local` reference for a hierarchical-only member (the §49
|
||||
ruling: a reference table sized by every RTL body for a rarely-asked
|
||||
answer), so the one-file re-analysis is the same trade the rename
|
||||
already makes.
|
||||
|
||||
Every connection-surface row of the `nav` harness is unchanged in result
|
||||
count and within noise in time (`aes` 14 locations / 9 files, `.clk_i`
|
||||
12 / 9). Every closed-file span is now guarded by `hover::spells_exactly`
|
||||
before it is rendered — one slice compare per location, unmeasurable —
|
||||
so a stale index can omit a location but never point at a wrong line
|
||||
(QA findings 1–4). `docs/features/references-hierarchical-surface/README.md`.
|
||||
@@ -0,0 +1,73 @@
|
||||
# Independent 0.52.0 review evidence — 2026-09-09
|
||||
|
||||
[Review, findings and assessment](../../performance_052_review.md) ·
|
||||
[Tracking file](../take5-tracking.md)
|
||||
|
||||
Candidate: `3ceba21bb2ef4404a188b076301b170af862075b` (0.52.0).
|
||||
Reference: `126a6bcdac99e940534c87bce94a5269cdc53ae4` (0.51.0), exported with
|
||||
`git archive` into scratch storage and freshly built. Both use the current
|
||||
0.52.0 harness. No build or test overlapped benchmark timing. Every run used
|
||||
the repository's 8 GiB / 1,800-second guard.
|
||||
|
||||
## Evidence files
|
||||
|
||||
- `provenance.json`: commits, compiler/OS, binary hashes, corpus state/hashes, build commands and exclusions.
|
||||
- `validation.json`: 4,374 passed / 0 failed / 45 ignored, 84 paired outcome rows with zero differences, final corpus checks and reproduced finding IDs. Passing the existing suite does not close the new reproductions.
|
||||
- `results.jsonl`: full paired LSP sample arrays, fingerprints, statuses, rename traces, RSS and cross-folder fixed-load results.
|
||||
- `load-retest.jsonl`: **use these rows for the normal warm loaded-scan comparison**. The initial normal `scanloadprobe` rows in `results.jsonl` are excluded because their fresh store made the first nominally warm trial cold (F2). The rerun uses the populated stores left by the completed cold/warm matrix.
|
||||
- `runs.jsonl`: all 20 initial paired phase commands, times, load samples, exits and corpus hash/status checks.
|
||||
- `verification-runs.jsonl`: corrected warm-load commands, two reproductions, fmt, clippy and full workspace-test commands/exits.
|
||||
- `symlink-results.jsonl`: initial three-session-per-version definition reproduction.
|
||||
- `symlink-lifecycle.log`: another three sessions per version, comparing definition and prepareRename at startup and after a whole rescan without source changes (F1).
|
||||
- `warm-priming-proof.log`: full scan traces for two nominally warm sessions, showing 0 hits / 3,974 misses on the first and 3,974 hits / 0 misses on the second (F2).
|
||||
- `build-*.log`, `fmt.log`, `clippy.log`, `tests.log`: freshness and correctness-check output.
|
||||
- `run.py`, `verify.py`, `symlink_probe.py`, `symlink_lifecycle.py`, `warm_priming_probe.py`: actual scratch scripts. They contain machine-specific paths and are evidence, not project tooling.
|
||||
|
||||
Raw phase console logs, the archived reference source/build and caches remain
|
||||
under `/tmp/lucisv-perf-review-20260909`. They are not copied wholesale into
|
||||
the repository. Corpus source was never written; workspace edits were captured
|
||||
or discarded. The symlink fixture is separate from OpenTitan.
|
||||
|
||||
## Measurement cautions
|
||||
|
||||
**F3:** do not use `scanload.settled_ms` or its `mid_scan_*`/after-settle
|
||||
classification as reliable scan-only measurements. The candidate's trace
|
||||
finishes around 1.77 s but the harness reports 3.41 s, the end of its request
|
||||
window. This review uses `publication[].scan_total` and wire waits over the
|
||||
entire fixed window. Raw fields are retained unchanged so the bug is reviewable.
|
||||
|
||||
Ordinary request arrays are first request plus three repeats; scan, RSS and
|
||||
first-after-edit arrays are three trials. Queue rows have explicit leader and
|
||||
follower values. Rename stage fields describe the last traced request, not a
|
||||
median CPU profile. RSS is KiB; report MiB by dividing by 1,024. The sampled
|
||||
request peaks are whole-process RSS, not allocation totals. A command-offer
|
||||
placeholder of zero is not execution; `capture` is an edit delivered to
|
||||
applyEdit but declined by the client; `refused` is no edit.
|
||||
|
||||
Cross-folder load cells offer a fixed window: 9 s cold or 3.5 s warm, with one
|
||||
request every 100 ms. Three sessions therefore contribute 270 or 105 responses
|
||||
per cell. `requests_offered` is per session; `requests_answered` is aggregated.
|
||||
Three processes are insufficient for population tail-percentile claims even
|
||||
when their pooled request count is larger.
|
||||
|
||||
## Reproduce a finding
|
||||
|
||||
Use the commits and paths in `provenance.json`, or adjust the scratch scripts
|
||||
to point to freshly built binaries on another machine. Run them through the
|
||||
guard from the repository root:
|
||||
|
||||
```sh
|
||||
tools/guard.sh -m 8 -t 1800 -- python3 /tmp/lucisv-perf-review-20260909/symlink_lifecycle.py
|
||||
```
|
||||
|
||||
The script creates its fixture under scratch storage, opens the real-path
|
||||
testbench, waits for startup, requests definition and prepareRename, sends a
|
||||
two-file watched-change notification to trigger a whole rescan, and asks
|
||||
again. It prints the actual responses; the candidate's false duplicate
|
||||
refusal is the finding, not an expected feature behavior.
|
||||
|
||||
`warm_priming_probe.py` requires its proof directory not to exist. Choose a
|
||||
new scratch proof directory for a rerun; it deliberately does not silently
|
||||
reuse or delete an earlier proof. The normal benchmark driver similarly needs
|
||||
the F2 priming correction before its warm-load rows can be trusted on fresh
|
||||
storage. Exact accepted and excluded commands are retained in the run logs.
|
||||
@@ -0,0 +1,2 @@
|
||||
Compiling lucisv_server v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/lucisv_server)
|
||||
Finished `release` profile [optimized] target(s) in 57.30s
|
||||
@@ -0,0 +1,27 @@
|
||||
Compiling proc-macro2 v1.0.107
|
||||
Compiling unicode-ident v1.0.24
|
||||
Compiling quote v1.0.47
|
||||
Compiling serde_core v1.0.229
|
||||
Compiling serde v1.0.229
|
||||
Compiling crossbeam-utils v0.8.22
|
||||
Compiling serde_json v1.0.140
|
||||
Compiling vlog_parser v0.51.0 (/tmp/lucisv-perf-review-20260909/reference/crates/vlog_parser)
|
||||
Compiling ryu v1.0.23
|
||||
Compiling itoa v1.0.18
|
||||
Compiling memchr v2.8.3
|
||||
Compiling bitflags v1.3.2
|
||||
Compiling lucisv_core v0.51.0 (/tmp/lucisv-perf-review-20260909/reference/crates/lucisv_core)
|
||||
Compiling fluent-uri v0.1.4
|
||||
Compiling log v0.4.33
|
||||
Compiling crossbeam-channel v0.5.16
|
||||
Compiling syn v3.0.3
|
||||
Compiling vlog_semantic v0.51.0 (/tmp/lucisv-perf-review-20260909/reference/crates/vlog_semantic)
|
||||
Compiling vlog_formatter v0.51.0 (/tmp/lucisv-perf-review-20260909/reference/crates/vlog_formatter)
|
||||
Compiling serde_derive v1.0.229
|
||||
Compiling serde_repr v0.1.21
|
||||
Compiling vlog_linter v0.51.0 (/tmp/lucisv-perf-review-20260909/reference/crates/vlog_linter)
|
||||
Compiling vlog_refactor v0.51.0 (/tmp/lucisv-perf-review-20260909/reference/crates/vlog_refactor)
|
||||
Compiling lsp-server v0.10.0
|
||||
Compiling lsp-types v0.97.0
|
||||
Compiling lucisv_server v0.51.0 (/tmp/lucisv-perf-review-20260909/reference/crates/lucisv_server)
|
||||
Finished `release` profile [optimized] target(s) in 1m 07s
|
||||
@@ -0,0 +1,9 @@
|
||||
Checking vlog_parser v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/vlog_parser)
|
||||
Checking lucisv_core v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/lucisv_core)
|
||||
Checking vlog_semantic v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/vlog_semantic)
|
||||
Checking vlog_formatter v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/vlog_formatter)
|
||||
Checking vlog_refactor v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/vlog_refactor)
|
||||
Checking vlog_linter v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/vlog_linter)
|
||||
Checking lucisv_server v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/lucisv_server)
|
||||
Checking lucisv v0.52.0 (/Users/guoliangchen/repo/verilogrustformatter/crates/lucisv)
|
||||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2m 04s
|
||||
Whitespace-only changes.
@@ -0,0 +1,2 @@
|
||||
{"phase": "scanload", "row": "definition every 100 ms, warm cache, 1 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 2, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [0.23437500931322575, 0.2786249970085919, 0.27879205299541354, 0.3429169883020222, 0.3560000332072377, 0.3707500291056931, 0.37225004052743316, 0.37745898589491844, 0.3807920147664845, 0.38191705243662, 0.38962496910244226, 0.3909170045517385, 0.3945829812437296, 0.39591704262420535, 0.39795797783881426, 0.419457966927439, 0.41983299888670444, 0.4202499985694885, 0.4267499898560345, 0.4297500126995146, 0.4308749921619892, 0.4320830339565873, 0.43708295561373234, 0.4479580093175173, 0.45666599180549383, 0.45683298958465457, 0.47037500189617276, 0.47979201190173626, 0.4801250179298222, 0.48170797526836395, 0.482875038869679, 0.4948750138282776, 0.5013329791836441, 0.6397910183295608, 0.6407910259440541, 0.6412909715436399, 0.7084590033628047, 0.7254999945871532, 0.7357920403592288, 0.7520000217482448, 0.9683750104159117, 0.9921250166371465, 1.0569170117378235, 1.2750829919241369, 1.375459018163383, 1.3993330067023635, 1.4586250181309879, 1.4692499535158277, 1.521750004030764, 1.6809169901534915, 1.774792035575956, 1.875291985925287, 2.033584052696824, 2.128041989635676, 2.6053329929709435, 2.644082996994257, 3.567832987755537, 10.479416989255697, 19.887125003151596, 20.610582956578583, 51.07304098783061, 51.93137499736622, 64.53425000654534, 70.25124999927357, 77.52504100790247, 79.93495900882408, 84.3826670316048, 86.70937502756715, 97.64420898864046, 109.81295898091048, 119.40683302236721, 120.58512499788776, 150.113333016634, 151.45741601008922, 163.3421669830568, 170.30383396195248, 175.4463340039365, 181.4691670006141, 183.25004196958616, 184.164458012674, 198.05016601458192, 208.9190420228988, 219.84766598325223, 220.00158298760653, 250.87466702098027, 252.19029100844637, 262.700000021141, 269.08900000853464, 275.53670800989494, 283.8588749873452, 297.9642499703914, 319.6956670144573, 319.85254102619365, 397.69845799310133, 418.8561250339262, 419.87824998795986, 499.8401670018211, 518.8152500195429, 519.4051250000484, 597.5716249668039, 619.3727909703739, 621.6692919842899, 699.8402920435183, 720.6624170066789, 721.715291030705], "latency_median_ms": 2.033584052696824, "latency_max_ms": 721.715291030705, "mid_scan_median_ms": 2.033584052696824, "mid_scan_max_ms": 721.715291030705, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 105, "after_settle_answers": 0, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 0, "settled_ms": [3406.4717919682153, 3407.3735430138186, 3406.602292030584], "tick_jitter_ms": 6.958250014577061, "publication": [{"publish_absorb": 452.75, "publish_candidates": 180.64, "publish_includes": 12.97, "publish_overlay": 0.61, "publish_total": 646.97, "publishes": 4, "published": 3519, "first_publish": 470.96, "scan_total": 1778.28}, {"publish_absorb": 476.16, "publish_candidates": 185.16, "publish_includes": 13.28, "publish_overlay": 0.67, "publish_total": 675.27, "publishes": 4, "published": 3494, "first_publish": 494.98, "scan_total": 1771.43}, {"publish_absorb": 446.83, "publish_candidates": 179.34, "publish_includes": 13.07, "publish_overlay": 0.65, "publish_total": 639.89, "publishes": 4, "published": 3513, "first_publish": 474.04, "scan_total": 1764.97}], "ts": "2026-09-09T01:22:08", "label": "0.52.0-review", "schema": 2, "units": "ms"}
|
||||
{"phase": "scanload", "row": "definition every 100 ms, warm cache, 1 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 2, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [241.55699997209013, 247.57100001443177, 275.5369999795221, 342.0218749670312, 346.5159999905154, 375.6269169971347, 440.8285000245087, 446.021625015419, 475.64991598483175, 540.7515830011107, 545.7169159781188, 576.1033750022762, 640.0489169755019, 646.3882910320535, 674.5119580300525, 739.6939580212347, 747.1998329856433, 774.6847500093281, 840.0745829567313, 847.3092500353232, 874.2899590288289, 941.5772079955786, 947.2306670504622, 973.9954579854384, 1041.8655420071445, 1046.7767500085756, 1075.9012500056997, 1141.7389169801027, 1146.351124974899, 1173.6330830026418, 1241.659208026249, 1246.7039580224082, 1273.9923750050366, 1340.223999985028, 1347.8122499655, 1374.1556670283899, 1440.9779999987222, 1446.6565829934552, 1473.9422079874203, 1541.2526250001974, 1546.17737501394, 1574.431375018321, 1640.8938340027817, 1647.3738750210032, 1674.7713339864276, 1739.9268340086564, 1746.503665985074, 1773.5807499848306, 1840.233499999158, 1846.9760829466395, 1873.2641249662265, 1939.728458004538, 1947.2075829980895, 1974.8794579645619, 2039.1076660016552, 2045.1457920134999, 2074.0201660082676, 2139.1950830002315, 2147.0947500201873, 2174.096333037596, 2239.5964169991203, 2247.3798339487985, 2274.172290985007, 2339.4442080170847, 2346.7091250349768, 2375.15783298295, 2440.894625033252, 2446.697583014611, 2474.30229105521, 2540.1668330305256, 2546.162332990207, 2574.7746669803746, 2639.975374971982, 2645.9845830104314, 2675.508540996816, 2739.6694580093026, 2745.4706669668667, 2774.191749980673, 2839.1245410311967, 2845.5262079951353, 2873.318500001915, 2940.369332965929, 2946.829541993793, 2973.2182910083793, 3040.314667043276, 3047.5078329909593, 3073.755874997005, 3141.1920840037055, 3146.8377920100465, 3174.6075420523994, 3239.4263750175014, 3246.957624971401, 3274.9790839734487, 3341.0877080168575, 3347.254416963551, 3373.97424998926, 3441.0788330133073, 3445.548250048887, 3474.267208017409, 3540.4448750196025, 3545.773416000884, 3573.324542026967, 3641.424166969955, 3647.3766670096666, 3675.449041998945], "latency_median_ms": 1947.2075829980895, "latency_max_ms": 3675.449041998945, "mid_scan_median_ms": 1947.2075829980895, "mid_scan_max_ms": 3675.449041998945, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 105, "after_settle_answers": 0, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 0, "settled_ms": [4255.203042004723, 4257.531625917181, 4287.717750063166], "tick_jitter_ms": 2.676916017662734, "publication": [{"publish_absorb": 2416.7, "publish_candidates": 682.01, "publish_includes": 49.98, "publish_overlay": 5.02, "publish_total": 3153.7099999999996, "publishes": 34, "published": 1807, "first_publish": 280.81, "scan_total": 4244.26}, {"publish_absorb": 2421.9, "publish_candidates": 681.68, "publish_includes": 50.02, "publish_overlay": 5.08, "publish_total": 3158.68, "publishes": 34, "published": 1808, "first_publish": 280.18, "scan_total": 4246.99}, {"publish_absorb": 2467.32, "publish_candidates": 682.1, "publish_includes": 51.98, "publish_overlay": 5.06, "publish_total": 3206.46, "publishes": 34, "published": 1808, "first_publish": 267.64, "scan_total": 4276.15}], "ts": "2026-09-09T01:22:26", "label": "0.51.0-reference", "schema": 2, "units": "ms"}
|
||||
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"date": "2026-09-09",
|
||||
"candidate_commit": "3ceba21bb2ef4404a188b076301b170af862075b",
|
||||
"reference_commit": "126a6bcdac99e940534c87bce94a5269cdc53ae4",
|
||||
"reference_method": "git archive into scratch directory; guarded fresh release build",
|
||||
"compiler": "rustc 1.97.1 (8bab26f4f 2026-07-14) (Homebrew)\nbinary: rustc\ncommit-hash: 8bab26f4f68e0e26f0bb7960be334d5b520ea452\ncommit-date: 2026-07-14\nhost: aarch64-apple-darwin\nrelease: 1.97.1\nLLVM version: 22.1.8",
|
||||
"os": "ProductName:\t\tmacOS\nProductVersion:\t\t27.0\nBuildVersion:\t\t26A5425a",
|
||||
"machine": "arm64",
|
||||
"python": "3.14.7",
|
||||
"logical_cpus": 10,
|
||||
"binary_sha256": {
|
||||
"/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server": "d9b177f254315c2f9ec40f386cc5218aafd9d3474d4e8762b499f113654d55f1",
|
||||
"/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server": "11a212b3f8771adcfc4d435d58f20ab02fe9f59f47fd99cf09d43f1f3d739336"
|
||||
},
|
||||
"corpus_commit": "00981352642fb65ef2b6c47143a0f6bb31fd4a97",
|
||||
"corpus_status": "M hw/ip/aes/dv/tb/tb.sv\n M hw/top_darjeeling/ip/ast/rtl/ast.sv\n M hw/top_earlgrey/ip/ast/rtl/ast.sv",
|
||||
"corpus_modified_sha256": {
|
||||
"hw/ip/aes/dv/tb/tb.sv": "09ae059220caa7667bb22acdd3157647b55d36de96ff2ca55a801bbbcd08146e",
|
||||
"hw/top_darjeeling/ip/ast/rtl/ast.sv": "2b63f9d7bc0068388e47a80383eaf048183cf5868b1cfd4692eac325393d2803",
|
||||
"hw/top_earlgrey/ip/ast/rtl/ast.sv": "15efd90c99030c6a43486ef1ed622897b967ad5153697d6b2c2c21cfb6eba35f"
|
||||
},
|
||||
"guard": {
|
||||
"memory_gib": 8,
|
||||
"seconds": 1800
|
||||
},
|
||||
"notes": [
|
||||
"Current 0.52.0 harness drives both binaries.",
|
||||
"Builds finished before any timing. All phases sequential; no benchmark/test concurrency.",
|
||||
"Corpus edits discarded and caches isolated in scratch storage.",
|
||||
"No remote fetch or checkout mutation. Initial repository status clean."
|
||||
],
|
||||
"excluded_measurements": [
|
||||
"results.jsonl: scanload rows without cross-folder in the row name (initial scanloadprobe runs); the first warm trial lacked a populated r4-load store. Use load-retest.jsonl instead.",
|
||||
"All scanload settled_ms, mid_scan_median_ms, mid_scan_max_ms, mid_scan_answers, after_settle_answers fields are not used as reliable completion/partition metrics (F3)."
|
||||
],
|
||||
"build_commands": [
|
||||
[
|
||||
"tools/guard.sh",
|
||||
"-m",
|
||||
"8",
|
||||
"-t",
|
||||
"1800",
|
||||
"--",
|
||||
"cargo",
|
||||
"build",
|
||||
"--release",
|
||||
"--locked",
|
||||
"-p",
|
||||
"lucisv_server",
|
||||
"--manifest-path",
|
||||
"Cargo.toml"
|
||||
],
|
||||
[
|
||||
"tools/guard.sh",
|
||||
"-m",
|
||||
"8",
|
||||
"-t",
|
||||
"1800",
|
||||
"--",
|
||||
"cargo",
|
||||
"build",
|
||||
"--release",
|
||||
"--locked",
|
||||
"-p",
|
||||
"lucisv_server",
|
||||
"--manifest-path",
|
||||
"/tmp/lucisv-perf-review-20260909/reference/Cargo.toml"
|
||||
]
|
||||
],
|
||||
"test_results": {
|
||||
"passed": 4374,
|
||||
"failed": 0,
|
||||
"ignored": 45,
|
||||
"result_blocks": 59
|
||||
},
|
||||
"corpus_after_all_checks_unchanged": true,
|
||||
"binary_hashes_after_all_checks_unchanged": true
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
{"phase": "offerkinds", "row": "tb-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [5.0712890625, 6.9306640625, 6.75439453125], "ms": [1.9282500143162906, 0.493000028654933, 0.21929200738668442, 0.18204195657745004], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:29", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [5.0712890625, 6.9306640625, 6.75439453125], "ms": [0.08808297570794821, 0.07833295967429876, 0.04891701973974705, 0.04008301766589284], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:29", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [5.0712890625, 6.9306640625, 6.75439453125], "ms": [0.26566704036667943, 0.21970801753923297, 0.18358399393036962, 0.23770902771502733], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:29", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [5.0712890625, 6.9306640625, 6.75439453125], "ms": [0.2045410219579935, 0.12845901073887944, 0.06900000153109431, 0.04654203075915575], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:29", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [5.0712890625, 6.9306640625, 6.75439453125], "ms": [0.05179096478968859, 0.063000014051795, 0.11837499914690852, 0.05725002847611904], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:29", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.0712890625, 6.9306640625, 6.75439453125], "ms": [0.1402500201947987, 0.09391701314598322, 0.14045799616724253, 0.1211669878102839], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:29", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [5.0712890625, 6.9306640625, 6.75439453125], "ms": [0.0607079709880054, 0.03862503217533231, 0.03545801155269146, 0.031791976653039455], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:29", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": null, "load": [5.1455078125, 6.9150390625, 6.74951171875], "ms": [4.584999987855554, 4.051957977935672, 3.7545409868471324, 3.612500033341348], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:09:32", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": [], "load": [5.1455078125, 6.9150390625, 6.74951171875], "ms": [0.12579199392348528, 0.0785829615779221, 0.07804197957739234, 0.060333055444061756], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:32", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["quickfix"], "load": [5.1455078125, 6.9150390625, 6.74951171875], "ms": [0.44899998465552926, 0.3641669754870236, 0.35441602813079953, 0.3295839997008443], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:32", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["refactor.extract"], "load": [5.1455078125, 6.9150390625, 6.74951171875], "ms": [0.0665830448269844, 0.061375030782073736, 0.04995899507775903, 0.09795802179723978], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:09:32", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["refactor.inline"], "load": [5.1455078125, 6.9150390625, 6.74951171875], "ms": [0.0740840332582593, 0.047291978262364864, 0.04662497667595744, 0.040207989513874054], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:09:32", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.1455078125, 6.9150390625, 6.74951171875], "ms": [3.1582920346409082, 2.8589580324478447, 2.9202920268289745, 3.103042021393776], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:32", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["source.organizeImports"], "load": [5.1455078125, 6.9150390625, 6.74951171875], "ms": [0.12320803944021463, 0.06208301056176424, 0.053791969548910856, 0.07720803841948509], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:32", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [1.3690409832634032, 1.1132080107927322, 1.0387920192442834, 1.0371250100433826], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.08533295476809144, 0.06483402103185654, 0.04983402322977781, 0.0468340003862977], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [1.1663340264931321, 1.2232500012032688, 1.1855000047944486, 1.142042048741132], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.0706670107319951, 0.06149994442239404, 0.0705840066075325, 0.052499992307275534], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.071291986387223, 0.04237500252202153, 0.03883300814777613, 0.03649998689070344], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.05395803600549698, 0.03854196984320879, 0.049667025450617075, 0.03912497777491808], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.04291697405278683, 0.044625019654631615, 0.04333403194323182, 0.04395801806822419], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [2.081208978779614, 2.016332990024239, 1.8178750178776681, 1.7115840455517173], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:39", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.10237499373033643, 0.06420904537662864, 0.05641602911055088, 0.05687499651685357], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:39", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [1.5573750133626163, 1.661374990362674, 1.5634170267730951, 1.4038340304978192], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:39", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.07491599535569549, 0.08695904398337007, 0.06758299423381686, 0.05783402593806386], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:39", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.06170797860249877, 0.053750001825392246, 0.06033299723640084, 0.0687920255586505], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:39", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.06587500683963299, 0.048916961532086134, 0.047707988414913416, 0.049708003643900156], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:39", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [5.2939453125, 6.916015625, 6.7509765625], "ms": [0.07333297980949283, 0.05887501174584031, 0.054791977163404226, 0.0451250234618783], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:39", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [5.35009765625, 6.900390625, 6.74609375], "ms": [25.831834005657583, 24.26745800767094, 24.51866597402841, 24.205999972764403], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:42", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [5.35009765625, 6.900390625, 6.74609375], "ms": [0.09516597492620349, 0.05691696424037218, 0.03875000402331352, 0.03129197284579277], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:42", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [5.35009765625, 6.900390625, 6.74609375], "ms": [23.996290983632207, 24.26624996587634, 24.21162504469976, 24.31587496539578], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:42", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [5.35009765625, 6.900390625, 6.74609375], "ms": [0.09320798562839627, 0.06279197987169027, 0.058375007938593626, 0.0503340270370245], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:42", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [5.35009765625, 6.900390625, 6.74609375], "ms": [0.048666028305888176, 0.0416660332120955, 0.0785409938544035, 0.14483300037682056], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:42", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.35009765625, 6.900390625, 6.74609375], "ms": [0.1807910157367587, 0.07395795546472073, 0.06245903205126524, 0.06058404687792063], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:42", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [5.35009765625, 6.900390625, 6.74609375], "ms": [0.061583006754517555, 0.05404202966019511, 0.07225002627819777, 0.05083298310637474], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:42", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [5.48193359375, 6.90185546875, 6.74755859375], "ms": [1.1078329989686608, 0.32133300555869937, 0.22008299129083753, 0.17808302072808146], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [5.48193359375, 6.90185546875, 6.74755859375], "ms": [0.10195799404755235, 0.06629200652241707, 0.054875039495527744, 0.04529103171080351], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [5.48193359375, 6.90185546875, 6.74755859375], "ms": [0.4765419871546328, 0.22708403412252665, 0.15837501268833876, 0.1877500326372683], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [5.48193359375, 6.90185546875, 6.74755859375], "ms": [0.06579200271517038, 0.047083012759685516, 0.04954100586473942, 0.05099998088553548], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [5.48193359375, 6.90185546875, 6.74755859375], "ms": [0.09745795978233218, 0.07141695823520422, 0.06966700311750174, 0.0636249897070229], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.48193359375, 6.90185546875, 6.74755859375], "ms": [0.059165991842746735, 0.04516699118539691, 0.03866699989885092, 0.049083027988672256], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "tb-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [5.48193359375, 6.90185546875, 6.74755859375], "ms": [0.046083005145192146, 0.06849999772384763, 0.10412500705569983, 0.04370900569483638], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": null, "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [3.441042033955455, 2.898292033933103, 3.575833048671484, 3.190334013197571], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:09:52", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": [], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.11799996718764305, 0.0743749551475048, 0.05408300785347819, 0.04170899046584964], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:52", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["quickfix"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.16474997391924262, 0.10470801498740911, 0.11637498391792178, 0.09270902955904603], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:52", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["refactor.extract"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.11237501166760921, 0.11420802911743522, 0.08416594937443733, 0.15366700245067477], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:09:52", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["refactor.inline"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.07387500954791903, 0.10183302219957113, 0.06145797669887543, 0.056165968999266624], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:09:52", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [2.856415987480432, 2.6895839837379754, 2.868750016205013, 2.9005000251345336], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:52", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-reg-instance ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "only": ["source.organizeImports"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.08145900210365653, 0.05520798731595278, 0.044791027903556824, 0.03716698847711086], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:52", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [1.2475409894250333, 0.43991697020828724, 0.2523339935578406, 0.21608301904052496], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.08662499021738768, 0.06312498589977622, 0.06245903205126524, 0.055582961067557335], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.18845894373953342, 0.14116702368482947, 0.1670410274527967, 0.15691597945988178], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.12037501437589526, 0.08174998220056295, 0.05562498699873686, 0.05724997026845813], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.07424998329952359, 0.04620797699317336, 0.06983400089666247, 0.05783297820016742], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.059083045925945044, 0.04016701132059097, 0.09741599205881357, 0.04087499110028148], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "aes-core-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_core.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [5.20263671875, 6.8203125, 6.7197265625], "ms": [0.10295899119228125, 0.06287498399615288, 0.05124998278915882, 0.03937497967854142], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [5.02587890625, 6.7568359375, 6.69775390625], "ms": [1.0873330174945295, 0.7634589564986527, 0.6050000083632767, 0.433207955211401], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:58", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [5.02587890625, 6.7568359375, 6.69775390625], "ms": [0.1058329944498837, 0.08004199480637908, 0.056334014516323805, 0.0527920201420784], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:58", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [5.02587890625, 6.7568359375, 6.69775390625], "ms": [0.2137920237146318, 0.18258305499330163, 0.15999999595806003, 0.17479195958003402], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:58", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [5.02587890625, 6.7568359375, 6.69775390625], "ms": [0.07766601629555225, 0.05858403164893389, 0.054708041716367006, 0.07137499051168561], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:58", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [5.02587890625, 6.7568359375, 6.69775390625], "ms": [0.07000000914558768, 0.07470801938325167, 0.06466597551479936, 0.052292016334831715], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:58", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [5.02587890625, 6.7568359375, 6.69775390625], "ms": [0.0688339932821691, 0.05204096669331193, 0.05183299072086811, 0.0636249897070229], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:58", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "spi-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/spi_device/rtl/spi_device.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [5.02587890625, 6.7568359375, 6.69775390625], "ms": [0.05641701864078641, 0.08274998981505632, 0.2233749837614596, 0.203792005777359], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:09:58", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment None", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": null, "load": [4.86328125, 6.6943359375, 6.67578125], "ms": [2.0860839867964387, 0.48016704386100173, 0.2994579845108092, 0.316707999445498], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment []", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": [], "load": [4.86328125, 6.6943359375, 6.67578125], "ms": [0.09029201464727521, 0.07112504681572318, 0.21000002743676305, 0.11354201706126332], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['quickfix']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["quickfix"], "load": [4.86328125, 6.6943359375, 6.67578125], "ms": [0.21208403632044792, 0.18095801351591945, 0.20987499738112092, 0.22983300732448697], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['refactor.extract']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.extract"], "load": [4.86328125, 6.6943359375, 6.67578125], "ms": [0.06600003689527512, 0.10249996557831764, 0.20412495359778404, 0.10166695574298501], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['refactor.inline']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.inline"], "load": [4.86328125, 6.6943359375, 6.67578125], "ms": [0.057375000324100256, 0.05366699770092964, 0.06616703467443585, 0.0541660119779408], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['refactor.rewrite.lucisv.ports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["refactor.rewrite.lucisv.ports"], "load": [4.86328125, 6.6943359375, 6.67578125], "ms": [0.17104099970310926, 0.07899996126070619, 0.06683298852294683, 0.0675840419717133], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerkinds", "row": "pinmux-comment ['source.organizeImports']", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "only": ["source.organizeImports"], "load": [4.86328125, 6.6943359375, 6.67578125], "ms": [0.04795799031853676, 0.04116696072742343, 0.044832995627075434, 0.04008400719612837], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerqueue", "row": "pinmux comment -> aes definition, pipeline 1", "ms": [0.8687080116942525, 0.8434589835815132], "leader_ms": 0.8687080116942525, "follower_ms": 0.8434589835815132, "status": "ok", "message": null, "result_count": 0, "follower_result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "ms is [leader, follower], not repeats", "ts": "2026-09-09T01:10:05", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerqueue", "row": "pinmux comment -> aes definition, pipeline 2", "ms": [0.28304196894168854, 0.2654170384630561], "leader_ms": 0.28304196894168854, "follower_ms": 0.2654170384630561, "status": "ok", "message": null, "result_count": 0, "follower_result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "ms is [leader, follower], not repeats", "ts": "2026-09-09T01:10:05", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerqueue", "row": "pinmux comment -> aes definition, pipeline 3", "ms": [0.3007500199601054, 0.2912500058300793], "leader_ms": 0.3007500199601054, "follower_ms": 0.2912500058300793, "status": "ok", "message": null, "result_count": 0, "follower_result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "ms is [leader, follower], not repeats", "ts": "2026-09-09T01:10:05", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerqueue", "row": "pinmux comment -> aes definition, pipeline 1", "ms": [27.79579203343019, 27.77458296623081], "leader_ms": 27.79579203343019, "follower_ms": 27.77458296623081, "status": "ok", "message": null, "result_count": 0, "follower_result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "ms is [leader, follower], not repeats", "ts": "2026-09-09T01:10:10", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerqueue", "row": "pinmux comment -> aes definition, pipeline 2", "ms": [24.377333000302315, 24.367875012103468], "leader_ms": 24.377333000302315, "follower_ms": 24.367875012103468, "status": "ok", "message": null, "result_count": 0, "follower_result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "ms is [leader, follower], not repeats", "ts": "2026-09-09T01:10:10", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offerqueue", "row": "pinmux comment -> aes definition, pipeline 3", "ms": [24.435000028461218, 24.425624986179173], "leader_ms": 24.435000028461218, "follower_ms": 24.425624986179173, "status": "ok", "message": null, "result_count": 0, "follower_result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "ms is [leader, follower], not repeats", "ts": "2026-09-09T01:10:10", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "pinmux-comment, first offer after didChange", "ms": [140.83441701950505, 137.8427500021644, 134.88454197067767], "status": "ok", "message": null, "result_count": 0, "result_counts": [0, 0, 0], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "load": [5.9599609375, 6.86865234375, 6.7373046875], "note": "each try is the first codeAction after its own didChange: the document is rebuilt, so nothing from the previous revision can be reused", "ts": "2026-09-09T01:10:15", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "pinmux-comment, repeated offer on the unchanged buffer", "titles": [], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "load": [5.9599609375, 6.86865234375, 6.7373046875], "note": "the same cursor and session as the row above, with no didChange between the tries", "ms": [24.3462499929592, 24.63841700227931, 23.784333025105298, 23.86854198994115], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:15", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "aes-reg-instance, first offer after didChange", "ms": [7.0216250023804605, 5.721417022868991, 7.452749996446073], "status": "ok", "message": null, "result_count": 2, "result_counts": [2, 2, 2], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "load": [5.802734375, 6.82080078125, 6.72119140625], "note": "each try is the first codeAction after its own didChange: the document is rebuilt, so nothing from the previous revision can be reused", "ts": "2026-09-09T01:10:18", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "aes-reg-instance, repeated offer on the unchanged buffer", "titles": ["lucisv: extract selection into module\u2026", "lucisv: inline `aes_reg_top` here"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "load": [5.802734375, 6.82080078125, 6.72119140625], "note": "the same cursor and session as the row above, with no didChange between the tries", "ms": [5.01037499634549, 4.5472909696400166, 4.70308301737532, 4.0991660207509995], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:10:18", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "tb-comment, first offer after didChange", "ms": [1.0847499943338335, 0.8207920473068953, 0.7546659908257425], "status": "ok", "message": null, "result_count": 0, "result_counts": [0, 0, 0], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "load": [5.978515625, 6.84033203125, 6.728515625], "note": "each try is the first codeAction after its own didChange: the document is rebuilt, so nothing from the previous revision can be reused", "ts": "2026-09-09T01:10:22", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "tb-comment, repeated offer on the unchanged buffer", "titles": [], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "load": [5.978515625, 6.84033203125, 6.728515625], "note": "the same cursor and session as the row above, with no didChange between the tries", "ms": [0.44724997133016586, 0.3376249806024134, 0.2398340147919953, 0.2550830249674618], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:22", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "pinmux-comment, first offer after didChange", "ms": [116.39108299277723, 113.5977499652654, 112.88149998290464], "status": "ok", "message": null, "result_count": 0, "result_counts": [0, 0, 0], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "load": [5.89990234375, 6.8095703125, 6.71826171875], "note": "each try is the first codeAction after its own didChange: the document is rebuilt, so nothing from the previous revision can be reused", "ts": "2026-09-09T01:10:26", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "pinmux-comment, repeated offer on the unchanged buffer", "titles": [], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv", "position": {"line": 0, "character": 2}, "load": [5.89990234375, 6.8095703125, 6.71826171875], "note": "the same cursor and session as the row above, with no didChange between the tries", "ms": [0.4027499817311764, 0.2316250465810299, 0.2471250481903553, 0.18354103667661548], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:26", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "aes-reg-instance, first offer after didChange", "ms": [6.09770801384002, 8.55158397462219, 5.045500001870096], "status": "ok", "message": null, "result_count": 2, "result_counts": [2, 2, 2], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "load": [5.89990234375, 6.8095703125, 6.71826171875], "note": "each try is the first codeAction after its own didChange: the document is rebuilt, so nothing from the previous revision can be reused", "ts": "2026-09-09T01:10:29", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "aes-reg-instance, repeated offer on the unchanged buffer", "titles": ["lucisv: extract selection into module\u2026", "lucisv: inline `aes_reg_top` here"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 103, "character": 2}, "load": [5.89990234375, 6.8095703125, 6.71826171875], "note": "the same cursor and session as the row above, with no didChange between the tries", "ms": [4.244667012244463, 3.879832976963371, 3.9809580193832517, 3.8547919830307364], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:10:29", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "tb-comment, first offer after didChange", "ms": [2.404582977760583, 0.9817919926717877, 0.8292499696835876], "status": "ok", "message": null, "result_count": 0, "result_counts": [0, 0, 0], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "load": [5.74755859375, 6.7626953125, 6.7021484375], "note": "each try is the first codeAction after its own didChange: the document is rebuilt, so nothing from the previous revision can be reused", "ts": "2026-09-09T01:10:32", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "offeredit", "row": "tb-comment, repeated offer on the unchanged buffer", "titles": [], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/dv/tb/tb.sv", "position": {"line": 0, "character": 2}, "load": [5.74755859375, 6.7626953125, 6.7021484375], "note": "the same cursor and session as the row above, with no didChange between the tries", "ms": [0.17487496370449662, 0.15174999134615064, 0.19766698824241757, 0.1948749995790422], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:10:32", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "tail: state_q -> state_q_x", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "b39defb212655f29e68c0e15b88dda405d2779a24c4b522a1798b6f44c9a04f7", "peak_rss_kib": 610208.0, "file": "hw/ip/entropy_src/rtl/entropy_src_main_sm.sv", "new_name": "state_q_x", "titles": ["entropy_src_core.sv", "entropy_src_main_sm.sv"], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 95, \"rungs_reference\": 122, \"rungs_instantiation\": 19, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 1, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 113, \"indirect_instantiation\": 19, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 1, \"verify_total\": 73.3, \"verify_tokens\": 4.2, \"verify_watched\": 106, \"verify_watched_bytes\": 1919528, \"verify_before\": 14.4, \"verify_rebuild\": 37.5, \"verify_after\": 7.9, \"verify_checks\": 0.0, \"parses_index\": 135, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 2, \"parses_after\": 0, \"index_lead\": 0.4, \"index_kept\": 107.3, \"index_other\": 0.0, \"index_reused\": 31.4, \"index_merge\": 23.5, \"index_kept_files\": 134, \"index_kept_bytes\": 2892477, \"index_other_files\": 103, \"index_other_bytes\": 1652269, \"index_reused_files\": 238, \"index_reused_bytes\": 4554326, \"warnings_defines\": 1.9, \"warnings_macro_uses\": 42.4, \"warnings_sva\": 2.6, \"warnings_unfinished\": 0.4, \"warnings_unaccounted\": 0.1, \"warnings_scanned\": 135, \"select\": 14.1, \"selected\": 238, \"fallback\": false, \"bytes\": 4554326, \"edited\": 2, \"index\": 163.0, \"locate\": 0.0, \"edits\": 11.6, \"warnings\": 50.5, \"parses\": 137}", "ms": [359.1919590253383, 327.24062498891726, 324.5032500126399, 324.597500031814], "status": "ok", "result_count": 1, "edits": 5, "files": 2, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 95, "trace_rungs_reference": 122, "trace_rungs_instantiation": 19, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 1, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 113, "trace_indirect_instantiation": 19, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 1, "trace_verify_total": 73.3, "trace_verify_tokens": 4.2, "trace_verify_watched": 106, "trace_verify_watched_bytes": 1919528, "trace_verify_before": 14.4, "trace_verify_rebuild": 37.5, "trace_verify_after": 7.9, "trace_verify_checks": 0.0, "trace_parses_index": 135, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 2, "trace_parses_after": 0, "trace_index_lead": 0.4, "trace_index_kept": 107.3, "trace_index_other": 0.0, "trace_index_reused": 31.4, "trace_index_merge": 23.5, "trace_index_kept_files": 134, "trace_index_kept_bytes": 2892477, "trace_index_other_files": 103, "trace_index_other_bytes": 1652269, "trace_index_reused_files": 238, "trace_index_reused_bytes": 4554326, "trace_warnings_defines": 1.9, "trace_warnings_macro_uses": 42.4, "trace_warnings_sva": 2.6, "trace_warnings_unfinished": 0.4, "trace_warnings_unaccounted": 0.1, "trace_warnings_scanned": 135, "trace_select": 14.1, "trace_selected": 238, "trace_fallback": false, "trace_bytes": 4554326, "trace_edited": 2, "trace_index": 163.0, "trace_locate": 0.0, "trace_edits": 11.6, "trace_warnings": 50.5, "trace_parses": 137, "ts": "2026-09-09T01:10:40", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "ordinary: aes -> aes_renamed", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "fa7e31c78382176d5f96d661228ce82328df8bc77bd6d8575dd38717814cb26c", "peak_rss_kib": 459808.0, "file": "hw/ip/aes/dv/tb/tb.sv", "new_name": "aes_renamed", "titles": ["aes.sv", "aes_bind.sv", "aes_cov_bind.sv", "aes_tb.sv", "aes_wrap.sv", "darjeeling_pd_main.sv", "earlgrey_pd_main.sv", "englishbreakfast_pd_main.sv", "tb.sv"], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 4, \"rungs_reference\": 8, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 1, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 46.8, \"verify_tokens\": 15.1, \"verify_watched\": 12, \"verify_watched_bytes\": 398160, \"verify_before\": 4.6, \"verify_rebuild\": 22.7, \"verify_after\": 2.9, \"verify_checks\": 0.0, \"parses_index\": 13, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 9, \"parses_after\": 0, \"index_lead\": 0.2, \"index_kept\": 16.1, \"index_other\": 0.0, \"index_reused\": 3.6, \"index_merge\": 2.6, \"index_kept_files\": 12, \"index_kept_bytes\": 396735, \"index_other_files\": 0, \"index_other_bytes\": 0, \"index_reused_files\": 13, \"index_reused_bytes\": 400051, \"warnings_defines\": 0.2, \"warnings_macro_uses\": 7.3, \"warnings_sva\": 0.2, \"warnings_unfinished\": 0.0, \"warnings_unaccounted\": 0.1, \"warnings_scanned\": 13, \"select\": 8.2, \"selected\": 13, \"fallback\": false, \"bytes\": 400051, \"edited\": 9, \"index\": 22.6, \"locate\": 0.1, \"edits\": 2.4, \"warnings\": 8.3, \"parses\": 22}", "ms": [102.21650003222749, 93.63725001458079, 93.02333300001919, 91.25554200727493], "status": "ok", "result_count": 1, "edits": 14, "files": 9, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 4, "trace_rungs_reference": 8, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 1, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 46.8, "trace_verify_tokens": 15.1, "trace_verify_watched": 12, "trace_verify_watched_bytes": 398160, "trace_verify_before": 4.6, "trace_verify_rebuild": 22.7, "trace_verify_after": 2.9, "trace_verify_checks": 0.0, "trace_parses_index": 13, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 9, "trace_parses_after": 0, "trace_index_lead": 0.2, "trace_index_kept": 16.1, "trace_index_other": 0.0, "trace_index_reused": 3.6, "trace_index_merge": 2.6, "trace_index_kept_files": 12, "trace_index_kept_bytes": 396735, "trace_index_other_files": 0, "trace_index_other_bytes": 0, "trace_index_reused_files": 13, "trace_index_reused_bytes": 400051, "trace_warnings_defines": 0.2, "trace_warnings_macro_uses": 7.3, "trace_warnings_sva": 0.2, "trace_warnings_unfinished": 0.0, "trace_warnings_unaccounted": 0.1, "trace_warnings_scanned": 13, "trace_select": 8.2, "trace_selected": 13, "trace_fallback": false, "trace_bytes": 400051, "trace_edited": 9, "trace_index": 22.6, "trace_locate": 0.1, "trace_edits": 2.4, "trace_warnings": 8.3, "trace_parses": 22, "ts": "2026-09-09T01:10:44", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "unique internal: cipher_alert -> cipher_alert_x", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "5f53e977da59093f59ac3153a59036de64ff2fc041017271d8ebbd9ba41ba1e1", "peak_rss_kib": 434560.0, "file": "hw/ip/aes/rtl/aes_core.sv", "new_name": "cipher_alert_x", "titles": ["aes_core.sv"], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 0, \"rungs_reference\": 2, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 1, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 2, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 1, \"verify_total\": 5.4, \"verify_tokens\": 1.9, \"verify_watched\": 1, \"verify_watched_bytes\": 48933, \"verify_before\": 0.5, \"verify_rebuild\": 2.7, \"verify_after\": 0.2, \"verify_checks\": 0.0, \"parses_index\": 1, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 1, \"parses_after\": 0, \"index_lead\": 2.0, \"index_kept\": 0.0, \"index_other\": 0.0, \"index_reused\": 0.5, \"index_merge\": 0.3, \"index_kept_files\": 0, \"index_kept_bytes\": 0, \"index_other_files\": 3, \"index_other_bytes\": 19542, \"index_reused_files\": 4, \"index_reused_bytes\": 68475, \"warnings_defines\": 0.0, \"warnings_macro_uses\": 0.8, \"warnings_sva\": 0.0, \"warnings_unfinished\": 0.0, \"warnings_unaccounted\": 0.0, \"warnings_scanned\": 1, \"select\": 6.6, \"selected\": 4, \"fallback\": false, \"bytes\": 68475, \"edited\": 1, \"index\": 2.8, \"locate\": 0.2, \"edits\": 0.0, \"warnings\": 0.9, \"parses\": 2}", "ms": [28.592207992915064, 21.334541030228138, 18.542082980275154, 16.863790981005877], "status": "ok", "result_count": 1, "edits": 3, "files": 1, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 0, "trace_rungs_reference": 2, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 1, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 2, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 1, "trace_verify_total": 5.4, "trace_verify_tokens": 1.9, "trace_verify_watched": 1, "trace_verify_watched_bytes": 48933, "trace_verify_before": 0.5, "trace_verify_rebuild": 2.7, "trace_verify_after": 0.2, "trace_verify_checks": 0.0, "trace_parses_index": 1, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 1, "trace_parses_after": 0, "trace_index_lead": 2.0, "trace_index_kept": 0.0, "trace_index_other": 0.0, "trace_index_reused": 0.5, "trace_index_merge": 0.3, "trace_index_kept_files": 0, "trace_index_kept_bytes": 0, "trace_index_other_files": 3, "trace_index_other_bytes": 19542, "trace_index_reused_files": 4, "trace_index_reused_bytes": 68475, "trace_warnings_defines": 0.0, "trace_warnings_macro_uses": 0.8, "trace_warnings_sva": 0.0, "trace_warnings_unfinished": 0.0, "trace_warnings_unaccounted": 0.0, "trace_warnings_scanned": 1, "trace_select": 6.6, "trace_selected": 4, "trace_fallback": false, "trace_bytes": 68475, "trace_edited": 1, "trace_index": 2.8, "trace_locate": 0.2, "trace_edits": 0.0, "trace_warnings": 0.9, "trace_parses": 2, "ts": "2026-09-09T01:10:47", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "common port: clk_i -> clk_ix", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "31aadc134628bf567da7423a8fc20dda98a76fec4abd9ffa6392f80d4923420a", "peak_rss_kib": 1863968.0, "file": "hw/ip/entropy_src/rtl/entropy_src_main_sm.sv", "new_name": "clk_ix", "titles": ["entropy_src_core.sv", "entropy_src_main_sm.sv"], "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 719.3, \"verify_tokens\": 4.1, \"verify_watched\": 1200, \"verify_watched_bytes\": 19257967, \"verify_before\": 218.7, \"verify_rebuild\": 273.2, \"verify_after\": 138.0, \"verify_checks\": 0.0, \"parses_index\": 1249, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 2, \"parses_after\": 0, \"index_lead\": 0.4, \"index_kept\": 859.0, \"index_other\": 0.0, \"index_reused\": 222.0, \"index_merge\": 202.7, \"index_kept_files\": 1248, \"index_kept_bytes\": 19867243, \"index_other_files\": 2727, \"index_other_bytes\": 15936487, \"index_reused_files\": 3976, \"index_reused_bytes\": 35813310, \"warnings_defines\": 13.4, \"warnings_macro_uses\": 374.3, \"warnings_sva\": 15.3, \"warnings_unfinished\": 4.0, \"warnings_unaccounted\": 0.2, \"warnings_scanned\": 1249, \"select\": 254.2, \"selected\": 3976, \"fallback\": true, \"bytes\": 35813310, \"edited\": 2, \"index\": 1289.0, \"locate\": 0.1, \"edits\": 100.4, \"warnings\": 434.9, \"parses\": 1251}", "ms": [3049.7538750059903, 2961.388874973636, 2883.6807499756105, 2881.177250004839], "status": "ok", "result_count": 1, "edits": 2, "files": 2, "created": 0, "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 719.3, "trace_verify_tokens": 4.1, "trace_verify_watched": 1200, "trace_verify_watched_bytes": 19257967, "trace_verify_before": 218.7, "trace_verify_rebuild": 273.2, "trace_verify_after": 138.0, "trace_verify_checks": 0.0, "trace_parses_index": 1249, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 2, "trace_parses_after": 0, "trace_index_lead": 0.4, "trace_index_kept": 859.0, "trace_index_other": 0.0, "trace_index_reused": 222.0, "trace_index_merge": 202.7, "trace_index_kept_files": 1248, "trace_index_kept_bytes": 19867243, "trace_index_other_files": 2727, "trace_index_other_bytes": 15936487, "trace_index_reused_files": 3976, "trace_index_reused_bytes": 35813310, "trace_warnings_defines": 13.4, "trace_warnings_macro_uses": 374.3, "trace_warnings_sva": 15.3, "trace_warnings_unfinished": 4.0, "trace_warnings_unaccounted": 0.2, "trace_warnings_scanned": 1249, "trace_select": 254.2, "trace_selected": 3976, "trace_fallback": true, "trace_bytes": 35813310, "trace_edited": 2, "trace_index": 1289.0, "trace_locate": 0.1, "trace_edits": 100.4, "trace_warnings": 434.9, "trace_parses": 1251, "ts": "2026-09-09T01:11:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "conflict: state_q -> state_d", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "96f32d4243b1dc541a3e1e90a29a077520688efcc3f8e6c278c5c5f83cdb146b", "peak_rss_kib": 527264.0, "file": "hw/ip/entropy_src/rtl/entropy_src_main_sm.sv", "new_name": "state_d", "titles": [], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 98, \"rungs_reference\": 122, \"rungs_instantiation\": 19, \"rungs_macro\": 0, \"rungs_speller\": 1, \"rungs_open\": 1, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 112, \"indirect_instantiation\": 19, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 1, \"verify_total\": 67.4, \"verify_tokens\": 4.3, \"verify_watched\": 111, \"verify_watched_bytes\": 1962908, \"verify_before\": 14.6, \"verify_rebuild\": 38.4, \"verify_after\": 1.0, \"verify_checks\": 0.0, \"parses_index\": 142, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 2, \"parses_after\": 0, \"index_lead\": 0.3, \"index_kept\": 112.1, \"index_other\": 0.0, \"index_reused\": 31.7, \"index_merge\": 24.0, \"index_kept_files\": 141, \"index_kept_bytes\": 2988561, \"index_other_files\": 100, \"index_other_bytes\": 1572093, \"index_reused_files\": 242, \"index_reused_bytes\": 4570234, \"warnings_defines\": 0.0, \"warnings_macro_uses\": 0.0, \"warnings_sva\": 0.0, \"warnings_unfinished\": 0.0, \"warnings_unaccounted\": 0.0, \"warnings_scanned\": 0, \"select\": 14.9, \"selected\": 242, \"fallback\": false, \"bytes\": 4570234, \"edited\": 2, \"index\": 168.6, \"locate\": 0.0, \"edits\": 12.5, \"warnings\": 0.0, \"parses\": 144}", "ms": [287.52633300609887, 275.6854579783976, 269.93208297062665, 272.1635830239393], "status": "refused", "result_count": 0, "message": "lucisv: renaming `state_q` to `state_d` would change what `state_d` means in entropy_src_core.sv; the rename was abandoned.", "edits": 0, "files": 0, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 98, "trace_rungs_reference": 122, "trace_rungs_instantiation": 19, "trace_rungs_macro": 0, "trace_rungs_speller": 1, "trace_rungs_open": 1, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 112, "trace_indirect_instantiation": 19, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 1, "trace_verify_total": 67.4, "trace_verify_tokens": 4.3, "trace_verify_watched": 111, "trace_verify_watched_bytes": 1962908, "trace_verify_before": 14.6, "trace_verify_rebuild": 38.4, "trace_verify_after": 1.0, "trace_verify_checks": 0.0, "trace_parses_index": 142, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 2, "trace_parses_after": 0, "trace_index_lead": 0.3, "trace_index_kept": 112.1, "trace_index_other": 0.0, "trace_index_reused": 31.7, "trace_index_merge": 24.0, "trace_index_kept_files": 141, "trace_index_kept_bytes": 2988561, "trace_index_other_files": 100, "trace_index_other_bytes": 1572093, "trace_index_reused_files": 242, "trace_index_reused_bytes": 4570234, "trace_warnings_defines": 0.0, "trace_warnings_macro_uses": 0.0, "trace_warnings_sva": 0.0, "trace_warnings_unfinished": 0.0, "trace_warnings_unaccounted": 0.0, "trace_warnings_scanned": 0, "trace_select": 14.9, "trace_selected": 242, "trace_fallback": false, "trace_bytes": 4570234, "trace_edited": 2, "trace_index": 168.6, "trace_locate": 0.0, "trace_edits": 12.5, "trace_warnings": 0.0, "trace_parses": 144, "ts": "2026-09-09T01:11:07", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "new name many uses spell: cipher_alert -> clk_i", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "96f32d4243b1dc541a3e1e90a29a077520688efcc3f8e6c278c5c5f83cdb146b", "peak_rss_kib": 1699984.0, "file": "hw/ip/aes/rtl/aes_core.sv", "new_name": "clk_i", "titles": [], "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 661.5, \"verify_tokens\": 1.7, \"verify_watched\": 1200, \"verify_watched_bytes\": 19257967, \"verify_before\": 310.8, \"verify_rebuild\": 271.7, \"verify_after\": 3.5, \"verify_checks\": 0.0, \"parses_index\": 1249, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 1, \"parses_after\": 0, \"index_lead\": 2.3, \"index_kept\": 861.1, \"index_other\": 0.0, \"index_reused\": 222.8, \"index_merge\": 201.7, \"index_kept_files\": 1248, \"index_kept_bytes\": 19827890, \"index_other_files\": 2727, \"index_other_bytes\": 15936487, \"index_reused_files\": 3976, \"index_reused_bytes\": 35813310, \"warnings_defines\": 0.0, \"warnings_macro_uses\": 0.0, \"warnings_sva\": 0.0, \"warnings_unfinished\": 0.0, \"warnings_unaccounted\": 0.0, \"warnings_scanned\": 0, \"select\": 264.2, \"selected\": 3976, \"fallback\": true, \"bytes\": 35813310, \"edited\": 1, \"index\": 1294.3, \"locate\": 0.3, \"edits\": 2.2, \"warnings\": 0.0, \"parses\": 1250}", "ms": [2459.582125011366, 2338.0812499672174, 2282.9822920029983, 2284.597833000589], "status": "refused", "result_count": 0, "message": "lucisv: renaming `cipher_alert` to `clk_i` would change what the set of declarations means in aes_core.sv; the rename was abandoned.", "edits": 0, "files": 0, "created": 0, "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 661.5, "trace_verify_tokens": 1.7, "trace_verify_watched": 1200, "trace_verify_watched_bytes": 19257967, "trace_verify_before": 310.8, "trace_verify_rebuild": 271.7, "trace_verify_after": 3.5, "trace_verify_checks": 0.0, "trace_parses_index": 1249, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 1, "trace_parses_after": 0, "trace_index_lead": 2.3, "trace_index_kept": 861.1, "trace_index_other": 0.0, "trace_index_reused": 222.8, "trace_index_merge": 201.7, "trace_index_kept_files": 1248, "trace_index_kept_bytes": 19827890, "trace_index_other_files": 2727, "trace_index_other_bytes": 15936487, "trace_index_reused_files": 3976, "trace_index_reused_bytes": 35813310, "trace_warnings_defines": 0.0, "trace_warnings_macro_uses": 0.0, "trace_warnings_sva": 0.0, "trace_warnings_unfinished": 0.0, "trace_warnings_unaccounted": 0.0, "trace_warnings_scanned": 0, "trace_select": 264.2, "trace_selected": 3976, "trace_fallback": true, "trace_bytes": 35813310, "trace_edited": 1, "trace_index": 1294.3, "trace_locate": 0.3, "trace_edits": 2.2, "trace_warnings": 0.0, "trace_parses": 1250, "ts": "2026-09-09T01:11:20", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "duplicate module: rstmgr_por -> rstmgr_por_x", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "96f32d4243b1dc541a3e1e90a29a077520688efcc3f8e6c278c5c5f83cdb146b", "peak_rss_kib": 733184.0, "file": "hw/top_darjeeling/ip_autogen/rstmgr/rtl/rstmgr.sv", "new_name": "rstmgr_por_x", "titles": [], "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 0.0, \"verify_tokens\": 0.0, \"verify_watched\": 0, \"verify_watched_bytes\": 0, \"verify_before\": 0.0, \"verify_rebuild\": 0.0, \"verify_after\": 0.0, \"verify_checks\": 0.0, \"parses_index\": 14, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 0, \"parses_after\": 0, \"index_lead\": 1.3, \"index_kept\": 4.7, \"index_other\": 0.0, \"index_reused\": 220.1, \"index_merge\": 203.2, \"index_kept_files\": 13, \"index_kept_bytes\": 87644, \"index_other_files\": 3962, \"index_other_bytes\": 35700552, \"index_reused_files\": 3976, \"index_reused_bytes\": 35813310, \"warnings_defines\": 0.0, \"warnings_macro_uses\": 0.0, \"warnings_sva\": 0.0, \"warnings_unfinished\": 0.0, \"warnings_unaccounted\": 0.0, \"warnings_scanned\": 0, \"select\": 259.7, \"selected\": 3976, \"fallback\": true, \"bytes\": 35813310, \"edited\": 0, \"index\": 435.7, \"locate\": 0.3, \"edits\": 0.0, \"warnings\": 0.0, \"parses\": 14}", "ms": [786.3199580460787, 781.5626250230707, 754.0115410229191, 730.4007500060834], "status": "refused", "result_count": 0, "message": "lucisv: `rstmgr_por` is declared in more than one indexed file; lucisv will not guess which declaration this rename means.", "edits": 0, "files": 0, "created": 0, "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 0.0, "trace_verify_tokens": 0.0, "trace_verify_watched": 0, "trace_verify_watched_bytes": 0, "trace_verify_before": 0.0, "trace_verify_rebuild": 0.0, "trace_verify_after": 0.0, "trace_verify_checks": 0.0, "trace_parses_index": 14, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 0, "trace_parses_after": 0, "trace_index_lead": 1.3, "trace_index_kept": 4.7, "trace_index_other": 0.0, "trace_index_reused": 220.1, "trace_index_merge": 203.2, "trace_index_kept_files": 13, "trace_index_kept_bytes": 87644, "trace_index_other_files": 3962, "trace_index_other_bytes": 35700552, "trace_index_reused_files": 3976, "trace_index_reused_bytes": 35813310, "trace_warnings_defines": 0.0, "trace_warnings_macro_uses": 0.0, "trace_warnings_sva": 0.0, "trace_warnings_unfinished": 0.0, "trace_warnings_unaccounted": 0.0, "trace_warnings_scanned": 0, "trace_select": 259.7, "trace_selected": 3976, "trace_fallback": true, "trace_bytes": 35813310, "trace_edited": 0, "trace_index": 435.7, "trace_locate": 0.3, "trace_edits": 0.0, "trace_warnings": 0.0, "trace_parses": 14, "ts": "2026-09-09T01:11:26", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "no symbol: whole scope then refuse", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "peak_rss_kib": 427232.0, "file": "hw/ip/aes/dv/tb/tb.sv", "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 0.0, \"verify_tokens\": 0.0, \"verify_watched\": 0, \"verify_watched_bytes\": 0, \"verify_before\": 0.0, \"verify_rebuild\": 0.0, \"verify_after\": 0.0, \"verify_checks\": 0.0, \"parses_index\": 0, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 0, \"parses_after\": 0, \"index_lead\": 0.0, \"index_kept\": 0.0, \"index_other\": 0.0, \"index_reused\": 0.0, \"index_merge\": 0.0, \"index_kept_files\": 0, \"index_kept_bytes\": 0, \"index_other_files\": 0, \"index_other_bytes\": 0, \"index_reused_files\": 0, \"index_reused_bytes\": 0, \"warnings_defines\": 0.0, \"warnings_macro_uses\": 0.0, \"warnings_sva\": 0.0, \"warnings_unfinished\": 0.0, \"warnings_unaccounted\": 0.0, \"warnings_scanned\": 0, \"select\": 0.0, \"selected\": 0, \"fallback\": false, \"bytes\": 0, \"edited\": 0, \"index\": 0.0, \"locate\": 0.0, \"edits\": 0.0, \"warnings\": 0.0, \"parses\": 0, \"preflight\": true}", "ms": [2.702499972656369, 0.37045800127089024, 0.19737501861527562, 0.2185420016758144], "status": "refused", "result_count": 0, "message": "lucisv: there is no symbol to rename at this position.", "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 0.0, "trace_verify_tokens": 0.0, "trace_verify_watched": 0, "trace_verify_watched_bytes": 0, "trace_verify_before": 0.0, "trace_verify_rebuild": 0.0, "trace_verify_after": 0.0, "trace_verify_checks": 0.0, "trace_parses_index": 0, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 0, "trace_parses_after": 0, "trace_index_lead": 0.0, "trace_index_kept": 0.0, "trace_index_other": 0.0, "trace_index_reused": 0.0, "trace_index_merge": 0.0, "trace_index_kept_files": 0, "trace_index_kept_bytes": 0, "trace_index_other_files": 0, "trace_index_other_bytes": 0, "trace_index_reused_files": 0, "trace_index_reused_bytes": 0, "trace_warnings_defines": 0.0, "trace_warnings_macro_uses": 0.0, "trace_warnings_sva": 0.0, "trace_warnings_unfinished": 0.0, "trace_warnings_unaccounted": 0.0, "trace_warnings_scanned": 0, "trace_select": 0.0, "trace_selected": 0, "trace_fallback": false, "trace_bytes": 0, "trace_edited": 0, "trace_index": 0.0, "trace_locate": 0.0, "trace_edits": 0.0, "trace_warnings": 0.0, "trace_parses": 0, "trace_preflight": true, "ts": "2026-09-09T01:11:29", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "tail: state_q -> state_q_x", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "b39defb212655f29e68c0e15b88dda405d2779a24c4b522a1798b6f44c9a04f7", "peak_rss_kib": 614656.0, "file": "hw/ip/entropy_src/rtl/entropy_src_main_sm.sv", "new_name": "state_q_x", "titles": ["entropy_src_core.sv", "entropy_src_main_sm.sv"], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 95, \"rungs_reference\": 122, \"rungs_instantiation\": 19, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 1, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 113, \"indirect_instantiation\": 19, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 1, \"verify_total\": 74.4, \"verify_tokens\": 4.3, \"verify_watched\": 106, \"verify_watched_bytes\": 1919528, \"verify_before\": 14.2, \"verify_rebuild\": 38.4, \"verify_after\": 7.9, \"verify_checks\": 0.0, \"parses_index\": 238, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 2, \"parses_after\": 0, \"select\": 13.8, \"selected\": 238, \"fallback\": false, \"bytes\": 4554326, \"edited\": 2, \"index\": 228.5, \"locate\": 0.0, \"edits\": 12.3, \"warnings\": 51.2, \"parses\": 240}", "ms": [429.2307500145398, 393.72162497602403, 391.3822500035167, 391.78733399603516], "status": "ok", "result_count": 1, "edits": 5, "files": 2, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 95, "trace_rungs_reference": 122, "trace_rungs_instantiation": 19, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 1, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 113, "trace_indirect_instantiation": 19, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 1, "trace_verify_total": 74.4, "trace_verify_tokens": 4.3, "trace_verify_watched": 106, "trace_verify_watched_bytes": 1919528, "trace_verify_before": 14.2, "trace_verify_rebuild": 38.4, "trace_verify_after": 7.9, "trace_verify_checks": 0.0, "trace_parses_index": 238, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 2, "trace_parses_after": 0, "trace_select": 13.8, "trace_selected": 238, "trace_fallback": false, "trace_bytes": 4554326, "trace_edited": 2, "trace_index": 228.5, "trace_locate": 0.0, "trace_edits": 12.3, "trace_warnings": 51.2, "trace_parses": 240, "ts": "2026-09-09T01:11:37", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "ordinary: aes -> aes_renamed", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "fa7e31c78382176d5f96d661228ce82328df8bc77bd6d8575dd38717814cb26c", "peak_rss_kib": 461952.0, "file": "hw/ip/aes/dv/tb/tb.sv", "new_name": "aes_renamed", "titles": ["aes.sv", "aes_bind.sv", "aes_cov_bind.sv", "aes_tb.sv", "aes_wrap.sv", "darjeeling_pd_main.sv", "earlgrey_pd_main.sv", "englishbreakfast_pd_main.sv", "tb.sv"], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 4, \"rungs_reference\": 8, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 1, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 47.3, \"verify_tokens\": 14.8, \"verify_watched\": 12, \"verify_watched_bytes\": 398160, \"verify_before\": 4.2, \"verify_rebuild\": 23.4, \"verify_after\": 3.2, \"verify_checks\": 0.0, \"parses_index\": 13, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 9, \"parses_after\": 0, \"select\": 8.3, \"selected\": 13, \"fallback\": false, \"bytes\": 400051, \"edited\": 9, \"index\": 22.9, \"locate\": 0.1, \"edits\": 2.3, \"warnings\": 8.4, \"parses\": 22}", "ms": [103.15541597083211, 92.31041703606024, 91.90749999834225, 91.97866701288149], "status": "ok", "result_count": 1, "edits": 14, "files": 9, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 4, "trace_rungs_reference": 8, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 1, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 47.3, "trace_verify_tokens": 14.8, "trace_verify_watched": 12, "trace_verify_watched_bytes": 398160, "trace_verify_before": 4.2, "trace_verify_rebuild": 23.4, "trace_verify_after": 3.2, "trace_verify_checks": 0.0, "trace_parses_index": 13, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 9, "trace_parses_after": 0, "trace_select": 8.3, "trace_selected": 13, "trace_fallback": false, "trace_bytes": 400051, "trace_edited": 9, "trace_index": 22.9, "trace_locate": 0.1, "trace_edits": 2.3, "trace_warnings": 8.4, "trace_parses": 22, "ts": "2026-09-09T01:11:41", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "unique internal: cipher_alert -> cipher_alert_x", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "5f53e977da59093f59ac3153a59036de64ff2fc041017271d8ebbd9ba41ba1e1", "peak_rss_kib": 436512.0, "file": "hw/ip/aes/rtl/aes_core.sv", "new_name": "cipher_alert_x", "titles": ["aes_core.sv"], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 0, \"rungs_reference\": 2, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 1, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 2, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 1, \"verify_total\": 5.5, \"verify_tokens\": 1.9, \"verify_watched\": 1, \"verify_watched_bytes\": 48933, \"verify_before\": 0.4, \"verify_rebuild\": 2.7, \"verify_after\": 0.2, \"verify_checks\": 0.0, \"parses_index\": 4, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 1, \"parses_after\": 0, \"select\": 6.4, \"selected\": 4, \"fallback\": false, \"bytes\": 68475, \"edited\": 1, \"index\": 3.4, \"locate\": 0.2, \"edits\": 0.0, \"warnings\": 0.9, \"parses\": 5}", "ms": [34.129833977203816, 21.798916975967586, 18.88545899419114, 17.188500030897558], "status": "ok", "result_count": 1, "edits": 3, "files": 1, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 0, "trace_rungs_reference": 2, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 1, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 2, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 1, "trace_verify_total": 5.5, "trace_verify_tokens": 1.9, "trace_verify_watched": 1, "trace_verify_watched_bytes": 48933, "trace_verify_before": 0.4, "trace_verify_rebuild": 2.7, "trace_verify_after": 0.2, "trace_verify_checks": 0.0, "trace_parses_index": 4, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 1, "trace_parses_after": 0, "trace_select": 6.4, "trace_selected": 4, "trace_fallback": false, "trace_bytes": 68475, "trace_edited": 1, "trace_index": 3.4, "trace_locate": 0.2, "trace_edits": 0.0, "trace_warnings": 0.9, "trace_parses": 5, "ts": "2026-09-09T01:11:44", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "common port: clk_i -> clk_ix", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "31aadc134628bf567da7423a8fc20dda98a76fec4abd9ffa6392f80d4923420a", "peak_rss_kib": 1879200.0, "file": "hw/ip/entropy_src/rtl/entropy_src_main_sm.sv", "new_name": "clk_ix", "titles": ["entropy_src_core.sv", "entropy_src_main_sm.sv"], "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 728.7, \"verify_tokens\": 4.3, \"verify_watched\": 1200, \"verify_watched_bytes\": 19257967, \"verify_before\": 222.9, \"verify_rebuild\": 276.7, \"verify_after\": 138.9, \"verify_checks\": 0.0, \"parses_index\": 3975, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 2, \"parses_after\": 0, \"select\": 255.6, \"selected\": 3976, \"fallback\": true, \"bytes\": 35813310, \"edited\": 2, \"index\": 1865.9, \"locate\": 0.1, \"edits\": 102.2, \"warnings\": 444.7, \"parses\": 3977}", "ms": [3631.98983395705, 3527.5039579719305, 3475.931875000242, 3482.873166038189], "status": "ok", "result_count": 1, "edits": 2, "files": 2, "created": 0, "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 728.7, "trace_verify_tokens": 4.3, "trace_verify_watched": 1200, "trace_verify_watched_bytes": 19257967, "trace_verify_before": 222.9, "trace_verify_rebuild": 276.7, "trace_verify_after": 138.9, "trace_verify_checks": 0.0, "trace_parses_index": 3975, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 2, "trace_parses_after": 0, "trace_select": 255.6, "trace_selected": 3976, "trace_fallback": true, "trace_bytes": 35813310, "trace_edited": 2, "trace_index": 1865.9, "trace_locate": 0.1, "trace_edits": 102.2, "trace_warnings": 444.7, "trace_parses": 3977, "ts": "2026-09-09T01:12:02", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "conflict: state_q -> state_d", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "96f32d4243b1dc541a3e1e90a29a077520688efcc3f8e6c278c5c5f83cdb146b", "peak_rss_kib": 514672.0, "file": "hw/ip/entropy_src/rtl/entropy_src_main_sm.sv", "new_name": "state_d", "titles": [], "note": "{\"rungs_request\": 1, \"rungs_declaration\": 98, \"rungs_reference\": 122, \"rungs_instantiation\": 19, \"rungs_macro\": 0, \"rungs_speller\": 1, \"rungs_open\": 1, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 112, \"indirect_instantiation\": 19, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 1, \"verify_total\": 64.8, \"verify_tokens\": 4.2, \"verify_watched\": 111, \"verify_watched_bytes\": 1962908, \"verify_before\": 14.1, \"verify_rebuild\": 36.9, \"verify_after\": 1.0, \"verify_checks\": 0.0, \"parses_index\": 242, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 2, \"parses_after\": 0, \"select\": 14.4, \"selected\": 242, \"fallback\": false, \"bytes\": 4570234, \"edited\": 2, \"index\": 217.5, \"locate\": 0.0, \"edits\": 11.9, \"warnings\": 0.0, \"parses\": 244}", "ms": [355.68770801182836, 324.15045803645626, 318.635290954262, 317.3258330207318], "status": "refused", "result_count": 0, "message": "lucisv: renaming `state_q` to `state_d` would change what `state_d` means in entropy_src_core.sv; the rename was abandoned.", "edits": 0, "files": 0, "created": 0, "trace_rungs_request": 1, "trace_rungs_declaration": 98, "trace_rungs_reference": 122, "trace_rungs_instantiation": 19, "trace_rungs_macro": 0, "trace_rungs_speller": 1, "trace_rungs_open": 1, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 112, "trace_indirect_instantiation": 19, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 1, "trace_verify_total": 64.8, "trace_verify_tokens": 4.2, "trace_verify_watched": 111, "trace_verify_watched_bytes": 1962908, "trace_verify_before": 14.1, "trace_verify_rebuild": 36.9, "trace_verify_after": 1.0, "trace_verify_checks": 0.0, "trace_parses_index": 242, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 2, "trace_parses_after": 0, "trace_select": 14.4, "trace_selected": 242, "trace_fallback": false, "trace_bytes": 4570234, "trace_edited": 2, "trace_index": 217.5, "trace_locate": 0.0, "trace_edits": 11.9, "trace_warnings": 0.0, "trace_parses": 244, "ts": "2026-09-09T01:12:07", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "new name many uses spell: cipher_alert -> clk_i", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "96f32d4243b1dc541a3e1e90a29a077520688efcc3f8e6c278c5c5f83cdb146b", "peak_rss_kib": 1617488.0, "file": "hw/ip/aes/rtl/aes_core.sv", "new_name": "clk_i", "titles": [], "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 671.0, \"verify_tokens\": 1.7, \"verify_watched\": 1200, \"verify_watched_bytes\": 19257967, \"verify_before\": 318.1, \"verify_rebuild\": 272.3, \"verify_after\": 3.7, \"verify_checks\": 0.0, \"parses_index\": 3975, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 1, \"parses_after\": 0, \"select\": 258.7, \"selected\": 3976, \"fallback\": true, \"bytes\": 35813310, \"edited\": 1, \"index\": 1872.4, \"locate\": 0.3, \"edits\": 2.3, \"warnings\": 0.0, \"parses\": 3976}", "ms": [3070.1524579781108, 2962.2283750213683, 2906.755500007421, 2867.969457991421], "status": "refused", "result_count": 0, "message": "lucisv: renaming `cipher_alert` to `clk_i` would change what the set of declarations means in aes_core.sv; the rename was abandoned.", "edits": 0, "files": 0, "created": 0, "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 671.0, "trace_verify_tokens": 1.7, "trace_verify_watched": 1200, "trace_verify_watched_bytes": 19257967, "trace_verify_before": 318.1, "trace_verify_rebuild": 272.3, "trace_verify_after": 3.7, "trace_verify_checks": 0.0, "trace_parses_index": 3975, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 1, "trace_parses_after": 0, "trace_select": 258.7, "trace_selected": 3976, "trace_fallback": true, "trace_bytes": 35813310, "trace_edited": 1, "trace_index": 1872.4, "trace_locate": 0.3, "trace_edits": 2.3, "trace_warnings": 0.0, "trace_parses": 3976, "ts": "2026-09-09T01:12:22", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "duplicate module: rstmgr_por -> rstmgr_por_x", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "96f32d4243b1dc541a3e1e90a29a077520688efcc3f8e6c278c5c5f83cdb146b", "peak_rss_kib": 918416.0, "file": "hw/top_darjeeling/ip_autogen/rstmgr/rtl/rstmgr.sv", "new_name": "rstmgr_por_x", "titles": [], "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 0.0, \"verify_tokens\": 0.0, \"verify_watched\": 0, \"verify_watched_bytes\": 0, \"verify_before\": 0.0, \"verify_rebuild\": 0.0, \"verify_after\": 0.0, \"verify_checks\": 0.0, \"parses_index\": 3975, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 0, \"parses_after\": 0, \"select\": 252.8, \"selected\": 3976, \"fallback\": true, \"bytes\": 35813310, \"edited\": 0, \"index\": 1891.3, \"locate\": 0.3, \"edits\": 0.0, \"warnings\": 0.0, \"parses\": 3975}", "ms": [2251.112958008889, 2206.4846249995753, 2207.0510829798877, 2180.649332993198], "status": "refused", "result_count": 0, "message": "lucisv: `rstmgr_por` is declared in more than one indexed file; lucisv will not guess which declaration this rename means.", "edits": 0, "files": 0, "created": 0, "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 0.0, "trace_verify_tokens": 0.0, "trace_verify_watched": 0, "trace_verify_watched_bytes": 0, "trace_verify_before": 0.0, "trace_verify_rebuild": 0.0, "trace_verify_after": 0.0, "trace_verify_checks": 0.0, "trace_parses_index": 3975, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 0, "trace_parses_after": 0, "trace_select": 252.8, "trace_selected": 3976, "trace_fallback": true, "trace_bytes": 35813310, "trace_edited": 0, "trace_index": 1891.3, "trace_locate": 0.3, "trace_edits": 0.0, "trace_warnings": 0.0, "trace_parses": 3975, "ts": "2026-09-09T01:12:34", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "renametrace", "row": "no symbol: whole scope then refuse", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "peak_rss_kib": 914448.0, "file": "hw/ip/aes/dv/tb/tb.sv", "note": "{\"rungs_request\": 0, \"rungs_declaration\": 0, \"rungs_reference\": 0, \"rungs_instantiation\": 0, \"rungs_macro\": 0, \"rungs_speller\": 0, \"rungs_open\": 0, \"indirect_request\": 0, \"indirect_declaration\": 0, \"indirect_reference\": 0, \"indirect_instantiation\": 0, \"indirect_macro\": 0, \"indirect_speller\": 0, \"indirect_open\": 0, \"verify_total\": 0.0, \"verify_tokens\": 0.0, \"verify_watched\": 0, \"verify_watched_bytes\": 0, \"verify_before\": 0.0, \"verify_rebuild\": 0.0, \"verify_after\": 0.0, \"verify_checks\": 0.0, \"parses_index\": 3975, \"parses_locate\": 0, \"parses_edits\": 0, \"parses_before\": 0, \"parses_rebuild\": 0, \"parses_after\": 0, \"select\": 0.0, \"selected\": 3976, \"fallback\": true, \"bytes\": 35813310, \"edited\": 0, \"index\": 1891.5, \"locate\": 0.1, \"edits\": 0.0, \"warnings\": 0.0, \"parses\": 3975}", "ms": [2244.7303340304643, 2204.6456660027616, 2205.368582974188, 2177.3032499477267], "status": "refused", "result_count": 0, "message": "lucisv: there is no symbol to rename at this position.", "trace_rungs_request": 0, "trace_rungs_declaration": 0, "trace_rungs_reference": 0, "trace_rungs_instantiation": 0, "trace_rungs_macro": 0, "trace_rungs_speller": 0, "trace_rungs_open": 0, "trace_indirect_request": 0, "trace_indirect_declaration": 0, "trace_indirect_reference": 0, "trace_indirect_instantiation": 0, "trace_indirect_macro": 0, "trace_indirect_speller": 0, "trace_indirect_open": 0, "trace_verify_total": 0.0, "trace_verify_tokens": 0.0, "trace_verify_watched": 0, "trace_verify_watched_bytes": 0, "trace_verify_before": 0.0, "trace_verify_rebuild": 0.0, "trace_verify_after": 0.0, "trace_verify_checks": 0.0, "trace_parses_index": 3975, "trace_parses_locate": 0, "trace_parses_edits": 0, "trace_parses_before": 0, "trace_parses_rebuild": 0, "trace_parses_after": 0, "trace_select": 0.0, "trace_selected": 3976, "trace_fallback": true, "trace_bytes": 35813310, "trace_edited": 0, "trace_index": 1891.5, "trace_locate": 0.1, "trace_edits": 0.0, "trace_warnings": 0.0, "trace_parses": 3975, "ts": "2026-09-09T01:12:46", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "scan", "row": "default, cold cache", "ms": [92.21495903329924, 107.13670798577368, 91.90629201475531], "settled_ms": [92.21495903329924, 107.13670798577368, 91.90629201475531], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 124 files indexed | nothing in flight during the scan", "ts": "2026-09-09T01:12:51", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "default, warm cache", "ms": [53.92179201589897, 46.04308295529336, 41.25883401138708], "settled_ms": [53.92179201589897, 46.04308295529336, 41.25883401138708], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 124 files indexed, 123 from cache | nothing in flight during the scan", "ts": "2026-09-09T01:12:56", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "empty-index, cold cache", "ms": [105.30445899348706, 103.75137499067932, 108.87637495761737], "settled_ms": [105.30445899348706, 103.75137499067932, 108.87637495761737], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 124 files indexed | nothing in flight during the scan", "ts": "2026-09-09T01:13:01", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "empty-index, warm cache", "ms": [45.0200840132311, 43.97104197414592, 41.873250040225685], "settled_ms": [45.0200840132311, 43.97104197414592, 41.873250040225685], "fresh_process": true, "result_count": 3, "note": "124 files indexed, 123 from cache | nothing in flight during the scan", "ts": "2026-09-09T01:13:06", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "depth0, cold cache", "ms": [7.711249985732138, 8.780958014540374, 10.425499989651144], "settled_ms": [7.711249985732138, 8.780958014540374, 10.425499989651144], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 1 file indexed | nothing in flight during the scan", "ts": "2026-09-09T01:13:10", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "depth0, warm cache", "ms": [7.134040992241353, 9.76633297977969, 10.451290989294648], "settled_ms": [7.134040992241353, 9.76633297977969, 10.451290989294648], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 1 file indexed | nothing in flight during the scan", "ts": "2026-09-09T01:13:15", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "workspace, cold cache", "ms": [2896.5727079776116, 2884.8891250090674, 2880.1893750205636], "settled_ms": [2896.5727079776116, 2884.8891250090674, 2880.1893750205636], "fresh_process": true, "result_count": 3, "note": "3976 files indexed, 3 skipped | nothing in flight during the scan", "ts": "2026-09-09T01:13:28", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "workspace, warm cache", "ms": [1110.262457979843, 1068.6567079974338, 1073.9933750010096], "settled_ms": [1110.262457979843, 1068.6567079974338, 1073.9933750010096], "fresh_process": true, "result_count": 3, "note": "3976 files indexed, 3975 from cache, 3 skipped | nothing in flight during the scan", "ts": "2026-09-09T01:13:36", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "workspace, cold cache, first useful answer", "ms": [276.73141699051484, 278.63349998369813, 279.1064159828238], "first_answer_ms": [276.73141699051484, 278.63349998369813, 279.1064159828238], "settled_ms": [2903.118457994424, 2916.8199590058066, 2931.6357920179144], "fresh_process": true, "status": "ok", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "message": null, "result_count": 1, "result_counts": [1, 1, 1], "note": "ms is the definition sent during the scan; a 0 result count means the answer arrived before the index could give one. settled_ms is that session's own scan, perturbed by serving the request", "ts": "2026-09-09T01:13:50", "label": "0.51.0-reference", "schema": 2, "units": "ms"}
|
||||
{"phase": "scan", "row": "workspace, warm cache, first useful answer", "ms": [294.1113749984652, 295.10295897489414, 294.5136670023203], "first_answer_ms": [294.1113749984652, 295.10295897489414, 294.5136670023203], "settled_ms": [1082.7908339560963, 1085.090084001422, 1084.30279197637], "fresh_process": true, "status": "ok", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "message": null, "result_count": 1, "result_counts": [1, 1, 1], "note": "ms is the definition sent during the scan; a 0 result count means the answer arrived before the index could give one. settled_ms is that session's own scan, perturbed by serving the request", "ts": "2026-09-09T01:13:58", "label": "0.51.0-reference", "schema": 2, "units": "ms"}
|
||||
{"phase": "scan", "row": "default, cold cache", "ms": [96.67558304499835, 111.83595901820809, 94.76049995282665], "settled_ms": [96.67558304499835, 111.83595901820809, 94.76049995282665], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 124 files indexed | nothing in flight during the scan", "ts": "2026-09-09T01:14:04", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "default, warm cache", "ms": [56.957875029183924, 47.349958040285856, 46.934207959566265], "settled_ms": [56.957875029183924, 47.349958040285856, 46.934207959566265], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 124 files indexed, 123 from cache | nothing in flight during the scan", "ts": "2026-09-09T01:14:09", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "empty-index, cold cache", "ms": [110.82133301533759, 100.80170800210908, 106.90266598248854], "settled_ms": [110.82133301533759, 100.80170800210908, 106.90266598248854], "fresh_process": true, "result_count": 3, "note": "124 files indexed | nothing in flight during the scan", "ts": "2026-09-09T01:14:13", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "empty-index, warm cache", "ms": [35.27233301429078, 47.46295895893127, 50.83083303179592], "settled_ms": [35.27233301429078, 47.46295895893127, 50.83083303179592], "fresh_process": true, "result_count": 3, "note": "124 files indexed, 123 from cache | nothing in flight during the scan", "ts": "2026-09-09T01:14:18", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "depth0, cold cache", "ms": [6.20275002438575, 8.890166995115578, 8.290541998576373], "settled_ms": [6.20275002438575, 8.890166995115578, 8.290541998576373], "fresh_process": true, "result_count": 3, "note": "1 file indexed | nothing in flight during the scan", "ts": "2026-09-09T01:14:23", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "depth0, warm cache", "ms": [9.672541986219585, 12.35333300428465, 13.59712501289323], "settled_ms": [9.672541986219585, 12.35333300428465, 13.59712501289323], "fresh_process": true, "result_count": 3, "note": "0 files indexed | 1 file indexed | nothing in flight during the scan", "ts": "2026-09-09T01:14:27", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "workspace, cold cache", "ms": [2913.358584046364, 2886.6533340187743, 2886.046791973058], "settled_ms": [2913.358584046364, 2886.6533340187743, 2886.046791973058], "fresh_process": true, "result_count": 3, "note": "3976 files indexed, 3 skipped | nothing in flight during the scan", "ts": "2026-09-09T01:14:41", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "workspace, warm cache", "ms": [1058.0805420177057, 1064.7187079885043, 1083.7782500311732], "settled_ms": [1058.0805420177057, 1064.7187079885043, 1083.7782500311732], "fresh_process": true, "result_count": 3, "note": "3976 files indexed, 3975 from cache, 3 skipped | nothing in flight during the scan", "ts": "2026-09-09T01:14:49", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok"}
|
||||
{"phase": "scan", "row": "workspace, cold cache, first useful answer", "ms": [84.42629198543727, 82.43237499846146, 85.15745803015307], "first_answer_ms": [84.42629198543727, 82.43237499846146, 85.15745803015307], "settled_ms": [2996.103417011909, 2864.957375044469, 2927.270332991611], "fresh_process": true, "status": "ok", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "message": null, "result_count": 1, "result_counts": [1, 1, 1], "note": "ms is the definition sent during the scan; a 0 result count means the answer arrived before the index could give one. settled_ms is that session's own scan, perturbed by serving the request", "ts": "2026-09-09T01:15:02", "label": "0.52.0-review", "schema": 2, "units": "ms"}
|
||||
{"phase": "scan", "row": "workspace, warm cache, first useful answer", "ms": [120.29304099269211, 118.48579195793718, 118.49116702796891], "first_answer_ms": [120.29304099269211, 118.48579195793718, 118.49116702796891], "settled_ms": [1067.8267090115696, 1107.2501249727793, 1102.342874975875], "fresh_process": true, "status": "ok", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "message": null, "result_count": 1, "result_counts": [1, 1, 1], "note": "ms is the definition sent during the scan; a 0 result count means the answer arrived before the index could give one. settled_ms is that session's own scan, perturbed by serving the request", "ts": "2026-09-09T01:15:10", "label": "0.52.0-review", "schema": 2, "units": "ms"}
|
||||
{"phase": "rss", "row": "server RSS after workspace scan, cold cache", "units": "KiB", "rss_kib": [503632.0, 501264.0, 503824.0], "peak_rss_kib": [503632.0, 501264.0, 503824.0], "store_kib": 45404, "fresh_process": true, "result_count": 3, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "idle RSS a second after the scan settled; peak from `ps -o rss=` sampled at 50 ms; no latency in this row", "ts": "2026-09-09T01:15:27", "label": "0.52.0-review", "schema": 2, "status": "ok"}
|
||||
{"phase": "rss", "row": "server RSS after workspace scan, warm cache", "units": "KiB", "rss_kib": [428000.0, 428608.0, 428032.0], "peak_rss_kib": [428000.0, 428608.0, 428032.0], "store_kib": 45404, "fresh_process": true, "result_count": 3, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "idle RSS a second after the scan settled; peak from `ps -o rss=` sampled at 50 ms; no latency in this row", "ts": "2026-09-09T01:15:38", "label": "0.52.0-review", "schema": 2, "status": "ok"}
|
||||
{"phase": "rss", "row": "server RSS after workspace scan, cold cache", "units": "KiB", "rss_kib": [502304.0, 501808.0, 505712.0], "peak_rss_kib": [502304.0, 501808.0, 505712.0], "store_kib": 45404, "fresh_process": true, "result_count": 3, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "idle RSS a second after the scan settled; peak from `ps -o rss=` sampled at 50 ms; no latency in this row", "ts": "2026-09-09T01:15:56", "label": "0.51.0-reference", "schema": 2, "status": "ok"}
|
||||
{"phase": "rss", "row": "server RSS after workspace scan, warm cache", "units": "KiB", "rss_kib": [430048.0, 428992.0, 429824.0], "peak_rss_kib": [430048.0, 428992.0, 429824.0], "store_kib": 45404, "fresh_process": true, "result_count": 3, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "note": "idle RSS a second after the scan settled; peak from `ps -o rss=` sampled at 50 ms; no latency in this row", "ts": "2026-09-09T01:16:07", "label": "0.51.0-reference", "schema": 2, "status": "ok"}
|
||||
{"phase": "scanload", "row": "definition every 100 ms, warm cache, 1 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 2, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [231.02662502788007, 272.09970902185887, 331.03475003736094, 340.92241601319984, 369.39124995842576, 430.9707919601351, 440.27550000464544, 469.78204196784645, 530.8990830089897, 540.1587910018861, 569.5378750097007, 630.5581249762326, 640.1443749782629, 671.7419580090791, 731.8317499593832, 739.0144579694606, 770.2299589873292, 832.5662499992177, 838.3662080159411, 870.1959579484537, 932.8641250031069, 940.040957997553, 969.7758330148645, 1031.0971660073847, 1039.0954170143232, 1071.4224579860456, 1130.5584160145372, 1140.0499579613097, 1171.6288750176318, 1232.7175000100397, 1239.933791977819, 1269.8522499995306, 1332.8708750195801, 1339.6738750161603, 1370.3380840015598, 1430.838499974925, 1439.9789590388536, 1469.619415991474, 1531.3660000101663, 1538.9199169585481, 1569.6899999747984, 1631.8986659753136, 1639.9600409786217, 1670.0302499812096, 1732.8165840008296, 1739.4487090059556, 1770.040458010044, 1830.7587080053054, 1839.7049169871025, 1870.1480000163428, 1931.5903329988942, 1939.2652499955148, 1970.9985830122605, 2031.8161670002155, 2038.5732920258306, 2071.1795419920236, 2131.9097920204513, 2139.734208001755, 2169.8138340143487, 2232.7430410077795, 2238.7706249719486, 2269.540250010323, 2330.260500020813, 2339.9529170128517, 2371.424290991854, 2430.893625016324, 2438.0488749593496, 2469.0436249948107, 2531.3126249820925, 2539.099332992919, 2569.7709579835646, 2631.048333016224, 2639.473250019364, 2669.6615829714574, 2730.802041012794, 2739.449583052192, 2770.3413339913823, 2830.8503750013188, 2838.9876669971272, 2870.1325000147335, 2930.2297080284916, 2939.758874999825, 2970.087166002486, 3032.330791989807, 3039.64408300817, 3069.535666028969, 3131.768374994863, 3140.2731670532376, 3170.615667011589, 3232.2637080214918, 3238.4166659903713, 3269.410874985624, 3332.262041978538, 3339.3877079943195, 3368.84916695999, 3430.7034999947064, 3439.3887919723056, 3468.9126249868423, 3532.510709017515, 3539.43108295789, 3569.068040989805, 3632.623917015735, 3638.7511249631643, 3671.2672500289045, 3740.291874972172], "latency_median_ms": 1970.9985830122605, "latency_max_ms": 3740.291874972172, "mid_scan_median_ms": 1970.9985830122605, "mid_scan_max_ms": 3740.291874972172, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 105, "after_settle_answers": 0, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 0, "settled_ms": [5449.216000037268, 4283.975166967139, 4251.313499931712], "tick_jitter_ms": 2.73800001014024, "publication": [{"publish_absorb": 1943.89, "publish_candidates": 555.04, "publish_includes": 52.54, "publish_overlay": 5.24, "publish_total": 2556.71, "publishes": 35, "published": 1807, "first_publish": 172.45, "scan_total": 5435.57}, {"publish_absorb": 2423.5, "publish_candidates": 717.32, "publish_includes": 53.01, "publish_overlay": 5.25, "publish_total": 3199.08, "publishes": 34, "published": 1807, "first_publish": 267.32, "scan_total": 4276.19}, {"publish_absorb": 2406.18, "publish_candidates": 693.44, "publish_includes": 52.27, "publish_overlay": 5.15, "publish_total": 3157.04, "publishes": 34, "published": 1807, "first_publish": 275.31, "scan_total": 4243.78}], "ts": "2026-09-09T01:16:27", "label": "0.51.0-reference", "schema": 2, "units": "ms"}
|
||||
{"phase": "scanload", "row": "definition every 100 ms, warm cache, 1 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 2, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [0.2507920144125819, 0.254875048995018, 0.2752500004135072, 0.36295794416218996, 0.3658750210888684, 0.36633398849517107, 0.37595804315060377, 0.3797499812208116, 0.38595800288021564, 0.38662500446662307, 0.3871670342050493, 0.39129104698076844, 0.39199995808303356, 0.4087500274181366, 0.4116250202059746, 0.4124999977648258, 0.42108300840482116, 0.42679201578721404, 0.4311670199967921, 0.43145898962393403, 0.4496669862419367, 0.458541966509074, 0.4627919988706708, 0.4814580315724015, 0.48895797226577997, 0.49579201731830835, 0.5095829837955534, 0.5250420072115958, 0.6151669658720493, 0.6951250252313912, 0.7722079753875732, 1.1667080107145011, 1.2279170332476497, 1.2295409687794745, 1.2410409981384873, 1.2829999905079603, 1.2955829733982682, 1.3219169923104346, 1.4695830177515745, 1.5291669988073409, 1.767750014550984, 2.201541035901755, 2.298375009559095, 2.323874970898032, 2.4139999877661467, 2.4449999909847975, 2.7526660123839974, 2.9757089796476066, 2.9851250001229346, 3.46829101908952, 16.16749999811873, 56.933583051431924, 57.05958401085809, 63.06950002908707, 65.63550001010299, 85.42033302364871, 85.74033301556483, 86.31454198621213, 91.15687501616776, 92.75670803617686, 102.7654999634251, 104.0377079625614, 114.4633749499917, 156.94762498605996, 157.04829100286588, 162.06729202531278, 167.66520804958418, 184.46358299115673, 186.2744580139406, 187.62683303793892, 190.6358340056613, 192.6114580128342, 203.79220903851092, 203.98637501057237, 216.29620797466487, 257.43712502298877, 257.4719170224853, 265.0065829511732, 285.87370802415535, 286.47783404449, 291.2995829829015, 293.3724169852212, 304.28579199360684, 315.87270798627287, 386.30954100517556, 403.1678750179708, 415.92470899922773, 486.33124999469146, 504.24404203658924, 514.9935000226833, 586.5473749581724, 601.8317090347409, 615.8681670203805, 685.2300420287065, 704.1380000300705, 716.2059170077555, 785.5232919682749, 886.2317090388387, 985.2439580135979, 1084.3474169960245, 1184.8837499856018, 1285.2690410218202, 1386.270124989096, 1486.5427910117432, 1586.5333330002613], "latency_median_ms": 57.05958401085809, "latency_max_ms": 1586.5333330002613, "mid_scan_median_ms": 57.05958401085809, "mid_scan_max_ms": 1586.5333330002613, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 105, "after_settle_answers": 0, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 0, "settled_ms": [4032.0170000195503, 3407.352709036786, 3408.2122499821708], "tick_jitter_ms": 5.591708060819656, "publication": [{"publish_absorb": 764.26, "publish_candidates": 275.96, "publish_includes": 19.26, "publish_overlay": 1.3, "publish_total": 1060.78, "publishes": 7, "published": 3676, "first_publish": 660.76, "scan_total": 4018.68}, {"publish_absorb": 470.51, "publish_candidates": 183.67, "publish_includes": 13.52, "publish_overlay": 0.65, "publish_total": 668.35, "publishes": 4, "published": 3441, "first_publish": 493.11, "scan_total": 1781.58}, {"publish_absorb": 474.3, "publish_candidates": 192.46, "publish_includes": 12.97, "publish_overlay": 0.66, "publish_total": 680.39, "publishes": 4, "published": 3482, "first_publish": 492.07, "scan_total": 1785.99}], "ts": "2026-09-09T01:16:43", "label": "0.52.0-review", "schema": 2, "units": "ms"}
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, cold cache, 0 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 270, "requests_offered": 90, "rate_ms": 100, "open_buffers": 1, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [0.20474998746067286, 0.22149999858811498, 0.22633298067376018, 0.22674998035654426, 0.25866698706522584, 0.335542019456625, 0.33662497298792005, 0.342374958563596, 0.3535420401021838, 0.3541670157574117, 0.35570800537243485, 0.3559160395525396, 0.35924999974668026, 0.3604159574024379, 0.3625419922173023, 0.36291603464633226, 0.363041996024549, 0.36533299135044217, 0.3654159954749048, 0.36862498382106423, 0.3690419835038483, 0.36987499333918095, 0.3708339645527303, 0.37237495416775346, 0.3729589516296983, 0.37399999564513564, 0.3751249751076102, 0.3754580393433571, 0.37633400643244386, 0.3767090383917093, 0.3768749884329736, 0.3773330245167017, 0.37820899160578847, 0.37854205584153533, 0.37920899922028184, 0.3792499774135649, 0.37929200334474444, 0.37933303974568844, 0.3802499850280583, 0.38045895053073764, 0.3809579648077488, 0.38179202238097787, 0.3837919794023037, 0.38491602754220366, 0.38595800288021564, 0.38762501208111644, 0.3892919630743563, 0.39054203080013394, 0.39091601502150297, 0.39245799416676164, 0.39425003342330456, 0.3957499866373837, 0.39666699012741446, 0.3969999961555004, 0.39712502621114254, 0.3975420258939266, 0.39787503192201257, 0.3987079835496843, 0.40020799497142434, 0.400707998778671, 0.4023329820483923, 0.40495803114026785, 0.4065419780090451, 0.40675001218914986, 0.40691602043807507, 0.4069579881615937, 0.4075420438311994, 0.40791602805256844, 0.4095829790458083, 0.41024998063221574, 0.4107080167159438, 0.413707981351763, 0.4164170240983367, 0.41691696969792247, 0.4177080118097365, 0.419542018789798, 0.4201669944450259, 0.42033300269395113, 0.42212504195049405, 0.4242919967509806, 0.4248339682817459, 0.4274160019122064, 0.4309579962864518, 0.43233297765254974, 0.43258402729406953, 0.44362503103911877, 0.44470897410064936, 0.4504999960772693, 0.462208001408726, 0.4670420312322676, 0.46729197492823005, 0.4699170240201056, 0.4777089925482869, 0.48991700168699026, 0.4908330156467855, 0.49841601867228746, 0.5057909875176847, 0.5127500044181943, 0.5805420223623514, 0.5873749614693224, 0.5931250052526593, 0.6327499868348241, 0.6843330338597298, 0.7296249968931079, 0.759792048484087, 0.7769999792799354, 0.8421249804086983, 0.8471250184811652, 0.8660839521326125, 0.8999169804155827, 0.9412500075995922, 0.9451250080019236, 0.9730419842526317, 1.0114579927176237, 1.0394169948995113, 1.074250030796975, 1.1261670151725411, 1.1672499822452664, 1.1826250120066106, 1.1919999960809946, 1.1953340144827962, 1.1954579968005419, 1.2069999938830733, 1.2120829778723419, 1.2217919575050473, 1.2232079752720892, 1.2319170054979622, 1.2464590254239738, 1.2742499820888042, 1.2877089902758598, 1.2995409779250622, 1.3074579765088856, 1.3085830141790211, 1.3187919976189733, 1.3228750322014093, 1.3254169607535005, 1.3257079990580678, 1.3427499798126519, 1.348958001472056, 1.3496670289896429, 1.3552919845096767, 1.373290957417339, 1.3737920089624822, 1.3811249518767, 1.3877080054953694, 1.4210829976946115, 1.4228749787434936, 1.4255410060286522, 1.4413330354727805, 1.4820420183241367, 1.484000007621944, 1.4983330038376153, 1.4985839952714741, 1.5417920076288283, 1.5435419627465308, 1.55533297220245, 1.5656249597668648, 1.5688749845139682, 1.5930410008877516, 1.6286669997498393, 1.6395000275224447, 1.6602500109001994, 1.6760409926064312, 1.6874169814400375, 1.7006249981932342, 1.7213340033777058, 1.7252079560421407, 1.7261250177398324, 1.7387500265613198, 1.742499996908009, 1.743166008964181, 1.7470000311732292, 1.7499999958090484, 1.7636249540373683, 1.8167499802075326, 1.8392089987173676, 1.8726250273175538, 1.9636250217445195, 1.9641669932752848, 1.9680000259540975, 2.0008329884149134, 2.0903749973513186, 2.1107920329086483, 2.1733749890699983, 2.1801249822601676, 2.326708985492587, 2.3330420372076333, 2.4499999708496034, 2.465625002514571, 2.5036250008270144, 2.567416988313198, 2.6513339835219085, 2.6877920026890934, 2.7570000384002924, 2.9014170286245644, 3.0343750258907676, 3.4132080036215484, 3.4826669725589454, 3.908999962732196, 4.281750007066876, 4.511666018515825, 4.662249993998557, 5.844958999659866, 6.637290993239731, 8.537958026863635, 8.620499982498586, 9.497040999121964, 13.173083018045872, 13.2913330453448, 14.414749981369823, 17.024791974108666, 17.170417006127536, 22.697874985Line truncated
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, cold cache, 10 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 270, "requests_offered": 90, "rate_ms": 100, "open_buffers": 11, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [0.30983303440734744, 0.3370419726707041, 0.35729201044887304, 0.36687497049570084, 0.37174997851252556, 0.37699996028095484, 0.3802920109592378, 0.38333400152623653, 0.38454204332083464, 0.38716697599738836, 0.3905409830622375, 0.39079098496586084, 0.39125001057982445, 0.39250002009794116, 0.3927499637939036, 0.3927919897250831, 0.3927919897250831, 0.3944169729948044, 0.39504095911979675, 0.39529200876131654, 0.3957919543609023, 0.3969580284319818, 0.39720896165817976, 0.3973339917138219, 0.39770902367308736, 0.39775000186637044, 0.39787503192201257, 0.39916601963341236, 0.4005000228062272, 0.40133402217179537, 0.40241697570309043, 0.4077079938724637, 0.4082500236108899, 0.40924997301772237, 0.4146249848417938, 0.41516695637255907, 0.41799998143687844, 0.4189580213278532, 0.4190829931758344, 0.4197079688310623, 0.42033399222418666, 0.4225000157020986, 0.42279198532924056, 0.42395800119265914, 0.425292004365474, 0.4265420138835907, 0.4267080221325159, 0.42799999937415123, 0.4300840082578361, 0.4306669579818845, 0.43291598558425903, 0.43337501119822264, 0.43641700176522136, 0.4408329841680825, 0.4409999819472432, 0.44237502152100205, 0.4467919934540987, 0.44741597957909107, 0.44875004095956683, 0.45324995880946517, 0.45416696229949594, 0.45774999307468534, 0.45904202852398157, 0.4615000216290355, 0.4622919950634241, 0.4653329961001873, 0.46720902901142836, 0.47083396930247545, 0.4742500022985041, 0.4751670057885349, 0.475957989692688, 0.48041599802672863, 0.4877499886788428, 0.48779096687212586, 0.4997500218451023, 0.5112919607199728, 0.5207500071264803, 0.5226670182310045, 0.5446249851956964, 0.553040998056531, 0.5556250107474625, 0.5634579574689269, 0.584208988584578, 0.5941659910604358, 0.5979160196147859, 0.6147499661892653, 0.6167909596115351, 0.6177910254336894, 0.6242080125957727, 0.6294170161709189, 0.6585000082850456, 0.6617920007556677, 0.685208011418581, 0.7040839991532266, 0.7118330104276538, 0.7658330141566694, 0.7750410004518926, 0.7893750444054604, 0.7909999694675207, 0.8316250168718398, 0.8324579684995115, 0.8532500360161066, 0.9313340415246785, 0.9760410175658762, 1.0762079618871212, 1.2182919890619814, 1.221290964167565, 1.2397499522194266, 1.2471670052036643, 1.2690420262515545, 1.3246249873191118, 1.340750022791326, 1.3515420141629875, 1.38766597956419, 1.4245000202208757, 1.4327910030260682, 1.4412080054171383, 1.4444999978877604, 1.46266701631248, 1.4721660409122705, 1.4892079634591937, 1.4954999787732959, 1.5902910381555557, 1.5985410427674651, 1.607084006536752, 1.6452079871669412, 1.64695899002254, 1.6876250156201422, 1.7329580150544643, 1.7848749994300306, 1.8157500308007002, 1.8334159976802766, 1.8654169980436563, 1.9495830056257546, 2.0004999823868275, 2.024749992415309, 2.0325829973444343, 2.0814170129597187, 2.120583027135581, 2.181417017709464, 2.2225420107133687, 2.2851249668747187, 2.3669590009376407, 2.3923339904285967, 2.500667003914714, 2.5042080087587237, 2.507208031602204, 2.5184580008499324, 2.523000002838671, 2.6686249766498804, 2.711333043407649, 2.772292005829513, 2.85274995258078, 2.8778749983757734, 2.9494999907910824, 2.9971670010127127, 3.046875004656613, 3.2251669908873737, 3.2452080049552023, 3.304417012259364, 3.400582994800061, 3.6621250328607857, 3.8219999987632036, 4.026332986541092, 4.794790991581976, 5.849041976034641, 6.338791979942471, 7.691999955568463, 14.305416960269213, 16.713917022570968, 18.137291015591472, 19.85200005583465, 20.210040966048837, 26.58591599902138, 30.635958013590425, 34.43729202263057, 37.48991701286286, 39.7868329891935, 46.27154103945941, 56.808458000887185, 61.78120902040973, 62.26433295523748, 63.64629196468741, 88.9579170034267, 89.34254199266434, 95.10308300377801, 105.09333299705759, 107.09433298325166, 117.04608297441155, 117.6811249461025, 133.5414579953067, 141.11837500240654, 145.95749997533858, 156.75395802827552, 162.67208300996572, 163.51245797704905, 163.76908303936943, 188.09583398979157, 189.94449998717755, 193.4614999918267, 204.7862090403214, 207.31595798861235, 213.70245900470763, 214.99179198872298, 234.83412497444078, 239.55479101277888, 248.0264589539729, 257.06808298127726, 261.8468749569729, 262.2977909632027, 262.5469579943456, 286.16537497146055, 288.01099996780977, 288.8112089713104,Line truncated
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, warm cache, 0 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 1, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [0.1567089930176735, 0.17258297884836793, 0.1823750208131969, 0.25870901299640536, 0.2644580090418458, 0.36449998151510954, 0.36574999103322625, 0.3720829845406115, 0.3748340532183647, 0.37875003181397915, 0.38124999264255166, 0.3813749644905329, 0.38241699803620577, 0.383291975595057, 0.3884999896399677, 0.39187498623505235, 0.40145800448954105, 0.4021669737994671, 0.40433299727737904, 0.4044999950565398, 0.41087501449510455, 0.41108299046754837, 0.4130000015720725, 0.413333997130394, 0.4136249772273004, 0.4182499833405018, 0.4194590146653354, 0.4242080030962825, 0.4327499773353338, 0.43404201278463006, 0.43474999256432056, 0.4431669949553907, 0.4461670177988708, 0.4463749937713146, 0.4469580017030239, 0.44883304508402944, 0.45658304588869214, 0.4680419806391001, 0.47883298248052597, 0.5232089897617698, 0.5246659857220948, 0.5428750300779939, 0.5557909607887268, 0.5991249927319586, 0.7135000196285546, 0.7223749998956919, 0.7272089715115726, 0.8579160203225911, 1.209291978739202, 1.3354999828152359, 1.4036669745109975, 1.4447080320678651, 1.4527919702231884, 1.5151670086197555, 1.607124984730035, 1.6437500016763806, 1.8583749770186841, 2.0522080012597144, 2.193042018916458, 2.610374998766929, 2.73574999300763, 2.846500021405518, 5.394583975430578, 6.07674999628216, 17.992291948758066, 22.500499966554344, 42.14462504023686, 53.77991701243445, 58.73687501298264, 62.88029096322134, 64.46104100905359, 68.37300001643598, 69.29458299418911, 71.31700002355501, 73.76408303389326, 77.44875003118068, 91.45237499615178, 106.47966695250943, 117.42566601606086, 122.7285839850083, 143.3283329824917, 154.95533298235387, 159.0279579977505, 162.34554204856977, 163.19733299314976, 169.55983301158994, 169.74654200021178, 171.22979200212285, 173.7276670173742, 179.29766600718722, 192.81229202169925, 207.69812498474494, 243.17854194669053, 253.59558296622708, 263.5240840027109, 268.47504096804187, 272.7592080482282, 273.0323339928873, 278.23041699593887, 292.0156249892898, 305.3441250231117, 343.2315409881994, 355.6066660094075, 375.48070901539177, 379.6020420268178], "latency_median_ms": 1.4527919702231884, "latency_max_ms": 379.6020420268178, "mid_scan_median_ms": 1.4527919702231884, "mid_scan_max_ms": 379.6020420268178, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 105, "after_settle_answers": 0, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 0, "settled_ms": [3407.0167089812458, 3410.8658749610186, 3406.7385410307907], "tick_jitter_ms": 5.397125030867755, "publication": [{"publish_absorb": 401.18, "publish_candidates": 173.44, "publish_includes": 13.0, "publish_overlay": 0.36, "publish_total": 587.98, "publishes": 5, "published": 3436, "first_publish": 120.52, "scan_total": 1701.39}, {"publish_absorb": 331.32, "publish_candidates": 139.03, "publish_includes": 11.15, "publish_overlay": 0.34, "publish_total": 481.84, "publishes": 4, "published": 3081, "first_publish": 118.75, "scan_total": 1536.76}, {"publish_absorb": 400.81, "publish_candidates": 171.16, "publish_includes": 13.23, "publish_overlay": 0.36, "publish_total": 585.56, "publishes": 5, "published": 3456, "first_publish": 118.22, "scan_total": 1687.39}], "ts": "2026-09-09T01:18:02", "label": "0.52.0-review", "schema": 2, "units": "ms"}
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, warm cache, 10 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 11, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [0.2995419781655073, 0.36920898128300905, 0.3736250218935311, 0.37712499033659697, 0.3893329994753003, 0.3900409792549908, 0.3937500296160579, 0.41191698983311653, 0.41683303425088525, 0.4172499757260084, 0.41916698683053255, 0.42216700967401266, 0.42983301682397723, 0.44733297545462847, 0.4491670406423509, 0.4497499903663993, 0.4505419638007879, 0.4556670319288969, 0.46545802615582943, 0.47637498937547207, 0.4775419947691262, 0.517958018463105, 0.5207500071264803, 0.5358750349842012, 0.5608749925158918, 0.5793749587610364, 0.5881660035811365, 0.589708040934056, 0.6294999620877206, 0.6559999892488122, 0.6595830200240016, 0.7256660028360784, 0.8640410378575325, 0.9828750044107437, 1.304500037804246, 1.3474579900503159, 1.413875026628375, 1.4257910079322755, 1.4327919925563037, 1.4707499649375677, 1.5054999967105687, 1.5845000161789358, 1.5974999987520278, 1.8340839887969196, 1.9388750079087913, 1.9652079790830612, 1.9924999796785414, 2.091667032800615, 2.192125015426427, 2.3298750165849924, 2.576208033133298, 3.8130839820951223, 9.627292049117386, 10.309334029443562, 11.340291996020824, 35.95295798731968, 43.56899997219443, 67.1394580276683, 70.5937499878928, 76.90470904344693, 86.34304197039455, 100.13583302497864, 104.83595903497189, 109.47245801799, 111.3881670171395, 111.64237500634044, 131.83370896149427, 142.8550000418909, 165.45312496600673, 169.5360830053687, 174.75624999497086, 187.0386659866199, 200.70391695480794, 202.87862495752051, 210.3013750165701, 211.4611670258455, 212.0887089986354, 233.8570419815369, 241.73633399186656, 267.42375001776963, 270.5379169783555, 275.0038750236854, 285.7787079992704, 301.1213330319151, 309.6685410127975, 310.35241700010374, 335.9032919979654, 385.5018329923041, 410.56766599649563, 434.6805409877561, 487.36441700020805, 511.1273330403492, 534.6575410221703, 587.2191250091419, 611.5488329669461, 635.8172500040382, 686.5012499620207, 711.7035000119358, 733.7996250134893, 786.4580830209889, 811.6557910107076, 834.1072909533978, 887.8402920090593, 912.226666987408, 935.9836250077933], "latency_median_ms": 9.627292049117386, "latency_max_ms": 935.9836250077933, "mid_scan_median_ms": 93.2394374976866, "mid_scan_max_ms": 935.9836250077933, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 88, "after_settle_answers": 17, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 0, "settled_ms": [3414.8414590163156, 3411.4109999500215, 1714.3974580103531], "tick_jitter_ms": 4.853875027038157, "publication": [{"publish_absorb": 584.21, "publish_candidates": 218.45, "publish_includes": 15.06, "publish_overlay": 3.37, "publish_total": 821.09, "publishes": 5, "published": 3644, "first_publish": 455.71, "scan_total": 1962.48}, {"publish_absorb": 589.67, "publish_candidates": 227.47, "publish_includes": 14.66, "publish_overlay": 3.31, "publish_total": 835.11, "publishes": 5, "published": 3577, "first_publish": 453.08, "scan_total": 1989.54}, {"publish_absorb": 425.04, "publish_candidates": 178.03, "publish_includes": 12.39, "publish_overlay": 2.43, "publish_total": 617.89, "publishes": 4, "published": 3244, "first_publish": 499.65, "scan_total": 1703.0}], "ts": "2026-09-09T01:18:18", "label": "0.52.0-review", "schema": 2, "units": "ms"}
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, cold cache, 0 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 270, "requests_offered": 90, "rate_ms": 100, "open_buffers": 1, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [9.902124991640449, 10.340040957089514, 10.616042010951787, 22.2932500182651, 23.17745902109891, 25.093042000662535, 32.31020801467821, 34.17783399345353, 36.73487500054762, 37.10945800412446, 37.140625005122274, 39.037459006067365, 41.09216696815565, 45.823332970030606, 47.85100003937259, 54.68316696351394, 55.404125014320016, 57.97408299986273, 58.836374955717474, 62.380584015045315, 63.21670801844448, 64.11545805167407, 64.65700000990182, 68.94033396383747, 70.02041599480435, 71.02074997965246, 71.06916705379263, 71.84799999231473, 73.54337500873953, 73.76087503507733, 74.9115829821676, 76.5977919800207, 78.02445802371949, 78.11358396429569, 78.71583302039653, 78.77341599669307, 79.56245803507045, 80.36583400098607, 80.4101669928059, 80.86512499721721, 81.91404095850885, 82.29991601547226, 82.66950002871454, 83.45495798857883, 83.7867499794811, 83.92108301632106, 85.03516699420288, 85.23691701702774, 85.43437503976747, 85.49024997046217, 85.72933299001306, 86.40499995090067, 86.91891597118229, 87.58845902048051, 88.1728749955073, 88.21699995314702, 88.39762501884252, 88.51129101822153, 90.50724998814985, 91.40500001376495, 91.48658404592425, 92.35129202716053, 92.88879198720679, 92.89891697699204, 92.94633299577981, 92.97058399533853, 93.1052920059301, 93.22491701459512, 93.30479195341468, 94.42141698673368, 94.95887497905642, 95.17824999056756, 95.35841702017933, 95.46820801915601, 95.47904197825119, 95.94995900988579, 96.0554169723764, 96.22308297548443, 96.26812499482185, 96.40537499217317, 96.61700000287965, 97.11925004376099, 97.12937497533858, 97.32412500306964, 97.41849999409169, 97.48870803741738, 97.63412503525615, 97.68000000622123, 97.70887502236292, 97.8191249887459, 97.87066699936986, 97.93595899827778, 98.22325001005083, 98.47858402645215, 98.54566701687872, 98.85624999878928, 99.1745840292424, 99.51433399692178, 99.68670801026747, 99.70341698499396, 100.00020900042728, 100.02937499666587, 100.02995899412781, 100.04245804157108, 100.25141696678475, 100.47062498051673, 100.56333401007578, 100.58312502223998, 100.65420804312453, 100.82325001712888, 101.37779201613739, 101.7637500190176, 102.01987496111542, 102.06549998838454, 102.17554197879508, 102.56441700039431, 102.6337500079535, 102.95125003904104, 102.97695797635242, 103.00500004086643, 103.29733300022781, 103.68308302713558, 103.757124976255, 103.99470804259181, 104.04420900158584, 104.10029097693041, 104.14316697278991, 104.35429197968915, 104.35658297501504, 104.80116697726771, 104.91241596173495, 104.95158296544105, 105.39924999466166, 106.36249999515712, 106.42679099692032, 106.6551249823533, 106.89729102887213, 106.89845896558836, 107.16545803006738, 107.48775000683963, 107.64308302896097, 108.03720896365121, 108.17570798099041, 108.61404100432992, 108.90716704307124, 109.02274999534711, 109.03570899972692, 109.07679196679965, 109.42029202124104, 109.71345799043775, 109.79629104258493, 109.84841600293294, 110.11154198786244, 110.57020799489692, 110.6995830195956, 111.01520800730214, 111.03195900795981, 111.03754199575633, 111.08987499028444, 111.12729198066518, 111.35487497085705, 111.44095798954368, 111.64083302719519, 112.00345802353695, 112.08024999359623, 112.14445903897285, 112.59324999991804, 112.73483303375542, 112.80195799190551, 113.13004198018461, 113.20254195015877, 113.86216699611396, 113.87333302991465, 113.88779198750854, 114.08149998169392, 114.25145802786574, 114.28316595265642, 114.30666700471193, 114.87383302301168, 115.44000002322719, 115.6363749760203, 116.20345897972584, 116.24716699589044, 116.73141596838832, 116.73908401280642, 117.07812501117587, 117.14137502713129, 118.51104197558016, 119.12933300482109, 119.44983300054446, 119.60916599491611, 120.20429200492799, 120.42283295886591, 120.45120797120035, 120.76920800609514, 120.83033297676593, 121.53358396608382, 122.62758304132149, 123.52154101245105, 125.31479197787121, 126.85050000436604, 127.04187497729436, 127.08387500606477, 127.41695798467845, 127.52749997889623, 127.88216699846089, 128.0113750253804, 128.78487503621727, 129.35466703493148, 129.83937497483566, 129.93595900479704, 130.18787500914186, 130.81549998605624, 131.55774999177083, 131.71712501207367, 131.85233296826482, 136.42591598909348, 136.98545895749703, 137.199042015708Line truncated
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, cold cache, 10 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 270, "requests_offered": 90, "rate_ms": 100, "open_buffers": 11, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [335.74629097711295, 351.9685410428792, 361.7872910108417, 436.1903340322897, 450.64200001070276, 462.3638750053942, 537.0929580531083, 551.2578340130858, 561.5836659562774, 637.1752499835566, 652.9722500126809, 661.7090840009041, 736.8382080458105, 750.9314999915659, 762.0219580130652, 836.098832951393, 850.7772920420393, 861.2403749721125, 936.1467079725116, 950.924834003672, 961.6388329886831, 1036.666292056907, 1050.789333996363, 1061.6964590153657, 1134.976709028706, 1151.3806660077535, 1161.6623749723658, 1235.4647500324063, 1251.331165956799, 1262.5051669892855, 1336.8653330253437, 1352.5381250074133, 1361.712499987334, 1434.553833969403, 1453.097500023432, 1462.4552500317805, 1535.2574580465443, 1551.0733330156654, 1560.5822910438292, 1636.1803750041872, 1650.3649160149507, 1660.5697919731028, 1736.7307919776067, 1752.9838330228813, 1761.341916047968, 1836.5692910156213, 1851.1388340266421, 1860.4713749955408, 1936.8341660010628, 1951.8172919633798, 1962.0588749530725, 2036.9501669774763, 2052.606332988944, 2062.866166990716, 2136.9384579593316, 2151.1245000292547, 2160.258124989923, 2236.4027090370655, 2251.535875024274, 2260.2882910287008, 2334.7892920137383, 2351.7933749826625, 2361.9327500346117, 2436.7287079803646, 2452.03612500336, 2460.1993749965914, 2534.561541979201, 2552.803083031904, 2561.2569169607013, 2634.696041001007, 2651.343417004682, 2660.55241698632, 2736.4757080213167, 2751.4027080032974, 2760.564249998424, 2836.0392909962684, 2851.03129199706, 2860.690000001341, 2935.699583031237, 2950.104999996256, 2960.808083007578, 3035.130958945956, 3052.327666024212, 3060.855708026793, 3135.3868329897523, 3150.8257089881226, 3160.465083026793, 3235.545625037048, 3252.2037499584258, 3260.0273749558255, 3335.622207960114, 3350.1388329896145, 3362.3819159693085, 3435.717415995896, 3450.4259579698555, 3462.3161670169793, 3534.327791945543, 3551.6020829672925, 3561.8043749709614, 3635.847500001546, 3651.9291659933515, 3660.8253750018775, 3735.834957973566, 3751.119041990023, 3760.7715419726446, 3835.8214999898337, 3852.3707089480013, 3861.0295420512557, 3935.972916020546, 3952.2335839574225, 3961.5827500238083, 4036.1124590272084, 4050.8453749935143, 4062.064333993476, 4136.53008302208, 4151.65745903505, 4161.061082966626, 4234.56112499116, 4249.953665945213, 4261.988916958217, 4334.784250007942, 4350.1046250457875, 4361.916207999457, 4434.790125000291, 4451.016917009838, 4459.975999954622, 4535.127500013914, 4551.052875001915, 4561.625790956896, 4636.227999988478, 4651.573707989883, 4661.608667054679, 4734.10458303988, 4752.478415961377, 4761.7021659971215, 4834.567292011343, 4852.371957967989, 4861.618166032713, 4934.934791002888, 4950.29137498932, 4959.832750027999, 5034.84416694846, 5050.135708996095, 5059.938499995042, 5134.383374999743, 5150.64979204908, 5161.724624980707, 5234.324791003019, 5250.175666995347, 5261.034708004445, 5336.349499993958, 5352.110082982108, 5360.941874969285, 5436.137166980188, 5451.938499987591, 5460.516208957415, 5536.146625003312, 5550.955416983925, 5561.64616701426, 5635.494499991182, 5650.373124983162, 5660.847416962497, 5735.971832997166, 5750.328625028487, 5759.625124977902, 5835.67054203013, 5850.075749971438, 5860.600541986059, 5935.748916992452, 5952.0846249652095, 5961.269500025082, 6035.470750008244, 6051.5090840053745, 6061.692541989032, 6135.092667012941, 6151.113583007827, 6161.9017500197515, 6234.673833008856, 6250.1529170549475, 6261.178332963027, 6334.493833011948, 6350.415916997008, 6359.344583004713, 6434.55033301143, 6450.561375007965, 6460.448333004024, 6534.61316699395, 6550.55587500101, 6561.3799169659615, 6634.737292013597, 6650.008541007992, 6659.567583992612, 6734.620917006396, 6750.328458962031, 6760.721541999374, 6834.66870803386, 6851.530292013194, 6860.454749956261, 6934.099042031448, 6952.039625030011, 6959.739916026592, 7033.839791023638, 7051.724791992456, 7059.883916983381, 7135.669874958694, 7151.214708050247, 7160.776167002041, 7234.227417036891, 7251.2259999639355, 7259.151500009466, 7335.687457991298, 7351.7887920024805, 7360.632415977307, 7434.30637504207, 7450.542458042037, 7460.5222920072265, 7535.302457981743, 7549.733499996364, 7560.988833953161, 7634.430457954295, 7651.1622500256635, 7659.22620799392Line truncated
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, warm cache, 0 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 1, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [8.513291017152369, 11.442125018220395, 12.872666004113853, 76.23354200040922, 76.31550001678988, 81.47733402438462, 82.56333303870633, 83.7337090051733, 84.72541702212766, 84.82645801268518, 84.92162497714162, 85.51645802799612, 87.48149999883026, 87.49133296078071, 88.42720795655623, 90.84254200570285, 93.97200000239536, 95.2837910153903, 95.64212500117719, 95.79679102171212, 96.48095798911527, 97.31587499845773, 97.7104589692317, 98.02520804805681, 98.66770799271762, 98.9327909774147, 100.29308299999684, 100.76791699975729, 101.10033303499222, 101.34108300553635, 101.37787502026185, 101.54699999839067, 101.93033301038668, 105.4825410246849, 107.4730419786647, 109.47445797501132, 109.68079202575609, 109.70870801247656, 110.58504099491984, 110.72158301249146, 114.05054200440645, 114.19520899653435, 115.08333298843354, 116.50779203046113, 116.99279199820012, 118.19325003307313, 118.2911250507459, 122.54924996523187, 122.89016600698233, 123.42962494585663, 123.96112503483891, 125.28491602279246, 127.27191601879895, 127.64533399604261, 130.29279198963195, 132.18741700984538, 134.1168750077486, 134.126249991823, 136.49312499910593, 138.40866700047627, 139.75083304103464, 142.4806250142865, 144.7386249783449, 145.521208003629, 147.74429198587313, 149.14729201700538, 150.63629194628447, 152.63079199939966, 153.0972920008935, 156.06504201423377, 157.84966695355251, 158.5612500202842, 159.38783303136006, 163.85599999921396, 164.79541698936373, 165.45358300209045, 167.76574996765703, 170.40729196742177, 170.94570898916572, 174.81820797547698, 175.1023749820888, 176.07629200210795, 180.17962499288842, 180.74187502497807, 180.8608749997802, 184.17195801157504, 185.63754198839888, 186.6147500113584, 188.66854201769456, 190.0606660055928, 191.27537502208725, 192.07662501139566, 195.47370803775266, 196.9412500038743, 199.61499999044463, 200.48254198627546, 201.30316604627296, 203.65920796757564, 205.54445800371468, 207.62016699882224, 208.53337500011548, 209.34441598365083, 288.89537503710017, 303.5131670185365, 305.71375001454726], "latency_median_ms": 127.27191601879895, "latency_max_ms": 305.71375001454726, "mid_scan_median_ms": 127.27191601879895, "mid_scan_max_ms": 305.71375001454726, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 105, "after_settle_answers": 0, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 12, "settled_ms": [4105.060499976389, 4136.745374009479, 4203.156500996556], "tick_jitter_ms": 2.624417014885694, "publication": [{"publish_absorb": 2365.93, "publish_candidates": 616.22, "publish_includes": 51.27, "publish_overlay": 2.46, "publish_total": 3035.8799999999997, "publishes": 33, "published": 1861, "first_publish": 281.79, "scan_total": 4096.56}, {"publish_absorb": 2379.36, "publish_candidates": 636.7, "publish_includes": 50.72, "publish_overlay": 2.45, "publish_total": 3069.23, "publishes": 33, "published": 1860, "first_publish": 263.35, "scan_total": 4126.52}, {"publish_absorb": 2435.46, "publish_candidates": 642.64, "publish_includes": 51.03, "publish_overlay": 2.47, "publish_total": 3131.6, "publishes": 34, "published": 1859, "first_publish": 277.67, "scan_total": 4195.38}], "ts": "2026-09-09T01:19:51", "label": "0.51.0-reference", "schema": 2, "units": "ms"}
|
||||
{"phase": "scanload", "row": "cross-folder definition every 100 ms, warm cache, 10 extra buffer(s)", "fresh_process": true, "status": "ok", "message": null, "result_count": 105, "requests_offered": 35, "rate_ms": 100, "open_buffers": 11, "note": "ms is every request's own wait, sorted, across all tries; the arrival rate is wall-clock and independent of the responses (`tick_jitter_ms` is the largest slip); `publication` is each try's first traced scan \u2014 the four publish_* stages, the publish count and the files published; `mismatched_answers` is the coherence contract of docs/features/index-scope/README.md, `unsettled_answers` the review \u00a72 gate (every answer, empty ones included, equal to the settled one)", "ms": [226.20341699803248, 241.39650003053248, 271.0190420038998, 326.0454999981448, 342.26066700648516, 368.59662499045953, 424.6195000014268, 442.2450000420213, 468.7907920451835, 524.4040419929661, 541.9453749782406, 568.753416009713, 625.2409999724478, 641.9290840276517, 668.817957979627, 725.5809999769554, 741.6812080191448, 769.7975840419531, 825.5425000097603, 841.4298749994487, 868.5702080256306, 925.7162499707192, 941.3640000275336, 968.4813329949975, 1026.1333329835907, 1039.744374982547, 1069.9023330234922, 1125.8545409655198, 1141.3147920393385, 1168.9767920179293, 1225.8606659597717, 1241.5034580044448, 1269.3024579784833, 1326.0361250140704, 1340.0207090307958, 1369.5688750012778, 1426.2369999778457, 1440.6650839955546, 1469.5063750259578, 1524.385875032749, 1541.6793749900535, 1570.564249996096, 1625.3879999858327, 1642.1471670037135, 1669.5357079734094, 1725.0406249659136, 1740.206750051584, 1769.6382910362445, 1825.250750000123, 1840.3770829900168, 1868.4078750084154, 1925.3137079649605, 1940.7753749983385, 1970.4457079642452, 2025.6511659827083, 2040.7403749995865, 2068.381874996703, 2123.9959170343354, 2142.0173750375398, 2170.1701669953763, 2224.2987499921583, 2241.965666995384, 2267.0772920246236, 2323.862958000973, 2341.871041979175, 2369.6067499695346, 2424.045916995965, 2441.2017079885118, 2469.0970000228845, 2524.6080000069924, 2540.580125001725, 2568.7733750091866, 2624.219916004222, 2640.973749978002, 2669.201167009305, 2724.7269169893116, 2740.3815000434406, 2768.9377079950646, 2824.7620839974843, 2839.9895830079913, 2868.495417002123, 2924.243541958276, 2939.602416998241, 2970.3808749909513, 3026.1651659966446, 3041.0785830463283, 3070.2625829726458, 3124.8390420223586, 3139.5699169952422, 3170.6455829553306, 3225.3422920475714, 3240.330583998002, 3269.8907500016503, 3325.589958985802, 3340.089374978561, 3368.367124989163, 3425.539707997814, 3441.8976670131087, 3468.500499962829, 3526.063041004818, 3539.5341250114143, 3568.935749994125, 3626.2147499946877, 3641.9260410475545, 3670.666290970985], "latency_median_ms": 1940.7753749983385, "latency_max_ms": 3670.666290970985, "mid_scan_median_ms": 1940.7753749983385, "mid_scan_max_ms": 3670.666290970985, "requests_sent": [35, 35, 35], "requests_answered": 105, "mid_scan_answers": 105, "after_settle_answers": 0, "unanswered_requests": 0, "mismatched_answers": 0, "unsettled_answers": 105, "settled_ms": [4220.629334042314, 4275.046957947779, 4244.135040964466], "tick_jitter_ms": 3.8492910098284483, "publication": [{"publish_absorb": 2420.6, "publish_candidates": 663.82, "publish_includes": 50.22, "publish_overlay": 19.98, "publish_total": 3154.62, "publishes": 34, "published": 1807, "first_publish": 263.8, "scan_total": 4203.5}, {"publish_absorb": 2422.37, "publish_candidates": 703.05, "publish_includes": 51.54, "publish_overlay": 20.9, "publish_total": 3197.8599999999997, "publishes": 34, "published": 1807, "first_publish": 266.04, "scan_total": 4258.06}, {"publish_absorb": 2410.72, "publish_candidates": 678.44, "publish_includes": 51.64, "publish_overlay": 20.77, "publish_total": 3161.5699999999997, "publishes": 34, "published": 1808, "first_publish": 266.93, "scan_total": 4231.64}], "ts": "2026-09-09T01:20:09", "label": "0.51.0-reference", "schema": 2, "units": "ms"}
|
||||
{"phase": "refactor", "row": "expand-wildcard offer", "titles": ["lucisv: expand .* (32 connections)", "lucisv: extract selection into module\u2026"], "shapes": ["data", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/kmac/fpv/tb/sha3_fpv.sv", "position": {"line": 54, "character": 4}, "ms": [4.856499959714711, 2.038917038589716, 1.6384579939767718, 1.6377920401282609], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:13", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "expand-wildcard resolve: lucisv: expand .* (32 connections)", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "8f3a26dd147b2b8031ee2af6e47f52228c91d69fea1ab9a5b885e8b653c56115", "ms": [75.03170799463987, 56.26808403758332, 55.418417032342404, 54.370458994526416], "status": "ok", "result_count": 1, "edits": 1, "files": 1, "created": 0, "ts": "2026-09-09T01:20:13", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "expand-wildcard offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:13", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "organize-imports offer", "titles": ["lucisv: organize imports (removes 1, sorts 1)", "lucisv: extract selection into module\u2026"], "shapes": ["data", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_sbox_canright_masked.sv", "position": {"line": 42, "character": 2}, "ms": [4.029750009067357, 3.460415988229215, 3.4175420296378434, 3.51687497459352], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:16", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "organize-imports resolve: lucisv: organize imports (removes 1, sorts 1)", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "0ee027e37d070d54804a9a08169e8b8c5669ed7b81d9915e6637949d208bfa91", "ms": [9.7159169963561, 8.239208022132516, 7.986999989952892, 7.797166996169835], "status": "ok", "result_count": 1, "edits": 1, "files": 1, "created": 0, "ts": "2026-09-09T01:20:16", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "organize-imports offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:16", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "inline-module offer", "titles": ["lucisv: extract selection into module\u2026", "lucisv: inline `tlul_cmd_intg_gen` here"], "shapes": ["command", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_wrap.sv", "position": {"line": 66, "character": 2}, "ms": [0.9933750261552632, 0.612374977208674, 0.6608749972656369, 0.582791049964726], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:20", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "inline-module offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:20", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "inline-module offer is a command: lucisv: inline `tlul_cmd_intg_gen` here", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.inlineModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:20", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "port-actions offer", "titles": ["lucisv: connect 2 missing ports", "lucisv: extract selection into module\u2026"], "shapes": ["data", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_wrap.sv", "position": {"line": 78, "character": 2}, "ms": [2.08212505094707, 1.1158339912071824, 1.870499982032925, 1.207916997373104], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:23", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "port-actions resolve: lucisv: connect 2 missing ports", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "4b534a16bca7abd205bd16458820936d4dc0c4cea9c963c5374c29a47b13fffb", "ms": [161.33249999256805, 142.7456249948591, 132.87641695933416, 132.62791599845514], "status": "ok", "result_count": 1, "edits": 2, "files": 1, "created": 0, "ts": "2026-09-09T01:20:23", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "port-actions offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:23", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "ansi-header (no offer expected) offer", "titles": [], "shapes": [], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 8, "character": 0}, "ms": [0.6442079902626574, 0.4128750297240913, 0.43245794950053096, 0.3673749743029475], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:20:27", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "extract-module offer (selection)", "titles": ["lucisv: extract selection into module\u2026"], "shapes": ["command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 220, "character": 0}, "note": "selection 220:0-222:53", "ms": [2.6587090105749667, 0.5566250183619559, 0.5232089897617698, 0.4752080421894789], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:20:30", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "extract-module offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:30", "label": "0.51.0-reference", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "expand-wildcard offer", "titles": ["lucisv: expand .* (32 connections)", "lucisv: extract selection into module\u2026"], "shapes": ["data", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/kmac/fpv/tb/sha3_fpv.sv", "position": {"line": 54, "character": 4}, "ms": [1.682459027506411, 1.080457994248718, 1.0803749901242554, 1.00733304861933], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:34", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "expand-wildcard resolve: lucisv: expand .* (32 connections)", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "8f3a26dd147b2b8031ee2af6e47f52228c91d69fea1ab9a5b885e8b653c56115", "ms": [71.55108300503343, 54.28687500534579, 53.77562501234934, 53.80616703769192], "status": "ok", "result_count": 1, "edits": 1, "files": 1, "created": 0, "ts": "2026-09-09T01:20:34", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "expand-wildcard offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:34", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "organize-imports offer", "titles": ["lucisv: organize imports (removes 1, sorts 1)", "lucisv: extract selection into module\u2026"], "shapes": ["data", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_sbox_canright_masked.sv", "position": {"line": 42, "character": 2}, "ms": [5.887124978471547, 6.326834030915052, 10.169624991249293, 9.62525000795722], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:37", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "organize-imports resolve: lucisv: organize imports (removes 1, sorts 1)", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "0ee027e37d070d54804a9a08169e8b8c5669ed7b81d9915e6637949d208bfa91", "ms": [14.393708028364927, 10.427791974507272, 8.306875010021031, 8.056457969360054], "status": "ok", "result_count": 1, "edits": 1, "files": 1, "created": 0, "ts": "2026-09-09T01:20:37", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "organize-imports offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:37", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "inline-module offer", "titles": ["lucisv: extract selection into module\u2026", "lucisv: inline `tlul_cmd_intg_gen` here"], "shapes": ["command", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_wrap.sv", "position": {"line": 66, "character": 2}, "ms": [0.5479159881360829, 0.2696249866858125, 0.3247920540161431, 0.2489580074325204], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:41", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "inline-module offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:41", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "inline-module offer is a command: lucisv: inline `tlul_cmd_intg_gen` here", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.inlineModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:41", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "port-actions offer", "titles": ["lucisv: connect 2 missing ports", "lucisv: extract selection into module\u2026"], "shapes": ["data", "command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes_wrap.sv", "position": {"line": 78, "character": 2}, "ms": [0.9376669768244028, 0.6111669936217368, 0.5560829886235297, 0.5026250146329403], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:44", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "port-actions resolve: lucisv: connect 2 missing ports", "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "fingerprint": "4b534a16bca7abd205bd16458820936d4dc0c4cea9c963c5374c29a47b13fffb", "ms": [132.0979169686325, 127.92104197433218, 130.39050000952557, 130.16649999190122], "status": "ok", "result_count": 1, "edits": 2, "files": 1, "created": 0, "ts": "2026-09-09T01:20:44", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "port-actions offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:44", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "ansi-header (no offer expected) offer", "titles": [], "shapes": [], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 8, "character": 0}, "ms": [0.6773339700885117, 0.2851660246960819, 0.2228749799542129, 0.24008401669561863], "status": "ok", "result_count": 0, "ts": "2026-09-09T01:20:48", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "extract-module offer (selection)", "titles": ["lucisv: extract selection into module\u2026"], "shapes": ["command"], "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 220, "character": 0}, "note": "selection 220:0-222:53", "ms": [1.9001670298166573, 0.3470000228844583, 0.1950410078279674, 0.15654199523851275], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:20:51", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "refactor", "row": "extract-module offer is a command: lucisv: extract selection into module\u2026", "ms": [0.0], "result_count": 1, "client": {"resolveSupport": true, "applyEdit": false, "createFiles": false}, "command": "lucisv.extractModule", "note": "timed by the `execute` phase, not by resolve", "ts": "2026-09-09T01:20:51", "label": "0.52.0-review", "schema": 2, "units": "ms", "status": "ok", "fresh_process": false}
|
||||
{"phase": "execute", "row": "extract-module offer", "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 220, "character": 0}, "titles": ["lucisv: extract selection into module\u2026"], "shapes": ["command"], "ms": [1.0923329973593354, 0.6979579920880497, 0.4639580147340894, 0.41924999095499516], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:20:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "extract-module: lucisv: extract selection into module\u2026", "ms": [174.1382500040345, 150.16983303939924, 145.6700830021873, 146.66933397529647], "status": "capture", "message": "perf capture: the benchmark client never writes", "result_count": 1, "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "command": "lucisv.extractModule", "arguments": 3, "total_ms": [174.1775830159895, 150.20600002026185, 145.69983299588785, 146.70116698835045], "deliver_ms": [0.01529202563688159, 0.01370901009067893, 0.010917021427303553, 0.012416974641382694], "fingerprint": "090e92e7736e0a5a93557d75befa65a5bea0c2f44494d71dc67e3f8d70d05835", "warnings": ["lucisv: `aes_extracted` was written to a new file, `aes_extracted.sv`. (and 2 more \u2014 see the lucisv log)"], "note": "ms is executeCommand -> applyEdit: the edit computation. applyEdit label 'lucisv: lucisv.extractModule'", "edits": 2, "files": 2, "created": 1, "ts": "2026-09-09T01:20:55", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "inline-module offer", "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "file": "hw/ip/aes/rtl/aes_wrap.sv", "position": {"line": 66, "character": 2}, "titles": ["lucisv: extract selection into module\u2026", "lucisv: inline `tlul_cmd_intg_gen` here"], "shapes": ["command", "command"], "ms": [1.8940420122817159, 0.7072500302456319, 0.5643750191666186, 0.5397089989855886], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:20:59", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "inline-module: lucisv: extract selection into module\u2026", "ms": [835.7801670208573, 807.4812090490013, 803.160791983828, 806.56983301742], "status": "refused", "message": "lucisv: the selection drives `h2d_intg`, and something outside it passes the same name to a task or function, which may drive it too; lucisv will not make it an output over that.", "result_count": 0, "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "command": "lucisv.extractModule", "arguments": 3, "total_ms": [835.7801670208573, 807.4812090490013, 803.160791983828, 806.56983301742], "deliver_ms": null, "fingerprint": null, "warnings": [], "note": "no edit was pushed, so ms is the whole executeCommand round trip", "edits": 0, "files": 0, "created": 0, "ts": "2026-09-09T01:21:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "inline-module: lucisv: inline `tlul_cmd_intg_gen` here", "ms": [7.2315839934162796, 6.213875021785498, 6.317083025351167, 5.685417039785534], "status": "refused", "message": "lucisv: `tlul_cmd_intg_gen` uses a `generate` construct, whose block names are reachable through the hierarchy (`u_tlul_cmd_intg_gen.gen.x`) and would become names of `M`'s own; lucisv will not inline it.", "result_count": 0, "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "command": "lucisv.inlineModule", "arguments": 2, "total_ms": [7.2315839934162796, 6.213875021785498, 6.317083025351167, 5.685417039785534], "deliver_ms": null, "fingerprint": null, "warnings": [], "note": "no edit was pushed, so ms is the whole executeCommand round trip", "edits": 0, "files": 0, "created": 0, "ts": "2026-09-09T01:21:02", "label": "0.52.0-review", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "extract-module offer", "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "file": "hw/ip/aes/rtl/aes.sv", "position": {"line": 220, "character": 0}, "titles": ["lucisv: extract selection into module\u2026"], "shapes": ["command"], "ms": [2.516667009331286, 1.024707977194339, 1.3964169775135815, 0.6415829993784428], "status": "ok", "result_count": 1, "ts": "2026-09-09T01:21:06", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "extract-module: lucisv: extract selection into module\u2026", "ms": [178.08345798403025, 150.63129202462733, 148.5303749796003, 147.98329200129956], "status": "capture", "message": "perf capture: the benchmark client never writes", "result_count": 1, "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "command": "lucisv.extractModule", "arguments": 3, "total_ms": [178.11804095981643, 150.67979198647663, 148.60950002912432, 148.02891702856869], "deliver_ms": [0.011041003745049238, 0.02704199869185686, 0.029875023756176233, 0.02195802517235279], "fingerprint": "090e92e7736e0a5a93557d75befa65a5bea0c2f44494d71dc67e3f8d70d05835", "warnings": ["lucisv: `aes_extracted` was written to a new file, `aes_extracted.sv`. (and 2 more \u2014 see the lucisv log)"], "note": "ms is executeCommand -> applyEdit: the edit computation. applyEdit label 'lucisv: lucisv.extractModule'", "edits": 2, "files": 2, "created": 1, "ts": "2026-09-09T01:21:06", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "inline-module offer", "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "file": "hw/ip/aes/rtl/aes_wrap.sv", "position": {"line": 66, "character": 2}, "titles": ["lucisv: extract selection into module\u2026", "lucisv: inline `tlul_cmd_intg_gen` here"], "shapes": ["command", "command"], "ms": [5.88275003246963, 1.3801250024698675, 1.6199999954551458, 1.1981670395471156], "status": "ok", "result_count": 2, "ts": "2026-09-09T01:21:10", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "inline-module: lucisv: extract selection into module\u2026", "ms": [827.52095797332, 790.144250029698, 788.2610830129124, 794.3716250010766], "status": "refused", "message": "lucisv: the selection drives `h2d_intg`, and something outside it passes the same name to a task or function, which may drive it too; lucisv will not make it an output over that.", "result_count": 0, "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "command": "lucisv.extractModule", "arguments": 3, "total_ms": [827.52095797332, 790.144250029698, 788.2610830129124, 794.3716250010766], "deliver_ms": null, "fingerprint": null, "warnings": [], "note": "no edit was pushed, so ms is the whole executeCommand round trip", "edits": 0, "files": 0, "created": 0, "ts": "2026-09-09T01:21:13", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
{"phase": "execute", "row": "inline-module: lucisv: inline `tlul_cmd_intg_gen` here", "ms": [7.030457956716418, 6.090875016525388, 5.8352499618195, 5.980540998280048], "status": "refused", "message": "lucisv: `tlul_cmd_intg_gen` uses a `generate` construct, whose block names are reachable through the hierarchy (`u_tlul_cmd_intg_gen.gen.x`) and would become names of `M`'s own; lucisv will not inline it.", "result_count": 0, "client": {"resolveSupport": true, "applyEdit": true, "createFiles": true}, "command": "lucisv.inlineModule", "arguments": 2, "total_ms": [7.030457956716418, 6.090875016525388, 5.8352499618195, 5.980540998280048], "deliver_ms": null, "fingerprint": null, "warnings": [], "note": "no edit was pushed, so ms is the whole executeCommand round trip", "edits": 0, "files": 0, "created": 0, "ts": "2026-09-09T01:21:13", "label": "0.51.0-reference", "schema": 2, "units": "ms", "fresh_process": false}
|
||||
@@ -0,0 +1,20 @@
|
||||
import subprocess,os,json,time,hashlib
|
||||
from pathlib import Path
|
||||
root=Path('/Users/guoliangchen/repo/verilogrustformatter'); out=Path('/tmp/lucisv-perf-review-20260909'); corpus=Path('/Users/guoliangchen/repo/opentitan')
|
||||
old=str(out/'reference/target/release/lucisv-server')
|
||||
bins={'0.51.0-reference':old,'0.52.0-review':str(root/'target/release/lucisv-server')}
|
||||
def state():
|
||||
s=subprocess.check_output(['git','-C',str(corpus),'status','--porcelain'],text=True)
|
||||
return s,{p:hashlib.sha256((corpus/p).read_bytes()).hexdigest() for p in ['hw/ip/aes/dv/tb/tb.sv','hw/top_darjeeling/ip/ast/rtl/ast.sv','hw/top_earlgrey/ip/ast/rtl/ast.sv']}
|
||||
initial=state()
|
||||
for i,phase in enumerate(['offerkinds','offerqueue','offeredit','renametrace','scan','rss','scanloadprobe','scanloadcross','refactor','execute']):
|
||||
labels=list(bins) if i%2==0 else list(reversed(bins))
|
||||
for label in labels:
|
||||
cmd=['tools/guard.sh','-m','8','-t','1800','--','python3','tools/perf/bench.py',phase,'--server',bins[label],'--label',label,'--opentitan',str(corpus),'--storage',str(out/'caches'/label),'--out',str(out/'results.jsonl'),'--tries','3']
|
||||
r=dict(phase=phase,label=label,command=cmd,start=time.time(),load_before=os.getloadavg())
|
||||
print('START',phase,label,flush=True)
|
||||
with (out/(phase+'-'+label+'.log')).open('w') as f:p=subprocess.run(cmd,cwd=root,env=dict(os.environ,PYTHONDONTWRITEBYTECODE='1'),stdout=f,stderr=subprocess.STDOUT)
|
||||
r.update(exit=p.returncode,end=time.time(),load_after=os.getloadavg(),corpus_unchanged=state()==initial)
|
||||
with (out/'runs.jsonl').open('a') as f:f.write(json.dumps(r)+'\n')
|
||||
print('END',phase,label,p.returncode,flush=True)
|
||||
if p.returncode or not r['corpus_unchanged']:raise RuntimeError(r)
|
||||
@@ -0,0 +1,20 @@
|
||||
{"phase": "offerkinds", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "offerkinds", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934163.9507682, "load_before": [5.1650390625, 6.98046875, 6.77099609375], "exit": 0, "end": 1788934183.659245, "load_after": [5.35009765625, 6.900390625, 6.74609375], "corpus_unchanged": true}
|
||||
{"phase": "offerkinds", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "offerkinds", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934183.7768419, "load_before": [5.35009765625, 6.900390625, 6.74609375], "exit": 0, "end": 1788934202.40133, "load_after": [4.86328125, 6.6943359375, 6.67578125], "corpus_unchanged": true}
|
||||
{"phase": "offerqueue", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "offerqueue", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934202.5280929, "load_before": [4.86328125, 6.6943359375, 6.67578125], "exit": 0, "end": 1788934206.886931, "load_after": [5.4345703125, 6.7822265625, 6.70654296875], "corpus_unchanged": true}
|
||||
{"phase": "offerqueue", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "offerqueue", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934207.02068, "load_before": [5.4345703125, 6.7822265625, 6.70654296875], "exit": 0, "end": 1788934211.369911, "load_after": [5.9599609375, 6.86865234375, 6.7373046875], "corpus_unchanged": true}
|
||||
{"phase": "offeredit", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "offeredit", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934211.502112, "load_before": [5.9599609375, 6.86865234375, 6.7373046875], "exit": 0, "end": 1788934222.4556859, "load_after": [5.978515625, 6.84033203125, 6.728515625], "corpus_unchanged": true}
|
||||
{"phase": "offeredit", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "offeredit", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934222.5621262, "load_before": [5.978515625, 6.84033203125, 6.728515625], "exit": 0, "end": 1788934233.511609, "load_after": [5.74755859375, 6.7626953125, 6.7021484375], "corpus_unchanged": true}
|
||||
{"phase": "renametrace", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "renametrace", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934233.624834, "load_before": [5.74755859375, 6.7626953125, 6.7021484375], "exit": 0, "end": 1788934290.385715, "load_after": [5.0947265625, 6.37841796875, 6.5595703125], "corpus_unchanged": true}
|
||||
{"phase": "renametrace", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "renametrace", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934290.497727, "load_before": [5.0947265625, 6.37841796875, 6.5595703125], "exit": 0, "end": 1788934366.829311, "load_after": [3.87353515625, 5.6357421875, 6.25439453125], "corpus_unchanged": true}
|
||||
{"phase": "scan", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "scan", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934366.928801, "load_before": [3.87353515625, 5.6357421875, 6.25439453125], "exit": 0, "end": 1788934439.322835, "load_after": [4.4677734375, 5.47900390625, 6.1455078125], "corpus_unchanged": true}
|
||||
{"phase": "scan", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "scan", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934439.4233239, "load_before": [4.4677734375, 5.47900390625, 6.1455078125], "exit": 0, "end": 1788934510.867989, "load_after": [4.39306640625, 5.193359375, 5.97998046875], "corpus_unchanged": true}
|
||||
{"phase": "rss", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "rss", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934510.962989, "load_before": [4.39306640625, 5.193359375, 5.97998046875], "exit": 0, "end": 1788934539.531492, "load_after": [4.2470703125, 5.0908203125, 5.91552734375], "corpus_unchanged": true}
|
||||
{"phase": "rss", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "rss", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934539.6351821, "load_before": [4.2470703125, 5.0908203125, 5.91552734375], "exit": 0, "end": 1788934568.203514, "load_after": [3.87060546875, 4.9208984375, 5.82470703125], "corpus_unchanged": true}
|
||||
{"phase": "scanloadprobe", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "scanloadprobe", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934568.3059351, "load_before": [3.87060546875, 4.9208984375, 5.82470703125], "exit": 0, "end": 1788934587.887279, "load_after": [4.56494140625, 4.99365234375, 5.82861328125], "corpus_unchanged": true}
|
||||
{"phase": "scanloadprobe", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "scanloadprobe", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934588.0167758, "load_before": [4.56494140625, 4.99365234375, 5.82861328125], "exit": 0, "end": 1788934604.39112, "load_after": [5.30078125, 5.13916015625, 5.86572265625], "corpus_unchanged": true}
|
||||
{"phase": "scanloadcross", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "scanloadcross", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934604.5086, "load_before": [5.30078125, 5.13916015625, 5.86572265625], "exit": 0, "end": 1788934698.6455839, "load_after": [4.8388671875, 4.93994140625, 5.70556640625], "corpus_unchanged": true}
|
||||
{"phase": "scanloadcross", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "scanloadcross", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934698.75788, "load_before": [4.8388671875, 4.93994140625, 5.70556640625], "exit": 0, "end": 1788934809.883633, "load_after": [4.57666015625, 4.986328125, 5.63720703125], "corpus_unchanged": true}
|
||||
{"phase": "refactor", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "refactor", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934809.995477, "load_before": [4.57666015625, 4.986328125, 5.63720703125], "exit": 0, "end": 1788934830.940748, "load_after": [4.8779296875, 5.0205078125, 5.63330078125], "corpus_unchanged": true}
|
||||
{"phase": "refactor", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "refactor", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934831.072156, "load_before": [4.8779296875, 5.0205078125, 5.63330078125], "exit": 0, "end": 1788934851.975531, "load_after": [5.02880859375, 5.0234375, 5.6142578125], "corpus_unchanged": true}
|
||||
{"phase": "execute", "label": "0.52.0-review", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "execute", "--server", "/Users/guoliangchen/repo/verilogrustformatter/target/release/lucisv-server", "--label", "0.52.0-review", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.52.0-review", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934852.0846488, "load_before": [5.02880859375, 5.0234375, 5.6142578125], "exit": 0, "end": 1788934863.005026, "load_after": [4.99853515625, 5.02099609375, 5.6064453125], "corpus_unchanged": true}
|
||||
{"phase": "execute", "label": "0.51.0-reference", "command": ["tools/guard.sh", "-m", "8", "-t", "1800", "--", "python3", "tools/perf/bench.py", "execute", "--server", "/tmp/lucisv-perf-review-20260909/reference/target/release/lucisv-server", "--label", "0.51.0-reference", "--opentitan", "/Users/guoliangchen/repo/opentitan", "--storage", "/tmp/lucisv-perf-review-20260909/caches/0.51.0-reference", "--out", "/tmp/lucisv-perf-review-20260909/results.jsonl", "--tries", "3"], "start": 1788934863.116577, "load_before": [4.99853515625, 5.02099609375, 5.6064453125], "exit": 0, "end": 1788934874.024811, "load_after": [5.1455078125, 5.052734375, 5.6103515625], "corpus_unchanged": true}
|
||||
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user