Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66f38987ac | ||
|
|
8145a67be6 | ||
|
|
f7956060b3 | ||
|
|
f302b471a7 | ||
|
|
7aedfe2554 |
No files matched your search
@@ -4,6 +4,31 @@ 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.44.0 — 2026-09-05
|
||||
|
||||
### Opening a file no longer stalls the editor
|
||||
|
||||
- **`undriven-net` asked the workspace census once per declaration**,
|
||||
ahead of the local guards that silence almost every one, so a
|
||||
`didOpen` — and every keystroke flush — of a large file paid a walk
|
||||
over every indexed file thousands of times. Asked last now, the way
|
||||
its twin `unused-signal` always did. Opening opentitan's 42 192-line
|
||||
`pinmux_reg_top.sv` at workspace scope: 1 742 ms → 117 ms; typical
|
||||
IP files 51–95 ms → 5–8 ms. Same findings in the same order.
|
||||
- **Walk warnings.** An unreadable directory, an unreadable `.gitignore`
|
||||
or a dangling source-file symlink no longer fails a run: the CLI
|
||||
prints `warning: <path>: <message>` on stderr before the report with
|
||||
the exit code unchanged, and the server logs once per scan.
|
||||
- **A typo in `lucisv.lint.select` or `ignore`** is logged once
|
||||
(`lucisv.lint.select: unknown rule: <name>`) instead of silently
|
||||
emptying the selection.
|
||||
- **Inline aggregate types as parameter-override arguments**
|
||||
(`m #(.T(struct packed { logic a; })) u ();`) parse, format and are
|
||||
emitted by the instantiation skeleton.
|
||||
- **Comment slots inside delay lists** (`#( /*a*/ 1 : 2 : 3 )`, gate
|
||||
`#(rise, fall)`), and a line comment after a gate instance's comma
|
||||
now ends the line.
|
||||
|
||||
## 0.43.0 — 2026-09-05
|
||||
|
||||
### The repository analysis's three findings
|
||||
|
||||
Generated
+8
-8
@@ -97,7 +97,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lucisv"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
dependencies = [
|
||||
"lucisv_core",
|
||||
"rayon",
|
||||
@@ -108,11 +108,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lucisv_core"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
|
||||
[[package]]
|
||||
name = "lucisv_server"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
dependencies = [
|
||||
"lsp-server",
|
||||
"lsp-types",
|
||||
@@ -248,14 +248,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "vlog_formatter"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
dependencies = [
|
||||
"vlog_parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vlog_linter"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
dependencies = [
|
||||
"lucisv_core",
|
||||
"vlog_formatter",
|
||||
@@ -265,11 +265,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vlog_parser"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
|
||||
[[package]]
|
||||
name = "vlog_refactor"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
dependencies = [
|
||||
"vlog_parser",
|
||||
"vlog_semantic",
|
||||
@@ -277,7 +277,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vlog_semantic"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
dependencies = [
|
||||
"vlog_parser",
|
||||
]
|
||||
+1
-1
@@ -12,7 +12,7 @@ members = [
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
authors = ["Guoliang Chen"]
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
@@ -451,13 +451,14 @@ later:
|
||||
`StmtKind::Error` leaves. Sync tokens, the four guarantees and the
|
||||
deliberate gaps (no tolerant *lexer*, no recovery inside headers or lists)
|
||||
in `docs/features/error-recovery/README.md`. `parse_source` unchanged.
|
||||
- [ ] **Keep the CST lossless.** Current design (trivia in `Meta`) is
|
||||
- [x] **Keep the CST lossless.** Current design (trivia in `Meta`) is
|
||||
format-oriented; verify every source byte is reachable from the tree
|
||||
(tokens + trivia + spans). A `reconstruct(tree) == input` round-trip test
|
||||
makes losslessness a tested invariant — this is what makes the same tree
|
||||
serve formatter, linter, and highlighter. If gaps appear, consider a
|
||||
rowan-style green tree (rust-analyzer / ruff direction) rather than
|
||||
patching `Meta`.
|
||||
**Ruled dropped by the owner, 2026-09-05:** the verifier is the invariant — token equivalence and convergence on every output byte-for-byte; the token-level half (`spans.rs`) stays.
|
||||
- [x] **New crate `vlog_semantic`** (analog of `ruff_python_semantic`):
|
||||
symbol tables per scope (module/package/function/block/generate), binding
|
||||
→ references. Serves go-to-definition/hover first, then semantic lint
|
||||
@@ -1321,8 +1322,9 @@ and three owner items. See
|
||||
`references`' one `Def` span (`includeDeclaration`) is converted in the
|
||||
same one-fetch batch as that file's reference sites — filed again
|
||||
there rather than silently dropped.
|
||||
- [ ] Manual extension-host acceptance (themes, keyboard-only, zoom,
|
||||
- [x] Manual extension-host acceptance (themes, keyboard-only, zoom,
|
||||
screen readers, an old server binary, both VSIX shapes).
|
||||
**Checklist prepared 2026-09-05** (`docs/manual-acceptance.md`); the owner runs it.
|
||||
|
||||
## 11. Testbench-syntax wave (2026-08-29) — syntax_coverage.md findings
|
||||
|
||||
@@ -4378,10 +4380,13 @@ pre-existing modified files stay as they are). Every run under
|
||||
item with a reproduction; anything faster is credited to the section
|
||||
that did it.
|
||||
|
||||
- [ ] server table re-measured, 0.43.0 vs take 2 vs 0.39.0
|
||||
- [ ] CLI sweeps, three binaries, RSS included
|
||||
- [ ] `docs/performance_take3.md` + perf README entry
|
||||
- [ ] opentitan status unchanged after every run
|
||||
- [x] server table re-measured, 0.43.0 vs take 2 vs 0.39.0 — `performance_take3.md`
|
||||
§2; 0.39.0 server built from the tag in a scratch worktree, removed after
|
||||
- [x] CLI sweeps, three binaries, RSS included — take 3 §7, five trees ×
|
||||
{`format --check` cold/warm, `check`, `check --select error,warning,style`}
|
||||
- [x] `docs/performance_take3.md` + perf README entry (2026-09-05)
|
||||
- [x] opentitan status unchanged after every run — only the three pre-existing
|
||||
modified files, checked after every phase; no guard kill (peak 249 MB of 8 GB)
|
||||
|
||||
## 41. Repository-analysis fix 1 (planned 2026-09-04) — same-target atomic writers (topo §2.9-26)
|
||||
|
||||
@@ -4541,3 +4546,252 @@ the new slot.
|
||||
take 3 on opentitan. The audit's own doc edits (README, topo, site) are
|
||||
committed by the lead as one "docs: repository analysis" commit once that
|
||||
process is finished, before §41 starts.
|
||||
|
||||
## 44. Candidates from performance take 3 (filed 2026-09-05, not planned)
|
||||
|
||||
`docs/performance_take3.md` re-measured 0.43.0 against take 2 and 0.39.0.
|
||||
The lazy code action is worth 11.8× on the cursor-move path and the
|
||||
default-scope `didOpen` is 1 731 → 1 082 ms cold; nothing else moved
|
||||
since 0.39.0. Two findings are real work and wait for the owner's call:
|
||||
|
||||
- [x] **Eager `codeAction` (a client without `resolveSupport`) is
|
||||
1.35–1.40× slower than take 2 at every fan-out** — **ruled a
|
||||
non-hot path by the owner, 2026-09-05**: VS Code, Neovim's client
|
||||
and Helix all resolve; documented, not bisected. — already so at
|
||||
0.39.0, so it landed in the §29–§35 window; not bisected. Bisect
|
||||
over `~/.cache/lucisv-baselines/` (0.35.0–0.39.0 CLI binaries exist;
|
||||
the server needs building per tag) and fix the regression, or rule
|
||||
that non-resolving clients are not a hot path (VS Code, Neovim's
|
||||
built-in client and Helix all resolve).
|
||||
- [x] **A `didOpen` of a file already in scope delays the next request by
|
||||
21–51 ms**, scaling with file size (take 2: 2–4 ms). The open, not
|
||||
the request. Find what the open now does synchronously that it did
|
||||
not (the §33+ diagnostics pass? the §37 lint run construction?) and
|
||||
move it off the request path or measure it as the price of the
|
||||
diagnostics the file gets. — done by §46 (0.44.0), and it was
|
||||
neither: the lint pass is 75–95 % of the open and the rule
|
||||
`undriven-net` is 90–97 % of the lint pass, because it asked the
|
||||
workspace census once per declaration in the buffer before its own
|
||||
local guards could silence it. Asked last now, as its twin rule
|
||||
`unused-signal` always has. 51/70/95 → 4.6/7.3/7.8 ms on the three
|
||||
files of take 3 §8.4; 1 742 → 117 ms on opentitan's 42 192-line
|
||||
`pinmux_reg_top.sv`. Not a regression — 0.39.0 measures the same.
|
||||
`docs/features/didopen-cost/README.md`.
|
||||
- Noted, not actioned: `lucisv check` 6–10 % slower than 0.39.0 on
|
||||
`hw/ip` (73 rules vs 54; per-rule cost flat), `workspace/symbol`
|
||||
drifting 6.6 → 7.9 ms over three takes, `rename` 115 → 152 ms with two
|
||||
more files edited (per-file flat).
|
||||
|
||||
## Loop 2 order (owner's rulings, 2026-09-05)
|
||||
|
||||
Asked as twelve questions and answered. Ruled out: the eager codeAction
|
||||
regression (non-hot path), the lossless-CST tree round trip (the verifier
|
||||
is the invariant). The owner runs the manual acceptance checklist. Everything
|
||||
else runs, one lane at a time in the main tree, dev Opus 5 → QA Sonnet 5 →
|
||||
lead, a release every two or three sections:
|
||||
|
||||
§45 small items round 4 (topo 29, 30, 17, 22) → §46 the didOpen delay →
|
||||
0.44.0 → §47 `DataType` spans, retire `scan.rs` (topo 2) → §48 package
|
||||
re-exports (topo 16) → §49 cross-file instance-member tail in rename
|
||||
(topo 23) → 0.45.0 → §50 `.*` expansion → §51 non-ANSI → ANSI ports →
|
||||
0.46.0 → §52 organize imports → §53 extract / inline module → 0.47.0 →
|
||||
§54 coverage gaps L3/L6/L10 → 0.48.0. Sections after §46 are planned when
|
||||
reached.
|
||||
|
||||
## 45. Small items, round 4 (planned 2026-09-05) — topo §2.9-29, 30, 17, 22
|
||||
|
||||
One lane, §36's protocol. Feature README:
|
||||
`docs/features/small-items-4/README.md`. Ships in 0.44.0 with §46.
|
||||
|
||||
### 45.1 The editor's unknown rule name is said once (topo 29)
|
||||
|
||||
`lucisv.lint.select`/`ignore` naming a rule the registry does not know is
|
||||
dropped silently (`named()` skips it); the same typo in `[lint] select` is
|
||||
now logged once (§42). Log the editor's the same way — through
|
||||
`server/notification.rs`, once per (setting, name), re-armed when the
|
||||
setting changes — with the message `lucisv.lint.select: unknown rule: <name>`
|
||||
(the shape `lucisv.lint.options` already uses for its bad entries). A
|
||||
`select` emptied by the dropping falls back to the project's list, then the
|
||||
base set — the §42 ladder unchanged. Tests: unit on the settings decode;
|
||||
wire-level: one log line across four diagnostics passes, re-armed by a
|
||||
`didChangeConfiguration` that changes the list.
|
||||
|
||||
### 45.2 A warning channel for the walk (topo 30)
|
||||
|
||||
`lucisv_core::walk::collect_files` returns `Vec<PathBuf>`; an unreadable
|
||||
directory propagates `read_dir`'s error and fails the run, and a dangling
|
||||
source link is handed on to fail later. Give the walk a channel:
|
||||
`collect_files` returns `Walked { files, warnings: Vec<Warning> }` where
|
||||
`Warning { path, message }` — or keeps its signature and takes a
|
||||
`&mut dyn FnMut(Warning)`; pick the one that keeps both callers a one-line
|
||||
change and say why. An unreadable directory is skipped with a warning and
|
||||
the walk continues; a dangling source-file link is warned about here and
|
||||
NOT handed on (that reverses §43's review ruling deliberately, because the
|
||||
warning is now the error's home). CLI: warnings go to stderr as
|
||||
`warning: <path>: <message>` before the report, exit code unchanged (a
|
||||
warning is not a failure; `--check` still returns 1/0 on formatting alone).
|
||||
Server: each warning logged once per scan through `notification.rs`.
|
||||
Tests: a read-only directory (0o000) under the start — the run finishes,
|
||||
the other files are reported, one warning names the directory; a dangling
|
||||
link; the CLI's stderr and exit code pinned in `tests/cli.rs`; the server's
|
||||
scan over the same tree logs once and indexes the rest. Byte-identity of
|
||||
every corpus file unchanged; the opentitan sweep outcome unchanged.
|
||||
|
||||
### 45.3 An inline aggregate as a parameter-override argument (topo 17)
|
||||
|
||||
`m #(.T(struct packed { logic a; })) u ();` is rejected in expression
|
||||
position. `parse_connection`'s value already goes through
|
||||
`parse_expr_or_type`; find why an aggregate type is not accepted there (a
|
||||
`struct`/`union`/`enum` keyword at the head of the value) and accept it as
|
||||
a type argument, printed by the existing type printer. Then M4's
|
||||
`instantiation_plan` no longer drops such a `parameter type` default — emit
|
||||
the type text. Tests: parse + format round-trip (struct, union, enum, with
|
||||
packed dims and a comment inside), the plan emits it, strict/tolerant
|
||||
parity, byte-identity.
|
||||
|
||||
### 45.4 Comment gaps inside a delay list (topo 22)
|
||||
|
||||
`#(1:2:3)` and gate delays `#(a, b)` go through `parse_delay_values`
|
||||
(`parser/instance.rs`); the gaps around the `(`, the `:`s and the `,`s have
|
||||
no comment slots, so the verifier refuses them. Add the slots the way §43.2
|
||||
added `NetDelay`'s (read `docs/features/comment-slots/README.md`), print
|
||||
them inline, and extend the RTL gap fuzzer fixture so its zero-failure bar
|
||||
covers the construct. Tests: every gap with a comment, idempotent,
|
||||
comments kept; the `EXPECTED_RTL_GAPS` count updated with the reason.
|
||||
|
||||
### Gates (dev, guarded)
|
||||
|
||||
fmt/clippy/`cargo test --workspace`; corpus 814/820 same six; byte-identity
|
||||
vs 0.43.0 (lead); the opentitan sweep unchanged (lead); smoke.
|
||||
|
||||
- [x] 45.1 editor unknown-name log
|
||||
- [x] 45.2 walk warning channel, both front ends
|
||||
- [x] 45.3 inline aggregate override argument + plan emission
|
||||
- [x] 45.4 delay-list comment slots + fuzzer coverage
|
||||
- [x] docs: feature README; topo 29/30/17/22 struck (lead)
|
||||
- [x] Gates (guarded)
|
||||
- [x] QA: each item attacked on both front ends; the walker warnings on a
|
||||
cyclic + unreadable tree; the aggregate shapes with comments; the
|
||||
delay gaps through the fuzzer — REWORK, one MEDIUM finding (a line
|
||||
comment trailing a gate instance separator, `format/instance.rs`;
|
||||
see `docs/features/small-items-4/README.md` QA log)
|
||||
|
||||
## 46. The didOpen delay (planned 2026-09-05) — take-3 finding §44b
|
||||
|
||||
One lane after §45. Feature README: `docs/features/didopen-cost/README.md`.
|
||||
Ships in 0.44.0.
|
||||
|
||||
Take 3 (`docs/performance_take3.md`): a `didOpen` of a file already in
|
||||
scope delays the NEXT request by 21–51 ms, scaling with file size, where
|
||||
take 2 measured 2–4 ms; a second request at the same position costs
|
||||
0.07–0.21 ms, so the open is what costs. The server is a synchronous loop:
|
||||
whatever `didOpen` does before returning to the loop is what the next
|
||||
request waits for.
|
||||
|
||||
- **Measure first.** Write a scratch driver (framed JSON-RPC; take 3's
|
||||
method, §9 of that doc) and time `didOpen` → first `hover` on opentitan's
|
||||
`aes.sv`, `aes_core.sv` and the 42k-line `tl_peri_pkg.sv`-class file, at
|
||||
0.43.0 and at 0.39.0 (server built from the tag in a scratch worktree,
|
||||
removed after). Then profile the open path with the shipped `--verbose`
|
||||
timings (no instrumentation added) or with temporary `eprintln!` timings
|
||||
removed before finishing: what runs synchronously — the tolerant parse,
|
||||
the diagnostics pass (lint run construction from §42: discovery, waiver
|
||||
files, the once-only memo), semantic tokens, the index update of the
|
||||
buffer, the completion word table patch?
|
||||
- **Fix the largest item, not all of them.** Likely shapes: publish the
|
||||
open's diagnostics from the same debounce `didChange` uses instead of
|
||||
synchronously; skip re-indexing a buffer whose text equals the disk facts
|
||||
the index already holds (content hash); build the `LintRun` lazily.
|
||||
Whatever it is, the contract is: `didOpen` returns to the loop in
|
||||
≤ 5 ms for a 1k-line file, and the first request after it is answered
|
||||
from up-to-date state (diagnostics may arrive a debounce later — say
|
||||
which and pin it).
|
||||
- Tests: a wire-level test timing `didOpen` → next response on a generated
|
||||
2k-line file (an upper bound, generous enough for CI: ≤ 25 ms where
|
||||
today is ~50); correctness pins that the first hover/definition after an
|
||||
open of an edited-on-disk file sees the buffer's text; the take-3 rows
|
||||
re-measured in the README.
|
||||
|
||||
- [x] measurement + profile, in the README — and the finding understated it:
|
||||
`pinmux_reg_top.sv` (42 192 lines) delayed the next request by **1 742
|
||||
ms**, of which 1 608 was the one rule `undriven-net` asking the
|
||||
workspace census once per declaration ahead of its own local guards
|
||||
- [x] the fix, with the ≤ 5 ms return contract pinned — the census question
|
||||
moved behind the guards, where `unused-signal` has always asked. Met
|
||||
for a generated 1 000-line buffer (<2 ms); 5.9–6.9 ms for
|
||||
`aes_core.sv`, 1 145 lines of dense RTL whose 3.0–4.4 ms of parse
|
||||
cannot be deferred without answering the next request from stale
|
||||
state. Recorded as the limit in the README, not redefined
|
||||
- [x] docs; §44b ticked; take-3 finding 2 annotated — the annotation text and
|
||||
a `docs/perf/README.md` entry are in the feature README under "Docs to
|
||||
apply at merge (lead)"
|
||||
- [x] Gates (guarded); the take-3 rows re-measured — 3 814 tests (was 3 810),
|
||||
corpus 814/820 same six, clippy and fmt clean, smoke OK; §8.4's three
|
||||
files 51/70/95 ms → 4.6/7.3/7.8 ms
|
||||
- [x] QA: the driver re-run on the three files at three sizes; the
|
||||
diagnostics still arrive; no request answered from stale state —
|
||||
PASS, independently re-derived on a new driver: 0.43.0 vs fixed
|
||||
3.4×/11×/17× on aes.sv/aes_core.sv/pinmux_reg_top.sv; opentitan
|
||||
`hw/ip/{aes,hmac,spi_device}` and
|
||||
`hw/top_darjeeling/ip_autogen/pinmux` byte-identical; counting-oracle
|
||||
test confirmed to fail on a hand-reverted scratch copy; gates
|
||||
reproduced (3814/0/44, corpus 814/820, clippy/smoke clean); QA log
|
||||
in `docs/features/didopen-cost/README.md`
|
||||
|
||||
## 47. Type-name spans on the AST; retire `vlog_semantic/src/scan.rs` (planned 2026-09-05) — topo §2.9-2
|
||||
|
||||
One lane after 0.44.0, §36's protocol. Feature README:
|
||||
`docs/features/type-name-spans/README.md`. Ships in 0.45.0 with §48/§49.
|
||||
|
||||
`vlog_semantic/src/scan.rs` (193 lines) recovers the byte range of a name
|
||||
the AST kept only as a `String` by scanning the construct's source text.
|
||||
Its two remaining users, both in `bind/`: `bind/decl.rs` (the type name of
|
||||
a declaration — `DataType::name`, split as `pkg::item` into unit and item
|
||||
spans by `NameScanner`, or as `iface.modport` into head and tail) and
|
||||
`bind/stmt.rs` (`disable <label>`). Every other name already has
|
||||
`name_span` on its node (`src[name_span] == name` is pinned over the corpus
|
||||
census, 21 485 symbols).
|
||||
|
||||
- **`DataType::name_span: TextRange`** — the range of the name exactly as
|
||||
written, so `src[name_span]` is `pkg::item` (with an escaped segment's
|
||||
trailing space, §29) or `iface.mp`. Set by every site that builds a
|
||||
`DataType` (`parse_type_ref`, the implicit/`logic` cases — for an
|
||||
implicit type with no written name, the empty range at the position the
|
||||
name would have had, the convention `name_span` already uses for the
|
||||
unnamed-DPI-formal case, decl.rs:436). Segment spans are derived from
|
||||
`name_span` alone — split the *span's own text* on `::`/`.`, never
|
||||
rescan the construct — in one helper `DataType::segments() ->
|
||||
impl Iterator<Item = (&str, TextRange)>`.
|
||||
- **Size.** `DataType` rides in every `Expr` through `ExprKind::Type`;
|
||||
`size_pins` holds `Expr ≤ 96`. Measure before and after; if the 8 bytes
|
||||
push `Expr` over, move `name_span` into the already-boxed `TypeExtra`
|
||||
(making `extra` `Some` whenever a name is written) or box — say which
|
||||
and why; the pin does not move.
|
||||
- **`StmtKind::Disable`** (and any other statement that names a label or
|
||||
identifier as a bare `String` — grep `scan::` and `String` names in
|
||||
`ast/stmt.rs`) gains `name_span` the same way.
|
||||
- **Delete `scan.rs`**, its `mod`, and the `src` parameter the README's
|
||||
Handshakes say goes with it if nothing else reads it; the binder reads
|
||||
the spans. `vlog_semantic/README.md` and `docs/features/vlog-semantic/README.md`
|
||||
Handshakes updated (delivered).
|
||||
- **Consumers that benefit:** hover/definition/references on a type name
|
||||
(`nav.rs`, `hover.rs`) — nothing to change if they already go through
|
||||
`Reference::name_span`; confirm, and add a test that definition on
|
||||
`pkg::t` in a declaration lands on `t`'s declaration with the *item*
|
||||
range selected, and on `bus_if.mp` on the interface with the head range.
|
||||
- Pins: the corpus census assertion `src[name_span] == name` now covers
|
||||
type-name references too (extend `tests/census.rs` or the semantic
|
||||
corpus test that holds the 21 485 number — report the new count);
|
||||
strict/tolerant parity; byte-identity of every corpus file (the
|
||||
formatter does not print spans); `cargo test --workspace`; opentitan
|
||||
sweep unchanged; a before/after of `definition` on 200 type-name
|
||||
positions over opentitan (read-only) to show nothing regressed.
|
||||
|
||||
- [ ] 47.1 `DataType::name_span` + `segments()`, size ruled
|
||||
- [ ] 47.2 `StmtKind::Disable` name span
|
||||
- [ ] 47.3 `scan.rs` deleted; binder reads spans; census pin extended
|
||||
- [ ] docs: feature README; topo §2.9-2 struck (lead); semantic READMEs
|
||||
- [ ] Gates (guarded)
|
||||
- [ ] QA: census re-derived; escaped and scoped type names; `iface.mp`
|
||||
ports; implicit types; definition/hover on type names over
|
||||
opentitan (read-only)
|
||||
@@ -366,7 +366,12 @@ fn gather(opts: &Options) -> Result<Vec<(PathBuf, Config, FileConfig)>, String>
|
||||
return Err(format!("--lines needs a file, not a directory: {input}"));
|
||||
}
|
||||
let exclude = opts.exclude_with(&discovery.for_input(Path::new(input))?);
|
||||
collect_files(input, &exclude, !opts.no_gitignore, &mut files)?;
|
||||
// The walk's own warnings — an unreadable directory, a source file
|
||||
// that is only a broken link — go to stderr as they are found, before
|
||||
// the report and exactly as a filelist's do. A warning is not a
|
||||
// failure: the exit code is the formatting's alone.
|
||||
let mut warn = |w| eprintln!("warning: {w}");
|
||||
collect_files(input, &exclude, !opts.no_gitignore, &mut files, &mut warn)?;
|
||||
}
|
||||
// Filelists come after the command line's own inputs, in flag order: they
|
||||
// add files, they never replace or reorder what was named directly.
|
||||
|
||||
@@ -2146,3 +2146,88 @@ fn rules_doc_refuses_files_and_belongs_to_check() {
|
||||
stderr(&out)
|
||||
);
|
||||
}
|
||||
|
||||
// --- the walk's own warnings (docs/features/small-items-4/README.md) -------
|
||||
|
||||
/// A tree with the two things the walk can only warn about: a directory it
|
||||
/// cannot read, and a source file that is only a broken link.
|
||||
#[cfg(unix)]
|
||||
fn unwalkable_tree(tag: &str) -> TempDir {
|
||||
use std::os::unix::fs::{symlink, PermissionsExt};
|
||||
let dir = TempDir::new(tag);
|
||||
dir.write("a.sv", UNFORMATTED);
|
||||
dir.write("z/late.sv", UNFORMATTED);
|
||||
dir.write("locked/hidden.sv", UNFORMATTED);
|
||||
symlink("nowhere.sv", dir.path.join("gone.sv")).expect("symlink");
|
||||
std::fs::set_permissions(dir.path.join("locked"), std::fs::Permissions::from_mode(0o000))
|
||||
.expect("chmod");
|
||||
dir
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn lock(dir: &TempDir) {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
std::fs::set_permissions(dir.path.join("locked"), std::fs::Permissions::from_mode(0o000))
|
||||
.expect("chmod");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn unlock(dir: &TempDir) {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let _ =
|
||||
std::fs::set_permissions(dir.path.join("locked"), std::fs::Permissions::from_mode(0o755));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_directory_is_a_warning_and_the_rest_of_the_tree_is_formatted() {
|
||||
// The finding TODO §45.2 closes: one permission-denied directory used to
|
||||
// propagate `read_dir`'s error and fail the whole run.
|
||||
let dir = unwalkable_tree("walk-warn");
|
||||
let out = run(&[&dir.root()]);
|
||||
unlock(&dir);
|
||||
|
||||
assert_eq!(code(&out), 0, "a warning is not a failure: {}", stderr(&out));
|
||||
let said = stderr(&out);
|
||||
assert_eq!(said.matches("warning: ").count(), 2, "{said}");
|
||||
assert!(said.contains("locked"), "{said}");
|
||||
assert!(said.contains("gone.sv: broken symbolic link"), "{said}");
|
||||
assert_eq!(dir.read("a.sv"), FORMATTED, "the other files were formatted");
|
||||
assert_eq!(dir.read("z/late.sv"), FORMATTED, "including the ones sorted after it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn the_walks_warnings_leave_check_modes_exit_code_alone() {
|
||||
let dir = unwalkable_tree("walk-warn-check");
|
||||
let out = run(&["--check", &dir.root()]);
|
||||
unlock(&dir);
|
||||
|
||||
// `--check` answers on formatting alone: two files would be reformatted.
|
||||
assert_eq!(code(&out), 1, "{}", stderr(&out));
|
||||
assert_eq!(stderr(&out).matches("warning: ").count(), 2, "{}", stderr(&out));
|
||||
assert!(!stdout(&out).contains("warning"), "warnings stay off stdout: {}", stdout(&out));
|
||||
|
||||
// And with nothing left to reformat the run is clean, warnings and all.
|
||||
dir.write("a.sv", FORMATTED);
|
||||
dir.write("z/late.sv", FORMATTED);
|
||||
lock(&dir);
|
||||
let out = run(&["--check", &dir.root()]);
|
||||
unlock(&dir);
|
||||
assert_eq!(code(&out), 0, "{}", stderr(&out));
|
||||
assert_eq!(stderr(&out).matches("warning: ").count(), 2, "{}", stderr(&out));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_dangling_source_link_named_on_the_command_line_is_still_an_error() {
|
||||
// The walk drops the link; a path the user typed is not walked at all, so
|
||||
// "no such file or directory" is still what naming one gets.
|
||||
let dir = TempDir::new("walk-warn-named");
|
||||
std::os::unix::fs::symlink("nowhere.sv", dir.path.join("gone.sv")).expect("symlink");
|
||||
let named = dir.path.join("gone.sv").to_string_lossy().into_owned();
|
||||
|
||||
let out = run(&[&named]);
|
||||
assert_eq!(code(&out), 2, "{}", stderr(&out));
|
||||
assert!(stderr(&out).contains("no such file or directory"), "{}", stderr(&out));
|
||||
}
|
||||
+187
-33
@@ -11,15 +11,43 @@ pub const EXTENSIONS: &[&str] = &["v", "sv", "vh", "svh"];
|
||||
/// The name of the per-directory ignore file that is honoured by default.
|
||||
const GITIGNORE: &str = ".gitignore";
|
||||
|
||||
/// Something the walk could not do and went on regardless: a directory it
|
||||
/// could not read, an ignore file it could not open, a source file that is
|
||||
/// only a broken link.
|
||||
///
|
||||
/// The walk's warning channel exists because none of these is worth failing a
|
||||
/// run over — one unreadable directory used to drop every file already found
|
||||
/// — and because a silent skip loses the user the fact entirely. Rendering is
|
||||
/// the front end's job: the CLI writes `warning: <path>: <message>` to stderr,
|
||||
/// the server logs the same text once per scan.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Warning {
|
||||
/// What could not be used.
|
||||
pub path: PathBuf,
|
||||
/// Why, in the operating system's own words where there are any.
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Warning {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}: {}", self.path.display(), self.message)
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds `input` to `files`: the file itself, or every Verilog file under
|
||||
/// it if it is a directory. Exclude patterns and `.gitignore` rules apply
|
||||
/// to directory walks only — a path named on the command line is always
|
||||
/// formatted.
|
||||
///
|
||||
/// `warn` is called once for everything the walk skipped and wants said; see
|
||||
/// [`Warning`]. Only `input` itself naming nothing is an error — that is the
|
||||
/// user's own typo, and the run has nothing to do.
|
||||
pub fn collect_files(
|
||||
input: &str,
|
||||
exclude: &[String],
|
||||
gitignore: bool,
|
||||
files: &mut Vec<PathBuf>,
|
||||
warn: &mut dyn FnMut(Warning),
|
||||
) -> Result<(), String> {
|
||||
let path = Path::new(input);
|
||||
if path.is_dir() {
|
||||
@@ -30,8 +58,9 @@ pub fn collect_files(
|
||||
rel: Vec::new(),
|
||||
visited: HashSet::new(),
|
||||
files,
|
||||
warn,
|
||||
};
|
||||
walk.dir(path).map_err(|e| format!("{input}: {e}"))?;
|
||||
walk.dir(path);
|
||||
} else if path.is_file() {
|
||||
files.push(path.to_path_buf());
|
||||
} else {
|
||||
@@ -82,15 +111,37 @@ struct Walk<'a> {
|
||||
rel: Vec<String>,
|
||||
visited: HashSet<DirId>,
|
||||
files: &'a mut Vec<PathBuf>,
|
||||
warn: &'a mut dyn FnMut(Warning),
|
||||
}
|
||||
|
||||
impl Walk<'_> {
|
||||
fn dir(&mut self, dir: &Path) -> std::io::Result<()> {
|
||||
fn dir(&mut self, dir: &Path) {
|
||||
if !self.enter(dir) {
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
let pushed = self.push_ignore(dir);
|
||||
self.entries(dir);
|
||||
if pushed {
|
||||
self.ignores.pop();
|
||||
}
|
||||
}
|
||||
|
||||
/// One directory's entries, in name order. A directory that cannot be read
|
||||
/// — the permission-denied one somewhere under the start — is said and
|
||||
/// skipped: everything already found stays found and the walk goes on,
|
||||
/// which is the whole reason this channel exists.
|
||||
fn entries(&mut self, dir: &Path) {
|
||||
let read = match std::fs::read_dir(dir) {
|
||||
Ok(read) => read,
|
||||
Err(e) => return self.say(dir, e.to_string()),
|
||||
};
|
||||
let mut entries = Vec::new();
|
||||
for entry in read {
|
||||
match entry {
|
||||
Ok(entry) => entries.push(entry),
|
||||
Err(e) => self.say(dir, e.to_string()),
|
||||
}
|
||||
}
|
||||
let pushed = self.push_ignore(dir)?;
|
||||
let mut entries: Vec<_> = std::fs::read_dir(dir)?.collect::<Result<_, _>>()?;
|
||||
entries.sort_by_key(|e| e.path());
|
||||
for entry in entries {
|
||||
let path = entry.path();
|
||||
@@ -100,31 +151,34 @@ impl Walk<'_> {
|
||||
// One `metadata` call per entry, exactly as before — it follows
|
||||
// symlinks, so it answers "directory?" for a symlinked directory
|
||||
// the way `is_dir()` did. A dangling symlink has no metadata at
|
||||
// all. One that *names a source file* is still handed on, so the
|
||||
// front end reports "no such file" for it as it always has (§43's
|
||||
// QA: a silent skip loses the user an error they had); one that
|
||||
// names anything else is neither a directory to walk nor a file
|
||||
// to read, and is skipped.
|
||||
// all. One that *names a source file* is warned about and dropped:
|
||||
// §43's QA was right that a silent skip loses the user the fact,
|
||||
// and §45.2 gives that fact a home of its own rather than handing
|
||||
// the path on to fail as "no such file" in the front end. One that
|
||||
// names anything else was never going to be read, and is skipped
|
||||
// as quietly as it always was.
|
||||
let Ok(meta) = std::fs::metadata(&path) else {
|
||||
if is_source(&path) {
|
||||
self.files.push(path);
|
||||
let why = broken_link_reason(&path);
|
||||
self.say(&path, why);
|
||||
}
|
||||
continue;
|
||||
};
|
||||
self.rel.push(entry.file_name().to_string_lossy().into_owned());
|
||||
if !is_ignored(&self.ignores, &self.rel, meta.is_dir()) {
|
||||
if meta.is_dir() {
|
||||
self.dir(&path)?;
|
||||
self.dir(&path);
|
||||
} else if meta.is_file() && is_source(&path) {
|
||||
self.files.push(path);
|
||||
}
|
||||
}
|
||||
self.rel.pop();
|
||||
}
|
||||
if pushed {
|
||||
self.ignores.pop();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Hand one warning to the front end.
|
||||
fn say(&mut self, path: &Path, message: String) {
|
||||
(self.warn)(Warning { path: path.to_path_buf(), message });
|
||||
}
|
||||
|
||||
/// Records `dir` as entered, and answers whether it had not been entered
|
||||
@@ -143,14 +197,38 @@ impl Walk<'_> {
|
||||
|
||||
/// Reads `dir`'s `.gitignore`, if there is one, onto the rule stack.
|
||||
/// Returns whether anything was pushed, so `dir` can pop it again.
|
||||
fn push_ignore(&mut self, dir: &Path) -> std::io::Result<bool> {
|
||||
///
|
||||
/// An ignore file that cannot be read is said and ignored, for the same
|
||||
/// reason an unreadable directory is: the walk that finds too much is a
|
||||
/// better failure than the walk that finds nothing.
|
||||
fn push_ignore(&mut self, dir: &Path) -> bool {
|
||||
let path = dir.join(GITIGNORE);
|
||||
if !self.gitignore || !path.is_file() {
|
||||
return Ok(false);
|
||||
return false;
|
||||
}
|
||||
let rules = parse_gitignore(&std::fs::read_to_string(&path)?);
|
||||
self.ignores.push(Ignore { base: self.rel.len(), rules });
|
||||
Ok(true)
|
||||
match std::fs::read_to_string(&path) {
|
||||
Ok(text) => {
|
||||
self.ignores.push(Ignore { base: self.rel.len(), rules: parse_gitignore(&text) });
|
||||
true
|
||||
}
|
||||
Err(e) => {
|
||||
self.say(&path, e.to_string());
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Why a directory entry has no metadata, said the way a person would.
|
||||
///
|
||||
/// A broken symbolic link is what this is nearly always about, and naming it
|
||||
/// as one is worth more than the bare `No such file or directory` the follow
|
||||
/// produced; anything else keeps the operating system's own words.
|
||||
fn broken_link_reason(path: &Path) -> String {
|
||||
match std::fs::symlink_metadata(path) {
|
||||
Ok(meta) if meta.file_type().is_symlink() => "broken symbolic link".to_string(),
|
||||
Ok(_) => "cannot be read".to_string(),
|
||||
Err(e) => e.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +509,16 @@ mod tests {
|
||||
self.write(rel, "module m;\nendmodule\n");
|
||||
}
|
||||
|
||||
/// Set `rel`'s permission bits. `0o000` is how a test builds the
|
||||
/// directory the walk cannot read; the test puts them back so the
|
||||
/// temp tree can be removed.
|
||||
fn chmod(&self, rel: &str, mode: u32) {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let path = self.path.join(rel);
|
||||
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(mode))
|
||||
.expect("set permissions");
|
||||
}
|
||||
|
||||
/// `rel` as a symlink to `target`, which is relative to `rel`'s own
|
||||
/// directory — the spelling a checked-in symlink actually uses.
|
||||
fn link(&self, rel: &str, target: &str) {
|
||||
@@ -442,18 +530,38 @@ mod tests {
|
||||
}
|
||||
|
||||
/// The walk from `rel` (empty for the root), as sorted paths
|
||||
/// relative to the tree root.
|
||||
/// relative to the tree root. Warnings are dropped; the tests that
|
||||
/// care about them call [`TempTree::warned`].
|
||||
fn walk(&self, rel: &str) -> Vec<String> {
|
||||
self.walked(rel).0
|
||||
}
|
||||
|
||||
/// The same, plus what the walk said, each warning's path made
|
||||
/// relative to the tree root so the assertions read.
|
||||
fn warned(&self, rel: &str) -> (Vec<String>, Vec<String>) {
|
||||
self.walked(rel)
|
||||
}
|
||||
|
||||
fn walked(&self, rel: &str) -> (Vec<String>, Vec<String>) {
|
||||
let start = if rel.is_empty() { self.path.clone() } else { self.path.join(rel) };
|
||||
let mut files = Vec::new();
|
||||
collect_files(start.to_str().expect("utf-8 temp path"), &[], true, &mut files)
|
||||
.expect("the walk finishes");
|
||||
let mut out: Vec<String> = files
|
||||
.iter()
|
||||
.map(|p| p.strip_prefix(&self.path).unwrap_or(p).to_string_lossy().into_owned())
|
||||
.collect();
|
||||
let mut warnings = Vec::new();
|
||||
collect_files(
|
||||
start.to_str().expect("utf-8 temp path"),
|
||||
&[],
|
||||
true,
|
||||
&mut files,
|
||||
&mut |w| warnings.push(format!("{}: {}", self.rel_of(&w.path), w.message)),
|
||||
)
|
||||
.expect("the walk finishes");
|
||||
let mut out: Vec<String> = files.iter().map(|p| self.rel_of(p)).collect();
|
||||
out.sort();
|
||||
out
|
||||
warnings.sort();
|
||||
(out, warnings)
|
||||
}
|
||||
|
||||
fn rel_of(&self, path: &Path) -> String {
|
||||
path.strip_prefix(&self.path).unwrap_or(path).to_string_lossy().into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,14 +613,60 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_dangling_directory_link_is_skipped_and_a_dangling_source_link_is_reported() {
|
||||
// The directory link cannot be entered; the source-file link is kept
|
||||
// so the front end's "no such file" error survives (0.42.0 parity).
|
||||
fn a_dangling_source_link_is_warned_about_and_not_handed_on() {
|
||||
// §43's review kept the dangling source link in the file list so the
|
||||
// front end's "no such file" error survived. TODO §45.2 reverses that
|
||||
// on purpose: the warning is now the error's home, so the link is said
|
||||
// once here and never reaches the formatter. A dangling link that
|
||||
// names no source file was never going to be read and stays silent.
|
||||
let tree = TempTree::new("dangling");
|
||||
tree.source("a/x.sv");
|
||||
tree.link("a/gone.sv", "nowhere.sv");
|
||||
tree.link("a/gonedir", "nowhere");
|
||||
assert_eq!(tree.walk(""), ["a/gone.sv", "a/x.sv"]);
|
||||
let (files, warnings) = tree.warned("");
|
||||
assert_eq!(files, ["a/x.sv"]);
|
||||
assert_eq!(warnings, ["a/gone.sv: broken symbolic link"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_directory_is_skipped_and_the_walk_goes_on() {
|
||||
// The finding this channel exists for: one permission-denied directory
|
||||
// used to propagate `read_dir`'s error out of the whole walk, dropping
|
||||
// every file already found and failing the run.
|
||||
let tree = TempTree::new("unreadable");
|
||||
tree.source("a.sv");
|
||||
tree.source("locked/hidden.sv");
|
||||
tree.source("z/late.sv");
|
||||
tree.chmod("locked", 0o000);
|
||||
let (files, warnings) = tree.warned("");
|
||||
tree.chmod("locked", 0o755);
|
||||
assert_eq!(files, ["a.sv", "z/late.sv"], "the walk finished");
|
||||
assert_eq!(warnings.len(), 1, "{warnings:?}");
|
||||
assert!(warnings[0].starts_with("locked: "), "the warning names it: {warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_ignore_file_is_said_and_the_directory_is_still_walked() {
|
||||
let tree = TempTree::new("lockedignore");
|
||||
tree.write(".gitignore", "build\n");
|
||||
tree.source("keep.sv");
|
||||
tree.chmod(".gitignore", 0o000);
|
||||
let (files, warnings) = tree.warned("");
|
||||
tree.chmod(".gitignore", 0o644);
|
||||
assert_eq!(files, ["keep.sv"]);
|
||||
assert_eq!(warnings.len(), 1, "{warnings:?}");
|
||||
assert!(warnings[0].starts_with(".gitignore: "), "{warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_clean_walk_says_nothing() {
|
||||
let tree = TempTree::new("quiet");
|
||||
tree.source("a/x.sv");
|
||||
tree.source("b/y.sv");
|
||||
assert_eq!(tree.warned(""), (vec!["a/x.sv".to_string(), "b/y.sv".to_string()], Vec::new()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -127,6 +127,13 @@ pub struct Server {
|
||||
/// open buffers — and the memo is the one thing a pass has to write.
|
||||
/// Nothing is called while it is borrowed.
|
||||
lint_config_problems: std::cell::RefCell<crate::lint::ProblemLog>,
|
||||
/// The unknown-rule-name lines already logged for the **editor's**
|
||||
/// `lucisv.lint.select`/`ignore` (§45.1), exactly as the last settings
|
||||
/// value produced them. A client that re-pushes the same section — VS Code
|
||||
/// does, whenever anything in it changes — says nothing again; a list the
|
||||
/// user edited re-arms every name that is new to it. The project file's
|
||||
/// twin memo is `lint_config_problems` above.
|
||||
said_lint_names: Vec<String>,
|
||||
abilities: ClientAbilities,
|
||||
/// The id of the file-watcher registration in force, if any. Kept so a
|
||||
/// changed `lucisv.filelist` can replace it: the watched filelist path is
|
||||
@@ -307,6 +314,7 @@ impl Server {
|
||||
workspace: Workspace::default(),
|
||||
config_warnings: HashSet::new(),
|
||||
lint_config_problems: std::cell::RefCell::default(),
|
||||
said_lint_names: Vec::new(),
|
||||
abilities,
|
||||
watchers: None,
|
||||
registrations: 0,
|
||||
|
||||
@@ -259,6 +259,23 @@ impl Server {
|
||||
},
|
||||
);
|
||||
}
|
||||
// A name in `lucisv.lint.select`/`ignore` the registry does not know is
|
||||
// dropped just as silently, and the same typo in a `lucisv.toml`'s
|
||||
// `[lint] select` has been said since §42. Said here too — but **once**
|
||||
// per (setting, name): unlike the options warnings above, which cost a
|
||||
// line each time the setting arrives, a client that re-pushes its whole
|
||||
// section on every keystroke must not repeat these. A list the user
|
||||
// edited re-arms whatever is new in it. See §2.9-29.
|
||||
for warning in unsaid(&settings.lint_name_warnings, &self.said_lint_names) {
|
||||
self.notify(
|
||||
LogMessage::METHOD,
|
||||
LogMessageParams {
|
||||
typ: MessageType::WARNING,
|
||||
message: format!("lucisv: {warning}"),
|
||||
},
|
||||
);
|
||||
}
|
||||
self.said_lint_names.clone_from(&settings.lint_name_warnings);
|
||||
// And the same for `lucisv.lint.waivers`: a file that is not there, or
|
||||
// a directive that does not parse, is dropped and said once — here,
|
||||
// where the setting arrives, rather than on every keystroke from the
|
||||
@@ -356,3 +373,13 @@ fn waiver_problems(
|
||||
let paths = lint::waiver_paths(settings, roots, &lucisv_core::config::FileConfig::default());
|
||||
lint::external_waivers(&paths).1
|
||||
}
|
||||
|
||||
/// The lines of `warnings` that `said` does not already hold, in order.
|
||||
///
|
||||
/// The whole of §45.1's "once": the memo is the previous settings value's own
|
||||
/// warning list, so re-pushing a section says nothing and editing the list
|
||||
/// says exactly what is new in it. Both lists are a handful of entries at
|
||||
/// most — one per typo — so a scan is cheaper than a set.
|
||||
fn unsaid<'a>(warnings: &'a [String], said: &[String]) -> Vec<&'a String> {
|
||||
warnings.iter().filter(|w| !said.contains(w)).collect()
|
||||
}
|
||||
@@ -408,3 +408,95 @@ fn an_answer_to_a_request_the_server_never_tracked_is_silently_ignored() {
|
||||
session.answer(RequestId::from("never-sent".to_string()), serde_json::json!([{ "indent": 2 }]));
|
||||
assert_eq!(session.server.workspace.client_settings().indent, Some(4));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// the editor's unknown rule name (TODO §45.1, docs/topo.md §2.9-29)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/// A `didChangeConfiguration` push with the given `lucisv.lint` section.
|
||||
fn push_lint(session: &mut Session, lint: Value) {
|
||||
session.notify(
|
||||
DidChangeConfiguration::METHOD,
|
||||
serde_json::json!({ "settings": { "lucisv": { "lint": lint } } }),
|
||||
);
|
||||
}
|
||||
|
||||
/// The unknown-rule lines the server logged since the last drain.
|
||||
fn unknown_rule_lines(session: &Session) -> Vec<String> {
|
||||
session
|
||||
.logged()
|
||||
.into_iter()
|
||||
.map(|(_, message)| message)
|
||||
.filter(|message| message.contains("unknown rule"))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_rule_name_in_the_editors_select_is_logged_once() {
|
||||
let tree = Tree::new("unknownrule");
|
||||
tree.write("m.sv", "module m;\nendmodule\n");
|
||||
let mut session = Session::new(vec![tree.path.clone()], false);
|
||||
let uri = session.open(&tree.path.join("m.sv"), "module m;\nendmodule\n");
|
||||
let _ = session.drain();
|
||||
|
||||
push_lint(&mut session, serde_json::json!({ "select": ["no-tabs", "no-tab"] }));
|
||||
assert_eq!(
|
||||
unknown_rule_lines(&session),
|
||||
["lucisv: lucisv.lint.select: unknown rule: no-tab"],
|
||||
"said once, naming the list and the name"
|
||||
);
|
||||
|
||||
// Four diagnostics passes later it has not been said again: the pass runs
|
||||
// on every keystroke and the log is not a place to shout from.
|
||||
for _ in 0..4 {
|
||||
session.server.publish(&uri);
|
||||
}
|
||||
assert!(unknown_rule_lines(&session).is_empty(), "not repeated by a diagnostics pass");
|
||||
|
||||
// Nor by the same section arriving again, which is what VS Code sends
|
||||
// whenever anything at all in it changes.
|
||||
push_lint(&mut session, serde_json::json!({ "select": ["no-tabs", "no-tab"] }));
|
||||
assert!(unknown_rule_lines(&session).is_empty(), "not repeated by an identical push");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_changed_list_re_arms_the_log() {
|
||||
let tree = Tree::new("unknownrulearm");
|
||||
let mut session = Session::new(vec![tree.path.clone()], false);
|
||||
let _ = session.drain();
|
||||
|
||||
push_lint(&mut session, serde_json::json!({ "select": ["no-tab"] }));
|
||||
assert_eq!(unknown_rule_lines(&session).len(), 1);
|
||||
|
||||
// A second typo added to the list is new, and is said; the first is not.
|
||||
push_lint(&mut session, serde_json::json!({ "select": ["no-tab", "nope"] }));
|
||||
assert_eq!(
|
||||
unknown_rule_lines(&session),
|
||||
["lucisv: lucisv.lint.select: unknown rule: nope"],
|
||||
"only what is new in the list"
|
||||
);
|
||||
|
||||
// Cleared and re-typed: the memo is the previous value, so it is armed
|
||||
// again.
|
||||
push_lint(&mut session, serde_json::json!({ "select": [] }));
|
||||
assert!(unknown_rule_lines(&session).is_empty(), "an empty list has nothing to say");
|
||||
push_lint(&mut session, serde_json::json!({ "select": ["no-tab"] }));
|
||||
assert_eq!(unknown_rule_lines(&session).len(), 1, "re-armed by the change");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_select_emptied_by_the_dropping_falls_through_the_ladder_unchanged() {
|
||||
// §42's ladder: a `select` that named nothing the registry knows is an
|
||||
// empty `select`, which is no opinion at all — the project's list, then
|
||||
// the base set. The log line is the whole of what §45.1 changed.
|
||||
let tree = Tree::new("unknownruleladder");
|
||||
let mut session = Session::new(vec![tree.path.clone()], false);
|
||||
let base = settings::lint_selection(session.server.workspace.client_settings());
|
||||
let _ = session.drain();
|
||||
|
||||
push_lint(&mut session, serde_json::json!({ "select": ["no-tab", "nope"] }));
|
||||
assert_eq!(unknown_rule_lines(&session).len(), 2, "both names said");
|
||||
let now = session.server.workspace.client_settings();
|
||||
assert!(now.lint_select.is_empty(), "the dropping left an empty select");
|
||||
assert_eq!(settings::lint_selection(now), base, "and the rule set is untouched");
|
||||
}
|
||||
@@ -202,6 +202,17 @@ pub struct ClientSettings {
|
||||
/// One line per refused `lucisv.lint.options` entry, ready for a
|
||||
/// `window/logMessage`. Empty for a settings push that was all valid.
|
||||
pub lint_option_warnings: Vec<String>,
|
||||
/// One line per name in `lucisv.lint.select` / `lucisv.lint.ignore` that
|
||||
/// the registry does not know, in the shape
|
||||
/// `lucisv.lint.select: unknown rule: <name>`.
|
||||
///
|
||||
/// Separate from [`ClientSettings::lint_option_warnings`] because the two
|
||||
/// are said differently: an options warning is raised every time the
|
||||
/// setting arrives, while an unknown name is said **once** per (setting,
|
||||
/// name) and re-armed only when the list changes — a client that re-pushes
|
||||
/// its whole section on every keystroke must not repeat it
|
||||
/// (`docs/features/small-items-4/README.md`).
|
||||
pub lint_name_warnings: Vec<String>,
|
||||
/// `lucisv.lint.waivers`: external waiver files, each absolute or relative
|
||||
/// to the first workspace root — the editor's spelling of
|
||||
/// `lucisv check --waiver-file` and of `waivers` under `[lint]` in a
|
||||
@@ -242,6 +253,7 @@ impl Default for ClientSettings {
|
||||
lint_rules: BTreeMap::new(),
|
||||
lint_options: RuleOptions::new(),
|
||||
lint_option_warnings: Vec::new(),
|
||||
lint_name_warnings: Vec::new(),
|
||||
lint_waivers: Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -313,6 +325,11 @@ pub fn from_payload(settings: &Value) -> ClientSettings {
|
||||
// And `lucisv.lint.select` / `lucisv.lint.ignore` the same way again.
|
||||
let lint = lucisv.get("lint");
|
||||
let (options, warnings) = rule_options(lint.and_then(|l| l.get("options")));
|
||||
// The names the registry did not know, collected as the two lists are
|
||||
// filtered so the user hears about a typo instead of losing a rule to it.
|
||||
let mut names = Vec::new();
|
||||
let lint_select = rules(lint.and_then(|l| l.get("select")), "select", &mut names);
|
||||
let lint_ignore = rules(lint.and_then(|l| l.get("ignore")), "ignore", &mut names);
|
||||
ClientSettings {
|
||||
line_length: bounded(lucisv.get("lineLength"), LINE_LENGTH_RANGE),
|
||||
indent: bounded(lucisv.get("indent"), INDENT_RANGE),
|
||||
@@ -354,14 +371,15 @@ pub fn from_payload(settings: &Value) -> ClientSettings {
|
||||
// prevent.
|
||||
large_file_threshold: count(large_file.and_then(|f| f.get("threshold")))
|
||||
.unwrap_or(DEFAULT_LARGE_FILE_THRESHOLD),
|
||||
lint_select: rules(lint.and_then(|l| l.get("select"))),
|
||||
lint_ignore: rules(lint.and_then(|l| l.get("ignore"))),
|
||||
lint_select,
|
||||
lint_ignore,
|
||||
// `lucisv.lint.severity.<class>` and `lucisv.lint.rules.<name>` nest
|
||||
// one level deeper again, for the same reason `index.*` does.
|
||||
lint_severity: severity_switches(lint.and_then(|l| l.get("severity"))),
|
||||
lint_rules: rule_toggles(lint.and_then(|l| l.get("rules"))),
|
||||
lint_options: options,
|
||||
lint_option_warnings: warnings,
|
||||
lint_name_warnings: names,
|
||||
// Paths, not rule names: nothing to validate against the registry, and
|
||||
// a path that names nothing is reported when the file is read.
|
||||
lint_waivers: strings(lint.and_then(|l| l.get("waivers"))),
|
||||
@@ -369,13 +387,28 @@ pub fn from_payload(settings: &Value) -> ClientSettings {
|
||||
}
|
||||
|
||||
/// The rule names in a settings array, dropping every one that names neither a
|
||||
/// rule nor a severity class.
|
||||
/// rule nor a severity class and describing each drop in `warnings`.
|
||||
///
|
||||
/// Silence rather than an error, on this module's standing rule: a push is
|
||||
/// JSON on a socket, and a typo in one name must not cost the user every
|
||||
/// diagnostic in the file. A dropped name leaves the rule where it was.
|
||||
fn rules(value: Option<&Value>) -> Vec<String> {
|
||||
strings(value).into_iter().filter(|name| vlog_linter::rules_named(name).is_some()).collect()
|
||||
/// The drop itself is this module's standing rule: a push is JSON on a socket,
|
||||
/// and a typo in one name must not cost the user every diagnostic in the file,
|
||||
/// so a name the registry does not know leaves the rule where it was. Silence
|
||||
/// about it was not the rule, only the state of things — `[lint] select` in a
|
||||
/// `lucisv.toml` has said the same mistake out loud since §42, and this is the
|
||||
/// editor's half of that (`docs/topo.md` §2.9-29).
|
||||
///
|
||||
/// `setting` is `select` or `ignore`, so the line names the list the user
|
||||
/// typed in.
|
||||
fn rules(value: Option<&Value>, setting: &str, warnings: &mut Vec<String>) -> Vec<String> {
|
||||
strings(value)
|
||||
.into_iter()
|
||||
.filter(|name| {
|
||||
let known = vlog_linter::rules_named(name).is_some();
|
||||
if !known {
|
||||
warnings.push(format!("lucisv.lint.{setting}: unknown rule: {name}"));
|
||||
}
|
||||
known
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The three class master switches, each `true` unless a client turned it off.
|
||||
@@ -901,6 +934,39 @@ mod tests {
|
||||
}}}));
|
||||
assert_eq!(found.lint_select, vec!["style", "no-tabs"]);
|
||||
assert_eq!(found.lint_ignore, vec!["warning"]);
|
||||
// And the one name that is neither is described, not just dropped.
|
||||
assert_eq!(found.lint_name_warnings, vec!["lucisv.lint.select: unknown rule: nope"]);
|
||||
}
|
||||
|
||||
/// TODO §45.1: a name the registry does not know is still dropped — the
|
||||
/// rule stays where it was — and now says so, once per name, naming the
|
||||
/// list the user typed it in.
|
||||
#[test]
|
||||
fn an_unknown_rule_name_is_described_for_each_list_it_appears_in() {
|
||||
let found = settings(json!({"lucisv": {"lint": {
|
||||
"select": ["no-tabs", "nope", "also-nope"],
|
||||
"ignore": ["nope"],
|
||||
}}}));
|
||||
assert_eq!(found.lint_select, vec!["no-tabs"]);
|
||||
assert!(found.lint_ignore.is_empty());
|
||||
assert_eq!(
|
||||
found.lint_name_warnings,
|
||||
vec![
|
||||
"lucisv.lint.select: unknown rule: nope",
|
||||
"lucisv.lint.select: unknown rule: also-nope",
|
||||
"lucisv.lint.ignore: unknown rule: nope",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_lists_of_known_names_describe_nothing() {
|
||||
let found = settings(json!({"lucisv": {"lint": {
|
||||
"select": ["no-tabs", "error"],
|
||||
"ignore": ["unused-signal"],
|
||||
}}}));
|
||||
assert!(found.lint_name_warnings.is_empty(), "{:?}", found.lint_name_warnings);
|
||||
assert!(settings(json!({"lucisv": {}})).lint_name_warnings.is_empty());
|
||||
}
|
||||
|
||||
/// What the server compares two settings pushes by, to decide whether the
|
||||
|
||||
@@ -1008,11 +1008,12 @@ impl Workspace {
|
||||
self.docs.values().filter_map(|doc| doc.path.as_deref()).collect();
|
||||
let mut skipped = 0usize;
|
||||
let mut texts: Vec<(PathBuf, String)> = Vec::new();
|
||||
let mut warnings: Vec<String> = Vec::new();
|
||||
// The walk of the *added* directories alone, by the same rung-3 rules
|
||||
// `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) {
|
||||
for path in self.widened_files(added, &mut |w| warnings.push(w)) {
|
||||
// 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.
|
||||
@@ -1073,9 +1074,9 @@ impl Workspace {
|
||||
// `+incdir+`. Carried from the graph in hand rather than assumed
|
||||
// empty, so folding a widen in never *changes* the search path.
|
||||
incdirs: self.includes.incdirs().to_vec(),
|
||||
// Warnings come from resolving the scope, and a widen resolves no
|
||||
// filelist: rung 1 is not a scope an open buffer can widen.
|
||||
warnings: Vec::new(),
|
||||
// A widen resolves no filelist — rung 1 is not a scope an open
|
||||
// buffer can widen — so the only warnings here are the walk's own.
|
||||
warnings,
|
||||
at: 0,
|
||||
staged: Vec::new(),
|
||||
staged_at: Vec::new(),
|
||||
@@ -1088,11 +1089,11 @@ 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]) -> Vec<PathBuf> {
|
||||
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)
|
||||
self.walked_files(added, warn)
|
||||
}
|
||||
|
||||
/// Index the next file of `scan`, reporting whether there was one.
|
||||
@@ -1867,16 +1868,21 @@ impl Workspace {
|
||||
/// 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 {
|
||||
return Scope { files: self.default_files(), ..Default::default() };
|
||||
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) => Scope {
|
||||
files: self.default_files(),
|
||||
incdirs: Vec::new(),
|
||||
warnings: vec![format!("{problem} — indexing the workspace instead")],
|
||||
},
|
||||
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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1903,11 +1909,11 @@ impl Workspace {
|
||||
|
||||
/// 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) -> Vec<PathBuf> {
|
||||
fn default_files(&self, warn: &mut dyn FnMut(String)) -> Vec<PathBuf> {
|
||||
if self.walks_the_workspace() {
|
||||
return self.walked_files(&self.roots);
|
||||
return self.walked_files(&self.roots, warn);
|
||||
}
|
||||
self.folder_files()
|
||||
self.folder_files(warn)
|
||||
}
|
||||
|
||||
/// Rung 3: the folder scope — [`Workspace::scope_dirs`], walked with every
|
||||
@@ -1919,12 +1925,12 @@ impl Workspace {
|
||||
/// 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) -> Vec<PathBuf> {
|
||||
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)
|
||||
self.walked_files(&dirs, warn)
|
||||
}
|
||||
|
||||
/// Every source file under `dirs`, found by the CLI's own walk: the same
|
||||
@@ -1938,7 +1944,7 @@ impl Workspace {
|
||||
/// 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]) -> Vec<PathBuf> {
|
||||
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 {
|
||||
@@ -1958,8 +1964,9 @@ impl Workspace {
|
||||
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 simply not indexed, exactly as before this walk was shared.
|
||||
let _ = collect_files(input, &exclude, true, &mut out);
|
||||
// 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();
|
||||
@@ -2750,7 +2757,11 @@ mod tests {
|
||||
let mut ws = Workspace::default();
|
||||
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)).len(), 2, "two files, once each");
|
||||
assert_eq!(
|
||||
ws.walked_files(from_ref(&tree.path), &mut |_| {}).len(),
|
||||
2,
|
||||
"two files, once each"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3360,6 +3371,35 @@ mod tests {
|
||||
assert!(warnings[0].contains("indexing the workspace instead"), "{warnings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_directory_is_said_once_per_scan_and_the_rest_is_indexed() {
|
||||
// TODO §45.2: the walk's warnings ride out on the scope's own
|
||||
// warnings, which the server logs once per scan. Before the channel
|
||||
// existed the walk returned an error the index simply dropped, so a
|
||||
// permission-denied directory cost every file after it silently.
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let tree = Tree::new("walkwarn");
|
||||
tree.package("rtl/a.sv", "a");
|
||||
tree.package("rtl/z.sv", "z");
|
||||
tree.package("locked/hidden.sv", "hidden");
|
||||
std::os::unix::fs::symlink("nowhere.sv", tree.path.join("rtl/gone.sv")).expect("symlink");
|
||||
let locked = tree.path.join("locked");
|
||||
fs::set_permissions(&locked, fs::Permissions::from_mode(0o000)).expect("chmod");
|
||||
|
||||
let mut ws = Workspace::default();
|
||||
let warnings = ws.open_whole_workspace(vec![tree.path.clone()]);
|
||||
let _ = fs::set_permissions(&locked, fs::Permissions::from_mode(0o755));
|
||||
|
||||
assert_eq!(indexed(&ws, &["a", "z", "hidden"]), ["a", "z"], "the scan finished");
|
||||
assert_eq!(warnings.len(), 2, "{warnings:?}");
|
||||
assert!(warnings.iter().any(|w| w.contains("locked")), "{warnings:?}");
|
||||
assert!(
|
||||
warnings.iter().any(|w| w.contains("gone.sv: broken symbolic link")),
|
||||
"{warnings:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_filelists_own_warnings_reach_the_caller() {
|
||||
let tree = filelist_tree("filelistwarn");
|
||||
|
||||
@@ -7963,3 +7963,207 @@ fn the_cli_and_the_server_run_the_same_rules_for_the_same_buffer() {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TODO.md §46 — what a `didOpen` costs the request behind it
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// `talk` writes a whole session before reading a byte, which is what every
|
||||
// test above wants and what a *timing* test cannot use: the number this round
|
||||
// is about is the gap between the `didOpen` frame going out and the next
|
||||
// response coming back. `Live` — the held-open session two hundred lines up —
|
||||
// is the one that can measure it. The three tests below are §46's contract:
|
||||
// the open returns to the loop fast, the first request after it is answered
|
||||
// from the **buffer**, and the diagnostics still arrive with no edit and no
|
||||
// further request behind them.
|
||||
|
||||
/// A started session over `root`, indexed at the whole-workspace scope with
|
||||
/// the scan already run — the barrier request at the end is what makes that
|
||||
/// true, since the loop answers nothing until a rescan a message asked for has
|
||||
/// finished.
|
||||
fn live_at(root: &Path) -> Live {
|
||||
let mut live = Live::start();
|
||||
live.send(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"processId":null,"rootUri":"file://{}","capabilities":{{}}}}}}"#,
|
||||
root.display()
|
||||
));
|
||||
live.wait_for(|m| m["id"] == 1);
|
||||
live.send(r#"{"jsonrpc":"2.0","method":"initialized","params":{}}"#);
|
||||
live.send(WIDE_SCOPE);
|
||||
live.send(r#"{"jsonrpc":"2.0","id":2,"method":"workspace/symbol","params":{"query":"zzz"}}"#);
|
||||
live.wait_for(|m| m["id"] == 2);
|
||||
live
|
||||
}
|
||||
|
||||
/// The `didOpen` frame for a buffer.
|
||||
fn open_frame(uri: &str, text: &str) -> String {
|
||||
format!(
|
||||
r#"{{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{{"textDocument":{{"uri":"{uri}","languageId":"systemverilog","version":1,"text":{}}}}}}}"#,
|
||||
serde_json::to_string(text).expect("json")
|
||||
)
|
||||
}
|
||||
|
||||
/// Open `uri` and ask for a `hover` in the same write, and report how long the
|
||||
/// hover took to come back.
|
||||
///
|
||||
/// That wait *is* the open: the loop is synchronous, so whatever the open does
|
||||
/// before returning to it is what the hover queues behind.
|
||||
fn open_then_hover(live: &mut Live, id: u32, uri: &str, text: &str) -> std::time::Duration {
|
||||
let hover = format!(
|
||||
r#"{{"jsonrpc":"2.0","id":{id},"method":"textDocument/hover","params":{{"textDocument":{{"uri":"{uri}"}},"position":{{"line":0,"character":8}}}}}}"#
|
||||
);
|
||||
let started = std::time::Instant::now();
|
||||
live.send(&open_frame(uri, text));
|
||||
live.send(&hover);
|
||||
live.wait_for(|m| m["id"] == id);
|
||||
started.elapsed()
|
||||
}
|
||||
|
||||
/// A workspace of `files` small packages, so the index holds a *project*
|
||||
/// rather than one buffer — which is what switches the cross-file lint rules
|
||||
/// on at all (`LintRun::for_document`).
|
||||
fn indexed_neighbours(dir: &Path, files: usize) {
|
||||
for k in 0..files {
|
||||
std::fs::write(
|
||||
dir.join(format!("pkg{k}.sv")),
|
||||
format!("package pkg{k};\n localparam int K{k} = {k};\nendpackage\n"),
|
||||
)
|
||||
.expect("write neighbour");
|
||||
}
|
||||
}
|
||||
|
||||
/// §46's contract, on the wire: a `didOpen` of a 2 000-line buffer must not
|
||||
/// leave the request behind it waiting.
|
||||
///
|
||||
/// **An upper bound, not a benchmark, and a debug-build one.** `cargo test`
|
||||
/// builds unoptimized, where one tolerant parse of 2 000 lines is ~53 ms all
|
||||
/// by itself — measured on this machine, and stable to a millisecond across
|
||||
/// runs. So the 200 ms here is that floor with room for a loaded CI box, not
|
||||
/// the ≤ 25 ms §46 asked for: **that figure is a release number**, and the
|
||||
/// release binary opens the same buffer in 2–4 ms.
|
||||
///
|
||||
/// **What this test does and does not catch.** It catches an open that starts
|
||||
/// doing something *unbounded* — the shape §46 fixed. It cannot catch the
|
||||
/// §46 defect itself at this size: the census walk that cost 1.6 s on
|
||||
/// opentitan's 42 000-line `pinmux_reg_top.sv` costs milliseconds over a
|
||||
/// forty-file fixture, and a fixture of opentitan's four thousand files has
|
||||
/// no business in a unit-test suite. The exact pin for that is
|
||||
/// `undriven_net`'s `the_project_is_asked_only_about_the_signals_that_would_be_reported`,
|
||||
/// which counts the questions instead of timing them
|
||||
/// (`docs/features/didopen-cost/README.md`).
|
||||
///
|
||||
/// Best of three distinct buffers: the first open of a process pays cold code
|
||||
/// paths that have nothing to do with the buffer, and a wall-clock assertion
|
||||
/// that cannot tolerate one scheduling hiccup is a flake, not a pin.
|
||||
#[test]
|
||||
fn opening_a_two_thousand_line_buffer_does_not_delay_the_request_behind_it() {
|
||||
let dir = temp_dir("didopen_cost");
|
||||
indexed_neighbours(&dir, 40);
|
||||
let mut generated = Vec::new();
|
||||
for n in 0..3 {
|
||||
let name = format!("gen{n}");
|
||||
// The generator the perf tables use: a thousand declarations, every
|
||||
// one declared, driven and read — the cheap case for the *findings*
|
||||
// and the expensive one for the walk that decides there are none.
|
||||
let text = generated_module(&name, 2_000);
|
||||
assert!(text.lines().count() >= 2_000, "the premise: a 2 000-line buffer");
|
||||
let path = dir.join(format!("{name}.sv"));
|
||||
std::fs::write(&path, &text).expect("write");
|
||||
generated.push((path, text));
|
||||
}
|
||||
let mut live = live_at(&dir);
|
||||
// A warm-up open of a small buffer, for the cold code paths.
|
||||
let warm = format!("file://{}", dir.join("pkg0.sv").display());
|
||||
open_then_hover(&mut live, 10, &warm, "package pkg0;\n localparam int K0 = 0;\nendpackage\n");
|
||||
|
||||
let mut best = std::time::Duration::MAX;
|
||||
for (n, (path, text)) in generated.iter().enumerate() {
|
||||
let uri = format!("file://{}", path.display());
|
||||
best = best.min(open_then_hover(&mut live, 20 + n as u32, &uri, text));
|
||||
}
|
||||
live.finish();
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
|
||||
assert!(
|
||||
best <= std::time::Duration::from_millis(200),
|
||||
"a didOpen of a 2 000-line buffer delayed the next request by {best:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The other half of §46's contract: the request after an open is answered
|
||||
/// from the **buffer**, not from what is on disk.
|
||||
///
|
||||
/// Nothing about the open was deferred — it still analyzes the buffer before
|
||||
/// it returns to the loop — and this is what says so out loud. The buffer
|
||||
/// names something the file on disk does not, and declares it on a line the
|
||||
/// disk file does not, and the very first hover and the very first definition
|
||||
/// after the open both find the buffer's.
|
||||
#[test]
|
||||
fn the_first_hover_after_an_open_sees_the_buffer_and_not_the_disk() {
|
||||
let dir = temp_dir("didopen_buffer_wins");
|
||||
indexed_neighbours(&dir, 4);
|
||||
let file = dir.join("m.sv");
|
||||
std::fs::write(
|
||||
&file,
|
||||
"module m;\n localparam int ON_DISK = 1;\n logic a;\n assign a = ON_DISK;\nendmodule\n",
|
||||
)
|
||||
.expect("write");
|
||||
let uri = format!("file://{}", file.display());
|
||||
// What the editor holds: a different name, declared on a different line.
|
||||
let buffer = "module m;\n\n localparam int IN_BUFFER = 2;\n logic a;\n \
|
||||
assign a = IN_BUFFER;\nendmodule\n";
|
||||
|
||||
let mut live = live_at(&dir);
|
||||
live.send(&open_frame(&uri, buffer));
|
||||
// The cursor on `IN_BUFFER` where line 4 reads it.
|
||||
live.send(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":30,"method":"textDocument/hover","params":{{"textDocument":{{"uri":"{uri}"}},"position":{{"line":4,"character":16}}}}}}"#
|
||||
));
|
||||
let card = live.wait_for(|m| m["id"] == 30)["result"]["contents"]["value"]
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
live.send(&format!(
|
||||
r#"{{"jsonrpc":"2.0","id":31,"method":"textDocument/definition","params":{{"textDocument":{{"uri":"{uri}"}},"position":{{"line":4,"character":16}}}}}}"#
|
||||
));
|
||||
let definition = live.wait_for(|m| m["id"] == 31);
|
||||
live.finish();
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
|
||||
assert!(card.contains("IN_BUFFER"), "the first hover did not read the buffer: {card:?}");
|
||||
assert!(!card.contains("ON_DISK"), "the first hover read the disk file: {card:?}");
|
||||
let locations = definition["result"].as_array().expect("an array of locations");
|
||||
assert_eq!(locations.len(), 1, "one declaration, got {locations:#?}");
|
||||
assert_eq!(locations[0]["range"]["start"]["line"], 2, "the buffer's line, not the disk's");
|
||||
}
|
||||
|
||||
/// And the third: the open still publishes, with no edit and no further
|
||||
/// request to trigger it.
|
||||
///
|
||||
/// **There is no debounce on the open.** §46 allowed the diagnostics to be
|
||||
/// moved onto the change debounce and to arrive one quiet period later; they
|
||||
/// were not, because the cost was never the publish — it was one rule inside
|
||||
/// it. So the guarantee is the one this server has always had: the diagnostics
|
||||
/// for an opened buffer go out inside the `didOpen`, ahead of anything queued
|
||||
/// behind it.
|
||||
#[test]
|
||||
fn an_open_still_publishes_its_diagnostics_with_no_edit_behind_it() {
|
||||
let dir = temp_dir("didopen_publishes");
|
||||
indexed_neighbours(&dir, 4);
|
||||
let file = dir.join("tabbed.sv");
|
||||
let text = "module tabbed;\n\twire a;\nendmodule\n";
|
||||
std::fs::write(&file, text).expect("write");
|
||||
let uri = format!("file://{}", file.display());
|
||||
|
||||
let mut live = live_at(&dir);
|
||||
live.send(&open_frame(&uri, text));
|
||||
let published = live.wait_for(|m| {
|
||||
m["method"] == "textDocument/publishDiagnostics" && m["params"]["uri"] == uri
|
||||
});
|
||||
live.finish();
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
|
||||
let items = published["params"]["diagnostics"].as_array().expect("a diagnostics array");
|
||||
let codes: Vec<&str> = items.iter().filter_map(|d| d["code"].as_str()).collect();
|
||||
assert!(codes.contains(&"no-tabs"), "the open published nothing about the tab: {items:#?}");
|
||||
}
|
||||
@@ -310,8 +310,17 @@ impl<'a> Fmt<'a> {
|
||||
// strictly. Printed verbatim so nothing is lost if that ever
|
||||
// changes — see `ListItem::from_raw`.
|
||||
ExprKind::Error(raw) => self.raw_inline(raw),
|
||||
ExprKind::MinTypMax { min, typ, max } => {
|
||||
concat(vec![self.expr(min), text(":"), self.expr(typ), text(":"), self.expr(max)])
|
||||
ExprKind::MinTypMax { min, typ, max, comments } => {
|
||||
let mut docs = vec![self.expr(min)];
|
||||
self.slot_comments(&comments.before_typ, &mut docs);
|
||||
docs.push(text(":"));
|
||||
self.slot_comments(&comments.after_typ, &mut docs);
|
||||
docs.push(self.expr(typ));
|
||||
self.slot_comments(&comments.before_max, &mut docs);
|
||||
docs.push(text(":"));
|
||||
self.slot_comments(&comments.after_max, &mut docs);
|
||||
docs.push(self.expr(max));
|
||||
concat(docs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,30 +342,83 @@ impl<'a> Fmt<'a> {
|
||||
if let Some(s) = &g.strength {
|
||||
docs.push(text(format!(" {}", drive_strength(s))));
|
||||
}
|
||||
if !g.delay.is_empty() {
|
||||
// The gap in front of the `#` is a space unless the source wrote
|
||||
// a comment in it, exactly as a net delay's `before_hash` is.
|
||||
match g.before_hash.is_empty() {
|
||||
true => docs.push(text(" ")),
|
||||
false => self.inline_comments_spaced(&g.before_hash, &mut docs),
|
||||
}
|
||||
docs.push(text("#"));
|
||||
self.slot_comments(&g.after_hash, &mut docs);
|
||||
}
|
||||
if let [delay] = g.delay.as_slice() {
|
||||
// One value prints itself, brackets and all (`#5`, `#(5)`).
|
||||
docs.push(text(" #"));
|
||||
docs.push(self.expr(delay));
|
||||
docs.push(self.expr(&delay.expr));
|
||||
} else if !g.delay.is_empty() {
|
||||
// `#(rise, fall[, turn-off])` — the parens are the list's own.
|
||||
docs.push(text(" #("));
|
||||
// `#(rise, fall[, turn-off])` — the parens and the commas are the
|
||||
// list's own, so the comments written around them are too.
|
||||
docs.push(text("("));
|
||||
for (i, d) in g.delay.iter().enumerate() {
|
||||
if i > 0 {
|
||||
docs.push(text(", "));
|
||||
docs.push(text(","));
|
||||
match d.leading.is_empty() {
|
||||
true => docs.push(text(" ")),
|
||||
false => self.inline_comments_spaced(&d.leading, &mut docs),
|
||||
}
|
||||
} else {
|
||||
self.slot_comments(&d.leading, &mut docs);
|
||||
}
|
||||
docs.push(self.expr(d));
|
||||
docs.push(self.expr(&d.expr));
|
||||
self.slot_comments(&d.trailing, &mut docs);
|
||||
}
|
||||
docs.push(text(")"));
|
||||
}
|
||||
let last = g.instances.len().saturating_sub(1);
|
||||
// True once a trailing comment has ended the previous instance's line:
|
||||
// the next instance then starts on a fresh, indented line, and the
|
||||
// space that normally separates it from the `,` is not written.
|
||||
let mut broke = false;
|
||||
for (i, inst) in g.instances.iter().enumerate() {
|
||||
docs.push(if i > 0 { text(", ") } else { text(" ") });
|
||||
// What stands between the delay (or the previous instance's `,`)
|
||||
// and this instance's name — a space when nothing does.
|
||||
match (broke, inst.meta.leading.is_empty()) {
|
||||
(true, true) => {}
|
||||
(false, true) => docs.push(text(" ")),
|
||||
(_, false) => self.inline_comments_spaced(&inst.meta.leading, &mut docs),
|
||||
}
|
||||
broke = false;
|
||||
if let Some(name) = &inst.name {
|
||||
docs.push(name_doc(name));
|
||||
docs.push(text(" "));
|
||||
match inst.before_args.is_empty() {
|
||||
true => docs.push(text(" ")),
|
||||
false => self.inline_comments_spaced(&inst.before_args, &mut docs),
|
||||
}
|
||||
}
|
||||
docs.push(self.expr_list("(", &inst.args, ")"));
|
||||
if i == last {
|
||||
continue;
|
||||
}
|
||||
// Comments written between the instance and its `,` print on the
|
||||
// instance's side of it, as every list element's do.
|
||||
if self.inline_comments(&inst.meta.before_sep, &mut docs) {
|
||||
docs.push(Doc::HardLine);
|
||||
}
|
||||
docs.push(text(","));
|
||||
if let Some(tr) = &inst.meta.trailing {
|
||||
docs.push(text(" "));
|
||||
docs.push(self.comment(tr));
|
||||
// A line comment ends the line (a `// p` would otherwise
|
||||
// swallow the next instance on re-lex — §45's QA); the next
|
||||
// instance continues one level in. A block comment stays
|
||||
// inline, as the case table for this slot expects.
|
||||
if is_line_comment(&tr.text) {
|
||||
docs.push(indent(vec![Doc::HardLine]));
|
||||
broke = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
docs.push(text(";"));
|
||||
docs.push(self.semi(&g.before_semi));
|
||||
concat(docs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,8 +362,12 @@ impl<'a> Fmt<'a> {
|
||||
}
|
||||
if let Some(delay) = &a.delay {
|
||||
docs.push(text("#"));
|
||||
self.slot_comments(&a.after_hash, &mut docs);
|
||||
docs.push(self.expr(delay));
|
||||
docs.push(text(" "));
|
||||
match a.after_delay.is_empty() {
|
||||
true => docs.push(text(" ")),
|
||||
false => self.inline_comments_spaced(&a.after_delay, &mut docs),
|
||||
}
|
||||
}
|
||||
let items: Vec<ListItem> = a
|
||||
.assigns
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# TODO §45.4 — the comment slots inside a delay list. `parse_delay_values`
|
||||
# serves `#(1:2:3)` on nets and continuous assignments and `#(rise, fall)` on
|
||||
# gates; the gaps around the `(`, the two `:` and the `,` had no owner, so a
|
||||
# comment written in one moved and `verify.rs` refused the file.
|
||||
#
|
||||
# The `min:typ:max` colons: `MinTypMaxComments`, four slots, one grammar
|
||||
# shared with the parenthesized `(a:b:c)` expression.
|
||||
module m;
|
||||
wire #(1 /* b */ : /* c */ 2 /* d */ : /* e */ 3) w;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
wire #(1 /* b */ : /* c */ 2 /* d */ : /* e */ 3) w;
|
||||
endmodule
|
||||
====
|
||||
# The parentheses of a one-value delay are its own `ExprKind::Paren`, which
|
||||
# has had the two slots all along — and a comment inside a bracket pair forces
|
||||
# that pair open, as it does everywhere else in the formatter.
|
||||
module m;
|
||||
wire #( /* a */ 1:2:3 /* f */ ) w;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
wire #(
|
||||
/* a */
|
||||
1:2:3 /* f */
|
||||
) w;
|
||||
endmodule
|
||||
====
|
||||
# A continuous assignment's delay: the gap after its `#` and the gap between
|
||||
# the delay and the first left-hand side. Without the second slot the comment
|
||||
# joins the first pair's leading comments, which print in front of the delay.
|
||||
module m;
|
||||
assign # /* g */ (1:2:3) /* h */ z = a;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
assign # /* g */ (1:2:3) /* h */ z = a;
|
||||
endmodule
|
||||
====
|
||||
# A gate's multi-value list writes its own parentheses and commas, so it owns
|
||||
# the comments around them: `DelayValue::{leading, trailing}`. With them the
|
||||
# gate's `before_hash`, `after_hash`, the instance's `before_args` and the
|
||||
# item's `before_semi`.
|
||||
module m;
|
||||
and /* i */ # /* j */ ( /* k */ 2 /* l */ , /* m */ 3 /* n */ ) g1 /* o */ (y, a, b) /* p */ ;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
and /* i */ # /* j */ ( /* k */ 2 /* l */ , /* m */ 3 /* n */ ) g1 /* o */ (y, a, b) /* p */ ;
|
||||
endmodule
|
||||
====
|
||||
# A line comment runs to end of line, so what follows it starts a new one —
|
||||
# the same rule every other slot in the formatter obeys.
|
||||
module m;
|
||||
wire #(1 // why
|
||||
:2:3) w;
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
wire #(
|
||||
1 // why
|
||||
:2:3
|
||||
) w;
|
||||
endmodule
|
||||
====
|
||||
# Nothing written in any of the slots costs a byte: the comment-free spellings
|
||||
# are laid out exactly as they were before the slots existed.
|
||||
module m;
|
||||
wire #(1:2:3) a;
|
||||
assign #(1:2:3) z = a;
|
||||
and #(1, 2, 3) g1 (o, a, b);
|
||||
not #(1:2:3, 4:5:6) n0 (o, a);
|
||||
buf #(5) b1 (o, a);
|
||||
buf #5 b2 (o, a);
|
||||
buf b3 (o, a);
|
||||
nand (weak0, weak1) #2 n1 (o, a, b);
|
||||
and #(2, 3) g0 (y, a), g2 (z, b);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
wire #(1:2:3) a;
|
||||
assign #(1:2:3) z = a;
|
||||
and #(1, 2, 3) g1 (o, a, b);
|
||||
not #(1:2:3, 4:5:6) n0 (o, a);
|
||||
buf #(5) b1 (o, a);
|
||||
buf #5 b2 (o, a);
|
||||
buf b3 (o, a);
|
||||
nand (weak0, weak1) #2 n1 (o, a, b);
|
||||
and #(2, 3) g0 (y, a), g2 (z, b);
|
||||
endmodule
|
||||
====
|
||||
# A comment between two gate instances, and one written before the `,` that
|
||||
# separates them: the element's own `leading` and `before_sep`.
|
||||
module m;
|
||||
and #(2, 3) g0 (y, a) /* before */ , /* after */ g1 (z, b);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
and #(2, 3) g0 (y, a) /* before */, /* after */ g1 (z, b);
|
||||
endmodule
|
||||
@@ -224,3 +224,42 @@ module tb;
|
||||
sub #() u1 (.a(x));
|
||||
sub #(.W(8)) u2 (.a(x));
|
||||
endmodule
|
||||
====
|
||||
# TODO §45.3 — an inline aggregate as a parameter-override argument. It is a
|
||||
# type where a type is legal (IEEE 1800 §6.19, §7.2), the override a
|
||||
# `parameter type` defaulting to one takes, and it prints through the existing
|
||||
# type printer: a struct or union body opens, an enum body stays inline.
|
||||
module m;
|
||||
sub #(.T(struct packed { logic a; })) u0 ();
|
||||
sub #(.T(union packed { logic [7:0] a; })) u1 ();
|
||||
sub #(.T(enum logic [1:0] {A, B})) u2 ();
|
||||
sub #(.T(struct packed { /* why */ logic a; })) u3 ();
|
||||
sub #(.T(logic [7:0])) u4 ();
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
sub #(
|
||||
.T(
|
||||
struct packed {
|
||||
logic a;
|
||||
}
|
||||
)
|
||||
) u0 ();
|
||||
sub #(
|
||||
.T(
|
||||
union packed {
|
||||
logic [7:0] a;
|
||||
}
|
||||
)
|
||||
) u1 ();
|
||||
sub #(.T(enum logic [1:0] {A, B})) u2 ();
|
||||
sub #(
|
||||
.T(
|
||||
struct packed {
|
||||
/* why */
|
||||
logic a;
|
||||
}
|
||||
)
|
||||
) u3 ();
|
||||
sub #(.T(logic [7:0])) u4 ();
|
||||
endmodule
|
||||
@@ -106,3 +106,16 @@ module m;
|
||||
wire #5 /* after */
|
||||
x;
|
||||
endmodule
|
||||
====
|
||||
# a line comment after a gate instance's comma ends the line: the next
|
||||
# instance continues one level in (§45's QA; the module-instantiation
|
||||
# printer already did this)
|
||||
module m;
|
||||
and #(2, 3) g0 (y, a), // p
|
||||
g1 (z, b);
|
||||
endmodule
|
||||
----
|
||||
module m;
|
||||
and #(2, 3) g0 (y, a), // p
|
||||
g1 (z, b);
|
||||
endmodule
|
||||
@@ -2354,6 +2354,12 @@ const RTL_FIXTURES: &[&str] = &[
|
||||
// `#` is `NetDelay::before_hash` (TODO §43.2), and the fuzzer is what
|
||||
// says the other gaps around it kept their owners.
|
||||
"module m;\n wire #5 a;\n wire [7:0] #1 b = c;\nendmodule\n",
|
||||
// A delay *list*: the `min:typ:max` spelling a net and a continuous
|
||||
// assignment take, and the `(rise, fall)` spelling only a gate takes
|
||||
// (TODO §45.4). The gaps around the `(`, the two `:` and the `,` had no
|
||||
// owner until this round — `MinTypMaxComments`, `DelayValue`, and the
|
||||
// gate's own `before_hash`/`after_hash`/`before_args`/`before_semi`.
|
||||
"module m;\n wire #(1:2:3) a;\n assign #(1:2:3) z = a;\n and #(2, 3) g1 (y, a, b);\nendmodule\n",
|
||||
];
|
||||
|
||||
#[test]
|
||||
@@ -2361,8 +2367,9 @@ fn a_comment_in_every_rtl_gap_still_formats() {
|
||||
assert_no_failing_gaps("RTL", RTL_FIXTURES, EXPECTED_RTL_GAPS);
|
||||
}
|
||||
|
||||
/// Inter-token gaps across [`RTL_FIXTURES`].
|
||||
const EXPECTED_RTL_GAPS: usize = 374;
|
||||
/// Inter-token gaps across [`RTL_FIXTURES`]. 374 before TODO §45.4 added the
|
||||
/// delay-list fixture, whose 45 gaps brought the total here.
|
||||
const EXPECTED_RTL_GAPS: usize = 419;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Vendor and formal collateral — `vendor-formal-grammar`
|
||||
@@ -2892,3 +2899,106 @@ fn a_structured_assertion_may_be_relaid_out() {
|
||||
assert!(out.contains("lbl: assert property (@(posedge clk) disable iff (rst)"), "{out}");
|
||||
assert_eq!(format_source(&out, &Config::default()).expect("and is a fixed point"), out);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The delay list's new comment slots — `docs/features/small-items-4/README.md`
|
||||
//
|
||||
// `verify.rs` was not touched and no normalization was widened; these are the
|
||||
// standing attack pairs CLAUDE.md invariant 4 asks for anyway, one per token
|
||||
// a slot added by TODO §45.4 is defined *between*. Each moves the comment
|
||||
// across exactly that token, and each must be refused.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_delay_comment_moved_across_a_min_typ_max_colon_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n wire #(1 /*c*/ : 2 : 3) w;\nendmodule\n",
|
||||
"module m;\n wire #(1 : /*c*/ 2 : 3) w;\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n wire #(1 : 2 /*c*/ : 3) w;\nendmodule\n",
|
||||
"module m;\n wire #(1 : 2 : /*c*/ 3) w;\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_delay_comment_moved_across_the_lists_brackets_is_rejected() {
|
||||
// The `(` of a one-value delay, whose slots are its `ExprKind::Paren`'s.
|
||||
expect_divergence(
|
||||
"module m;\n wire # /*c*/ (1:2:3) w;\nendmodule\n",
|
||||
"module m;\n wire #( /*c*/ 1:2:3) w;\nendmodule\n",
|
||||
);
|
||||
// And the `)`.
|
||||
expect_divergence(
|
||||
"module m;\n wire #(1:2:3 /*c*/ ) w;\nendmodule\n",
|
||||
"module m;\n wire #(1:2:3) /*c*/ w;\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_gate_delay_comment_moved_across_the_hash_or_a_comma_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n and /*c*/ #(2, 3) g (y, a);\nendmodule\n",
|
||||
"module m;\n and # /*c*/ (2, 3) g (y, a);\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n and #(2 /*c*/, 3) g (y, a);\nendmodule\n",
|
||||
"module m;\n and #(2, /*c*/ 3) g (y, a);\nendmodule\n",
|
||||
);
|
||||
// The gate instance's own two new slots: before its `(` and before the `;`.
|
||||
expect_divergence(
|
||||
"module m;\n and #(2, 3) g /*c*/ (y, a);\nendmodule\n",
|
||||
"module m;\n and #(2, 3) g ( /*c*/ y, a);\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n and #(2, 3) g (y, a) /*c*/ ;\nendmodule\n",
|
||||
"module m;\n and #(2, 3) g (y, a); /*c*/\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_continuous_assignments_delay_comment_moved_across_it_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n assign # /*c*/ (5) y = a;\nendmodule\n",
|
||||
"module m;\n assign /*c*/ #(5) y = a;\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n assign #(5) /*c*/ y = a;\nendmodule\n",
|
||||
"module m;\n assign /*c*/ #(5) y = a;\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_delay_list_comment_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n and #(2 /*c*/, 3) g (y, a);\nendmodule\n",
|
||||
"module m;\n and #(2, 3) g (y, a);\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// The inline aggregate as a parameter-override argument — TODO §45.3
|
||||
//
|
||||
// A construct the parser refused until this round is a construct the safety
|
||||
// net had never been asked about. These say it is asked now.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#[test]
|
||||
fn a_dropped_member_of_an_inline_aggregate_override_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n sub #(.T(struct packed {logic a; logic b;})) u ();\nendmodule\n",
|
||||
"module m;\n sub #(.T(struct packed {logic a;})) u ();\nendmodule\n",
|
||||
);
|
||||
expect_divergence(
|
||||
"module m;\n sub #(.T(enum logic [1:0] {A, B})) u ();\nendmodule\n",
|
||||
"module m;\n sub #(.T(enum logic [1:0] {A})) u ();\nendmodule\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dropped_packed_keyword_in_an_override_argument_is_rejected() {
|
||||
expect_divergence(
|
||||
"module m;\n sub #(.T(struct packed {logic a;})) u ();\nendmodule\n",
|
||||
"module m;\n sub #(.T(struct {logic a;})) u ();\nendmodule\n",
|
||||
);
|
||||
}
|
||||
@@ -68,13 +68,6 @@ impl Rule for UndrivenNet {
|
||||
if intentionally_unused(&decl.name) || !signals.judgeable(decl) || decl.has_init {
|
||||
continue;
|
||||
}
|
||||
// A name another file in the project writes down may be driven
|
||||
// from there — a hierarchical assignment, a `force` in a
|
||||
// testbench, a `bind`-ed override — none of which this file can
|
||||
// see. Silence is the only honest answer.
|
||||
if ctx.mentioned_elsewhere(&decl.name) {
|
||||
continue;
|
||||
}
|
||||
let Some(usage) = signals.usage(decl) else { continue };
|
||||
// A `release`/`deassign` is a write that establishes no value, so
|
||||
// it is not what saves a signal from this rule.
|
||||
@@ -82,6 +75,25 @@ impl Rule for UndrivenNet {
|
||||
if signals.connected(decl) || driven || usage.reads == 0 {
|
||||
continue;
|
||||
}
|
||||
// A name another file in the project writes down may be driven
|
||||
// from there — a hierarchical assignment, a `force` in a
|
||||
// testbench, a `bind`-ed override — none of which this file can
|
||||
// see. Silence is the only honest answer.
|
||||
//
|
||||
// **Asked last, of the handful of declarations that would
|
||||
// otherwise be reported**, and not second, of every declaration in
|
||||
// the file: the oracle walks every indexed file's word list per
|
||||
// question (`WorkspaceIndex::files_mentioning`), so at the position
|
||||
// this check used to sit at, a 42 000-line buffer asked it four
|
||||
// thousand times and the rule cost 1.6 s of every `didOpen` and
|
||||
// every keystroke flush. The guards above are all local and all
|
||||
// O(1)-ish, the whole condition is one conjunction of `continue`s,
|
||||
// and `unused-signal` — the twin rule with the same oracle — has
|
||||
// always asked last. Same findings, in the same order
|
||||
// (`docs/features/didopen-cost/README.md`).
|
||||
if ctx.mentioned_elsewhere(&decl.name) {
|
||||
continue;
|
||||
}
|
||||
found.push(Violation::new(
|
||||
NAME,
|
||||
format!("`{}` is read but never driven", decl.name),
|
||||
@@ -107,17 +119,56 @@ mod tests {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// An oracle that says exactly these names are mentioned in another file.
|
||||
struct Elsewhere(&'static [&'static str]);
|
||||
/// An oracle that says exactly these names are mentioned in another file,
|
||||
/// and counts how often it was asked.
|
||||
struct Elsewhere(&'static [&'static str], std::sync::atomic::AtomicUsize);
|
||||
|
||||
impl Elsewhere {
|
||||
fn new(names: &'static [&'static str]) -> Elsewhere {
|
||||
Elsewhere(names, std::sync::atomic::AtomicUsize::new(0))
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::MentionOracle for Elsewhere {
|
||||
fn mentioned_elsewhere(&self, name: &str) -> bool {
|
||||
self.1.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
self.0.contains(&name)
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO.md §46: the oracle is asked about the declarations that would
|
||||
/// otherwise be **reported**, not about every declaration in the file.
|
||||
///
|
||||
/// One question per real candidate is the whole of the fix: the server's
|
||||
/// oracle walks every indexed file's word list per question, so asking it
|
||||
/// ahead of the local guards cost 1.6 s of every `didOpen` of opentitan's
|
||||
/// 42 000-line `pinmux_reg_top.sv` — see
|
||||
/// `docs/features/didopen-cost/README.md`. Asserted on the count, because
|
||||
/// the findings alone cannot tell the two orders apart.
|
||||
#[test]
|
||||
fn the_project_is_asked_only_about_the_signals_that_would_be_reported() {
|
||||
// Ten signals: nine driven and read, one read and undriven.
|
||||
let mut src = String::from("module m (output logic q);\n");
|
||||
for k in 0..9 {
|
||||
src.push_str(&format!(" wire d{k};\n assign d{k} = 1'b0;\n"));
|
||||
}
|
||||
src.push_str(" wire lonely;\n assign q = lonely");
|
||||
for k in 0..9 {
|
||||
src.push_str(&format!(" ^ d{k}"));
|
||||
}
|
||||
src.push_str(";\nendmodule\n");
|
||||
|
||||
let oracle = Elsewhere::new(&[]);
|
||||
let ctx = LintContext::new(&src, None).with_oracle(&oracle);
|
||||
let found = UndrivenNet.check(&ctx);
|
||||
assert_eq!(found.len(), 1, "only the undriven one: {found:#?}");
|
||||
assert!(found[0].message.contains("lonely"), "{:?}", found[0].message);
|
||||
let asked = oracle.1.load(std::sync::atomic::Ordering::Relaxed);
|
||||
assert_eq!(asked, 1, "the project was asked about the driven signals too");
|
||||
}
|
||||
|
||||
fn names_in_a_project(src: &str, elsewhere: &'static [&'static str]) -> Vec<String> {
|
||||
let oracle = Elsewhere(elsewhere);
|
||||
let oracle = Elsewhere::new(elsewhere);
|
||||
let ctx = LintContext::new(src, None).with_oracle(&oracle);
|
||||
UndrivenNet
|
||||
.check(&ctx)
|
||||
|
||||
@@ -259,9 +259,32 @@ pub enum ExprKind {
|
||||
min: Box<Expr>,
|
||||
typ: Box<Expr>,
|
||||
max: Box<Expr>,
|
||||
/// What was written around the two `:`.
|
||||
comments: Box<MinTypMaxComments>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Comments written around the two `:` of a `min : typ : max` delay
|
||||
/// (IEEE 1800 §28.14):
|
||||
///
|
||||
/// ```text
|
||||
/// min /*before_typ*/ : /*after_typ*/ typ /*before_max*/ : /*after_max*/ max
|
||||
/// ```
|
||||
///
|
||||
/// Boxed by its holder for the reason every expression-level slot is: `Expr`
|
||||
/// is walked recursively and its size is pinned at 96 bytes.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct MinTypMaxComments {
|
||||
/// Between `min` and the first `:`.
|
||||
pub before_typ: Vec<Comment>,
|
||||
/// Just after the first `:`.
|
||||
pub after_typ: Vec<Comment>,
|
||||
/// Between `typ` and the second `:`.
|
||||
pub before_max: Vec<Comment>,
|
||||
/// Just after the second `:`.
|
||||
pub after_max: Vec<Comment>,
|
||||
}
|
||||
|
||||
/// Comments written in the fixed slots of a **postfix segment** or a
|
||||
/// **bracketed range** — the one shape the grammar writes in five places:
|
||||
///
|
||||
|
||||
@@ -162,8 +162,15 @@ pub struct ContAssign {
|
||||
/// Drive strength: the `(weak0, pull1)` in
|
||||
/// `assign (weak0, pull1) x = y;` (IEEE 1800 §10.3.1), in source order.
|
||||
pub strength: Option<DriveStrength>,
|
||||
/// Comments written between the `#` and the delay itself.
|
||||
pub after_hash: Vec<Comment>,
|
||||
/// Delay expression: the `5` in `assign #5 x = y;`
|
||||
pub delay: Option<Expr>,
|
||||
/// Comments written between that delay and the first left-hand side.
|
||||
/// Without a slot here they would join the first pair's `meta.leading`,
|
||||
/// which prints straight after the `assign` — in front of the delay the
|
||||
/// source wrote them behind.
|
||||
pub after_delay: Vec<Comment>,
|
||||
pub assigns: Vec<AssignPair>,
|
||||
}
|
||||
|
||||
@@ -363,12 +370,37 @@ pub struct GateInstantiation {
|
||||
/// The `(weak1)` in `pullup (weak1) p (x);` (IEEE 1800 §28.3), or the
|
||||
/// `(strong0, strong1)` pair every driving gate also accepts.
|
||||
pub strength: Option<DriveStrength>,
|
||||
/// Comments written between the gate (or its drive strength) and the `#`
|
||||
/// of the delay: the `/* c */` of `and /* c */ #(2, 3) g (y, a, b);`.
|
||||
pub before_hash: Vec<Comment>,
|
||||
/// Comments written between that `#` and the delay itself.
|
||||
pub after_hash: Vec<Comment>,
|
||||
/// The delay written after `#`: empty when there is none, one element for
|
||||
/// every spelling a net or a continuous assignment also accepts, and two
|
||||
/// or three for the `(rise, fall[, turn-off])` list that only a gate
|
||||
/// takes (IEEE 1800 §28.14, `top_earlgrey/ip/ast/rtl/aon_osc.sv:41`).
|
||||
pub delay: Vec<Expr>,
|
||||
pub delay: Vec<DelayValue>,
|
||||
pub instances: Vec<GateInstance>,
|
||||
/// Comments written between the last instance and the `;`.
|
||||
pub before_semi: Vec<Comment>,
|
||||
}
|
||||
|
||||
/// One value of a delay list, with the comments written on either side of the
|
||||
/// separator that reaches it.
|
||||
///
|
||||
/// A one-value delay keeps its comments in its own [`ExprKind::Paren`], which
|
||||
/// has had the two slots all along; this shape exists for the multi-value
|
||||
/// `#(rise, fall[, turn-off])` list, whose parentheses and commas the printer
|
||||
/// writes itself and which therefore has nowhere else to put them. The first
|
||||
/// value's `leading` is what stood just inside the `(`, and the last value's
|
||||
/// `trailing` is what stood just before the `)`.
|
||||
#[derive(Debug)]
|
||||
pub struct DelayValue {
|
||||
/// Comments between the `(` or the `,` before this value and the value.
|
||||
pub leading: Vec<Comment>,
|
||||
pub expr: Expr,
|
||||
/// Comments between the value and the `,` or `)` that follows it.
|
||||
pub trailing: Vec<Comment>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -377,6 +409,9 @@ pub struct GateInstance {
|
||||
pub name: Option<String>,
|
||||
/// Byte range of `name`.
|
||||
pub name_span: Option<TextRange>,
|
||||
/// Comments written between the instance name and the `(` of its
|
||||
/// terminal list.
|
||||
pub before_args: Vec<Comment>,
|
||||
pub args: Vec<ExprItem>,
|
||||
/// Code extent of the gate instance.
|
||||
pub span: TextRange,
|
||||
|
||||
@@ -21,9 +21,17 @@ impl<'a> Parser<'a> {
|
||||
pub(super) fn parse_cont_assign(&mut self) -> PResult<ContAssign> {
|
||||
self.expect_kw("assign")?;
|
||||
let strength = self.parse_opt_drive_strength()?;
|
||||
let mut after_hash = Vec::new();
|
||||
let mut after_delay = Vec::new();
|
||||
let delay = if self.cur().is_sym("#") {
|
||||
self.bump();
|
||||
Some(self.parse_delay_value()?)
|
||||
after_hash = self.take_gap();
|
||||
let delay = self.parse_delay_value()?;
|
||||
// The gap between the delay and the first left-hand side is the
|
||||
// delay's, not the pair's: a pair's leading comments print right
|
||||
// after the `assign`, which is in front of the delay.
|
||||
after_delay = self.take_gap();
|
||||
Some(delay)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -55,7 +63,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
self.expect_sym(";")?;
|
||||
Ok(ContAssign { strength, delay, assigns })
|
||||
Ok(ContAssign { strength, after_hash, delay, after_delay, assigns })
|
||||
}
|
||||
|
||||
/// The optional `( strength0 , strength1 )` of a continuous assignment
|
||||
@@ -94,46 +102,75 @@ impl<'a> Parser<'a> {
|
||||
/// spelling has always produced, so `#(5)` and `#(1:2:3)` still print
|
||||
/// exactly as written; only a real comma list yields more than one
|
||||
/// element.
|
||||
fn parse_delay_values(&mut self) -> PResult<Vec<Expr>> {
|
||||
fn parse_delay_values(&mut self) -> PResult<Vec<DelayValue>> {
|
||||
if !self.cur().is_sym("(") {
|
||||
return Ok(vec![self.parse_primary()?]);
|
||||
let expr = self.parse_primary()?;
|
||||
return Ok(vec![DelayValue { leading: Vec::new(), expr, trailing: Vec::new() }]);
|
||||
}
|
||||
let start = self.here();
|
||||
self.bump(); // (
|
||||
let mut out = Vec::new();
|
||||
// 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();
|
||||
let mut leading = self.take_gap();
|
||||
let mut out: Vec<DelayValue> = Vec::new();
|
||||
loop {
|
||||
let inner_start = self.here();
|
||||
let first = self.parse_expr()?;
|
||||
out.push(if self.eat_sym(":") {
|
||||
let typ = self.parse_expr()?;
|
||||
self.expect_sym(":")?;
|
||||
let max = self.parse_expr()?;
|
||||
self.expr_at(
|
||||
inner_start,
|
||||
ExprKind::MinTypMax {
|
||||
min: Box::new(first),
|
||||
typ: Box::new(typ),
|
||||
max: Box::new(max),
|
||||
},
|
||||
)
|
||||
} else {
|
||||
first
|
||||
});
|
||||
let expr = self.parse_min_typ_max_tail(inner_start, first)?;
|
||||
let trailing = self.gap_before(",");
|
||||
out.push(DelayValue { leading: std::mem::take(&mut leading), expr, trailing });
|
||||
if !self.eat_sym(",") {
|
||||
break;
|
||||
}
|
||||
leading = self.take_gap();
|
||||
}
|
||||
if let Some(last) = out.last_mut() {
|
||||
last.trailing = self.gap_before(")");
|
||||
}
|
||||
self.expect_sym(")")?;
|
||||
if out.len() == 1 {
|
||||
let inner = out.remove(0);
|
||||
return Ok(vec![self.expr_at(
|
||||
// One value keeps the `( )` node the one-value spelling has always
|
||||
// produced, and its two comment slots are where the paren gaps go.
|
||||
let DelayValue { leading, expr, trailing } = out.remove(0);
|
||||
let paren = self.expr_at(
|
||||
start,
|
||||
ExprKind::Paren { inner: Box::new(inner), before: Vec::new(), after: Vec::new() },
|
||||
)]);
|
||||
ExprKind::Paren { inner: Box::new(expr), before: leading, after: trailing },
|
||||
);
|
||||
return Ok(vec![DelayValue { leading: Vec::new(), expr: paren, trailing: Vec::new() }]);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The `: typ : max` tail of a `min : typ : max` expression, or `min`
|
||||
/// unchanged when no `:` follows it.
|
||||
///
|
||||
/// One grammar for the two places that write it — a delay list and a
|
||||
/// parenthesized expression — so the four comment slots around the two
|
||||
/// colons exist in both.
|
||||
pub(super) fn parse_min_typ_max_tail(&mut self, start: u32, min: Expr) -> PResult<Expr> {
|
||||
let before_typ = self.gap_before(":");
|
||||
if !self.eat_sym(":") {
|
||||
return Ok(min);
|
||||
}
|
||||
let mut comments = MinTypMaxComments { before_typ, ..Default::default() };
|
||||
comments.after_typ = self.take_gap();
|
||||
let typ = self.parse_expr()?;
|
||||
comments.before_max = self.gap_before(":");
|
||||
self.expect_sym(":")?;
|
||||
comments.after_max = self.take_gap();
|
||||
let max = self.parse_expr()?;
|
||||
Ok(self.expr_at(
|
||||
start,
|
||||
ExprKind::MinTypMax {
|
||||
min: Box::new(min),
|
||||
typ: Box::new(typ),
|
||||
max: Box::new(max),
|
||||
comments: Box::new(comments),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
/// The single delay value a net declaration or a continuous assignment
|
||||
/// takes. The multi-value list is a gate-instantiation spelling only —
|
||||
/// see [`Parser::parse_delay_values`].
|
||||
@@ -142,7 +179,9 @@ impl<'a> Parser<'a> {
|
||||
if values.len() > 1 {
|
||||
return self.error("a multi-value delay list is only allowed on a gate instantiation");
|
||||
}
|
||||
Ok(values.remove(0))
|
||||
// A lone value carries no comments of its own: `parse_delay_values`
|
||||
// folded the paren gaps into its `ExprKind::Paren`.
|
||||
Ok(values.remove(0).expr)
|
||||
}
|
||||
|
||||
/// True when the cursor opens a `bind` directive (IEEE 1800 §23.11).
|
||||
@@ -647,8 +686,11 @@ impl<'a> Parser<'a> {
|
||||
// instance's argument list would, and only a strength keyword after
|
||||
// the `(` tells the two apart.
|
||||
let strength = self.parse_opt_drive_strength()?;
|
||||
let before_hash = self.take_before_open("#");
|
||||
let mut after_hash = Vec::new();
|
||||
let delay = if self.cur().is_sym("#") {
|
||||
self.bump();
|
||||
after_hash = self.take_gap();
|
||||
self.parse_delay_values()?
|
||||
} else {
|
||||
Vec::new()
|
||||
@@ -660,6 +702,7 @@ impl<'a> Parser<'a> {
|
||||
let name =
|
||||
if self.cur().kind == TokenKind::Ident { Some(self.expect_name()?) } else { None };
|
||||
let (name, name_span) = split_label(name);
|
||||
let before_args = self.take_before_open("(");
|
||||
self.expect_sym("(")?;
|
||||
let mut args = Vec::new();
|
||||
if !self.cur().is_sym(")") {
|
||||
@@ -673,12 +716,21 @@ impl<'a> Parser<'a> {
|
||||
if more {
|
||||
meta.trailing = self.take_trailing();
|
||||
}
|
||||
instances.push(GateInstance { meta, name, name_span, args, span });
|
||||
instances.push(GateInstance { meta, name, name_span, before_args, args, span });
|
||||
if !more {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let before_semi = self.gap_before(";");
|
||||
self.expect_sym(";")?;
|
||||
Ok(GateInstantiation { gate, strength, delay, instances })
|
||||
Ok(GateInstantiation {
|
||||
gate,
|
||||
strength,
|
||||
before_hash,
|
||||
after_hash,
|
||||
delay,
|
||||
instances,
|
||||
before_semi,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -97,21 +97,7 @@ impl<'a> Parser<'a> {
|
||||
let mark = self.pending_trailing.len();
|
||||
let inner_start = self.here();
|
||||
let inner = self.parse_expr()?;
|
||||
let inner = if self.eat_sym(":") {
|
||||
let typ = self.parse_expr()?;
|
||||
self.expect_sym(":")?;
|
||||
let max = self.parse_expr()?;
|
||||
self.expr_at(
|
||||
inner_start,
|
||||
ExprKind::MinTypMax {
|
||||
min: Box::new(inner),
|
||||
typ: Box::new(typ),
|
||||
max: Box::new(max),
|
||||
},
|
||||
)
|
||||
} else {
|
||||
inner
|
||||
};
|
||||
let inner = self.parse_min_typ_max_tail(inner_start, inner)?;
|
||||
let after = self.take_around(mark);
|
||||
self.expect_sym(")")?;
|
||||
Ok(self.expr_at(
|
||||
@@ -454,8 +440,18 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
/// In parameter connections a value may be a type (`.T(logic [7:0])`).
|
||||
///
|
||||
/// An **anonymous aggregate** is a type too — `.T(struct packed { logic a;
|
||||
/// })`, the override a `parameter type` defaulting to one takes (IEEE 1800
|
||||
/// §6.19, §7.2). `parse_type_ref` has read that body since the first day;
|
||||
/// only this door was closed, because `struct`/`union`/`enum` are not in
|
||||
/// [`TYPE_KEYWORDS`] and so fell through to `parse_expr`, whose keyword arm
|
||||
/// answers "unexpected keyword `struct` in expression".
|
||||
pub(super) fn parse_expr_or_type(&mut self) -> PResult<Expr> {
|
||||
let t = self.cur();
|
||||
if t.is_kw("struct") || t.is_kw("union") || t.is_kw("enum") {
|
||||
return self.parse_type_expr();
|
||||
}
|
||||
if t.kind == TokenKind::Keyword
|
||||
&& TYPE_KEYWORDS.contains(&t.text.as_str())
|
||||
&& !self.nth(1).is_sym("'")
|
||||
|
||||
@@ -190,7 +190,7 @@ fn a_gate_takes_a_multi_value_delay_list() {
|
||||
// The one-value parenthesized spelling keeps its `Paren` node, which
|
||||
// is what makes `#(5)` print back as `#(5)` and not as `#5`.
|
||||
let ItemKind::GateInstantiation(g) = &m.items[2].kind else { panic!("expected a gate") };
|
||||
assert!(matches!(g.delay[0].kind, ExprKind::Paren { .. }));
|
||||
assert!(matches!(g.delay[0].expr.kind, ExprKind::Paren { .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -218,3 +218,41 @@ fn a_bind_instance_may_be_a_hierarchical_path() {
|
||||
let ItemKind::Bind(b) = &f.items[0].kind else { panic!("expected a bind") };
|
||||
assert_eq!(b.instances.iter().map(|i| i.text.as_str()).collect::<Vec<_>>(), ["a.b", "plain"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_inline_aggregate_is_a_parameter_override_argument() {
|
||||
// TODO §45.3: a `parameter type` defaulting to an anonymous aggregate is
|
||||
// overridden with one, and `parse_type_ref` has read that body all along —
|
||||
// only `parse_expr_or_type`'s door was shut (`struct`/`union`/`enum` are
|
||||
// not `TYPE_KEYWORDS`), so the value read as an expression and failed.
|
||||
for src in [
|
||||
"module m;\n sub #(.T(struct packed { logic a; })) u ();\nendmodule\n",
|
||||
"module m;\n sub #(.T(union packed { logic [7:0] a; })) u ();\nendmodule\n",
|
||||
"module m;\n sub #(.T(enum logic [1:0] {A, B})) u ();\nendmodule\n",
|
||||
"module m;\n sub #(.T(struct packed { /* why */ logic a; })) u ();\nendmodule\n",
|
||||
] {
|
||||
let f = parse_ok(src);
|
||||
let ItemKind::Instantiation(i) = &module_of(&f).items[0].kind else {
|
||||
panic!("expected an instantiation")
|
||||
};
|
||||
let params = i.params.as_ref().expect("an override list");
|
||||
let value = oks(params)[0].expr.as_ref().expect("a value");
|
||||
assert!(matches!(value.kind, ExprKind::Type(_)), "{src:?} read as {:?}", value.kind);
|
||||
// Strict and tolerant must agree: the tolerant parser reports nothing
|
||||
// where the strict one succeeds.
|
||||
let (_, diags) = crate::parse_source_tolerant(src);
|
||||
assert!(diags.is_empty(), "{src:?} left {diags:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_ordered_parameter_override_takes_an_inline_aggregate_too() {
|
||||
// The bare-expression arm of `parse_connection` shares `parse_expr_or_type`
|
||||
// with the named one, so both doors opened at once.
|
||||
let f = parse_ok("module m;\n sub #(struct packed { logic a; }) u ();\nendmodule\n");
|
||||
let ItemKind::Instantiation(i) = &module_of(&f).items[0].kind else {
|
||||
panic!("expected an instantiation")
|
||||
};
|
||||
let params = i.params.as_ref().expect("an override list");
|
||||
assert!(matches!(oks(params)[0].expr.as_ref().expect("a value").kind, ExprKind::Type(_)));
|
||||
}
|
||||
@@ -614,7 +614,7 @@ fn check_item(src: &str, item: &Item, parent: TextRange) {
|
||||
}
|
||||
ItemKind::GateInstantiation(g) => {
|
||||
for d in &g.delay {
|
||||
check_expr(src, d, here);
|
||||
check_expr(src, &d.expr, here);
|
||||
}
|
||||
for i in &g.instances {
|
||||
assert_inside(src, "gate instance", i.span, here);
|
||||
@@ -1227,7 +1227,7 @@ fn check_expr(src: &str, e: &Expr, parent: TextRange) {
|
||||
check_expr(src, lo, here);
|
||||
check_expr(src, hi, here);
|
||||
}
|
||||
ExprKind::MinTypMax { min, typ, max } => {
|
||||
ExprKind::MinTypMax { min, typ, max, .. } => {
|
||||
check_expr(src, min, here);
|
||||
check_expr(src, typ, here);
|
||||
check_expr(src, max, here);
|
||||
|
||||
@@ -353,19 +353,24 @@ fn params(module: &Module, text: &str) -> Vec<PlanParam> {
|
||||
|
||||
/// A parameter's default as an override list can write it, or nothing.
|
||||
///
|
||||
/// Two things disqualify one, and the corpus produced both from a single
|
||||
/// header (`common_cells/src/ecc_encode.sv`, a `parameter type` defaulting to
|
||||
/// an anonymous multi-line `struct packed`):
|
||||
/// Two things disqualify one:
|
||||
///
|
||||
/// * it is written across several lines — the source's own indentation means
|
||||
/// nothing inside a `#( ... )` on someone else's line, and re-flowing it
|
||||
/// would risk rewriting a string literal's spaces;
|
||||
/// * writing it back does not parse — lucisv's expression grammar does not
|
||||
/// accept an inline aggregate as a parameter override, and a skeleton that
|
||||
/// does not parse hands the user a red squiggle from our own server.
|
||||
/// * writing it back does not parse, which the probe below asks rather than
|
||||
/// guesses, because a skeleton that does not parse hands the user a red
|
||||
/// squiggle from our own server.
|
||||
///
|
||||
/// A default lucisv cannot write back is simply not offered: the tabstop comes
|
||||
/// up empty and the user types what they meant.
|
||||
///
|
||||
/// The probe is what makes this grow with the grammar. An **inline aggregate**
|
||||
/// default (`parameter type T = struct packed { logic a; }`) used to fail it —
|
||||
/// the override grammar refused a `struct` head — and was dropped; since
|
||||
/// TODO §45.3 the same probe passes and the type text is emitted. Only the
|
||||
/// multi-line spelling, which the corpus's `common_cells/src/ecc_encode.sv`
|
||||
/// writes, is still refused, and by the first rule rather than the second.
|
||||
fn default_text(text: &str, param: &ParamPort) -> String {
|
||||
let Some(expr) = ¶m.default else { return String::new() };
|
||||
let written = slice(text, expr.span).trim();
|
||||
@@ -743,6 +748,38 @@ endmodule
|
||||
assert!(parse_source_tolerant(&probe).1.is_empty(), "the skeleton must parse: {skeleton}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_one_line_inline_aggregate_default_is_emitted() {
|
||||
// TODO §45.3: the override grammar accepts an inline aggregate, so the
|
||||
// probe in `default_text` passes and the type text is offered instead
|
||||
// of an empty tabstop. Only the multi-line spelling is still dropped,
|
||||
// by the "written across several lines" rule above it.
|
||||
let text = "\
|
||||
module agg #(
|
||||
parameter type packed_t = struct packed {logic parity; logic [7:0] word;},
|
||||
parameter type state_e = enum logic [1:0] {IDLE, BUSY}
|
||||
) ();
|
||||
endmodule
|
||||
";
|
||||
let plan = plan(text, "agg");
|
||||
assert_eq!(
|
||||
plan.params,
|
||||
vec![
|
||||
PlanParam {
|
||||
name: "packed_t".into(),
|
||||
default: "struct packed {logic parity; logic [7:0] word;}".into(),
|
||||
},
|
||||
PlanParam {
|
||||
name: "state_e".into(),
|
||||
default: "enum logic [1:0] {IDLE, BUSY}".into(),
|
||||
},
|
||||
]
|
||||
);
|
||||
let skeleton = plan.render(&Layout::default());
|
||||
let probe = format!("module p;\n{skeleton}\nendmodule\n");
|
||||
assert!(parse_source_tolerant(&probe).1.is_empty(), "the skeleton must parse: {skeleton}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_multi_line_type_is_shown_on_one_line() {
|
||||
let text = "\
|
||||
|
||||
@@ -175,7 +175,7 @@ impl<'a> Binder<'a> {
|
||||
// same rule connection port names follow).
|
||||
ExprKind::NamedArg { value, .. } => self.bind_expr(value, scope),
|
||||
ExprKind::Type(ty) => self.bind_data_type(ty, e.span, scope),
|
||||
ExprKind::MinTypMax { min, typ, max } => {
|
||||
ExprKind::MinTypMax { min, typ, max, .. } => {
|
||||
self.bind_expr(min, scope);
|
||||
self.bind_expr(typ, scope);
|
||||
self.bind_expr(max, scope);
|
||||
|
||||
@@ -108,7 +108,7 @@ impl<'a> Binder<'a> {
|
||||
ItemKind::Bind(b) => self.bind_bind(b, scope),
|
||||
ItemKind::GateInstantiation(g) => {
|
||||
for d in &g.delay {
|
||||
self.bind_expr(d, scope);
|
||||
self.bind_expr(&d.expr, scope);
|
||||
}
|
||||
for inst in &g.instances {
|
||||
if let (Some(name), Some(ns)) = (&inst.name, inst.name_span) {
|
||||
|
||||
@@ -0,0 +1,565 @@
|
||||
# didOpen cost
|
||||
|
||||
## Goal
|
||||
|
||||
Take 3 (`docs/performance_take3.md` §8.4) measured that a `didOpen` of a file
|
||||
the index already covers delays the **next** request by 21–51 ms, scaling with
|
||||
file size, where take 2 measured a flat 2–4 ms. The server is a synchronous
|
||||
loop, so whatever the open does before returning is what the next request waits
|
||||
behind. TODO.md §46 asked for the cost to be measured, broken down, and for the
|
||||
largest item in it — not all of them — to be fixed, with the open returning to
|
||||
the loop fast enough that the request behind it is not left waiting and is
|
||||
still answered from up-to-date state.
|
||||
|
||||
The finding turned out to understate the problem by an order of magnitude. At
|
||||
the whole-workspace scope, opening opentitan's 42 000-line
|
||||
`pinmux_reg_top.sv` delayed the next request by **1.74 seconds**, and the whole
|
||||
of it was one lint rule asking the workspace census a question per declaration
|
||||
in the buffer. Moving that question behind the rule's own local guards — where
|
||||
its twin rule has always asked it — took the same open to **117 ms**, and took
|
||||
the take-3 rows from 51–95 ms to 3–9 ms.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **The oracle is a pure predicate.** `MentionOracle::mentioned_elsewhere` reads
|
||||
the index and returns a `bool`; it has no side effects, so where in a
|
||||
conjunction of `continue` guards it is asked cannot change what the rule
|
||||
finds. Pinned empirically as well as argued: the 0.39.0 binary and the fixed
|
||||
one publish byte-identical diagnostics for a workspace built to exercise both
|
||||
answers (below).
|
||||
- **A `didOpen`'s buffer must be analyzed before the open returns.** Every
|
||||
request flushes dirty buffers first (`Server::answer_request`), so deferring
|
||||
the *parse* to the change debounce would move the cost, not remove it, and
|
||||
would break "the first request after the open is answered from up-to-date
|
||||
state". The parse stays synchronous, and so does the publish.
|
||||
- The measurements are wire-level and on one machine (below). Sub-millisecond
|
||||
differences are not claimed; everything reported here is a factor, not a
|
||||
percent.
|
||||
- opentitan is read-only. The index cache went to a scratch
|
||||
`initializationOptions.storagePath`; `git -C ~/repo/opentitan status
|
||||
--porcelain` reported the same three pre-existing modified files before and
|
||||
after every phase.
|
||||
|
||||
## Handshakes
|
||||
|
||||
- **`vlog_linter` → the server, unchanged.** `UndrivenNet::check` returns the
|
||||
same violations, in the same order, for the same context. No rule signature,
|
||||
no registry entry, no severity and no `default_on`/`needs_workspace` answer
|
||||
moved. `lucisv check` is unaffected in every way (it has no oracle, so the
|
||||
reordered test is a constant `false` there).
|
||||
- **`WorkspaceIndex::files_mentioning` — no change requested.** Its doc comment
|
||||
records that a merged `word → files` map was measured against the per-file
|
||||
walk and rejected. That ruling stands and is not reopened here: the fix is to
|
||||
ask the question a thousand times fewer, not to make the question faster.
|
||||
What this round adds to the record is the cost of *one* question — a walk
|
||||
over every indexed file — which is what makes asking it per declaration a
|
||||
mistake at any workspace size.
|
||||
- **`Server::publish` / `flush_dirty` — untouched.** §46 allowed the open's
|
||||
diagnostics to be moved onto the change debounce. They were not; see
|
||||
"What was not done".
|
||||
|
||||
## The measurement
|
||||
|
||||
### Method
|
||||
|
||||
`scratchpad/perf46/driver.py`, take 3's method (§9 of that doc): framed
|
||||
JSON-RPC over the server's stdio, `workspace/configuration` answered with
|
||||
`{"index":{"scope":"workspace"}}`, cache warmth through
|
||||
`initializationOptions.storagePath`, positions resolved from the file text at
|
||||
run time. Per file, in one settled session: `didOpen` and a `textDocument/hover`
|
||||
at the first `module <name>` token written in the **same** flush, timed from the
|
||||
`didOpen` frame going out to the hover response coming back; then the identical
|
||||
hover again as the control. Three tries per file per binary, warm store.
|
||||
|
||||
Both binaries `cargo build --release -p lucisv_server`: the tree at f795606
|
||||
(0.43.0) and `v0.39.0` from a scratch `git worktree` (removed afterwards).
|
||||
Every server run, build and sweep went through `tools/guard.sh -m 8 -t 900`;
|
||||
no guard kill occurred.
|
||||
|
||||
Machine: Apple M1 Max, 10 cores, 64 GB, macOS 27.0, quiet (load 1–3), nothing
|
||||
else building.
|
||||
|
||||
**Note on the file set.** §46 named "the largest file in
|
||||
`hw/top_darjeeling/ip/xbar_peri/rtl/autogen/` (tl_peri_pkg.sv-class, ~42k
|
||||
lines)". In this checkout that directory holds only an 8 KB and a 3.6 KB file;
|
||||
the ~42 000-line file the plan meant is
|
||||
`hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv` (42 192 lines,
|
||||
1.3 MB), the largest `.sv` in the tree. That is the file used.
|
||||
|
||||
### Where the time went — the breakdown
|
||||
|
||||
Temporary `eprintln!` timings inside `didOpen`, `Document::new`,
|
||||
`Server::publish`, `diagnostics::all_in` and `lint_with`'s rule loop, on the
|
||||
release build; **all of them removed before finishing** (`git diff` shows only
|
||||
the rule and the tests). Milliseconds, one representative try per file.
|
||||
|
||||
| Stage | `aes.sv` 326 L | `aes_core.sv` 1 145 L | `pinmux_reg_top.sv` 42 192 L |
|
||||
|---|---:|---:|---:|
|
||||
| lex | 0.31 | 1.01 | 41.24 |
|
||||
| tolerant parse | 0.59 | 1.01 | 31.73 |
|
||||
| `collect_defines` | 0.00 | 0.01 | 0.57 |
|
||||
| `analyze` | 0.17 | 0.56 | 11.57 |
|
||||
| `resolve_external` | 0.12 | 0.32 | 4.79 |
|
||||
| line index | 0.01 | 0.03 | 0.62 |
|
||||
| **`Document::new` (the whole parse)** | **1.33** | **3.04** | **90.61** |
|
||||
| `LintRun::for_document` (discovery, waivers, memo) | 0.34 | 0.07 | 0.09 |
|
||||
| `diagnostics::all_in` (the lint pass) | 4.87 | 54.43 | **1 653.76** |
|
||||
| — of which the rule `undriven-net` | 4.38 | 52.23 | **1 608.45** |
|
||||
| — of which `multiply-driven` | — | — | 8.22 |
|
||||
| — every other rule, together | ≈0.5 | ≈2.2 | ≈37 |
|
||||
| **`didOpen` total** | **7.07** | **58.01** | **1 745.06** |
|
||||
|
||||
Two things the table settles:
|
||||
|
||||
1. **The widen is not involved.** At the whole-workspace scope every file is
|
||||
already in scope, so `widen_of` answers `Nothing` and the open costs the
|
||||
parse plus the publish and nothing else. The `didOpen` total is the sum of
|
||||
the two rows above it to within 0.2 ms.
|
||||
2. **The lint pass is 75 / 94 / 95 % of the open, and one rule is 90 / 96 /
|
||||
97 % of the lint pass.** `LintRun::for_document` — §42's discovery, the
|
||||
waiver-file reads and the once-only memo, the thing §46 guessed at — costs
|
||||
70–340 µs and is not a candidate. Neither is the completion word table or
|
||||
the semantic tokens: neither runs on an open at all.
|
||||
|
||||
### Why `undriven-net` cost that
|
||||
|
||||
The rule asked the workspace census about **every** declaration in the buffer,
|
||||
before any of its local guards had a chance to silence it:
|
||||
|
||||
```rust
|
||||
if intentionally_unused(..) || !judgeable(..) || has_init { continue }
|
||||
if ctx.mentioned_elsewhere(&decl.name) { continue } // ← was here
|
||||
let Some(usage) = signals.usage(decl) else { continue };
|
||||
if connected || driven || reads == 0 { continue }
|
||||
found.push(..)
|
||||
```
|
||||
|
||||
One `mentioned_elsewhere` is `WorkspaceIndex::files_mentioning`, a walk over
|
||||
**every indexed file** binary-searching its sorted word list — 3 976 files in
|
||||
opentitan at the workspace scope. `pinmux_reg_top.sv` has roughly four thousand
|
||||
declarations, and essentially all of them are driven, so all four thousand
|
||||
questions were asked and all four thousand answers were thrown away by the very
|
||||
next guard. `unused-signal`, the twin rule with the same oracle, has always
|
||||
asked last, which is why it never showed up in a profile.
|
||||
|
||||
The fix is to ask the question where its twin asks it: last, of the handful of
|
||||
declarations that would otherwise be reported. It is a pure reordering of a
|
||||
conjunction of `continue` guards over a side-effect-free predicate, so the
|
||||
findings and their order are unchanged.
|
||||
|
||||
### Before and after — the three §46 files
|
||||
|
||||
Wire time, `didOpen` → the hover behind it, three tries, warm store, workspace
|
||||
scope, ms.
|
||||
|
||||
| File | lines | KB | 0.39.0 | 0.43.0 **before** | 0.43.0 **after** | factor |
|
||||
|---|---:|---:|---|---|---|---:|
|
||||
| `hw/ip/aes/rtl/aes.sv` | 326 | 14 | 8.6 / 9.5 / 7.8 | 8.1 / 5.9 / 10.1 | **4.3 / 1.8 / 2.3** | ~3× |
|
||||
| `hw/ip/aes/rtl/aes_core.sv` | 1 145 | 49 | 55.8 / 65.7 / 44.4 | 56.2 / 54.0 / 48.0 | **5.9 / 6.9 / 6.3** | ~8× |
|
||||
| `…/pinmux/rtl/pinmux_reg_top.sv` | 42 192 | 1 297 | 1 725.8 / 1 694.1 / 1 751.1 | 1 742.5 / 1 740.2 / 1 756.8 | **116.5 / 116.2 / 117.3** | ~15× |
|
||||
|
||||
The control — the identical hover issued straight after the first — is
|
||||
0.09–0.20 ms for `aes.sv`, 0.12–0.19 for `aes_core.sv` and 0.46–0.60 for
|
||||
`pinmux_reg_top.sv`, before and after alike. It is the open that costs, exactly
|
||||
as take 3 said.
|
||||
|
||||
**0.39.0 measures the same as 0.43.0 before the fix.** This was never a
|
||||
regression: `undriven-net` has asked in that order since it was written. Take
|
||||
3's §8.4 comparison against take 2's 2–4 ms is therefore not a "something got
|
||||
slower" story, and take 2's client — which no longer exists — most likely
|
||||
measured a session whose scope did not switch the workspace rules on at all.
|
||||
|
||||
### Before and after — take 3's own §8.4 rows
|
||||
|
||||
Same method, whole-workspace scope. (Take 3 measured these at the *default*
|
||||
scope after the `aes.sv` widen, where the census covers ~124 files rather than
|
||||
3 976; that is why the "before" column here is worse than §8.4's 21/31/51 ms.
|
||||
The two are the same defect at two census sizes.)
|
||||
|
||||
| File | KB | take 3 §8.4 (default scope) | **before** (workspace scope) | **after** |
|
||||
|---|---:|---:|---|---|
|
||||
| `hw/ip/hmac/rtl/hmac.sv` | 33 | 21.1 | 56.8 / 42.7 / 51.0 | **4.7 / 5.7 / 3.3** |
|
||||
| `hw/ip/kmac/rtl/kmac.sv` | 53 | 31.1 | 69.3 / 72.1 / 70.6 | **7.9 / 5.3 / 8.8** |
|
||||
| `hw/ip/spi_device/rtl/spi_device.sv` | 67 | 51.2 | 94.2 / 103.4 / 88.6 | **6.0 / 8.6 / 8.7** |
|
||||
|
||||
### The ≤ 5 ms contract, honestly
|
||||
|
||||
§46 asked for "`didOpen` returns to the loop in ≤ 5 ms for a 1 000-line file".
|
||||
|
||||
- For a **generated** 1 000-line buffer the release binary is under 2 ms. Met.
|
||||
- For `aes_core.sv` — 1 145 lines but 49 KB of dense opentitan RTL, four times
|
||||
the bytes per line of a generated file — the open is **5.9–6.9 ms**, of which
|
||||
**3.0–4.4 ms is `Document::new`**: the lex, the tolerant parse, the semantic
|
||||
analysis and the external resolution. The lint pass is now 1.3 ms of it.
|
||||
So the contract is met per line and missed per byte on the densest real file
|
||||
measured, and the remainder is the parse — which cannot be deferred without
|
||||
breaking "the first request after the open is answered from up-to-date
|
||||
state". Recorded as the limit rather than met by redefining the file.
|
||||
|
||||
### Behavioural equivalence, checked on the wire
|
||||
|
||||
A two-file scratch workspace built to exercise both oracle answers: `top.sv`
|
||||
declares `lonely` (read, undriven, mentioned nowhere else) and `shared_name`
|
||||
(read, undriven, but `force`d from `other.sv`). Both binaries publish exactly
|
||||
|
||||
```
|
||||
undriven-net @1:7 `lonely` is read but never driven
|
||||
```
|
||||
|
||||
and nothing about `shared_name` — the census still silences it. Byte-identical
|
||||
between 0.39.0 and the fixed build.
|
||||
|
||||
## What was not done, and why
|
||||
|
||||
- **The open's diagnostics were not moved onto the change debounce.** §46 named
|
||||
it as a likely shape and allowed the diagnostics to arrive a debounce later.
|
||||
They still go out inside the `didOpen`, synchronously, because after the fix
|
||||
the whole publish is 0.5–1.5 ms on a real RTL file and 24 ms on a
|
||||
42 000-line one; deferring it would buy a millisecond and cost the guarantee
|
||||
that an opened file is diagnosed before anything queued behind it is
|
||||
answered. **There is no debounce on the open, and there is nothing new to
|
||||
pin about when diagnostics arrive** — pinned anyway, by
|
||||
`an_open_still_publishes_its_diagnostics_with_no_edit_behind_it`.
|
||||
- **The buffer's re-index was not skipped on a content-hash match.** §46's
|
||||
other suggested shape. It is not on the open path at all: a `didOpen` of a
|
||||
file already in scope runs no index update — `widen_of` answers `Nothing` and
|
||||
the index is untouched until a `didSave`. There was nothing to skip.
|
||||
- **`WorkspaceIndex::files_mentioning` was not given an inverted index.** See
|
||||
Handshakes: that ruling is recorded in its own doc comment and is not this
|
||||
round's to reopen. It is now the largest single item left on the open path
|
||||
for a 42 000-line file (`multiply-driven` at 8 ms is the next), but at
|
||||
~117 ms total the file is no longer the round's problem.
|
||||
- **The other 95 ms of `pinmux_reg_top.sv`'s open is the parse** (lex 41 ms,
|
||||
parse 32 ms, analyze 12 ms). Not touched; it is the price of a 1.3 MB buffer
|
||||
and it is 25× under the large-file threshold that would skip it.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] Measure first: the driver, three files, three tries, both binaries, warm
|
||||
store, workspace scope.
|
||||
- [x] Profile the open path with temporary timings; the breakdown table above;
|
||||
the timings removed (`git diff` is the rule plus the tests).
|
||||
- [x] Fix the largest item: `undriven-net` asks the census last.
|
||||
- [x] Wire-level timing test on a generated 2 000-line buffer.
|
||||
- [x] Correctness pin: the first hover **and** the first definition after an
|
||||
open see the buffer, not the disk.
|
||||
- [x] Diagnostics-still-arrive pin, with the debounce question answered (there
|
||||
is none).
|
||||
- [x] Exact regression pin: the oracle is asked once per reported candidate.
|
||||
- [x] The take-3 rows re-measured, before and after, in this README.
|
||||
- [x] Gates: `cargo fmt -p lucisv_server -p vlog_linter`, `cargo clippy
|
||||
--all-targets`, `cargo test --workspace`, `tools/corpus_check.sh`,
|
||||
`editors/vscode/smoke.js` — all guarded.
|
||||
- [ ] QA.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-05 — dev (Fable 5.1)
|
||||
|
||||
- Built both binaries release: the tree at f795606, and `v0.39.0` in a scratch
|
||||
worktree under the scratchpad (removed at the end, `git worktree remove`).
|
||||
- Wrote `scratchpad/perf46/driver.py` to take 3's method and measured the three
|
||||
§46 files, three tries each, on both binaries. Both binaries measured the
|
||||
same, which is the first finding: **§8.4 is not a regression**.
|
||||
- Instrumented the open path with temporary `eprintln!` timings at four levels
|
||||
(the `didOpen` arm, `Document::new`'s six steps, `Server::publish` /
|
||||
`diagnostics_of`, and `lint_with`'s per-rule loop), measured, and removed
|
||||
every one of them. The breakdown table is above.
|
||||
- Result: the lint pass is 75–95 % of the open and `undriven-net` is 90–97 % of
|
||||
the lint pass, because it asked the workspace census once per declaration
|
||||
ahead of its own local guards. `unused-signal`, the twin rule, has always
|
||||
asked last.
|
||||
- **The fix**: move `ctx.mentioned_elsewhere` in `UndrivenNet::check` below the
|
||||
`usage` / `connected` / `driven` / `reads == 0` guards. Six lines moved, a
|
||||
comment saying why. A pure reordering of `continue`s over a side-effect-free
|
||||
predicate.
|
||||
- Checked equivalence three ways: the unit suite, the corpus check (unmoved),
|
||||
and a wire comparison of published diagnostics between the 0.39.0 binary and
|
||||
the fixed one over a workspace built so that the census both fires and does
|
||||
not. Identical.
|
||||
- Tests: one exact regression pin in the rule (a counting oracle — the findings
|
||||
alone cannot tell the two orders apart), and three wire-level tests in
|
||||
`crates/lucisv_server/tests/e2e.rs` reusing the `Live` session helper that
|
||||
was already there (`talk` writes a whole session before reading, so it cannot
|
||||
time anything).
|
||||
- **Deviation, stated plainly: the wire test's bound is 200 ms, not §46's
|
||||
25 ms.** Two reasons, both measured. (1) `cargo test` builds unoptimized, and
|
||||
one tolerant parse of a 2 000-line buffer costs ~53 ms there on its own —
|
||||
stable to a millisecond across runs — so 25 ms is unreachable in a debug
|
||||
build whatever the lint pass does; §46's 25 ms is a release figure, and the
|
||||
release binary opens the same buffer in 2–4 ms. (2) The test cannot catch the
|
||||
§46 defect at any bound: the census walk costs milliseconds over a forty-file
|
||||
fixture (measured — 53 ms with the fix, 54 ms without it, and 63 ms with the
|
||||
fixture grown to 400 files and per-file-unique names), and a fixture of
|
||||
opentitan's four thousand files has no business in the suite. So the wire
|
||||
test pins the contract — an open does not start doing something unbounded —
|
||||
and the counting oracle test in `undriven_net.rs` is the exact pin for the
|
||||
defect. Both are documented as such in their own doc comments.
|
||||
- Scratch worktree removed; driver and scratch stores deleted; opentitan
|
||||
`git status --porcelain` reports the three pre-existing files and nothing
|
||||
else.
|
||||
|
||||
**Files touched** (the plan's expected set, plus one):
|
||||
|
||||
- `crates/vlog_linter/src/rules/undriven_net.rs` — the fix and its test.
|
||||
- `crates/lucisv_server/tests/e2e.rs` — three wire tests and two helpers.
|
||||
- `docs/features/didopen-cost/README.md` — this file.
|
||||
- `TODO.md` — §46's four dev checkboxes and §44's `didOpen` line.
|
||||
|
||||
Nothing else. In particular **no server source file was changed**: the fix
|
||||
turned out to be one rule in `vlog_linter`, not anything in the open path
|
||||
itself, which is why `crates/lucisv_server/src/server/{notification,diagnostics,
|
||||
index}.rs` and `state.rs` are untouched despite being where §46 expected the
|
||||
work.
|
||||
|
||||
**Gate numbers**: `cargo fmt -p lucisv_server -p vlog_linter` clean; `cargo
|
||||
clippy --all-targets` clean; `cargo test --workspace` **3 814 passed, 0
|
||||
failed, 44 ignored** (baseline 3 810 — the four new tests);
|
||||
`tools/corpus_check.sh` **814/820**, the same six failures and the same
|
||||
`verification-error: none` / `crash: none`; `node editors/vscode/smoke.js
|
||||
target/release/lucisv-server` OK. Every one guarded at `-m 8`; no guard kill,
|
||||
and nothing came near the limit.
|
||||
|
||||
## Docs to apply at merge (lead)
|
||||
|
||||
### `docs/performance_take3.md` — annotate finding §8.4
|
||||
|
||||
Append to §8.4, after the "Reproduce" paragraph:
|
||||
|
||||
> **Fixed in 0.44.0 (TODO §46), and the finding understated it.** The delay is
|
||||
> not the widen, the diagnostics plumbing or §42's lint-run construction: it is
|
||||
> one rule. `undriven-net` asked the workspace census
|
||||
> (`WorkspaceIndex::files_mentioning`, a walk over every indexed file) once per
|
||||
> declaration in the buffer, *before* its own local guards had a chance to
|
||||
> silence it — so a file with four thousand declarations asked four thousand
|
||||
> questions and threw away four thousand answers. `unused-signal`, the twin
|
||||
> rule with the same oracle, has always asked last; `undriven-net` now does
|
||||
> too. At the whole-workspace scope, where the census covers 3 976 files rather
|
||||
> than this section's ~124, the same three files measured 51 / 70 / 95 ms
|
||||
> before and **4.6 / 7.3 / 7.8 ms** after, and opentitan's largest file,
|
||||
> `hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv` (42 192 lines),
|
||||
> went from **1 742 ms to 117 ms**. The take-2 comparison in this section
|
||||
> should be read as "take 2's session probably did not have the workspace rules
|
||||
> on", not as a regression: 0.39.0 measures the same as 0.43.0 on every cell.
|
||||
> Breakdown and method in `docs/features/didopen-cost/README.md`.
|
||||
|
||||
### `docs/perf/README.md` — a new entry
|
||||
|
||||
> ### 2026-09-05 — the `didOpen` delay (TODO §46, 0.44.0)
|
||||
>
|
||||
> Take 3's §8.4 (a `didOpen` of an already-indexed file delaying the next
|
||||
> request by 21–51 ms) measured and fixed. The breakdown, taken with temporary
|
||||
> timings on a release build and re-taken after: the tolerant parse plus the
|
||||
> semantic analysis is 1.3 / 3.0 / 91 ms for a 326- / 1 145- / 42 192-line
|
||||
> opentitan file, and the lint pass was 4.9 / 54 / 1 654 ms — of which
|
||||
> `undriven-net` alone was 4.4 / 52 / 1 608. The rule asked
|
||||
> `WorkspaceIndex::files_mentioning` (a walk over all 3 976 indexed files) once
|
||||
> per declaration, ahead of the local guards that silence almost all of them.
|
||||
> Moved behind them, where `unused-signal` has always asked.
|
||||
>
|
||||
> Wire time, `didOpen` → the request behind it, workspace scope, warm store,
|
||||
> three tries, M1 Max:
|
||||
>
|
||||
> | file | before | after |
|
||||
> |---|---|---|
|
||||
> | `aes.sv` (326 L) | 8.1 / 5.9 / 10.1 ms | 4.3 / 1.8 / 2.3 ms |
|
||||
> | `aes_core.sv` (1 145 L) | 56.2 / 54.0 / 48.0 ms | 5.9 / 6.9 / 6.3 ms |
|
||||
> | `hmac.sv` | 56.8 / 42.7 / 51.0 ms | 4.7 / 5.7 / 3.3 ms |
|
||||
> | `kmac.sv` | 69.3 / 72.1 / 70.6 ms | 7.9 / 5.3 / 8.8 ms |
|
||||
> | `spi_device.sv` | 94.2 / 103.4 / 88.6 ms | 6.0 / 8.6 / 8.7 ms |
|
||||
> | `pinmux_reg_top.sv` (42 192 L) | 1 742 / 1 740 / 1 757 ms | 116.5 / 116.2 / 117.3 ms |
|
||||
>
|
||||
> The same cost was paid on **every keystroke flush**, not just on opens: the
|
||||
> change debounce ends in the same `set_document` + `publish` pair.
|
||||
> 0.39.0 measures the same as 0.43.0 everywhere in the "before" column, so this
|
||||
> was never a regression — it is a rule that has been ordered that way since it
|
||||
> was written. Published diagnostics are byte-identical before and after.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-09-05 — QA (Sonnet)
|
||||
|
||||
**Verdict: PASS.** No HIGH or MEDIUM findings. Two LOW/informational notes
|
||||
below; neither blocks the fix.
|
||||
|
||||
**What was verified, and how.**
|
||||
|
||||
1. **Code reading.** `git diff` of the three touched files
|
||||
(`crates/vlog_linter/src/rules/undriven_net.rs`,
|
||||
`crates/lucisv_server/tests/e2e.rs`, `TODO.md`) — a pure reordering of six
|
||||
lines plus a comment in the rule, one new unit test asserting the oracle's
|
||||
call count, and three new wire-level tests reusing the existing `Live`
|
||||
helper. Confirmed `unused-signal` (`crates/vlog_linter/src/rules/
|
||||
unused_signal.rs`) already asks its oracle last, behind
|
||||
`mentioned_outside_declarations`, unchanged by this diff — the dev's "its
|
||||
twin rule has always asked last" claim checks out by inspection.
|
||||
`WorkspaceIndex::files_mentioning`/`files_naming_in_macros`
|
||||
(`crates/vlog_semantic/src/workspace/index.rs:286-331`) confirmed
|
||||
word-exact (binary search over a sorted per-file word list, no substring
|
||||
matching) and `crates/vlog_semantic/src/words.rs` confirmed comments
|
||||
contribute no words (only `Ident`/`SystemIdent` tokens and raw text inside
|
||||
macros/directives/attributes) and macro-argument text is folded into the
|
||||
*same* union census `files_mentioning` reads — so a macro-only mention is
|
||||
expected to silence the rule exactly as a plain mention does.
|
||||
2. **Equivalence, scratch workspace.** Built both binaries release
|
||||
(`tools/guard.sh -m 8 -t 900 -- cargo build --release -p lucisv -p
|
||||
lucisv_server`): the working tree at f795606-plus-uncommitted-diff, and
|
||||
`v0.43.0` in a scratch `git worktree` (removed after). Wrote a five-file
|
||||
scratch workspace (`top.sv`, `tb.sv`, `bound_over.sv`, `iface/bus_if.sv`,
|
||||
`pkg/util_pkg.sv`) exercising every guard interaction the attack list
|
||||
named: undriven+mentioned (silent), undriven+unmentioned (reported), driven
|
||||
locally+mentioned (silent), undriven but hierarchically assigned from a
|
||||
sibling testbench (silent), `force`d through a hierarchical path from a
|
||||
sibling (silent), named only in a sibling's `bind`-ed override connection
|
||||
(silent), a plain cross-file mention (silent), a name that is only a
|
||||
*substring* of a longer identifier in a sibling (still **reported** — no
|
||||
substring match), a name that appears in a sibling only inside a `//`
|
||||
comment (still **reported** — comments aren't tokens), a name that appears
|
||||
in a sibling only as a macro argument (silent — the raw-text fold), each
|
||||
port direction, a net inside a `generate` block, a `logic` variable
|
||||
(not a `wire`), an interface, and a package. `lucisv check --select
|
||||
undriven-net .` and `--select unused-signal,undriven-net .` and a full
|
||||
`check .`, text and `--output-format json`: **byte-identical** between the
|
||||
two binaries in every case (6 violations found; `undriven_hier`,
|
||||
`undriven_forced`, `undriven_bound`, `undriven_macro_arg`,
|
||||
`undriven_mentioned`, `driven_and_mentioned` all correctly silent).
|
||||
3. **Equivalence, opentitan (read-only).** `--select undriven-net,unused-signal
|
||||
--output-format json` over `hw/ip/aes`, `hw/ip/hmac`, `hw/ip/spi_device`,
|
||||
`hw/top_darjeeling/ip_autogen/pinmux`, sets compared (order does not
|
||||
matter here since neither directory produced more than one finding):
|
||||
**identical** in all four (`aes`: 1 finding both binaries, set-equal;
|
||||
the other three: 0 findings, both). `git -C ~/repo/opentitan status
|
||||
--porcelain` before and after: only the three pre-existing files
|
||||
(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
|
||||
`hw/top_earlgrey/ip/ast/rtl/ast.sv`).
|
||||
4. **The counting-oracle unit test, reverted.** Not reverted in this tree.
|
||||
Copied the dev's `undriven_net.rs` (with the fix and its new tests) into a
|
||||
fresh scratch worktree at f795606, hand-reverted only the six-line reorder
|
||||
(oracle back above the `usage`/`driven`/`connected`/`reads==0` guards,
|
||||
dev's new test left as written), and ran
|
||||
`cargo test -p vlog_linter --lib rules::undriven_net::`. Result: 16 of 17
|
||||
pass; `the_project_is_asked_only_about_the_signals_that_would_be_reported`
|
||||
**fails** — `assertion left == right failed: left: 10, right: 1` — exactly
|
||||
what asking the oracle before the local guards predicts (all ten
|
||||
signals in that fixture are `judgeable` with no initializer, so all ten
|
||||
reach the pre-fix guard). Confirms the test is an exact regression pin,
|
||||
not a tautology. Worktree removed after.
|
||||
5. **Wire timing, independently reproduced.** The dev's driver is gone, so a
|
||||
new one was written (`scratchpad/perf46_qa/driver.py`, this session's
|
||||
scratchpad) to the same shape: framed JSON-RPC over stdio,
|
||||
`initializationOptions.storagePath` for cache control, `workspace/
|
||||
didChangeConfiguration` to the workspace scope, a `workspace/symbol`
|
||||
barrier before timing, `didOpen`+`hover` in the same flush timed from send
|
||||
to the hover response, warm store, three tries. M1 Max (10 cores, 64 GB),
|
||||
`v0.43.0` (scratch worktree, removed after) vs the fixed tree's release
|
||||
build:
|
||||
|
||||
| File | 0.43.0 | fixed | factor |
|
||||
|---|---:|---:|---:|
|
||||
| `aes.sv` | 4.83 / 4.81 / 4.88 ms | 1.49 / 1.35 / 1.31 ms | ~3.4× |
|
||||
| `aes_core.sv` | 41.4 / 43.2 / 47.1 ms | 3.90 / 3.66 / 3.57 ms | ~11× |
|
||||
| `pinmux_reg_top.sv` | 1825 / 1805 / 1806 ms | 104 / 108 / 107 ms | ~17× |
|
||||
|
||||
Independently-measured numbers differ from the README's own table (a
|
||||
different driver, different process/JSON overhead, one machine) but the
|
||||
**direction and rough magnitude match closely**, `pinmux_reg_top.sv`
|
||||
especially (~17× here vs ~15× claimed, 104-108 ms here vs 116-117 ms
|
||||
claimed). The control hover (issued right after) was 0.05-0.85 ms in every
|
||||
case, before and after alike, confirming the open itself is what costs.
|
||||
Also timed a `didChange` full-text flush on `aes_core.sv` (not just
|
||||
`didOpen`): **42.6-43.5 ms (0.43.0) → 3.8-4.0 ms (fixed)** — confirms the
|
||||
README's "the same cost was paid on every keystroke flush" claim; the
|
||||
flush and the open cost the same because both end in the same
|
||||
`set_document` + `publish` pair, as documented.
|
||||
6. **`opentitan`'s 1.0 MiB index-scan cap, noted in passing (see finding
|
||||
below).** Confirmed by `window/logMessage` output during warm-up:
|
||||
`pinmux_reg_top.sv` under all three top-level variants is *skipped from
|
||||
the workspace index scan* ("skipped (1.3 MiB > 1.0 MiB cap)"), which is
|
||||
exactly take 3's "3976 indexed, 3 skipped" — not a new discovery, just
|
||||
confirms the population this round's numbers describe. The currently
|
||||
*open* buffer is unaffected by this cap (it goes through `Document::new`
|
||||
on `didOpen` regardless of size), which is why the dev's own breakdown
|
||||
table and this session's timings both see `pinmux_reg_top.sv` fully
|
||||
parsed and linted when opened.
|
||||
7. **e2e tests, 5×.** `tools/guard.sh -m 8 -t 300 -- cargo test -p
|
||||
lucisv_server --test e2e -- --test-threads=1
|
||||
opening_a_two_thousand_line_buffer_does_not_delay_the_request_behind_it
|
||||
the_first_hover_after_an_open_sees_the_buffer_and_not_the_disk
|
||||
an_open_still_publishes_its_diagnostics_with_no_edit_behind_it`: **3
|
||||
passed, 0 failed, every one of 5 runs**, 0.65-0.70 s each. Stable.
|
||||
8. **The 200 ms vs 25 ms question — my view for the lead.** The dev's
|
||||
reasoning holds up under independent measurement, not just their own
|
||||
instrumentation: (a) `target/debug/lucisv check` on a fresh 2000-line
|
||||
generated buffer (no workspace) took ~40 ms wall-clock (steady state,
|
||||
process spawn included) against `target/release/lucisv`'s ~10 ms on the
|
||||
same buffer — a debug/release ratio in the same ballpark as the dev's
|
||||
53 ms/2-4 ms claim for the parse alone; (b) a release-mode wire
|
||||
measurement of a comparable 2000-line generated buffer (matching the
|
||||
e2e test's own `generated_module` shape, 40 package neighbours, through
|
||||
the *actual LSP wire* including Python subprocess/JSON overhead) came
|
||||
back at 11.7-11.8 ms — comfortably under both 25 ms and 200 ms. This
|
||||
triangulates the dev's claim: the 200 ms bound is not hiding a live
|
||||
defect, it is debug-build parse cost that release mode does not pay, so
|
||||
asking the debug-build wire test for 25 ms would be asking it to beat a
|
||||
floor the interpreter/parser layer sets on its own. **200 ms is the
|
||||
right bound for this test**; I would not lower it, and I would not read
|
||||
"200 ms, not 25 ms" as the fix being incomplete.
|
||||
9. **Gates, guarded, re-run independently.** `cargo clippy --all-targets`:
|
||||
clean (0.12 s — fully cached, nothing to re-lint since the dev's own
|
||||
clean run). `tools/guard.sh -m 8 -t 1800 -- cargo test --workspace`:
|
||||
**3814 passed, 0 failed, 44 ignored** (summed across every crate's `test
|
||||
result:` line) — matches the dev's claimed count exactly.
|
||||
`tools/guard.sh -m 8 -t 1800 -- tools/corpus_check.sh`: **814/820
|
||||
(99.3%)**, `verification-error: none`, `crash: none`, the same six parse
|
||||
errors. `node editors/vscode/smoke.js target/release/lucisv-server`: OK
|
||||
(20 messages). No guard kill on any run.
|
||||
|
||||
**Findings.**
|
||||
|
||||
- **LOW (informational, not a defect).** While this QA was running, the
|
||||
shared working tree picked up further edits not part of the dev's
|
||||
original diff: `CHANGELOG.md`, `editors/vscode/CHANGELOG.md`,
|
||||
`editors/vscode/README.md` gained 0.44.0 release-note entries, and
|
||||
`TODO.md` gained the §46 dev-checkbox ticks (matching this README's
|
||||
Status/TODO) plus a new §47 planning section, beyond what this QA read at
|
||||
the start of its session. None of this touches the rule, the tests, or
|
||||
this README's content above this log entry, and none of it changed any
|
||||
number this QA independently re-measured — `crates/vlog_linter/src/
|
||||
rules/undriven_net.rs` and `crates/lucisv_server/tests/e2e.rs` are
|
||||
byte-identical to what was diffed at the start of this session (71 and
|
||||
204 changed lines respectively, matching exactly). Flagged so the lead
|
||||
knows the tree was not exclusively QA's for the whole session; not
|
||||
something this QA touched or reverted.
|
||||
- **LOW (context, not a defect).** `WorkspaceIndex`'s workspace-scan size cap
|
||||
(1.0 MiB) skips all three `pinmux_reg_top.sv` variants from the persistent
|
||||
cross-file census entirely. This is pre-existing and matches take 3's own
|
||||
"3976 indexed, 3 skipped" count — not introduced or affected by this
|
||||
change — but worth restating next to this round's numbers since a reader
|
||||
could otherwise wonder why a 1.3 MB file's own words never reach another
|
||||
file's `mentioned_elsewhere` answer. The *open* buffer's own analysis is
|
||||
unaffected by the cap, which is why the timings above still show the full
|
||||
parse+lint cost when the file itself is opened.
|
||||
|
||||
**Equivalence result:** identical findings, identical order, on the scratch
|
||||
fixture (text and JSON), on `lucisv check .` with no `--select`, and on all
|
||||
four opentitan directories — 0.43.0 and the fixed tree agree everywhere
|
||||
tested.
|
||||
|
||||
**Verdict: PASS.**
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-05 — lead.** Accepted; ships in 0.44.0 with §45. The plan's three
|
||||
guesses were wrong and the dev's first step — measure — is what found the
|
||||
real cause: one rule asking the whole-workspace census once per declaration
|
||||
before its local guards. The fix is six reordered lines over a
|
||||
side-effect-free predicate, with equivalence shown three ways (the suite,
|
||||
the corpus, and QA's crafted workspace covering every guard interaction
|
||||
plus four opentitan IPs byte-identical between 0.43.0 and the fix). 15× on
|
||||
the largest file, 10× on typical IPs, on every keystroke as well as every
|
||||
open. The 200 ms wire-test bound is ruled correct: it pins the contract in
|
||||
a debug build whose parse alone is ~53 ms, the exact regression pin is the
|
||||
counting-oracle unit test (verified to fail on a revert), and QA's release
|
||||
measurement of the same buffer (11.7 ms) shows the plan's 25 ms was a
|
||||
release number. No debounce was added and none is needed at 0.5–1.5 ms per
|
||||
publish. (The README lacked its Review section; added here.)
|
||||
@@ -0,0 +1,565 @@
|
||||
# small items, round 4
|
||||
|
||||
## Goal
|
||||
|
||||
Four items that belong to no larger feature, shipped together (TODO §45,
|
||||
release 0.44.0). Each closes an open handshake in `docs/topo.md` §2.9.
|
||||
|
||||
**45.1 — the editor's unknown rule name is said once (topo 29).** A name in
|
||||
`lucisv.lint.select` / `lucisv.lint.ignore` that the registry does not know was
|
||||
dropped in silence (`settings::rules` filtered it away), while the same typo in
|
||||
a `lucisv.toml`'s `[lint] select` has been logged since §42 and
|
||||
`lucisv.lint.options` has described its own bad entries since §34. The name is
|
||||
still dropped — a typo on a socket must not cost a session its diagnostics —
|
||||
and is now logged through `server/notification.rs` as
|
||||
`lucisv.lint.select: unknown rule: <name>`, **once** per (setting, name),
|
||||
re-armed only when the list changes. A `select` emptied by the dropping falls
|
||||
through §42's ladder exactly as before.
|
||||
|
||||
**45.2 — a warning channel for the walk (topo 30).** `Walk::dir` propagated
|
||||
`read_dir`'s error with `?`, so one permission-denied directory anywhere under
|
||||
the start dropped every file already found and failed the run — walk-cycles'
|
||||
QA found it on a link to `/`. `lucisv_core::walk::collect_files` now takes a
|
||||
`&mut dyn FnMut(Warning)` sink: an unreadable directory, an unreadable
|
||||
`.gitignore` and a source file that is only a broken link are each said once
|
||||
and skipped, and the walk goes on. The CLI writes `warning: <path>: <message>`
|
||||
to stderr before the report and changes no exit code; the server folds them
|
||||
into the scope's own warnings, which are logged once per scan. The dangling
|
||||
source link is **no longer handed on** — that reverses §43's review ruling on
|
||||
purpose, because the warning is now the error's home.
|
||||
|
||||
**45.3 — an inline aggregate as a parameter-override argument (topo 17).**
|
||||
`m #(.T(struct packed { logic a; })) u ();` was rejected: `parse_expr_or_type`
|
||||
routed a value to `parse_type_expr` only for a head in `TYPE_KEYWORDS`, and
|
||||
`struct`/`union`/`enum` are not in that table, so the value read as an
|
||||
expression and hit "unexpected keyword `struct` in expression".
|
||||
`parse_type_ref` had read that body since the first day and the type printer
|
||||
had printed it; only the door was shut. With it open,
|
||||
`vlog_refactor::instantiation_plan` stops dropping a one-line `parameter type`
|
||||
default that is an anonymous aggregate — its probe simply passes now — and
|
||||
emits the type text.
|
||||
|
||||
**45.4 — comment slots inside a delay list (topo 22's leftovers).**
|
||||
`parse_delay_values` serves `#(1:2:3)` on nets and continuous assignments and
|
||||
`#(rise, fall[, turn-off])` on gates. The gaps around the `(`, the two `:` and
|
||||
the `,` had no owner, so a comment written in one moved and `verify.rs` refused
|
||||
the file. They have owners now — `MinTypMaxComments`, `DelayValue`, the gate's
|
||||
`before_hash`/`after_hash`/`before_semi`, the gate instance's `before_args`,
|
||||
and the continuous assignment's `after_hash`/`after_delay` — and the RTL gap
|
||||
fuzzer's fixture set covers the construct at zero failures.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **45.1** — the memo is the *previous settings value's own warning list*, so
|
||||
"once per (setting, name)" and "re-armed when the setting changes" are one
|
||||
mechanism rather than two. A list edited from `[a]` to `[a, b]` says only
|
||||
`b`; cleared and re-typed, it says everything again. Both lists hold a
|
||||
handful of entries at most, so a linear scan beats a set.
|
||||
- **45.1** — the options warnings keep their old behaviour (raised every time
|
||||
the setting arrives). They are a different field for that reason; merging the
|
||||
two vectors would have quietly changed §34's contract.
|
||||
- **45.2** — a dangling link that does **not** name a source file stays silent.
|
||||
It was never going to be read, and warning about every broken link in a tree
|
||||
is noise, not information. The `walk.rs` test pins both halves.
|
||||
- **45.2** — a path the user names on the command line is not walked, so
|
||||
naming a dangling link directly is still `no such file or directory`, exit 2.
|
||||
The channel is about what the *walk* finds.
|
||||
- **45.2** — an unreadable `.gitignore` used to abort the run too; it is now a
|
||||
warning on the same channel. That is one step beyond the plan's wording and
|
||||
is the same judgement: a walk that finds too much is a better failure than a
|
||||
walk that finds nothing.
|
||||
- **45.2** — `Warning`'s `message` is the operating system's own words, except
|
||||
for a broken symbolic link, which is named as one (`symlink_metadata` says
|
||||
so) because `No such file or directory` reads as a lucisv bug there.
|
||||
- **45.3** — an aggregate head in expression position is *always* a type. No
|
||||
legal expression starts with `struct`, `union` or `enum`, so the new arm in
|
||||
`parse_expr_or_type` cannot take a value away from the expression grammar.
|
||||
It opens the same door for `$bits(struct packed {…})`, a stream slice size
|
||||
and an assignment-pattern key, all of which reach `parse_expr_or_type` too.
|
||||
- **45.3** — the aggregate prints through the existing type printer, so a
|
||||
`struct`/`union` body opens across lines exactly as it does in a declaration
|
||||
and an `enum` body stays inline. Nothing was laid out specially for the
|
||||
override list.
|
||||
- **45.4** — a comment inside a bracket pair forces that pair open. That has
|
||||
been true since comment-slots; the one-value `#( /*c*/ 1:2:3 )` case in
|
||||
`delay_comment_slots.cases` is a fixed point at that layout for that reason.
|
||||
- **45.4** — `Expr` stays at 96 bytes: `MinTypMaxComments` is boxed, as every
|
||||
expression-level slot is (`ast/mod.rs`'s size assertion is the check).
|
||||
- **45.4** — the empty case costs nothing. Every new slot is printed through
|
||||
`Fmt::slot_comments` or an `is_empty()` match that emits the space the old
|
||||
code emitted, which is what the corpus and opentitan byte-identity runs below
|
||||
measure.
|
||||
|
||||
## Handshakes
|
||||
|
||||
**Consumed, unchanged.** `Parser::{take_gap, gap_before, take_before_open,
|
||||
take_meta, take_before_sep}` — every new slot is built from them, on
|
||||
comment-slots' rule that a gap belongs to a construct only when the token that
|
||||
closes it was written. `Fmt::{slot_comments, inline_comments,
|
||||
inline_comments_spaced, semi, trailing}` likewise. `verify.rs` untouched and
|
||||
no normalization widened; ten new attack pairs ship anyway (CLAUDE.md
|
||||
invariant 4).
|
||||
|
||||
**Promised / changed.** All additive except where marked.
|
||||
|
||||
| node / API | change | note |
|
||||
|---|---|---|
|
||||
| `lucisv_core::walk::Warning` | new | `{ path, message }`, `Display` as `<path>: <message>` |
|
||||
| `lucisv_core::walk::collect_files` | **signature**: fifth parameter `&mut dyn FnMut(Warning)` | two callers, one line each |
|
||||
| `ExprKind::MinTypMax` | `comments: Box<MinTypMaxComments>` | four slots, two `:` |
|
||||
| `ContAssign` | `after_hash`, `after_delay` | `assign # /*a*/ (5) /*b*/ y = x;` |
|
||||
| `GateInstantiation` | `before_hash`, `after_hash`, `before_semi`; `delay: Vec<Expr>` → `Vec<DelayValue>` | **changed field type** |
|
||||
| `GateInstance` | `before_args` | `g1 /*c*/ (y, a)` |
|
||||
| `ast::DelayValue` | new | `{ leading, expr, trailing }` — the `(`, `,` and `)` slots of a multi-value list |
|
||||
| `settings::ClientSettings` | `lint_name_warnings: Vec<String>` | one line per unknown name |
|
||||
| `settings::rules` | **signature**: takes the setting's name and a warning sink | private to the module |
|
||||
| `Server::said_lint_names` | new field | §45.1's memo |
|
||||
| `Workspace::{walked_files, folder_files, default_files, widened_files}` | **signature**: each takes `&mut dyn FnMut(String)` | private to `state.rs` |
|
||||
|
||||
Why a **sink** and not a `Walked { files, warnings }` return: both callers
|
||||
accumulate into a `&mut Vec<PathBuf>` across a loop over their inputs — the
|
||||
CLI over `opts.inputs`, the server over its scope directories — so a struct
|
||||
return would have made each of them merge two vectors per iteration and give
|
||||
up the accumulator idiom. With the sink each call site is one changed line:
|
||||
the CLI adds `&mut |w| eprintln!("warning: {w}")`, the server adds
|
||||
`&mut |w| warn(w.to_string())` onto the scope warnings it already collects.
|
||||
|
||||
**Requests filed.** None. Nothing outside this round's own file set was
|
||||
edited.
|
||||
|
||||
## Docs to apply at merge (lead)
|
||||
|
||||
`docs/topo.md` §2.9 — four rows:
|
||||
|
||||
- **Row 17** (inline aggregate as a parameter-override argument) — strike, and
|
||||
append: *— **delivered 2026-09-05 by small-items-4 (TODO §45.3)**:
|
||||
`parse_expr_or_type` routes a `struct`/`union`/`enum` head to
|
||||
`parse_type_expr`, which `parse_type_ref` has been able to read since the
|
||||
first day; the value is an `ExprKind::Type` printed by the existing type
|
||||
printer (a struct or union body opens, an enum body stays inline). The same
|
||||
door opens for the four other callers of `parse_expr_or_type` — `$bits(…)`,
|
||||
a stream slice size, an assignment-pattern key and an ordered override.
|
||||
`vlog_refactor`'s `default_text` probe now passes such a default and
|
||||
`instantiation_plan` emits the type text; only the **multi-line** spelling
|
||||
(`common_cells/src/ecc_encode.sv`) is still dropped, and by the
|
||||
"written across several lines" rule rather than by the grammar. Corpus (860)
|
||||
and opentitan (3 947) byte-identical.*
|
||||
- **Row 22** (comment slots in shared machinery, already struck) — append to
|
||||
its delivered note: *A fifth fuzzer bar was added 2026-09-05 by
|
||||
small-items-4 (TODO §45.4): the **delay list** — `#(1:2:3)` on nets and
|
||||
continuous assignments, `#(rise, fall)` on gates — gained
|
||||
`MinTypMaxComments` (four slots, one grammar shared with the parenthesized
|
||||
`(a:b:c)` expression), `ast::DelayValue` for the multi-value list's `(`, `,`
|
||||
and `)`, and `ContAssign::{after_hash, after_delay}`,
|
||||
`GateInstantiation::{before_hash, after_hash, before_semi}`,
|
||||
`GateInstance::before_args`. `EXPECTED_RTL_GAPS` 374 → 419, still at zero
|
||||
failures.*
|
||||
- **Row 29** (the editor's unknown rule name) — strike, and append:
|
||||
*— **delivered 2026-09-05 by small-items-4 (TODO §45.1)**:
|
||||
`settings::rules` describes every dropped name into
|
||||
`ClientSettings::lint_name_warnings` as
|
||||
`lucisv.lint.<select|ignore>: unknown rule: <name>`, and `apply_settings`
|
||||
logs what `Server::said_lint_names` — the previous settings value's own
|
||||
warning list — does not already hold. Once per (setting, name); a
|
||||
`didChangeConfiguration` that changes the list re-arms exactly what is new in
|
||||
it; four diagnostics passes add nothing. The dropping itself, and §42's
|
||||
ladder under an emptied `select`, are unchanged.*
|
||||
- **Row 30** (an unreadable directory aborts the whole walk) — strike, and
|
||||
append: *— **delivered 2026-09-05 by small-items-4 (TODO §45.2)**:
|
||||
`walk::collect_files` takes a `&mut dyn FnMut(Warning)` sink (`Warning
|
||||
{ path, message }`), chosen over a `Walked { files, warnings }` return
|
||||
because both callers accumulate into a `&mut Vec<PathBuf>` across a loop and
|
||||
a struct return would have cost each of them a merge per input. An unreadable
|
||||
directory, an unreadable `.gitignore` and a dangling **source-file** link are
|
||||
each said once and skipped; the walk finishes. CLI: `warning: <path>:
|
||||
<message>` on stderr before the report, exit code unchanged. Server: the
|
||||
warnings join the scope's own and are logged once per scan through
|
||||
`report_scope`. §43's review ruling that a dangling source link is handed on
|
||||
to fail in the front end is **reversed** — the warning is the error's home
|
||||
now. A dangling link that names no source file is still skipped silently.*
|
||||
|
||||
Also worth a line in `README.md` where the walk is described, if it says a
|
||||
walk fails on an unreadable directory: it warns and continues now.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] 45.1 editor unknown-name log (`settings.rs`, `server/notification.rs`,
|
||||
`server/mod.rs`, `server/tests/settings.rs`)
|
||||
- [x] 45.2 walk warning channel, both front ends (`lucisv_core/src/walk.rs`,
|
||||
`lucisv/src/main.rs`, `lucisv/tests/cli.rs`,
|
||||
`lucisv_server/src/state.rs`)
|
||||
- [x] 45.3 inline aggregate override argument + plan emission
|
||||
(`parser/primary.rs`, `parser/tests/instance.rs`,
|
||||
`vlog_refactor/src/instantiate.rs`, `tests/cases/instantiation.cases`)
|
||||
- [x] 45.4 delay-list comment slots + fuzzer coverage (`ast/expr.rs`,
|
||||
`ast/module.rs`, `parser/instance.rs`, `format/expr.rs`,
|
||||
`format/instance.rs`, `format/item.rs`,
|
||||
`tests/cases/delay_comment_slots.cases`, `tests/verification.rs`)
|
||||
- [x] Gates (guarded): fmt, clippy, `cargo test --workspace`, corpus,
|
||||
byte-identity, smoke, the hostile-tree CLI run
|
||||
- [ ] docs: topo 29/30/17/22 struck (lead — text above)
|
||||
- [x] QA (2026-09-05 — REWORK, one MEDIUM finding; see QA log)
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-05 — dev (Fable 5.1)
|
||||
|
||||
**45.3 first, because it was one line of grammar.** `parse_expr_or_type`
|
||||
(`parser/primary.rs`) checked `TYPE_KEYWORDS`, which holds the *integral and
|
||||
non-integral* type keywords only. `struct`, `union` and `enum` are keywords
|
||||
too and `parse_type_ref` already dispatches all three to `parse_struct_type` /
|
||||
`parse_enum_type`, so the fix is a second arm in front of the existing one. No
|
||||
legal expression begins with one of those words, so the arm cannot take a
|
||||
value away from the expression grammar; the previous behaviour was
|
||||
"unexpected keyword `struct` in expression".
|
||||
|
||||
Nothing else was needed for the plan's second half. `default_text` in
|
||||
`vlog_refactor/src/instantiate.rs` already *probes* — it writes
|
||||
`m #(.P( <default> )) u ();` and asks the tolerant parser — so a one-line
|
||||
aggregate default started being emitted the moment the grammar accepted it.
|
||||
The doc comment there claimed the grammar was the reason such a default was
|
||||
dropped; it now says the probe is the rule and that the multi-line spelling is
|
||||
what is still refused, by the other rule above it. Test added.
|
||||
|
||||
**45.4 was measured, not guessed.** The candidate fixture went into
|
||||
`RTL_FIXTURES` first and the fuzzer named 23 failing gaps. Fixing them meant
|
||||
one new expression-level slot (`MinTypMaxComments`, boxed) and one new list
|
||||
shape:
|
||||
|
||||
- `parse_delay_values` now returns `Vec<DelayValue>` (`{ leading, expr,
|
||||
trailing }`). The **one-value** spelling still folds into the
|
||||
`ExprKind::Paren` it always produced, and the paren's existing `before` /
|
||||
`after` slots are exactly where the `#( … )` gaps go — so nets and continuous
|
||||
assignments needed no new node at all. Only the gate's multi-value list, whose
|
||||
parentheses and commas the *printer* writes, needed somewhere to put them.
|
||||
- The two `min : typ : max` grammars — the delay list's and the parenthesized
|
||||
expression's in `parser/primary.rs` — were folded into
|
||||
`Parser::parse_min_typ_max_tail`, so the four colon slots exist in both. That
|
||||
is the same "three duplicated grammars folded into one" move comment-slots
|
||||
made.
|
||||
- The gate instantiation had four gaps of its own with no owner once the delay
|
||||
had slots: before the `#`, after the `#`, before an instance's `(`, and
|
||||
before the `;`. `GateInstance::meta` was parsed but never printed, so the
|
||||
gap in front of an instance name is now printed too, along with the
|
||||
element's `before_sep` / `trailing` around the `,` between two instances.
|
||||
- `ContAssign` gained `after_hash` and `after_delay`. The second one matters:
|
||||
a continuous assignment prints its first pair's leading comments straight
|
||||
after the `assign` keyword, which is *in front of* the delay, so a comment
|
||||
written after the delay had to be taken out of that path before `take_meta`
|
||||
saw it.
|
||||
|
||||
`EXPECTED_RTL_GAPS` 374 → 419 with the reason on the constant and on the
|
||||
fixture. Six cases in a new `delay_comment_slots.cases`, plus five attack
|
||||
pairs in `verification.rs`, one per token a new slot sits beside.
|
||||
|
||||
**45.2 — the channel shape.** `&mut dyn FnMut(Warning)`, not `Walked { files,
|
||||
warnings }`. Both callers of `collect_files` accumulate into a `&mut
|
||||
Vec<PathBuf>` across a loop over their own inputs, so a struct return would
|
||||
have replaced one line with three at each of them and given up the accumulator
|
||||
the signature is built around. With the sink each call site is one changed
|
||||
line. Inside the crate, `Walk::dir` lost its `io::Result` entirely and split
|
||||
into `dir` (enter, push the ignore stack, pop it) and `entries` (read and
|
||||
recurse), which keeps both under twenty lines.
|
||||
|
||||
The reversal is deliberate and is the plan's: a dangling **source-file** link
|
||||
is warned about and **not** pushed into `files`. §43's review had kept it in
|
||||
the list so the front end's `no such file` error survived; the warning is that
|
||||
error's home now, and it says something the old path could not — that the file
|
||||
is a broken link rather than absent. The walk.rs test and its comment were
|
||||
rewritten to say so. A dangling link that names no source file is still
|
||||
skipped in silence; it was never going to be read.
|
||||
|
||||
Server plumbing: `walked_files` / `folder_files` / `default_files` /
|
||||
`widened_files` each take the sink, and `source_files` collects into the
|
||||
`Scope::warnings` that already existed for a filelist's problems. That road
|
||||
ends at `report_scope`, which logs each line once per scan and shows the first
|
||||
one — the same treatment a filelist's warnings have always had. **Deviation
|
||||
from the plan's letter:** the plan said "through `notification.rs`"; the scan
|
||||
warnings' channel is `server/client.rs`'s `report_scope`, called from
|
||||
`server/index.rs` and `server/mod.rs` where a scan finishes. Inventing a second
|
||||
road for the same class of message would have been worse than using the one
|
||||
that exists. "Once per scan" holds.
|
||||
|
||||
**45.1 — the memo.** `settings::rules` takes the setting's name and a warning
|
||||
sink and describes each dropped name; the lines land in a new
|
||||
`ClientSettings::lint_name_warnings`, kept separate from
|
||||
`lint_option_warnings` because the two are said differently. `apply_settings`
|
||||
logs the lines `Server::said_lint_names` does not hold and then replaces that
|
||||
memo with the current list — which is the whole of "once per (setting, name),
|
||||
re-armed when the setting changes". The options warnings' behaviour is
|
||||
untouched.
|
||||
|
||||
**Gates, all guarded.** `cargo fmt` per touched crate and `cargo fmt --all --
|
||||
--check` clean; `cargo clippy --all-targets` clean; `cargo test --workspace`
|
||||
**3 810 passed, 0 failed, 44 ignored** (baseline 3 788 — 22 new tests);
|
||||
`tools/corpus_check.sh` **814/820**, the same six errors, no verification error
|
||||
and no crash; byte-identity against the trunk binary (built from `git archive
|
||||
HEAD` into the scratchpad, never a checkout in this tree) **860 corpus files,
|
||||
0 diffs** and **3 947 opentitan files, 0 diffs**, with the same 6 and 9 errors
|
||||
either side; `node editors/vscode/smoke.js target/release/lucisv-server` OK;
|
||||
and `target/release/lucisv format --check` over a scratch tree with a `0o000`
|
||||
subdirectory and a dangling `x.sv` link printed exactly two `warning:` lines on
|
||||
stderr before the report, reported the other files, and exited 1 on the
|
||||
formatting alone. `git -C ~/repo/opentitan status --porcelain` shows only the
|
||||
three pre-existing files.
|
||||
|
||||
**Files touched outside the plan's expected set.** Three, all forced by an AST
|
||||
field the round added and each a mechanical pattern update:
|
||||
`crates/vlog_semantic/src/bind/expr.rs` (a `..` in the `MinTypMax` arm),
|
||||
`crates/vlog_semantic/src/bind/item.rs` (`&d.expr` for the gate delay) and
|
||||
`crates/vlog_parser/tests/spans.rs` (both of the same). Nothing else in
|
||||
`vlog_semantic` was changed.
|
||||
|
||||
### 2026-09-05 — lead, at review
|
||||
|
||||
QA's MEDIUM closed in the tree: a *line* comment trailing a gate instance's
|
||||
`,` now ends the line and the next instance continues one level in
|
||||
(`indent(vec![Doc::HardLine])`, the module-instantiation printer's rule); a
|
||||
block comment there stays inline, as the dev's own case table expects. A
|
||||
case in `net_delay_position.cases` pins the repro. The four topo rows are
|
||||
applied.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-09-05 — QA (Sonnet)
|
||||
|
||||
Build: `cargo build --release -p lucisv -p lucisv_server` clean, up to date
|
||||
with the uncommitted tree at f302b47+.
|
||||
|
||||
**45.1 — the editor's unknown rule name.** Read `settings.rs`,
|
||||
`server/notification.rs`, `server/mod.rs`, `server/tests/settings.rs` in
|
||||
full; behaviour matches the README exactly (memo = previous settings
|
||||
value's own warning list, `lint_option_warnings` untouched, severity words
|
||||
never warned). Added a temporary wire-level test to `tests/e2e.rs`
|
||||
(`talk`, framed JSON-RPC, real binary) driving: push `lucisv.lint.select:
|
||||
["no-tab"]` → open → three `didChange`s each forced through a `flush_dirty`
|
||||
by an interleaved `codeAction` request (four diagnostics passes total,
|
||||
confirmed by counting `textDocument/publishDiagnostics`) → re-push the
|
||||
identical list → push a second typo `nope` → push with the first typo
|
||||
fixed. Result: exactly one `window/logMessage` `lucisv: lucisv.lint.select:
|
||||
unknown rule: no-tab`, nothing across the four diagnostics passes or the
|
||||
identical re-push, exactly one more line for `nope` when it was added,
|
||||
nothing when the first typo was dropped from the list. Test removed after
|
||||
passing (file `tests/e2e.rs` is unchanged, confirmed by `git diff`). Unit
|
||||
tests already in the diff cover the `ignore` typo, an empty `select`
|
||||
falling through §42's ladder with the rule set unchanged, and a severity
|
||||
word (`style`, `warning`) never being reported — read and agree with all
|
||||
three. No findings.
|
||||
|
||||
**45.2 — the walk's warning channel.** Read `walk.rs`, `main.rs`,
|
||||
`tests/cli.rs`, `state.rs` diffs in full, plus `server/client.rs`'s
|
||||
`report_scope` (unchanged — confirmed the "went through `client.rs` instead
|
||||
of `notification.rs`" deviation is real and `report_scope` already does
|
||||
"logged once per scan, one showMessage summary at most" for every existing
|
||||
caller). Built eight hostile scratch trees under the scratchpad and ran the
|
||||
CLI over each through `tools/guard.sh -t 120`:
|
||||
- 0o000 subdirectory: warning on stderr before the report, `format --check`
|
||||
on an already-clean tree exits **0** with the warning still printed
|
||||
(the exact case TODO §45.2 calls out); `format --check` on a tree needing
|
||||
a reformat exits 1 on the formatting alone; `format` (real reformat, on a
|
||||
scratch copy) and `check` both warn and proceed, exit 0.
|
||||
- dangling `x.sv` link: warned, dropped, not handed to the formatter.
|
||||
- dangling link to a non-source name: silent, as specified.
|
||||
- unreadable `.gitignore` (0o000): warned, directory still walked.
|
||||
- a symlink cycle plus an unreadable directory in the same tree: no hang,
|
||||
no crash, the unreadable directory is warned once and the rest of the
|
||||
tree is reported.
|
||||
- **the start directory itself unreadable (0o000)**: `path.is_dir()`
|
||||
succeeds (stat needs only the parent's search bit), so the walk enters,
|
||||
`read_dir` fails, one warning is printed naming the start directory, and
|
||||
the run then fails with the CLI's ordinary `error: no Verilog files
|
||||
found` at exit 2 — sensible, not a crash, not silent. Not covered by the
|
||||
dev's own tests; recorded here since the plan asked "what happens?".
|
||||
- an unreadable file `y.sv` (chmod 0o000, not a directory): reported once,
|
||||
as the pre-existing per-file read error (`error: ...: Permission
|
||||
denied`), *not* as a walk warning — confirmed not duplicated.
|
||||
- 200 unreadable directories under one start: exactly 200 `warning:` lines,
|
||||
the walk finishes, the one real file is still reported.
|
||||
|
||||
Server: adapted the existing `Session`/`Tree` test harness (as
|
||||
`server/tests/*.rs` already does) into a temporary file
|
||||
(`server/tests/qa_scratch_45.rs`, registered and later removed from
|
||||
`server/tests/mod.rs`) to drive `Session::wide` over a tree with one 0o000
|
||||
subdirectory: the warning is logged exactly once via `logged()`, at most
|
||||
one `shown()` `window/showMessage` summary, and pushing a settings change
|
||||
that forces `reindex` (`lucisv.index.maxFileSize` with `scope: "workspace"`
|
||||
kept, mirroring `capping()` in `server/tests/index.rs`) logs the same
|
||||
warning again exactly once. `server/tests/mod.rs` and the deleted scratch
|
||||
file leave no diff (`git diff --stat` confirms only the intended lane
|
||||
files changed). No findings.
|
||||
|
||||
**45.3 — inline aggregate override argument.** Manually formatted a file
|
||||
covering `struct packed`, `union packed` (with two members), `enum`, a
|
||||
`struct packed` with a comment inside, a nested `struct packed` inside a
|
||||
`struct packed`, and the same aggregate as a **positional** override
|
||||
(`m #(struct packed {logic a;}) u5 ();`) — all format correctly (struct/
|
||||
union bodies open, enum stays inline, comment kept), round-trip is a fixed
|
||||
point (`format(format(x)) == format(x)`, byte-for-byte), and the comment
|
||||
survives. Confirmed the illegal expression-position case is unchanged and
|
||||
safe: `assign x = struct packed { logic a; };` still fails with the
|
||||
original `parse error: ... unexpected keyword \`struct\` in expression`
|
||||
under both `format --check` and `format --stdout`, exit 2, no corruption —
|
||||
`parse_expr` (assign's RHS) does not route through `parse_expr_or_type`, so
|
||||
the new door stays shut there exactly as the Assumptions section claims.
|
||||
Ran `vlog_refactor`'s new and neighboring tests directly
|
||||
(`a_one_line_inline_aggregate_default_is_emitted`,
|
||||
`a_multi_line_type_is_shown_on_one_line`): both green, confirming the
|
||||
one-line default is now emitted and the multi-line one is still dropped, by
|
||||
the "written across several lines" rule rather than the grammar. No
|
||||
findings.
|
||||
|
||||
**45.4 — delay-list comment slots.** Read the fixture
|
||||
(`delay_comment_slots.cases`) end to end against the `Promised / changed`
|
||||
table in the Handshakes section: every new field
|
||||
(`MinTypMaxComments`'s four slots, the one-value `Paren`'s two slots,
|
||||
`ContAssign::{after_hash, after_delay}`,
|
||||
`GateInstantiation::{before_hash, after_hash, before_semi}`,
|
||||
`DelayValue::{leading, trailing}`, `GateInstance::before_args`, and
|
||||
`GateInstance::meta.{before_sep, trailing}`) has at least one case, plus a
|
||||
byte-cost-zero case and one line-comment case (the `min:typ:max` colon
|
||||
only). Confirmed `EXPECTED_RTL_GAPS` 419 with the block-comment-per-gap
|
||||
fuzzer at 0 failures (`cargo test -p vlog_formatter
|
||||
a_comment_in_every_rtl_gap_still_formats`).
|
||||
|
||||
**Because the fuzzer and the fixture both probe with `/*block*/` comments
|
||||
only, I attacked every new slot again by hand with `//line` comments** (the
|
||||
plan explicitly asked for "line comments in each slot"). Seven of eight
|
||||
were fine (`before_hash`, `after_hash`, `before_args`, `before_semi`, the
|
||||
one-value delay's two `Paren` slots, `ContAssign::after_hash`,
|
||||
`ContAssign::after_delay` all correctly force a hard line after a line
|
||||
comment via `inline_comments_spaced`/`slot_comments`). The eighth is a
|
||||
**real bug**:
|
||||
|
||||
> **FINDING (MEDIUM) — a line comment trailing a gate instance's `,`
|
||||
> separator corrupts the rest of the statement into the comment; caught
|
||||
> by `verify.rs`, so no bad file is ever written, but `lucisv format`
|
||||
> hard-fails (exit 2) on legal, comment-bearing SystemVerilog that TODO
|
||||
> §45.4 claims this round closes.**
|
||||
>
|
||||
> `crates/vlog_formatter/src/format/instance.rs:400-405` (the gate
|
||||
> instantiation's multi-instance loop, only reached for `i < last`):
|
||||
> ```rust
|
||||
> docs.push(text(","));
|
||||
> if let Some(tr) = &inst.meta.trailing {
|
||||
> docs.push(text(" "));
|
||||
> docs.push(self.comment(tr));
|
||||
> }
|
||||
> ```
|
||||
> Nothing forces a line break after `tr` before the next iteration prints
|
||||
> the following instance's `meta.leading` (a bare `text(" ")` when that is
|
||||
> empty). When `tr` is a line comment, everything the next iteration emits
|
||||
> lands on the same source line, and a line comment runs to end of line —
|
||||
> so on re-lex the rest of the statement disappears into the comment.
|
||||
> `verify.rs` sees the token-stream divergence and correctly refuses to
|
||||
> write the file (invariant 1 upheld; nothing corrupted on disk); the
|
||||
> failure mode is a hard error on valid input, not corrupted output.
|
||||
>
|
||||
> Repro:
|
||||
> ```systemverilog
|
||||
> module m;
|
||||
> and #(2, 3) g0 (y, a), // p
|
||||
> g1 (z, b);
|
||||
> endmodule
|
||||
> ```
|
||||
> `target/release/lucisv format --stdout repro.sv` →
|
||||
> `error: repro.sv: verification failed: token stream diverges at index 17:
|
||||
> input has comment "// p" at 2:26, output has comment "// p g1 (z, b);" at
|
||||
> 2:26`, exit 2. Reproduces with three instances too (the whole remainder,
|
||||
> including a further `,`-separated instance, is swallowed).
|
||||
>
|
||||
> Contrast with the pre-existing, correct pattern four lines above this one
|
||||
> in the same file (`format/instance.rs:64-74`, the *module*-instantiation
|
||||
> multi-instance list), which already does the right thing:
|
||||
> ```rust
|
||||
> if let Some(tr) = &instance.meta.trailing {
|
||||
> inner.push(text(" "));
|
||||
> inner.push(self.comment(tr));
|
||||
> if i < last { inner.push(Doc::HardLine); }
|
||||
> } else if i < last { inner.push(Doc::Line); }
|
||||
> ```
|
||||
> The gate-instance printer added by 45.4 does not replicate the
|
||||
> `i < last` hard-line-after-trailing-comment rule (or use
|
||||
> `inline_comments_spaced`/`Fmt::trailing`, which both already know a line
|
||||
> comment forces a break).
|
||||
>
|
||||
> Not caught by the dev's own attack tests or the RTL fuzzer because both
|
||||
> only exercise the `before_sep`/`trailing` slot with **block** comments
|
||||
> (`delay_comment_slots.cases`'s last case:
|
||||
> `g0 (y, a) /* before */ , /* after */ g1 (z, b)`). Not a widened
|
||||
> `verify.rs` forgiveness (invariant 4 does not apply — nothing in
|
||||
> `verify.rs` changed), and not a dropped comment (invariant 3 holds —
|
||||
> the whole file is refused, not partially emitted). Severity kept at
|
||||
> MEDIUM rather than HIGH because of that: no corruption reaches disk,
|
||||
> the blast radius is exactly this one slot/comment-kind combination, and
|
||||
> the corpus and opentitan sweeps (neither of which contains this pattern)
|
||||
> are unaffected — confirmed by the unchanged 814/820 and the byte-identity
|
||||
> runs below.
|
||||
>
|
||||
> Suggested fix (for the dev, not applied here per QA's mandate not to
|
||||
> redesign): either call `self.inline_comments_spaced` for the trailing
|
||||
> comment instead of the raw `text(" ")` + `self.comment(tr)` pair (it
|
||||
> already emits `Doc::HardLine` when the comment is a line comment), or
|
||||
> mirror the module-instantiation loop's explicit `if i < last { push
|
||||
> HardLine }` after the trailing comment.
|
||||
|
||||
**Byte-identity and gates (all guarded).**
|
||||
- `cargo clippy --all-targets`: clean.
|
||||
- `tools/guard.sh -- cargo test --workspace`: **3 810 passed, 0 failed, 44
|
||||
ignored** — matches the dev's number exactly.
|
||||
- `tools/guard.sh -- tools/corpus_check.sh`: **814/820**, same six parse
|
||||
errors, 0 verification errors, 0 crashes.
|
||||
- `node editors/vscode/smoke.js target/release/lucisv-server`: OK.
|
||||
- Corpus byte-identity vs `~/.cache/lucisv-baselines/lucisv-0.43.0`:
|
||||
compared `format --stdout` + exit code file by file over all **860**
|
||||
corpus source files (not just the 820 `corpus_check.sh` reports on) —
|
||||
**0 differing**.
|
||||
- Opentitan `format --check` vs the same 0.43.0 baseline over `hw/ip`,
|
||||
`hw/top_earlgrey/ip`, `hw/top_darjeeling/ip`, `hw/dv`, `hw/vendor`:
|
||||
**2 553** source files (not the dev's 3 947 — a different, smaller
|
||||
file-extension/glob accounting was used here; not investigated further
|
||||
since exit codes and normalized stdout/stderr matched exactly either
|
||||
way); every exit code identical, and every stderr line identical once
|
||||
the baseline's incidental `, N files from cache` cache-hit annotation
|
||||
(a pre-existing `.lucisv_cache/` in the opentitan tree, untracked,
|
||||
gitignored, unaffected by which binary populated it) is stripped from
|
||||
both sides — **0 behavioural differences**.
|
||||
`git -C ~/repo/opentitan status --porcelain` after every run: only 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`).
|
||||
|
||||
**Cleanup.** All scratch trees removed (permissions restored with
|
||||
`chmod -R u+rwx` first). The two temporary test additions
|
||||
(`tests/e2e.rs`, `server/tests/qa_scratch_45.rs` + its `mod.rs`
|
||||
registration) were removed after use; `git diff --stat` shows no lane file
|
||||
touched by this QA pass except this README and the TODO.md checkbox.
|
||||
|
||||
**Verdict: REWORK.** One finding, filed above:
|
||||
- **MEDIUM** — `format/instance.rs:400-405`, a line comment trailing a
|
||||
gate instance's `,` separator (`GateInstance::meta.trailing`, not the
|
||||
last instance) corrupts the rest of the statement into the comment;
|
||||
`verify.rs` catches it and refuses the file rather than writing bad
|
||||
output, but `lucisv format` hard-fails on legal input the round claims
|
||||
to support. Needs a fix plus a line-comment test in
|
||||
`delay_comment_slots.cases` or `verification.rs` before this closes.
|
||||
|
||||
Everything else in 45.1, 45.2 and 45.3 checked out clean against the plan,
|
||||
including the corners the plan called out by name (the start-directory
|
||||
case, the 200-unreadable-directories case, the illegal-expression-position
|
||||
case, severity words never warned, four diagnostics passes, a rescan
|
||||
re-arming the server's log).
|
||||
|
||||
## Review
|
||||
|
||||
**2026-09-05 — lead.** Accepted with the rework above; ships in 0.44.0
|
||||
with §46. Four small items, each the shape the plan asked for. The sink
|
||||
choice for the walk (a closure over a struct return) is right for the
|
||||
reason given — both callers accumulate across a loop — and routing the
|
||||
server's scan warnings through the road filelist warnings already take,
|
||||
rather than `notification.rs`, is the better reading of the plan. The §43
|
||||
reversal (a dangling source link is warned about and not handed on) is now
|
||||
correct because the warning has a home. QA's MEDIUM was a real formatter
|
||||
refusal on legal input — the one class of bug the verifier exists to catch,
|
||||
and it did — fixed at review with the rule the sibling printer already had.
|
||||
Byte-identity: 0 of 860 corpus files and 0 of 3 947 opentitan files differ
|
||||
from 0.43.0.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Manual extension-host acceptance — checklist
|
||||
|
||||
The one test of the VS Code extension that is not `editors/vscode/smoke.js`.
|
||||
Run it on a release build (`code --install-extension lucisv-<v>-darwin-arm64.vsix --force`)
|
||||
with `/Users/guoliangchen/repo/opentitan` open as the workspace. About an
|
||||
hour. Record the release, the date and any failure in the table at the end.
|
||||
|
||||
| # | Step | Expected |
|
||||
|---|---|---|
|
||||
| 1 | Open `hw/ip/aes/rtl/aes.sv`. Status bar. | "lucisv" item appears; no error toast; Output → lucisv shows the server version. |
|
||||
| 2 | Wait for the scan bar to finish. Hover `aes_core` in an instantiation. | Hover card with the module's header and file:line; F12 jumps to `aes_core.sv`. |
|
||||
| 3 | Insert a tab at the start of a line. | A `no-tabs` squiggle within a second; lightbulb offers "Replace tab"; fix-on-save (`editor.codeActionsOnSave` with `source.fixAll.lucisv`) removes it. Undo. |
|
||||
| 4 | Cursor on `.clk_i` in an instantiation; open the lightbulb. | Port refactorings listed instantly (no hitch); picking one applies an edit (undo). |
|
||||
| 5 | Format Document (Shift+Alt+F) on `aes.sv`. | Reformats without an error toast; Format again is a no-op. Undo all. |
|
||||
| 6 | Settings → search "lucisv.lint". | Every rule has a toggle; `severity.style` off removes all style squiggles immediately. Restore. |
|
||||
| 7 | Add `[lint] select = ["no-tabs"]` in a scratch `lucisv.toml` beside the file. | Only `no-tabs` diagnostics remain; removing the file restores the defaults. |
|
||||
| 8 | Theme: switch Dark+ → Light+ → High Contrast. | Semantic highlighting readable in all three; no invisible tokens. |
|
||||
| 9 | Zoom: View → Appearance → Zoom In ×3, then reset. | Hierarchy view and hover cards scale; nothing clipped. |
|
||||
| 10 | Keyboard only: `Ctrl+Shift+O` (symbols), `F12`, `Shift+F12`, `F2` rename, `Esc`. | Every action reachable without the mouse; rename preview shows all files. |
|
||||
| 11 | Screen reader (VoiceOver, ⌘F5): tab through the lucisv hierarchy view. | Each row announced with its name; the toggle buttons announced. Turn VoiceOver off. |
|
||||
| 12 | Old server: point `lucisv.server.path` at `~/.cache/lucisv-baselines/lucisv-0.39.0`'s sibling server if kept, else skip. | Extension warns about the version mismatch and still works. Reset the setting. |
|
||||
| 13 | The other VSIX shape: install the `lucisv-<v>-universal.vsix` (no bundled server) with the CLI on PATH. | Same behaviour as steps 1–5. |
|
||||
| 14 | Restart the server (command palette: "lucisv: Restart Server"). | Diagnostics return within a few seconds; no duplicate status items. |
|
||||
|
||||
## Runs
|
||||
|
||||
| Release | Date | Result | Failures (step, what happened) |
|
||||
|---|---|---|---|
|
||||
| | | | |
|
||||
@@ -709,6 +709,37 @@ subsuming folder is twenty times the old scope, skipping the overlap saves 5 %.
|
||||
What the round bought is in the landing figure, and it grows with the workspace's
|
||||
vocabulary — which is why the opentitan table above is the one that matters.
|
||||
|
||||
## Measurement round — take 3 on opentitan (2026-09-05)
|
||||
|
||||
`docs/performance_take3.md` — 0.43.0 (`73799f3`) against a 0.39.0 server built
|
||||
from the tag for the comparison, plus the first CLI sweeps (`format --check`
|
||||
and `check` over five opentitan trees, 0.39.0 / 0.41.0 / 0.43.0, wall clock and
|
||||
peak RSS). Read-only round: nothing was fixed, findings were filed.
|
||||
|
||||
The three headline numbers:
|
||||
|
||||
- **`codeAction` on the hot path: 37 ms → 5 ms** at the `aes` cursor and
|
||||
**185 ms → 16 ms** at a 128-file fan-out, for a client that advertises
|
||||
`codeAction.resolveSupport` — §37.1's lazy offer, and it is flat in the
|
||||
fan-out where the eager path is linear in it. The whole hot path is now
|
||||
inside the frame budget; `codeAction` leaves the queue-blocking table it
|
||||
headed in both earlier takes.
|
||||
- **The first RTL `didOpen` at the shipped default: 1 411–1 568 ms →
|
||||
365 ms warm.** Take 2 called this "the wave's one real regression"; round 8
|
||||
above plus the index cache took it apart, and 0.39.0 already measures it, so
|
||||
it is closed.
|
||||
- **The CLI is 0.6 s for `format --check` over `hw/ip`'s 1 807 files** and
|
||||
0.40 s to lint them, at ~230 MB peak RSS — essentially flat across the three
|
||||
binaries.
|
||||
|
||||
Three findings filed, none fixed: the **eager** `codeAction` path (a client
|
||||
without `resolveSupport`) is ~1.37× slower than take 2 at every fan-out, and
|
||||
0.39.0 already shows it; a `didOpen` of a file already in scope delays the next
|
||||
request by 21–51 ms where take 2 measured 2–4 ms; and `lucisv check` is 6–10%
|
||||
slower than 0.39.0 (0.367 → 0.400 s on `hw/ip`). Take 3 also has something
|
||||
neither earlier take did — **a server-side column**, from the shipped
|
||||
`--verbose` flag, which confirms the wire numbers to within 0.4 ms.
|
||||
|
||||
## What it would take to go faster
|
||||
|
||||
Ranked by what the measurements above say is there, with what each would
|
||||
@@ -1047,3 +1078,34 @@ for one keystroke in a 10 000-line buffer, roughly 30 ms of it lex and parse.
|
||||
That is the figure any incremental-parsing proposal has to be argued against,
|
||||
and it now exists.
|
||||
|
||||
|
||||
### 2026-09-05 — the `didOpen` delay (TODO §46, 0.44.0)
|
||||
|
||||
Take 3's §8.4 (a `didOpen` of an already-indexed file delaying the next
|
||||
request by 21–51 ms) measured and fixed. The breakdown, taken with temporary
|
||||
timings on a release build and re-taken after: the tolerant parse plus the
|
||||
semantic analysis is 1.3 / 3.0 / 91 ms for a 326- / 1 145- / 42 192-line
|
||||
opentitan file, and the lint pass was 4.9 / 54 / 1 654 ms — of which
|
||||
`undriven-net` alone was 4.4 / 52 / 1 608. The rule asked
|
||||
`WorkspaceIndex::files_mentioning` (a walk over all 3 976 indexed files) once
|
||||
per declaration, ahead of the local guards that silence almost all of them.
|
||||
Moved behind them, where `unused-signal` has always asked.
|
||||
|
||||
Wire time, `didOpen` → the request behind it, workspace scope, warm store,
|
||||
three tries, M1 Max:
|
||||
|
||||
| file | before | after |
|
||||
|---|---|---|
|
||||
| `aes.sv` (326 L) | 8.1 / 5.9 / 10.1 ms | 4.3 / 1.8 / 2.3 ms |
|
||||
| `aes_core.sv` (1 145 L) | 56.2 / 54.0 / 48.0 ms | 5.9 / 6.9 / 6.3 ms |
|
||||
| `hmac.sv` | 56.8 / 42.7 / 51.0 ms | 4.7 / 5.7 / 3.3 ms |
|
||||
| `kmac.sv` | 69.3 / 72.1 / 70.6 ms | 7.9 / 5.3 / 8.8 ms |
|
||||
| `spi_device.sv` | 94.2 / 103.4 / 88.6 ms | 6.0 / 8.6 / 8.7 ms |
|
||||
| `pinmux_reg_top.sv` (42 192 L) | 1 742 / 1 740 / 1 757 ms | 116.5 / 116.2 / 117.3 ms |
|
||||
|
||||
The same cost was paid on **every keystroke flush**, not just on opens: the
|
||||
change debounce ends in the same `set_document` + `publish` pair. 0.39.0
|
||||
measures the same as 0.43.0 everywhere in the "before" column, so this was
|
||||
never a regression — the rule had been ordered that way since it was
|
||||
written. Published diagnostics are byte-identical before and after. Full
|
||||
account: `docs/features/didopen-cost/README.md`.
|
||||
@@ -0,0 +1,785 @@
|
||||
# lucisv performance against opentitan — take 3
|
||||
|
||||
Same corpus, same scenarios, same machine as
|
||||
[`performance.md`](performance.md) (take 1) and
|
||||
[`performance_take2.md`](performance_take2.md) (take 2); two new binaries and
|
||||
one new question. Take 2 measured `ee1efe3` — the merged performance wave.
|
||||
Take 3 measures **0.43.0 (`73799f3`)** against **0.39.0 (`0757503`)**, and
|
||||
every table carries take 2's number beside them so each row is a before/after.
|
||||
|
||||
This round also covers the **CLI** for the first time: `format --check` and
|
||||
`check` over five opentitan trees, three binaries, wall clock and peak RSS.
|
||||
|
||||
Every LSP number is a client-observed round trip on a monotonic clock
|
||||
(`time.perf_counter`) — what the editor, and therefore the user, actually
|
||||
experiences. Read §9 before quoting any of them.
|
||||
|
||||
---
|
||||
|
||||
## 0. Read this first — take 3 *does* have a server-side column
|
||||
|
||||
Take 1 and take 2 both opened with "no server-side instrumentation": their
|
||||
binaries carried no timing literals, so every number was a client round trip
|
||||
against a transport floor.
|
||||
|
||||
**That is no longer true, and it is an improvement, not a contamination.** The
|
||||
shipped server has a `--verbose` flag (`docs/features/verbose-timing/`) that
|
||||
logs `timing: <method> answered in <n> ms` per request over
|
||||
`window/logMessage`. It is present in 0.39.0 and in 0.43.0 and absent from
|
||||
take 2's binary. Nothing was added for this round: the default (no `--verbose`)
|
||||
sessions produce every number in this document, and one supplementary session
|
||||
per shape was re-run *with* `--verbose` to check the wire against the server's
|
||||
own clock.
|
||||
|
||||
| `codeAction` at the cursor | wire, no `--verbose` | wire, `--verbose` session | server's own line |
|
||||
|---|---:|---:|---:|
|
||||
| `prim_flop_2sync` (128), eager | 270.2 / 252.9–255.2 ms | 252.5 / 244.8–254.6 ms | 252.28 / 244.55–254.46 ms |
|
||||
| `prim_flop_2sync` (128), lazy | 24.0 / 15.6–16.9 ms | 22.4 / 13.4–14.6 ms | 22.04 / 13.21–14.41 ms |
|
||||
| `aes` (6), eager | 66.1 / 45.7–48.2 ms | 64.6 / 47.0–47.8 ms | 64.26 / 46.78–47.66 ms |
|
||||
| comment line | 1.8 / 0.7–0.8 ms | 1.7 / 0.7–0.8 ms | 1.30 / 0.58–0.68 ms |
|
||||
|
||||
**The wire is the server plus 0.2–0.4 ms, everywhere.** Take 1's and take 2's
|
||||
central assumption — `client round trip ≈ server handling + ~0.05 ms` — is now
|
||||
measured rather than assumed, and it holds with a slightly fatter floor
|
||||
(0.2–0.4 ms rather than 0.05 ms, this harness being a Python client rather
|
||||
than take 2's).
|
||||
|
||||
The transport baseline (an unknown method, `$/lucisvNoSuchMethod`, rejected
|
||||
without work) is correspondingly higher in take 3:
|
||||
|
||||
| | take 1 | take 2 | take 3, 0.43.0 | take 3, 0.39.0 |
|
||||
|---|---:|---:|---:|---:|
|
||||
| transport baseline, first in a settled session | 0.02 ms | 0.019 ms | 0.24 ms | 0.31 ms |
|
||||
| transport baseline, repeats | ≈0.05 ms | ≈0.05 ms | 0.059–0.092 ms | 0.057–0.064 ms |
|
||||
|
||||
**So every sub-millisecond row in take 3 sits on a ~0.06 ms floor rather than
|
||||
take 2's ~0.02 ms, and roughly 0.04 ms of every such row's "slowdown" against
|
||||
take 2 is this harness.** No conclusion is drawn below from any individual
|
||||
sub-0.3 ms movement.
|
||||
|
||||
---
|
||||
|
||||
## 1. Environment and provenance
|
||||
|
||||
| | take 2 | take 3 |
|
||||
|---|---|---|
|
||||
| Machine | Apple M1 Max, 10 cores, 64 GB | **same machine** |
|
||||
| OS | macOS 27.0 (26A5421a) | macOS 27.0 (**26A5425a**) |
|
||||
| Date | 2026-08-29 ~00:45–02:00 | **2026-09-05 ~02:45–04:00** |
|
||||
| Server under test | `ee1efe3`, 4 155 456 B, sha256 `a45d814c…` | **0.43.0 `73799f3`, 5 676 528 B, sha256 `0da08f40…`**, Mach-O arm64 |
|
||||
| Baseline server | take 1's `bf9170a`+ | **0.39.0 `0757503`, 5 517 936 B, sha256 `58f7044e…`** — built for this round in a scratch `git worktree` at `v0.39.0`, `cargo build --release -p lucisv_server`, removed afterwards |
|
||||
| CLI binaries | *not measured* | 0.43.0 `target/release/lucisv` (2 828 576 B, `89379a12…`), 0.41.0 (`5be28f2c…`) and 0.39.0 (`4caf841f…`) from `~/.cache/lucisv-baselines/` |
|
||||
| Corpus | `/Users/guoliangchen/repo/opentitan` @ `0098135264` | **same commit**, 3976 indexed + 3 skipped — but see the one corpus difference below |
|
||||
| Scenario file | `hw/ip/aes/dv/tb/tb.sv`; `aes` at 0-based 44:2 | same file, same position, resolved from the text at run time |
|
||||
| Client | `scratchpad/perf2/*.py` (no longer on disk) | **a new client, `scratchpad/perf3/{lspclient,bench}.py`** — same shape, written from take 2's §1 description |
|
||||
| Guard | — | **every server, `lucisv` and `cargo` run went through `tools/guard.sh -m 8 -t 1800`. No guard kill occurred.** |
|
||||
|
||||
### 1a. The one corpus difference, and it matters for two columns
|
||||
|
||||
`hw/ip/aes/dv/tb/tb.sv` is still modified in the checkout, but **the
|
||||
modification is no longer the trailing-space edit take 2 measured against — the
|
||||
file has since been reformatted by lucisv**, and is now lucisv-clean. Two
|
||||
consequences, both of which make take-3 columns *not* comparable to take 2's:
|
||||
|
||||
- `textDocument/diagnostic` (pull) returns **0 items** at every scope in take 3,
|
||||
where take 2 quoted "one `no-trailing-whitespace` item".
|
||||
- `textDocument/codeAction` on the `aes` instantiation and on a comment line
|
||||
returns **0 actions** in take 3, where take 2 recorded 1 at each. That one
|
||||
action was the `source.fixAll.lucisv` quick fix the trailing-space diagnostic
|
||||
raised; with no diagnostic there is nothing to fix. The *timings* are
|
||||
unaffected — the cost is the port-refactoring fan-out, not the quick fix
|
||||
(§6a proves this: the numbers track the fan-out, and the comment-line row is
|
||||
0.7 ms in both takes).
|
||||
|
||||
The other two modified files (`hw/top_{darjeeling,earlgrey}/ip/ast/rtl/ast.sv`)
|
||||
are unchanged from take 2 and are not in any scenario.
|
||||
|
||||
### 1b. The client, and what it does differently
|
||||
|
||||
The take-2 scripts were gone from the scratchpad, so take 3's client was
|
||||
rewritten from take 2's §1 description. It is the same shape: framed
|
||||
JSON-RPC over the server's stdio, `workspace/configuration` answered with a
|
||||
per-session scope word, cache warmth controlled through
|
||||
`initializationOptions.storagePath` (take 2's methodology fix, kept), positions
|
||||
resolved from the file text at run time, every request timed from send to
|
||||
response. Three deliberate differences:
|
||||
|
||||
1. **Client capabilities are settable per session.** A "VS Code-style" session
|
||||
advertises `textDocument.codeAction.resolveSupport.properties: ["edit"]`
|
||||
and gets §37.1's lazy offer; a session without it gets the eager shape.
|
||||
Both are measured everywhere `codeAction` appears.
|
||||
2. **A `--verbose` variant** of the codeAction sessions (§0).
|
||||
3. **`.clk_i` is the one in the `aes` port list, 0-based 45:5.** Take 2's §1
|
||||
says "line 49", which is `.output_valid_o()` in this file; the first
|
||||
`.clk_i` in the file is on 0-based line 34, in a different instantiation.
|
||||
Take 3 states its position rather than inheriting an ambiguous one, so the
|
||||
two `references`-on-`.clk_i` rows below compare cost, not result sets.
|
||||
|
||||
---
|
||||
|
||||
## 2. Summary table — worst first, take 2 → take 3
|
||||
|
||||
Workspace scope, warm cache, unless the row says otherwise. "Repeats" is the
|
||||
range over the 2nd–4th identical request in the same session; the "first" column
|
||||
is that request issued as the first real request of a dedicated session.
|
||||
|
||||
| Action | T2 first | T2 repeats | **0.43.0 first** | **0.43.0 repeats** | 0.39.0 first | 0.39.0 repeats |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| Workspace scan, **cold** cache (didOpen → 3976 indexed) | 2 958 ms | 2 919 – 2 955 | **2 867 ms** | 2 754 – 2 773 | 2 764 ms | 2 752 – 2 756 |
|
||||
| `textDocument/codeAction`, `prim_flop_2sync` (fan-out 128), **client without `resolveSupport`** | 200.7 ms | 184.9 – 186.2 | **270.2 ms** | 252.9 – 255.2 | 267.5 ms | 230.7 – 246.4 |
|
||||
| `textDocument/rename` on `aes` (edits computed, not applied) | 115 ms | 107 – 121 (7 files) | **151.8 ms** | 139.1 – 140.7 (**9 files**) | 147.4 ms | 137.4 – 139.1 (9 files) |
|
||||
| — anything queued behind that rename | 108 ms | — | **160.8 ms** | — | 162.0 ms | — |
|
||||
| `textDocument/codeAction`, `prim_alert_sender` (67), no `resolveSupport` | 163.6 ms | 138.8 – 139.8 | **213.4 ms** | 196.0 – 196.5 | 210.3 ms | 191.7 – 194.6 |
|
||||
| `textDocument/codeAction`, `prim_lc_sync` (42), no `resolveSupport` | 123.5 ms | 94.4 – 95.3 | **148.0 ms** | 128.9 – 130.4 | 137.7 ms | 125.4 – 126.8 |
|
||||
| `codeAction/resolve` at the one cursor that offers an action (`aes_wrap.sv`, 6) | — | — | **119.5 ms** | 119.5 – 121.9 | *n/a* — no resolve at 0.39.0 | |
|
||||
| Workspace scan, **warm** cache | 1 476 ms | 1 495 – 1 558 | **1 229.8 ms** | 1 220.5 – 1 229.7 | 1 227.9 ms | 1 218.1 – 1 225.1 |
|
||||
| First `didOpen` of an RTL file **at the default scope** (`aes.sv`, widens to `hw/ip`) | 1 731 ms cold | 1 411 – 1 568 warm | **1 081.6 ms cold** | **365.1 ms warm** | 1 078.6 cold | 355.5 warm |
|
||||
| diagnostics **publish** after a `didChange` (new row; ~150 ms of it is the debounce) | — | — | **161.1 ms** | 159.6 – 163.4 | 153.4 ms | 153.2 – 160.9 |
|
||||
| `textDocument/codeAction`, `prim_flop_2sync` (128), **client with `resolveSupport`** (the lazy offer) | *n/a* | | **24.0 ms** | **15.6 – 16.9** | *n/a* — no lazy offer before 0.41.0 | |
|
||||
| `codeAction` offer at the `aes_wrap.sv` cursor, lazy | — | — | **33.3 ms** | 21.2 – 26.8 | 119.7 ms (eager) | 117.4 – 119.3 |
|
||||
| `codeAction` **on the `aes` instantiation**, lazy | 39.2 ms | 36.4 – 37.6 | **5.15 ms** | **4.05 – 4.24** | 59.7 ms (eager) | 45.8 – 46.1 |
|
||||
| — definition pipelined behind that codeAction | 37.7 ms | 37.2 | **5.15 ms** | — | 59.7 ms | — |
|
||||
| `codeAction`, `aes_reg_top` (fan-out 1), lazy | 19.8 ms | 13.2 – 17.4 | **27.1 ms** | 16.4 – 20.6 | 16.9 ms *(eager)* | 13.2 – 14.3 |
|
||||
| `workspace/symbol "aes"` (256 results) | 6.6 ms | 6.6 – 7.4 | **8.8 ms** | 7.2 – 7.9 | 9.0 ms | 8.4 – 8.7 |
|
||||
| — anything queued behind it | 6.9 ms | — | 11.0 ms | — | 11.9 ms | — |
|
||||
| `textDocument/completion` at 0 typed characters (512 items) | 14.8 – 18.6 ms | — | **9.5 ms** | **2.3 – 2.8** | 5.2 ms | 3.0 – 3.3 |
|
||||
| `textDocument/completion` at 1 typed character | 15.3 ms | 14.2 – 19.4 | **3.2 ms** | **2.5 – 2.7** | 3.8 ms | 3.0 – 3.1 |
|
||||
| `textDocument/completion` at `aes_reg` | 0.59 ms (20 items) | 0.36 – 0.63 | **3.8 ms (512 items)** | 2.9 – 3.0 | 3.9 ms (512) | 2.6 – 2.9 |
|
||||
| `codeAction` on a **comment line** (contrast) | 0.70 ms | 0.47 – 0.49 | 1.69 ms | 0.66 – 0.81 | 4.50 ms | 0.56 – 0.87 |
|
||||
| `textDocument/references` on `aes` | 0.66 ms (7 hits) | 0.38 – 0.43 | **0.85 ms (14 hits)** | 0.54 – 0.61 | 0.92 ms (14) | 0.55 – 0.58 |
|
||||
| `textDocument/signatureHelp` inside the port list | 0.57 ms | 0.44 – 0.58 | 0.70 ms | 0.57 – 0.62 | 0.67 ms | 0.64 – 0.74 |
|
||||
| `textDocument/references` on `.clk_i` | 0.62 ms (10 hits) | 0.48 – 0.55 | 0.56 ms (12 hits) | 0.51 – 0.72 | 0.55 ms (12) | 0.61 – 0.65 |
|
||||
| `didChange` flush (measured with a `foldingRange` barrier) | 0.48 ms | 0.33 – 0.45 | 0.95 ms | 0.58 – 0.80 | 0.77 ms | 0.60 – 0.91 |
|
||||
| `textDocument/inlayHint` (whole file, 4 hints) | 0.38 ms | 0.23 – 0.34 | 0.49 ms | 0.26 – 0.43 | 0.45 ms | 0.25 – 0.27 |
|
||||
| `textDocument/prepareRename` on `aes` (pressing F2) | 0.07 ms | 0.05 – 0.09 | 0.31 ms | 0.08 – 0.16 | 0.18 ms | 0.07 – 0.08 |
|
||||
| — anything queued behind that prepareRename | 0.1 ms | — | 0.37 ms | — | 0.50 ms | — |
|
||||
| `textDocument/diagnostic` (pull, 0 items — §1a) | 0.11 ms | 0.06 | 0.34 ms | 0.17 – 0.19 | 0.31 ms | 0.16 – 0.20 |
|
||||
| `textDocument/definition` on `aes` | 0.27 ms | 0.05 – 0.11 | **0.19 ms** | 0.07 – 0.09 | 0.41 ms | 0.06 – 0.08 |
|
||||
| `textDocument/semanticTokens/full` (251 tokens) | 0.16 ms | 0.14 – 0.16 | 0.21 ms | 0.19 – 0.25 | 0.21 ms | 0.16 – 0.19 |
|
||||
| `textDocument/hover` on `aes` | 0.13 ms | 0.08 – 0.13 | 0.18 ms | 0.06 – 0.08 | 0.13 ms | 0.05 – 0.08 |
|
||||
| `textDocument/documentSymbol` | 0.16 ms | 0.11 – 0.48 | 0.18 ms | 0.12 – 0.15 | 0.18 ms | 0.12 – 0.13 |
|
||||
| `textDocument/foldingRange` | 0.05 ms | 0.04 – 0.08 | 0.10 ms | 0.05 – 0.07 | 0.05 ms | 0.05 – 0.06 |
|
||||
| `textDocument/selectionRange` | 0.08 ms | 0.04 – 0.05 | 0.09 ms | 0.05 | 0.09 ms | 0.05 |
|
||||
| `textDocument/documentHighlight` (1 result) | 0.04 ms | 0.04 – 0.07 | 0.10 ms | 0.04 – 0.05 | 0.05 ms | 0.04 – 0.05 |
|
||||
| `textDocument/codeLens` | 0.05 ms | 0.04 – 0.06 | 0.07 ms | 0.04 – 0.05 | 0.06 ms | 0.04 |
|
||||
| `textDocument/typeDefinition` on `aes` | 0.07 ms | 0.05 – 0.06 | 0.06 ms | 0.05 – 0.06 | 0.08 ms | 0.05 – 0.07 |
|
||||
| `textDocument/documentLink` | 0.09 ms | 0.05 – 0.07 | 0.06 ms | 0.04 – 0.05 | 0.05 ms | 0.04 – 0.05 |
|
||||
| `initialize` → response | 2.1 – 8.9 ms | — | 2.3 – 4.4 ms | — | 2.1 – 4.9 ms | — |
|
||||
| *transport baseline (does no work)* | *0.019 – 0.14 ms* | — | *0.06 – 0.24 ms* | — | *0.06 – 0.31 ms* | — |
|
||||
|
||||
**The one-line reading of that table:** 0.43.0 and 0.39.0 are the same server
|
||||
on almost every row. The single structural difference between them is
|
||||
`codeAction` for a client that can resolve — §37.1 — and it is worth **11.8×**
|
||||
on the hot path (59.7 → 5.15 ms at the `aes` cursor, 246 → 16 ms at a 128-file
|
||||
fan-out). Everything else that moved since take 2 moved *before* 0.39.0, and
|
||||
some of it moved the wrong way (§8).
|
||||
|
||||
---
|
||||
|
||||
## 3. The queue-blocking analysis — `codeAction` finally leaves the list
|
||||
|
||||
The server still runs a single-threaded request loop, so the latency a user
|
||||
feels for request *R* is *R*'s cost plus everything queued ahead of it. Each
|
||||
slow request was sent, then — back to back, no wait — the three requests a real
|
||||
editor fires on every cursor move.
|
||||
|
||||
| Sent first (the blocker) | Its own cost, T2 | **0.43.0** | 0.39.0 | `definition` behind it, T2 | **0.43.0** | 0.39.0 |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| `codeAction` on the `aes` token | 37.4 ms | **5.07 ms** | 59.6 ms | 37.4 ms | **5.15 ms** | 59.7 ms |
|
||||
| `prepareRename` on `aes` | 0.1 ms | 0.34 ms | 0.35 ms | 0.1 ms | 0.37 ms | 0.50 ms |
|
||||
| `rename` on `aes` | 107.7 ms | 160.8 ms | 162.0 ms | 107.7 ms | 160.8 ms | 162.1 ms |
|
||||
| `workspace/symbol "aes"` | 6.9 ms | 11.0 ms | 11.9 ms | 7.0 ms | 11.1 ms | 12.0 ms |
|
||||
|
||||
`hover` and `documentSymbol` behind each leader land 0.05–0.5 ms after the
|
||||
definition, as in both earlier takes: the queue is still strictly serial and
|
||||
the follower still pays the leader's bill almost exactly.
|
||||
|
||||
Take 1 and take 2 both named `codeAction` as the worst thing on the hot path —
|
||||
take 2 called it "the single worst thing" and asked for memoisation or an
|
||||
index-only answer. §37.1 did the second of those for the *offer*, and the row
|
||||
is now 5 ms: **under the 16 ms frame budget, on a request that fires on every
|
||||
cursor move.** Take 2's two structural conclusions survive with one amendment:
|
||||
|
||||
1. The absolute number still matters more than the ratio.
|
||||
2. `codeAction` and `completion` were "the only slow requests on the hot path".
|
||||
Both are now inside the frame budget for a modern client (5 ms and 2–3 ms).
|
||||
**The hot path is clean.** What is left slow is user-initiated
|
||||
(`rename`, 160 ms), once-per-session (the scan, 1.2–2.9 s), or paid only by
|
||||
a client that cannot resolve a code action (§6a).
|
||||
|
||||
---
|
||||
|
||||
## 4. Startup and scan, per scope config and cache state
|
||||
|
||||
Methodology unchanged: `didOpen tb.sv` → the last `$/progress` `end`, followed
|
||||
by 1.5 s of silence, three runs per cell. "Cold" = the `storagePath` directory
|
||||
was `rm -rf`'d immediately before; "warm" = it carries a previous session's
|
||||
store.
|
||||
|
||||
| Scope config | Cache | T2 didOpen → settled | **0.43.0** | 0.39.0 | files |
|
||||
|---|---|---:|---:|---:|---|
|
||||
| **default** (`[{}]` — no opinion at all) | cold | 94.0 ms | **81.9 / 92.5 / 93.1 ms** | 94.6 / 94.6 / 87.0 ms | 124 |
|
||||
| **default** | warm | 51.2 – 58.6 ms | **39.4 / 40.3 / 41.8 ms** | 31.7 / 35.8 / 40.2 ms | 124, 123 from cache |
|
||||
| `{"index":{}}` (the "empty" reply) | cold | 94.6 – 100.0 ms | **88.8 / 90.1 / 94.5 ms** | 91.1 / 92.1 / 92.4 ms | 124 |
|
||||
| `{"index":{}}` | warm | *n/a* | **34.7 / 39.1 / 39.3 ms** | 37.9 / 38.0 / 40.2 ms | 124 |
|
||||
| explicit `scopeDepth: 0` | cold | 98.9 ms | **93.5 / 101.6 / 105.5 ms** | 98.7 / 103.2 / 104.6 ms | 1 (after a ~90 ms 124-file scan is thrown away) |
|
||||
| explicit `scopeDepth: 0` | warm | 55.0 ms | **42.3 / 49.3 / 49.6 ms** | 41.6 / 47.1 / 50.5 ms | 1 |
|
||||
| `workspace` | cold | 2 918 – 2 958 ms | **2 754 / 2 773 / 2 867 ms** | 2 752 / 2 756 / 2 764 ms | 3976, 3 skipped |
|
||||
| `workspace` | warm | 1 476 – 1 558 ms (+ outliers to 3 073) | **1 220.5 / 1 229.7 / 1 229.8 ms** | 1 218.1 / 1 225.1 / 1 227.9 ms | 3975 from cache |
|
||||
|
||||
- `initialize` is still 2–5 ms and still does no scanning. (One 231 ms outlier,
|
||||
on the first server process this session ever spawned — a cold `exec`, not a
|
||||
measurement of anything.)
|
||||
- **The 0.39.0 column is why this table needed a baseline.** The warm workspace
|
||||
scan reads 1 476 ms in take 2 and 1 220 ms tonight — a 1.21× "improvement"
|
||||
that is *entirely* machine and page cache, because 0.39.0 measures 1 228 ms
|
||||
on the same night. No code change is responsible; take 2's own §9 warned
|
||||
about exactly this and said to quote the band, not the number. **Take 3's
|
||||
band for the warm workspace scan is 1 218 – 1 230 ms, and it is much tighter
|
||||
than take 2's** (12 ms spread across six runs and two binaries, against take
|
||||
2's 1 476–3 073) because tonight's machine was quieter.
|
||||
- **Persistence buys ~57%** on the workspace scan (2 800 → 1 225 ms) and ~57%
|
||||
on the default scope (90 → 39 ms). Take 2 measured 48% / 44%.
|
||||
- **A cold workspace scan is not fully cold**, and this is a shape both earlier
|
||||
takes had without recording it: the pulled `scope: "workspace"` arrives after
|
||||
the default-scope scan is already in flight, so the trace is `0 files → 124
|
||||
files (83–92 ms) → 3976 files`, and the workspace bar reports "123 from
|
||||
cache" even on a wiped store — those 123 are the default scan's own writes,
|
||||
read back seconds later. It costs 83–92 ms of the workspace total.
|
||||
- Both binaries emit ~1 100 `$/progress` reports and ~4 100 `indexing:` log
|
||||
lines on a cold workspace scan, as take 2 recorded.
|
||||
|
||||
### 4b. What each scope answers, at 0.43.0
|
||||
|
||||
Take 2's §4b table, re-taken. The `aes` instantiation in `tb.sv`:
|
||||
|
||||
| Request | default | explicit `scopeDepth 0` | workspace |
|
||||
|---|---|---|---|
|
||||
| `definition` | **1 result**, 0.18 ms | 0 results, 0.15 ms | 1 result, 0.19 ms |
|
||||
| `typeDefinition` | 1 result | 0 results | 1 result |
|
||||
| `hover` | 1 result | 0 results | 1 result |
|
||||
| `references` | **11 results**, 0.44 ms | 0 results | **14 results**, 0.85 ms |
|
||||
| `documentHighlight` | 1 result | 0 results | 1 result |
|
||||
| `signatureHelp` | 1 signature, 0.83 ms | 0 results | 1 signature, 0.70 ms |
|
||||
| `workspace/symbol "aes"` | 256, 3.0 ms | 0 results, 0.04 ms | 256, 8.8 ms |
|
||||
| `completion` at a fresh line | 512 items, 3.3 ms | 276 items, 2.0 ms | 512 items, 3.3 ms |
|
||||
| `inlayHint` (whole file) | **0** | 0 | **4** |
|
||||
|
||||
Everything take 2 found here still holds, and two counts grew: `references` at
|
||||
workspace scope is 14 rather than take 2's 7, and at the default scope 11
|
||||
rather than 4. 0.39.0 returns the same 14 and 11, so the growth predates it;
|
||||
it costs 0.85 ms against take 2's 0.66 ms for half the results, which is the
|
||||
right direction.
|
||||
|
||||
**`inlayHint` still returns 0 at the default scope and 4 at workspace, and
|
||||
§37.2 ruled that correct.** The four hints `tb.sv` can carry come from
|
||||
`pins_if` instantiations; `pins_if` is declared in
|
||||
`hw/dv/sv/common_ifs/pins_if.sv`, which is nowhere under `hw/ip/aes` — the
|
||||
default scope's root for this buffer. At that scope `definition`, `hover` and
|
||||
`signatureHelp` answer nothing about `pins_if` either, so inlay is not missing
|
||||
a lookup its neighbours have: the zero is a scope-reach result, not an
|
||||
inlay-hint defect. Take 2's §8 item 9 ("a correctness gap") is **closed as
|
||||
investigated, not as a bug**.
|
||||
|
||||
---
|
||||
|
||||
## 5. The `didOpen` widen
|
||||
|
||||
### 5a. At `scopeDepth 0` — apples to apples with take 1 and take 2
|
||||
|
||||
`tb.sv` open, then RTL files opened one at a time; the request sent immediately
|
||||
afterwards waits for the widen.
|
||||
|
||||
| Widening `didOpen` | T2 cold | T2 warm | **0.43.0 cold** | **0.43.0 warm** | 0.39.0 cold | 0.39.0 warm |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| `hw/ip/aes/rtl/aes.sv` | 22.3 ms | 22.0 ms | **19.3 ms** | **18.5 ms** | 18.7 ms | 16.5 ms |
|
||||
| `hw/ip/kmac/rtl/kmac.sv` | 33.5 ms | 18.1 ms | 32.9 ms | 25.9 ms | 32.5 ms | 23.9 ms |
|
||||
| `hw/ip/hmac/rtl/hmac.sv` | 18.2 ms | 12.2 ms | 30.4 ms | 20.4 ms | 32.1 ms | 22.1 ms |
|
||||
| `hw/ip/spi_device/rtl/spi_device.sv` | 83.4 ms | 45.7 ms | 85.2 ms | 37.0 ms | 84.0 ms | 35.8 ms |
|
||||
|
||||
`spi_device` is still the ceiling for the reason take 1 gave. The `hmac` row is
|
||||
the one that moved the wrong way (12.2 → 20.4 ms warm) and 0.39.0 shows the
|
||||
same 22.1, so it is not a 0.43.0 change; see §8.4.
|
||||
|
||||
### 5b. At the default scope — take 2's headline regression is 4× smaller
|
||||
|
||||
| Widening `didOpen` | T2 cold | T2 warm | **0.43.0 cold** | **0.43.0 warm** | 0.39.0 cold | 0.39.0 warm |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| `aes.sv` (widens `hw/ip/aes` → **`hw/ip`, 1 807 files**) | 1 731 ms | 1 411 – 1 568 ms | **1 081.6 ms** | **365.1 ms** | 1 078.6 ms | 355.5 ms |
|
||||
| `kmac.sv` (already in scope) | 3.9 ms | 2.7 ms | 24.3 ms | 31.1 ms | 23.9 ms | 30.0 ms |
|
||||
| `hmac.sv` (already in scope) | 3.6 ms | 2.1 ms | 22.6 ms | 21.1 ms | 24.8 ms | 22.1 ms |
|
||||
| `spi_device.sv` (already in scope) | 3.6 ms | 4.0 ms | 47.6 ms | 51.2 ms | 46.3 ms | 49.4 ms |
|
||||
|
||||
**The first row is the best news in this document.** Take 2 called the ~1.5 s
|
||||
first-RTL-open at the shipped default "the wave's one real regression" and "a
|
||||
real 1.5-second hang on the single most common navigation a Verilog user
|
||||
performs". It is now **365 ms warm** — a 3.9× improvement — and the warm case
|
||||
finally beats the cold one, which take 2's did not (1 411 warm vs 1 731 cold
|
||||
there; 365 warm vs 1 082 cold here). The index cache now serves the widen.
|
||||
0.39.0 shows the same number, so the credit belongs to whatever landed between
|
||||
`ee1efe3` and 0.39.0, not to §37 or §41–§43.
|
||||
|
||||
The other three rows moved the wrong way and are §8.4.
|
||||
|
||||
### 5c. What the widen does to the slow requests
|
||||
|
||||
Take 2's §5c shape: `aes.sv` is the *only* buffer opened, so the scope is
|
||||
whatever that one file raises, and the same requests are asked at all three
|
||||
configs. 0.43.0, lazy client, first / repeats:
|
||||
|
||||
| | T2 `depth0` | T2 default | T2 workspace | **0.43 `depth0`** | **0.43 default** | **0.43 workspace** |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| `codeAction` on the `prim_lc_sync` instantiation | 4.7 ms | 7.0 ms | 39.2 ms | **3.5 / 3.0–3.3** | **4.6 / 4.1–4.9** | **7.2 / 5.5–6.6** |
|
||||
| `codeAction` on the `aes_reg_top` instantiation | — | — | — | 21.1 / 14.6–15.8 | 21.4 / 15.5–18.1 | 25.1 / 17.5–20.4 |
|
||||
| `prepareRename` on `module aes` | 0.09 ms | 0.08 ms | 0.07 ms | **0.09 / 0.05–0.06** | 0.08 / 0.04–0.10 | 0.10 / 0.04–0.06 |
|
||||
| `rename` on `module aes` | 10.5 ms | 15.8 ms | 115 ms | **10.7 / 10.1–10.6** | 21.0 / 19.9–20.8 | 141.6 / 139.7–156.9 |
|
||||
| `workspace/symbol "aes"` (256 each) | 4.0 ms | 7.8 ms | 6.6 ms | 1.8 / 1.5–1.6 | 4.0 / 3.3–3.6 | 7.3 / 6.3–6.8 |
|
||||
|
||||
Take 2's cursor for the first row was "the instantiation" in a table whose
|
||||
client is gone; take 3 names two instantiations in `aes.sv` and gives both,
|
||||
because they differ by 5× for a reason worth seeing.
|
||||
|
||||
`prepareRename` is still flat in scope size — 0.04–0.10 ms at 40 files, at
|
||||
1 807 and at 3 976 — which was the wave's aim. `rename` still scales with the
|
||||
fan-out (10.7 → 141.6 ms), exactly as take 2 described. **The lazy
|
||||
`codeAction` is nearly flat too**: 3.5 → 7.2 ms across a 100× scope range for
|
||||
`prim_lc_sync`, against the eager path's 39 ms at workspace scope in take 2.
|
||||
The `aes_reg_top` row is the counter-example and the shape of what is left:
|
||||
21–25 ms, barely moving with scope, because the whole bill is reading and
|
||||
parsing that module's own 1 945-line declaration file — a per-cursor cost the
|
||||
offer cannot avoid without caching the declaration parse.
|
||||
|
||||
---
|
||||
|
||||
## 6. `codeAction`, offer and resolve — the round's main result
|
||||
|
||||
### 6a. Cost against the module's fan-out, three shapes
|
||||
|
||||
Workspace scope, warm cache, cursor on a module instantiation, four tries each.
|
||||
"Lazy" is a client that advertises
|
||||
`textDocument.codeAction.resolveSupport.properties: ["edit"]` (what VS Code
|
||||
sends); "eager" is a client that does not.
|
||||
|
||||
| Module at the cursor | Files instantiating it | T2 (eager only) | 0.39.0 eager | **0.43.0 eager** | **0.43.0 lazy offer** | Actions |
|
||||
|---|---:|---:|---:|---:|---:|---:|
|
||||
| `aes_reg_top` (in `aes.sv`) | 1 | 19.8 / 13.2–17.4 | 16.9 / 13.2–14.3 | 27.7 / 16.3–21.8 | **27.1 / 16.4–20.6** | 0 |
|
||||
| `aes` (in `tb.sv`) | 6 | 39.2 / 36.4–38.2 | 59.7 / 45.8–46.1 | 66.1 / 45.7–48.2 | **5.15 / 4.05–4.24** | 0 |
|
||||
| `prim_lc_sync` (in `aes.sv`) | 42 | 123.5 / 94.4–95.3 | 137.7 / 125.4–126.8 | 148.0 / 128.9–130.4 | **17.3 / 7.2–8.6** | 0 |
|
||||
| `prim_alert_sender` (in `aes.sv`) | 67 | 163.6 / 138.8–139.8 | 210.3 / 191.7–194.6 | 213.4 / 196.0–196.5 | **14.8 / 8.6–10.8** | 0 |
|
||||
| `prim_flop_2sync` (in `aon_timer.sv`) | 128 | 200.7 / 184.9–186.2 | 267.5 / 230.7–246.4 | 270.2 / 252.9–255.2 | **24.0 / 15.6–16.9** | 0 |
|
||||
| *(contrast) a comment line* | — | 0.70 / 0.47–0.49 | 4.50 / 0.56–0.87 | 1.80 / 0.71–0.78 | **1.69 / 0.66–0.81** | 0 |
|
||||
| **`aes` in `aes_wrap.sv` — the one cursor that offers** | 6 | — | 119.7 / 117.4–119.3 | 143.8 / 123.9–124.4 | **33.3 / 21.2–26.8** | **1** |
|
||||
|
||||
Two results, and they point in opposite directions.
|
||||
|
||||
**The lazy offer works, and it is the round's headline.** At a 128-file fan-out
|
||||
the offer is **15.6–16.9 ms against the eager path's 252.9–255.2 ms — 16×** —
|
||||
and, unlike the eager path, it does not track the fan-out at all: 4 ms at 6
|
||||
files, 8 ms at 42, 9 ms at 67, 16 ms at 128. What cost remains is the cursor's
|
||||
*own* file plus the instantiated module's declaration file, which is why the
|
||||
outlier is `aes_reg_top` (16–21 ms): that declaration is a 1 945-line, 51 KB
|
||||
autogenerated register file, and reading one of those is the whole bill.
|
||||
Take 2's "reads as a hang" line at ~200 ms is no longer crossed anywhere.
|
||||
|
||||
**`aes_reg_top` is the one cursor where the lazy shape is not a win**, and it
|
||||
is worth saying plainly: 27.1 / 16.4–20.6 ms at 0.43.0 against 0.39.0's eager
|
||||
16.9 / 13.2–14.3 ms. At a fan-out of 1 there is nothing for laziness to skip —
|
||||
the eager path reads one instantiating file, the lazy path reads the module's
|
||||
declaration, and here the declaration is the bigger of the two. It is one
|
||||
frame, on the cheapest fan-out there is, and it does not change the direction
|
||||
of the row above it; it is recorded so nobody re-derives it as a regression.
|
||||
|
||||
**The eager path got ~1.37× slower between take 2 and 0.39.0**, and 0.43.0
|
||||
holds that level. 95 → 126 ms at 42 files, 139 → 193 at 67, 185 → 246 at 128 —
|
||||
a consistent factor across four fan-out points, on a night whose scan rows are
|
||||
*faster* than take 2's, so it is not the machine. It is filed as §8.2. Note who
|
||||
pays it: only a client without `resolveSupport`, which since 0.41.0 is a
|
||||
shrinking population, but Vim/Neovim setups and simple clients are in it.
|
||||
|
||||
**The measured offer is now `O(1)` in the fan-out, and the resolve is `O(fan-out)`
|
||||
paid only on click.** For the one opentitan cursor that offers an action:
|
||||
|
||||
| | offer | resolve | total, if the user clicks | one-shot (eager client) |
|
||||
|---|---:|---:|---:|---:|
|
||||
| `aes_wrap.sv` 0-based 78:2, "lucisv: connect 2 missing ports" | 33.3 / 21.2–26.8 ms | **119.5 / 119.5–121.9 ms** | ~145 ms | 143.8 / 123.9–124.4 ms |
|
||||
|
||||
The `data`/`edit` split behaves exactly as §37.1 specifies: the lazy offer
|
||||
carries `data` and **no** `edit`; `codeAction/resolve` returns the same title
|
||||
with a 1-file `WorkspaceEdit`; the eager offer carries the edit inline. Both
|
||||
titles are byte-identical (`lucisv: connect 2 missing ports`).
|
||||
|
||||
### 6b. How rare an offer actually is — a new measurement
|
||||
|
||||
Take 2 recorded "0 actions after 95–186 ms of work" as a surprise and asked for
|
||||
a cheap pre-check. Take 3 measured how common that is. A sweep of every
|
||||
instantiation-shaped line in **205 RTL files** — all 165 of `hw/ip/prim/rtl`
|
||||
and all 40 of `hw/ip/aes/rtl` — found **exactly one position that offers a port
|
||||
refactoring**: `hw/ip/aes/rtl/aes_wrap.sv` at 0-based 78:2. A separate sweep of *every*
|
||||
identifier position in `hw/ip/prim/rtl/prim_lc_sync.sv` (557 identifier starts) found
|
||||
zero.
|
||||
|
||||
That is the real shape of the problem take 2 pointed at, and it is the
|
||||
strongest argument for §37.1 that exists: on this corpus the eager path spent
|
||||
95–255 ms per cursor move to answer "no" essentially always. The two
|
||||
refactorings are refused for structural reasons, not accidental ones —
|
||||
`remove port` refuses when the module's own body still uses the port (real RTL
|
||||
always does), and `connect missing ports` needs an instantiation that omits
|
||||
one (real RTL rarely does). Nothing is broken; the lightbulb is simply almost
|
||||
never lit, which is why computing its edit eagerly was the wrong trade.
|
||||
|
||||
### 6c. `prepareRename` and `rename`
|
||||
|
||||
`prepareRename` remains flat and free: 0.05–0.16 ms at every scope, on both
|
||||
binaries, with the byte-identical answer take 2 pinned
|
||||
(`{"placeholder":"aes","range":{"start":{"line":44,"character":2},"end":{"line":44,"character":5}}}`).
|
||||
|
||||
`rename` is 151.8 ms first / 139.1–140.7 repeats at 0.43.0 and
|
||||
147.4 / 137.4–139.1 at 0.39.0, against take 2's 115 / 107.5–121.4. **It now
|
||||
edits 9 files rather than take 2's 7**, so the per-edited-file cost is
|
||||
16.9 ms against take 2's 16.4 — flat. The extra two files are the same
|
||||
reference-set growth §4b sees. Variance stays tight (1.09× across repeats;
|
||||
take 1's was 2.4×).
|
||||
|
||||
### 6d. `completion`
|
||||
|
||||
| Typed prefix | T2 items | T2 | **0.43.0** | 0.39.0 | 0.43 items |
|
||||
|---|---:|---:|---:|---:|---:|
|
||||
| `` (empty) | 512 | 14.8 – 18.6 ms | **9.5 / 2.3 – 2.8 ms** | 5.2 / 3.0 – 3.3 ms | 512 |
|
||||
| `a` | 512 | 15.9 – 19.4 ms | **3.2 / 2.5 – 2.7 ms** | 3.8 / 3.0 – 3.1 ms | 512 |
|
||||
| `ae` | 483 | 16.8 – 18.5 ms | **4.0 / 2.6 – 2.9 ms** | 3.9 / 2.8 – 2.9 ms | 512 |
|
||||
| `aes` | 482 | 16.1 – 17.5 ms | 10.4 / 7.8 – 9.2 ms | 9.6 / 7.1 – 8.2 ms | 512 |
|
||||
| `aes_` | 476 | 15.9 – 17.4 ms | 7.5 / 6.8 – 8.2 ms | 8.1 / 6.5 – 7.0 ms | 512 |
|
||||
| `prim_` | 339 | 6.1 – 6.9 ms | 5.1 / 4.0 – 4.4 ms | 4.8 / 3.6 – 3.8 ms | 512 |
|
||||
| `clk` | 512 | 2.8 – 3.0 ms | 4.4 / 3.3 – 3.9 ms | 4.7 / 3.4 – 3.6 ms | 512 |
|
||||
| `aes_reg` | 20 | 0.36 – 0.63 ms | 3.8 / 2.9 – 3.0 ms | 3.9 / 2.6 – 2.9 ms | **512** |
|
||||
| `zzzz` | 1 | 0.11 – 0.13 ms | 1.4 / 0.31 – 0.34 ms | 1.4 / 0.32 – 0.59 ms | 1 |
|
||||
|
||||
**Take 2's 15–18 ms plateau at 0–4 typed characters is gone: the whole curve is
|
||||
2–10 ms**, another change that landed before 0.39.0. Take 2's §8 item 3
|
||||
("four dropped frames per identifier typed") is closed.
|
||||
|
||||
Two honest caveats on this table. The item counts changed — `aes_reg` returns
|
||||
512 rather than 20, and `ae`/`aes`/`aes_` return 512 rather than 476–483 —
|
||||
so the two `aes_reg` numbers are not measuring the same work, and the row
|
||||
that reads "slower" (0.6 → 3.0 ms) is answering 25× as many items. And the
|
||||
curve's shape inverted again: `aes`/`aes_` (7–9 ms) are now the *worst*
|
||||
prefixes, above the empty one (2.5 ms), where take 2 had them roughly level.
|
||||
|
||||
---
|
||||
|
||||
## 7. The CLI sweeps — first time measured
|
||||
|
||||
`format --check` and `check` over five trees, three binaries, three tries each,
|
||||
wall clock and peak RSS from `/usr/bin/time -l`, everything under
|
||||
`tools/guard.sh`. The formatter cache lives in a scratch `--cache-dir` outside
|
||||
the opentitan tree; nothing was ever written into the corpus.
|
||||
|
||||
| Tree | files | command | 0.39.0 wall (first / repeats) | 0.41.0 | **0.43.0** | peak RSS, 0.39 → 0.43 |
|
||||
|---|---:|---|---:|---:|---:|---:|
|
||||
| `hw/ip` | 1 807 | `format --check`, cold cache | 0.67 / 0.59–0.62 s | 0.66 / 0.61–0.64 | **0.63 / 0.61–0.66** | 211 → 233 MB |
|
||||
| `hw/ip` | | `format --check`, warm cache | 0.65 / 0.60–0.62 | 0.67 / 0.61–0.64 | **0.61 / 0.63–0.68** | 220 → 225 MB |
|
||||
| `hw/ip` | | `check` (default rules) | 0.37 / 0.36–0.37 | 0.39 / 0.37–0.39 | **0.40 / 0.39–0.41** | 191 → 194 MB |
|
||||
| `hw/ip` | | `check --select error,warning,style` | 0.42 / 0.41–0.43 | 0.43 / 0.43 | **0.45 / 0.47** | 187 → 198 MB |
|
||||
| `hw/top_earlgrey/ip` | 46 | `format --check`, cold / warm | 0.04 / 0.04 | 0.04 / 0.03 | **0.04 / 0.03** | 34 → 39 MB |
|
||||
| `hw/top_earlgrey/ip` | | `check` / `--select …` | 0.03 / 0.02 | 0.02 / 0.02 | **0.02 / 0.03** | 35 → 37 MB |
|
||||
| `hw/top_darjeeling/ip` | 49 | `format --check`, cold / warm | 0.03 / 0.03 | 0.03 / 0.03 | **0.02 / 0.03** | 23 → 26 MB |
|
||||
| `hw/top_darjeeling/ip` | | `check` / `--select …` | 0.02 / 0.02 | 0.02 / 0.02 | **0.02 / 0.02** | 28 → 29 MB |
|
||||
| `hw/dv` | 365 | `format --check`, cold / warm | 0.06 / 0.06 | 0.07 / 0.06 | **0.07 / 0.07** | 32 → 30 MB |
|
||||
| `hw/dv` | | `check` / `--select …` | 0.05 / 0.06 | 0.05 / 0.07 | **0.06 / 0.07** | 33 → 33 MB |
|
||||
| `hw/vendor` | 287 | `format --check`, cold / warm | 0.11 / 0.10 | 0.11 / 0.11 | **0.12 / 0.11** | 51 → 48 MB |
|
||||
| `hw/vendor` | | `check` / `--select …` | 0.07 / 0.08 | 0.07 / 0.09 | **0.08 / 0.10** | 53 → 58 MB |
|
||||
|
||||
- **The CLI is fast and essentially unchanged.** The biggest tree, 1 807 files,
|
||||
is checked for formatting in 0.6 s and linted in 0.4 s, on ten cores, at
|
||||
~200–230 MB.
|
||||
- **`check` is 6–10% slower at 0.43.0 than at 0.39.0** on the two trees big
|
||||
enough to measure it (`hw/ip` 0.367 → 0.400 s default rules, 0.420 → 0.463 s all
|
||||
classes; `hw/vendor` 0.070 → 0.083 s). Consistent across all three tries and
|
||||
both rule sets, and 0.41.0 sits between. Small in absolute terms; filed as
|
||||
§8.5.
|
||||
- **The formatter cache buys nothing on opentitan, and that is expected.** The
|
||||
cold and warm rows are within noise of each other everywhere, because the
|
||||
cache remembers *already-formatted* files and opentitan has almost none:
|
||||
30 of 1 806 in `hw/ip`, 3 of 365 in `hw/dv`, 12 of 287 in `hw/vendor`. The
|
||||
stores written are 4–8 KB. A tree that lucisv already formats would see the
|
||||
opposite.
|
||||
- Peak RSS scales with the tree, not the version: 23–58 MB for the four small
|
||||
trees, 183–249 MB for `hw/ip`. No version is more than ~10% off any other on
|
||||
the same row, and the ordering is not consistent, so nothing is claimed.
|
||||
|
||||
### 7a. Failure counts per tree, and every per-file outcome that changed
|
||||
|
||||
`format --check --no-cache` and `check`, full runs, both binaries:
|
||||
|
||||
| Tree | 0.39.0 `format --check` | **0.43.0** |
|
||||
|---|---|---|
|
||||
| `hw/ip` | 1773 would reformat, 30 unchanged, **4 failed** | **1772** would reformat, 30 unchanged, 4 failed |
|
||||
| `hw/top_earlgrey/ip` | 46 would reformat | 46 would reformat |
|
||||
| `hw/top_darjeeling/ip` | 48 would reformat, 1 failed | 48 would reformat, 1 failed |
|
||||
| `hw/dv` | 361 would reformat, 3 unchanged, **1 failed** | **362** would reformat, 3 unchanged, **0 failed** |
|
||||
| `hw/vendor` | 270 would reformat, 12 unchanged, **5 failed** | **271** would reformat, 12 unchanged, **4 failed** |
|
||||
|
||||
`check` findings: `hw/ip` 446 → **445**; `hw/top_earlgrey/ip` 14;
|
||||
`hw/top_darjeeling/ip` 23; `hw/dv` 85; `hw/vendor` 231 + 1 file that cannot be
|
||||
checked — every one of those unchanged. With `--select error,warning,style`:
|
||||
`hw/ip` 7 735 → **7 734**, and 551 / 382 / 1 158 / 1 666 unchanged.
|
||||
|
||||
**Exactly three per-file outcomes changed since 0.39.0, and all three were
|
||||
predicted:**
|
||||
|
||||
1. `hw/dv/sv/jtag_agent/jtag_if.sv` — was `parse error: 163:1: expected
|
||||
\`endinterface\` (found "<eof>")`, now **would reformat**. §38.1, the rival
|
||||
headers in a conditional region.
|
||||
2. `hw/vendor/pulp_riscv_dbg/tb/unused/SimDTM.sv` — was `parse error: 40:15:
|
||||
expected identifier (found "#")`, now **would reformat**. §38.2, the net
|
||||
delay after the type.
|
||||
3. `hw/ip/tlul/rtl/tlul_adapter_vh.sv` — was reported *beside* its symlink
|
||||
alias `tlul_adapter_shim.sv`; now only the alias (the first spelling seen)
|
||||
is reported, and the target is deduplicated away. §41.2, dedup by canonical
|
||||
identity. The same one line disappears from `check`
|
||||
(`tlul_adapter_vh.sv:43:101: style: line is 101 characters`), which is where
|
||||
the 446 → 445 and 7 735 → 7 734 come from.
|
||||
|
||||
**Nothing else moved**, on any tree, for either command, at any rule set.
|
||||
0.41.0's outcomes are byte-identical to 0.39.0's, which places all three
|
||||
changes in 0.42.0/0.43.0 exactly as their sections say.
|
||||
|
||||
The seven files that still fail to parse, for the record:
|
||||
`hw/ip/edn/dv/env/edn_env_cfg.sv`, `hw/ip/kmac/fpv/tb/keccak_2share_fpv.sv`,
|
||||
`hw/ip/kmac/pre_dv/kmac_reduced_tb/rtl/kmac_reduced_tb.sv`,
|
||||
`hw/ip/spi_device/dv/env/spi_device_scoreboard.sv`,
|
||||
`hw/top_darjeeling/ip/ast/rtl/ast.sv` (a locally modified file),
|
||||
`hw/vendor/lowrisc_ibex/dv/formal/check/peek/compare_helper.sv`,
|
||||
`hw/vendor/lowrisc_ibex/dv/uvm/core_ibex/riscv_dv_extension/riscv_core_setting.tpl.sv`
|
||||
(a template, not SystemVerilog), `hw/vendor/lowrisc_ibex/syn/rtl/latch_map.v`,
|
||||
`hw/vendor/lowrisc_ibex/vendor/google_riscv-dv/src/riscv_instr_cover_group.sv`.
|
||||
|
||||
---
|
||||
|
||||
## 8. Findings — filed, not fixed
|
||||
|
||||
Ordered by how much they matter. Nothing in this list was fixed in this round.
|
||||
|
||||
### 8.1 CREDIT, not a finding — the five things that got faster
|
||||
|
||||
Stated first so the rest reads in proportion.
|
||||
|
||||
| What | take 2 | take 3 | Credit |
|
||||
|---|---:|---:|---|
|
||||
| `codeAction` at the `aes` cursor, resolving client | 39.2 / 36.4–37.6 ms | **5.15 / 4.05–4.24 ms** | **§37.1** (0.41.0) |
|
||||
| `codeAction` at a 128-file fan-out, resolving client | 200.7 / 184.9–186.2 ms | **24.0 / 15.6–16.9 ms** | **§37.1** |
|
||||
| The first RTL `didOpen` at the default scope, warm | 1 411–1 568 ms | **365 ms** | pre-0.39.0 (take 2's §8.1 regression) |
|
||||
| `completion` at 0–4 typed characters | 14.8–19.4 ms | **2.3–4.0 ms** | pre-0.39.0 (take 2's §8.3 residual) |
|
||||
| `definition` on `aes`, first try | 0.27 ms | 0.19 ms (0.39.0: 0.41 ms) | §37.3's index-only `locate`, ~2× on the first try; repeats were already at the floor |
|
||||
|
||||
Two of those close take-2 findings outright (its §8 items 1 and 3), and §37.2's
|
||||
ruling closes its item 9.
|
||||
|
||||
### 8.2 FINDING (medium) — the eager `codeAction` path is ~1.37× slower than take 2
|
||||
|
||||
**What.** For a client that does *not* advertise
|
||||
`codeAction.resolveSupport.properties: ["edit"]`, `codeAction` on a module
|
||||
instantiation costs 1.35–1.40× what take 2 measured, at every fan-out:
|
||||
|
||||
| fan-out | take 2 repeats | 0.39.0 repeats | 0.43.0 repeats | factor vs T2 |
|
||||
|---:|---:|---:|---:|---:|
|
||||
| 42 | 94.4 – 95.3 ms | 125.4 – 126.8 ms | 128.9 – 130.4 ms | 1.37× |
|
||||
| 67 | 138.8 – 139.8 ms | 191.7 – 194.6 ms | 196.0 – 196.5 ms | 1.40× |
|
||||
| 128 | 184.9 – 186.2 ms | 230.7 – 246.4 ms | 252.9 – 255.2 ms | 1.37× |
|
||||
|
||||
**Reproduce.** `bench.py codeaction eager`; cursor on `prim_flop_2sync #(` in
|
||||
`hw/ip/aes/../aon_timer/rtl/aon_timer.sv` at 0-based 83:2, workspace scope,
|
||||
warm store, `tb.sv` also open; four tries. Server-side `--verbose` lines agree
|
||||
with the wire to 0.3 ms (§0), so this is server work, not transport.
|
||||
|
||||
**Where it landed.** Between `ee1efe3` (take 2) and 0.39.0 — 0.39.0 already
|
||||
shows it and 0.43.0 only adds ~3%. Not bisected; the candidates are §29–§35,
|
||||
of which the linter expansion (§33–§35, 73 rules) is the one that touched
|
||||
per-file work. Not attributed here.
|
||||
|
||||
**Why it is medium, not high.** It is paid only by clients without
|
||||
`resolveSupport`, it crosses take 2's 200 ms "reads as a hang" line only at
|
||||
fan-outs above ~67, and the same cursors cost 8–17 ms for a client that can
|
||||
resolve. But it is still a per-cursor-move request and the trend is the wrong
|
||||
way.
|
||||
|
||||
### 8.3 FINDING (low) — `rename` and its followers are ~1.4× slower in absolute terms
|
||||
|
||||
151.8 / 139.1–140.7 ms against take 2's 115 / 107.5–121.4, and anything queued
|
||||
behind it pays 160.8 ms. **Half the difference is more work**: the edit set is
|
||||
9 files rather than 7 (16.9 ms per edited file against 16.4 — flat). 0.39.0
|
||||
measures the same, so nothing in 0.41.0–0.43.0 caused it. Reproduce:
|
||||
`bench.py rename`, `textDocument/rename` on `aes` at `tb.sv` 44:2, newName
|
||||
`aes_renamed`, workspace scope; the edits are discarded.
|
||||
|
||||
### 8.4 FINDING (low–medium) — a `didOpen` of a file already in scope costs 21–51 ms before the next request is answered
|
||||
|
||||
**What.** At the default scope, take 2 measured 2.1–4.0 ms for the request
|
||||
following a `didOpen` of `kmac.sv` / `hmac.sv` / `spi_device.sv` — files
|
||||
already inside `hw/ip` after the `aes.sv` widen, so no rescan happens. Take 3
|
||||
measures 21–51 ms for the same three, on both binaries.
|
||||
|
||||
| file | size | T2 warm | 0.43.0 warm | 0.39.0 warm |
|
||||
|---|---:|---:|---:|---:|
|
||||
| `hmac.sv` | 33 KB | 2.1 ms | 21.1 ms | 22.1 ms |
|
||||
| `kmac.sv` | 53 KB | 2.7 ms | 31.1 ms | 30.0 ms |
|
||||
| `spi_device.sv` | 67 KB | 4.0 ms | 51.2 ms | 49.4 ms |
|
||||
|
||||
**It is the open, not the request.** A *second* `definition` at the same
|
||||
position, issued right after the first, costs **0.07–0.21 ms** in every one of
|
||||
these cells. So the 21–51 ms is work the `didOpen` queues (parse and analysis
|
||||
of the newly opened buffer) that the next request waits behind, and it scales
|
||||
with the file, which take 2's flat 2–4 ms did not.
|
||||
|
||||
**Caveat, stated plainly.** Take 2's client is gone from disk, so I cannot
|
||||
prove its follow-up request was the same one at the same position. If it used a
|
||||
cheaper barrier the comparison is not like-for-like. What take 3 *can* assert
|
||||
without reference to take 2: opening a 67 KB file that is already indexed
|
||||
delays the next request by 51 ms, three frames.
|
||||
|
||||
**Reproduce.** `bench.py widen default`, warm store; `didOpen spi_device.sv`
|
||||
then immediately `textDocument/definition` at the first `module ` token.
|
||||
|
||||
**Fixed in 0.44.0 (TODO §46), and the finding understated it.** The delay is
|
||||
not the widen, the diagnostics plumbing or §42's lint-run construction: it is
|
||||
one rule. `undriven-net` asked the workspace census
|
||||
(`WorkspaceIndex::files_mentioning`, a walk over every indexed file) once per
|
||||
declaration in the buffer, *before* its own local guards had a chance to
|
||||
silence it — so a file with four thousand declarations asked four thousand
|
||||
questions and threw away four thousand answers. `unused-signal`, the twin
|
||||
rule with the same oracle, has always asked last; `undriven-net` now does
|
||||
too. At the whole-workspace scope, where the census covers 3 976 files rather
|
||||
than this section's ~124, the same three files measured 51 / 70 / 95 ms
|
||||
before and **4.6 / 7.3 / 7.8 ms** after, and opentitan's largest file,
|
||||
`hw/top_darjeeling/ip_autogen/pinmux/rtl/pinmux_reg_top.sv` (42 192 lines),
|
||||
went from **1 742 ms to 117 ms** (QA re-derived 1 805–1 825 → 104–108). The
|
||||
take-2 comparison in this section should be read as "take 2's session
|
||||
probably did not have the workspace rules on", not as a regression: 0.39.0
|
||||
measures the same as 0.43.0 on every cell. Breakdown and method in
|
||||
`docs/features/didopen-cost/README.md`.
|
||||
|
||||
### 8.5 FINDING (low) — `lucisv check` is 6–10% slower than 0.39.0
|
||||
|
||||
`hw/ip`: 0.367 → 0.400 s mean of three (default rules), 0.420 → 0.463 s
|
||||
(`--select error,warning,style`); `hw/vendor`: 0.070 → 0.083 s and
|
||||
0.083 → 0.097 s. Consistent
|
||||
across three tries per cell, with 0.41.0 between the two, so it accumulated
|
||||
across 0.41–0.43 rather than in one release. `format --check` did not move
|
||||
(0.61 → 0.63 s on `hw/ip`, inside the spread). Candidates in that window
|
||||
include §41.2's `fs::canonicalize` per existing file in `dedup` and §42's
|
||||
config plumbing; not bisected. 40 ms on the largest tree in opentitan is not a
|
||||
user-visible cost — filed so the next round can see if it keeps accumulating.
|
||||
|
||||
### 8.6 FINDING (low) — `workspace/symbol` keeps drifting up
|
||||
|
||||
6.6 (take 1) → 6.6–7.4 (take 2) → **7.2–7.9 (0.43.0)**, 8.4–8.7 at 0.39.0, for
|
||||
the same 256 results. Take 2 already flagged this row as "~13% up and worth one
|
||||
glance". 0.43.0 is *better* than 0.39.0 here, so the drift is not monotonic,
|
||||
but the row has now moved in three consecutive takes and nothing in the
|
||||
document explains it.
|
||||
|
||||
### 8.7 SURPRISE — the port refactorings are offered at 1 of 205 RTL files
|
||||
|
||||
Detailed in §6b. Not a defect: both refactorings refuse for structural reasons
|
||||
that real RTL always satisfies. Recorded because it is the measurement that
|
||||
justifies §37.1 after the fact, and because a future round asking "why is
|
||||
`codeAction` slow" should know that it is almost always slow to say no.
|
||||
|
||||
### 8.8 STILL SLOW — the cold workspace scan at ~2.8 s
|
||||
|
||||
Essentially unmoved across three takes (3 003 → 2 958 → 2 767 mean), and still
|
||||
the largest absolute number in the document. Once per session per cold cache;
|
||||
never any round's target.
|
||||
|
||||
### 8.9 Movements inside the noise, listed and dismissed
|
||||
|
||||
`prepareRename` 0.07 → 0.31 ms first try, `documentHighlight` 0.04 → 0.10,
|
||||
`foldingRange` 0.05 → 0.10, `diagnostic` 0.11 → 0.34, `didChange` flush
|
||||
0.48 → 0.95, `inlayHint` 0.38 → 0.49, `semanticTokens` 0.16 → 0.21. Every one
|
||||
of these is within 0.3 ms of take 2 and sits on a transport floor that is
|
||||
0.04 ms fatter in this harness (§0); 0.39.0 measures the same as 0.43.0 on all
|
||||
of them. **No conclusion should be drawn from any of them.** The `diagnostic`
|
||||
row additionally answers 0 items rather than take 2's 1 (§1a).
|
||||
|
||||
---
|
||||
|
||||
## 9. Methodology and caveats — read before quoting any number
|
||||
|
||||
Take 1's and take 2's caveats still apply. The take-3-specific ones:
|
||||
|
||||
- **Three tries per row, first try and repeat range both reported.** "First" is
|
||||
the request issued as the first real request of a dedicated session, after
|
||||
the scan settled; "repeats" is the 2nd–4th identical request in that same
|
||||
session. Where a row needed its own session (`codeAction`, `rename`,
|
||||
`prepareRename`, each fan-out cursor, each scope/cache cell) it got one.
|
||||
- **There *is* a server-side column this time**, from the shipped `--verbose`
|
||||
flag, and it confirms the wire (§0). Nothing was instrumented for this round;
|
||||
no code in the lucisv repo was modified except the creation of this file, the
|
||||
`docs/perf/README.md` entry and `TODO.md`'s §40 ticks. No `cargo` command ran
|
||||
in the main tree.
|
||||
- **The comparison is binary-to-binary.** 0.43.0 is the packaged release build
|
||||
at `73799f3`; 0.39.0 was built for this round from the `v0.39.0` tag in a
|
||||
scratch `git worktree` under the scratchpad (`cargo build --release -p
|
||||
lucisv_server`), which was removed afterwards. The main tree was never
|
||||
checked out, reset or stashed.
|
||||
- **Machine state.** Apple M1 Max, 10 cores, 64 GB, macOS 27.0 (26A5425a).
|
||||
**The first 20 minutes of the session were contended** — two `rustc`
|
||||
processes from an unrelated build ran at 99% CPU, load average 6–13 — and the
|
||||
only measurements taken in that window were the untimed per-file outcome
|
||||
sweeps of §7a, which are correctness, not timing. Every timed number in this
|
||||
document was taken after those processes exited, at load average 2–4 with
|
||||
only the editor and this agent running. No `cargo` build of this repo ran
|
||||
during any timed measurement.
|
||||
- **The guard.** Every server session, every `lucisv` invocation and the one
|
||||
`cargo build` went through `tools/guard.sh -m 8 -t 1800`. **No guard kill
|
||||
occurred**, and the largest resident set any command reached was 249 MB
|
||||
(`lucisv format --check hw/ip`), 3% of the 8 GB limit.
|
||||
- **The opentitan checkout was never written.** `git status --porcelain` was
|
||||
checked after every phase and after the last run, and reports the same three
|
||||
pre-existing modified files throughout: `hw/ip/aes/dv/tb/tb.sv`,
|
||||
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`.
|
||||
`rename`, `codeAction/resolve` and `willRenameFiles`-shaped requests return
|
||||
edits; the client discarded every one. The formatter cache was directed to a
|
||||
scratch `--cache-dir` and the index cache to a scratch
|
||||
`initializationOptions.storagePath`; neither default (`.lucisv_cache` in the
|
||||
*current* directory, `~/Library/Caches/lucisv/index/<key>`) lands inside the
|
||||
corpus, and both were overridden anyway.
|
||||
- **One corpus difference from take 2** — `tb.sv` has been reformatted since,
|
||||
so it raises no diagnostic and offers no `source.fixAll` action (§1a). Two
|
||||
take-2 columns are therefore not comparable, and both are called out where
|
||||
they appear.
|
||||
- **Take 2's client no longer exists on disk**, so take 3's is a
|
||||
reimplementation from take 2's description, not the same code. Its transport
|
||||
floor is ~0.04 ms fatter (§0). Every sub-0.3 ms comparison against take 2
|
||||
should be read with that in mind, and §8.9 dismisses the lot.
|
||||
- **Page cache is hot and hotter than ever** — opentitan has now been walked by
|
||||
three measurement sessions and by tonight's outcome sweeps. "Cold cache"
|
||||
means *lucisv's* store was deleted, not that the OS file cache was dropped.
|
||||
- **Sub-millisecond results were stable to ±0.05 ms** across ~60 sessions;
|
||||
ten-to-hundred-millisecond ones should be read as ±10% (tighter than take
|
||||
2's ±20%, because the machine was quieter); the multi-second scan rows as
|
||||
±5% (take 3's six warm workspace scans span 12 ms).
|
||||
- **The fan-out counts in §6a are `grep`-derived**
|
||||
(`grep -rlE '^\s*<module>( |#|$)'` over `*.sv`), reproducing take 2's counts
|
||||
exactly (1 / 6 / 42 / 67 / 128).
|
||||
- **`--select error,warning,style` is not "all rules"** — it is the three rule
|
||||
classes by name, which is what §40 asked for; a rule outside those classes
|
||||
would not run.
|
||||
|
||||
---
|
||||
|
||||
## 10. Raw logs
|
||||
|
||||
All under `…/7b09ba01-…/scratchpad/perf3/` (removed after this document was
|
||||
written; the numbers here are the record):
|
||||
|
||||
| File | What |
|
||||
|---|---|
|
||||
| `lspclient.py` | the LSP client — framing, the configuration pull, per-session capabilities, `--verbose` capture |
|
||||
| `bench.py` | phases `startup` / `nav` / `codeaction` / `portaction` / `rename` / `blockers` / `completion` / `widen` / `diagnostics` |
|
||||
| `verbose_probe.py` | §0 — the server's own timing lines beside the wire |
|
||||
| `realfolder.py` | §5c — the slow requests with only `aes.sv` open, per scope |
|
||||
| `probe_offer.py`, `probe_ws.py` | §6b — the sweeps that found one offered action in 205 files |
|
||||
| `sweep.sh`, `sweeptable.py` | §7 — the timed CLI sweeps and their table |
|
||||
| `outcomes.sh` | §7a — the per-file outcome runs for the 0.39.0 → 0.43.0 diff |
|
||||
| `results.jsonl`, `logs/*.log` | every measurement, machine-readable |
|
||||
+4
-4
@@ -630,12 +630,12 @@ update the filing README(s) and this file.
|
||||
| ~~14~~ | ~~A `program` node with `name_span`/`end_label_span` for linked editing~~ — **delivered by vendor-formal-grammar (0.30.0)**: `parser/item.rs` routes `program` to `parse_module("endprogram")`; the resulting `ItemKind::Module` carries both spans and `linked.rs::module_pairs` consumes them. Confirmed in the 2026-09-04 source audit. | linked-editing | ~~vlog_parser~~ done |
|
||||
| ~~15~~ | ~~Bind semantics: whether a `bind`'s target scope and connections should resolve through the workspace index (today only the instantiated module name is recorded)~~ — **delivered 2026-09-02 by bind-semantics**: `BindDirective::target` is `Vec<PathSegment { name, span, index }>`; a lone target binds as `Target::Module`, an instance path records nothing (a guess would be a wrong answer); each connection's port half is `Target::Port(inst.module)` and its expression half `Target::BindScope` — the target's own scope first (`resolve::in_bind_target`, `None` on a miss because generate blocks open scopes of their own), the workspace's one-segment member path when the target lives elsewhere, the writing scope last. `FACTS_FORMAT` 14 → 15 | bind | ~~vlog_semantic~~ done |
|
||||
| 16 | DPI/package re-export halves as real references (`export pkg::item` doesn't resolve; `*::*` has `"*"` as its package name, which nothing expects) | dpi-export | vlog_semantic |
|
||||
| 17 | Inline aggregate as a parameter-override *argument* (`m #(.T(struct packed { logic a; })) u ();`) is rejected in expression position; M4's `instantiation_plan` drops such a `parameter type` default rather than emit unparseable text | refactor-instantiate (gap 1; its gap 2 was delivered by ansi-first-port) | vlog_parser |
|
||||
| ~~17~~ | ~~Inline aggregate as a parameter-override *argument* (`m #(.T(struct packed { logic a; })) u ();`) is rejected in expression position; M4's `instantiation_plan` drops such a `parameter type` default rather than emit unparseable text~~ — **delivered 2026-09-05 by small-items-4 (TODO §45.3):** `parse_expr_or_type` routes a `struct`/`union`/`enum` head to the type grammar; the value is an `ExprKind::Type` printed by the type printer. `instantiation_plan` emits a one-line `parameter type` aggregate default; a multi-line one is still dropped by the "written across several lines" rule, not the grammar. | refactor-instantiate (gap 1; its gap 2 was delivered by ansi-first-port) | vlog_parser |
|
||||
| ~~18~~ | ~~A macro-invocation census in `FileFacts`~~ — **delivered 2026-09-02**: the engine half by sva-bodies (`macro_use_warnings` pinned for a file in the source set) and the server half by macro-word-census (TODO §29.2): `FileFacts::macro_words` (`words::harvest_raw`, tag `MW`, `FACTS_FORMAT` 16 → 17, +3.1 % corpus / +1.7 % opentitan store), `WorkspaceIndex::files_naming_in_macros`, and a warning appended by `lucisv_server::rename` for every such file **outside** the set `rename_sources` built — no rung, nothing read (58 files in 186 µs on opentitan for `clk`). | refactor-rename; sva-bodies; macro-word-census | ~~vlog_semantic~~ done |
|
||||
| ~~19~~ | ~~An execute-command spelling of the instantiation skeleton (plain-text `render` through the same `plan_for`), for clients without `textDocument/inlineCompletion` — since the 2026-08-30 names-only popup, such a client (Neovim's built-in LSP, today) has no path to the full skeleton at all. Filed at lead review after correcting the dev's assumption that a `lucisv/instantiate` command already existed (it never did).~~ — **delivered 2026-09-02 by bind-semantics**: `lucisv.instantiate [uri, position, module]` (`lucisv_server/src/instantiate.rs`, advertised by `main.rs::commands()`, routed through `ports::execute`) — `plan_for` → plain `render` under `completion::layout_at` → `workspace/applyEdit`; `at_instantiation_site` validates the position; escaped names go in as plain text. Pinned at the plan level: the command's plan renders to the ghost's text. `editors/nvim/README.md` documents it | inline-instantiation (lead) | ~~lucisv_server~~ done |
|
||||
| ~~20~~ | ~~Rename loses its heads-up for an **unresolvable member/hierarchical tail** spelling the renamed name (`unknown_mod u_x (); … u_x.sig` when `unknown_mod` is indexed nowhere): before class-member-access the tail had no reference and `rename.rs::stray_reason` warned "a hierarchical or member tail, which lucisv does not resolve"; since round 2 it carries an `ExternalCandidate` the workspace cannot answer, which the engine neither edits (correct) nor mentions. Wanted: a warning for candidate references that spell the old name and stayed unresolved through the overlay — one message per file. Pinned as a premise by `a_hierarchical_tail_that_cannot_resolve_is_left_alone_and_named_as_such`. Same class as item 18.~~ — **delivered 2026-09-02 by comment-slots**: `Scope::unresolved_candidate_warnings` — a reference that stayed `ExternalTarget::StillUnresolved` through the overlay (or an `InheritedCandidate` that missed) is reported one line per (file, unit), run over every file that spells the name. The premise pin is inverted. Surfaced item 23 in the process | class-member-access round 2 (lead) | ~~vlog_refactor (`rename.rs`)~~ done |
|
||||
| ~~21~~ | ~~`Parser::parse_scoped_name` joins a `pkg::name` chain into one `String`, erasing the segment boundary, so an escaped segment (`\my-pkg ::\state-t` as a type, an instantiated module or a `bind` target) is reprinted without its terminating space and **refused by the safety net** — an error, never a corruption. Wanted: the AST keeps the segments (as `parse_method_name` already does for `FunctionDecl::scope`). Pinned by `escaped_identifiers.cases`'s one `#SKIP` and `verification::an_escaped_name_in_a_scoped_type_is_rejected_rather_than_corrupted`, both of which must keep failing-to-format until delivered~~ — **delivered 2026-09-02 by comment-slots**: `Parser::push_scope_segment` is the one join for every `::` chain and writes the escaped segment's terminator; `parse_method_name` keeps real segments (`ScopeSeg`, one comment slot per `::`). The `#SKIP` is a live case and the verification pin is inverted, with a new pair asserting the tightened spelling is still refused | escaped-identifiers | ~~vlog_parser~~ done |
|
||||
| ~~22~~ | ~~**Comment slots in shared expression/name machinery** drop the comment and the safety net refuses the file: `q[/*c*/ i]` (index expressions), `x inside {[/*c*/ 0:3]}` and `n /*c*/ inside {` (`inside` / `parse_value_range`), `pkg/*c*/ ::cls::name` (`parse_method_name` chains), `foreach (q[/*c*/ i])` (`parse_foreach_target`), `static /*c*/ constraint` / `pure /*c*/ static function` (`take_member_prefix`). Found by constraint-bodies' exhaustive gap fuzzer (358 gaps; these 40 fail identically on v0.26.0 in the same constructs outside a constraint). Inside a constraint they are regressions relative to the verbatim era — but no opentitan file hits one (sweep unchanged). Wanted: a parser-wide round giving each slot a `Meta`/comments field, then re-running the fuzzer to zero.~~ — **delivered 2026-09-02 by comment-slots**: ~70 named comment fields across `ExprKind`/`Stmt`/declarations/headers/labels (`SegmentComments`, `BinaryComments`, `CastComments`, `LabelComments`, `Stmt::before_semi` + `StmtKind::takes_semi()`), three duplicated grammars folded into `parse_postfix_segment` / `parse_value_range`, and four gap fuzzers at zero — covergroup 329, fragment 153, constraint 395 (committed at last), RTL 352 (new). Corpus (860 files) and opentitan (3 975 files) byte-identical to v0.30.0. Deliberately left: `if`/`case` in-paren comments still recovered print-side by `header_parens` (only `after_kw` got a slot) — a real slot there would change existing layout | constraint-bodies (dev + QA) | ~~vlog_parser~~ done |
|
||||
| ~~22~~ | ~~**Comment slots in shared expression/name machinery** drop the comment and the safety net refuses the file: `q[/*c*/ i]` (index expressions), `x inside {[/*c*/ 0:3]}` and `n /*c*/ inside {` (`inside` / `parse_value_range`), `pkg/*c*/ ::cls::name` (`parse_method_name` chains), `foreach (q[/*c*/ i])` (`parse_foreach_target`), `static /*c*/ constraint` / `pure /*c*/ static function` (`take_member_prefix`). Found by constraint-bodies' exhaustive gap fuzzer (358 gaps; these 40 fail identically on v0.26.0 in the same constructs outside a constraint). Inside a constraint they are regressions relative to the verbatim era — but no opentitan file hits one (sweep unchanged). Wanted: a parser-wide round giving each slot a `Meta`/comments field, then re-running the fuzzer to zero.~~ — **delivered 2026-09-02 by comment-slots**: ~70 named comment fields across `ExprKind`/`Stmt`/declarations/headers/labels (`SegmentComments`, `BinaryComments`, `CastComments`, `LabelComments`, `Stmt::before_semi` + `StmtKind::takes_semi()`), three duplicated grammars folded into `parse_postfix_segment` / `parse_value_range`, and four gap fuzzers at zero — covergroup 329, fragment 153, constraint 395 (committed at last), RTL 352 (new). Corpus (860 files) and opentitan (3 975 files) byte-identical to v0.30.0. Deliberately left: `if`/`case` in-paren comments still recovered print-side by `header_parens` (only `after_kw` got a slot) — a real slot there would change existing layout A fifth fuzzer bar 2026-09-05 (small-items-4, TODO §45.4): the **delay list** — `#(1:2:3)` on nets and continuous assignments, `#(rise, fall)` on gates — gained `MinTypMaxComments`, `ast::DelayValue`, `ContAssign::{after_hash, after_delay}`, `GateInstantiation::{before_hash, after_hash, before_semi}`, `GateInstance::before_args`; `EXPECTED_RTL_GAPS` 374 → 419 at zero. | constraint-bodies (dev + QA) | ~~vlog_parser~~ done |
|
||||
| 23 | A **cross-file instance-member tail does not resolve for rename**: with `module sub` in `sub.sv` and `assign w = u_x.sig;` in `top.sv`, renaming `sub`'s `wire sig` edits `sub.sv` only — the same shape in one file resolves and is edited (`a_hierarchical_tail_that_resolves_is_renamed_with_its_declaration`). Since comment-slots the rename *says so* (item 20's warning); the edit itself is the gap. Modules export ports and parameters only (the class-member-access round 2 ruling), so an internal net is exactly what the cross-file hop refuses — the fix is either an export rule for nets named through an instance or a rename-time in-file fallback resolution of the tail. | comment-slots (dev, surfaced by the §2.9-20 control test) | vlog_semantic / vlog_refactor |
|
||||
| ~~24~~ | ~~A **half-typed `#(` parameter override whose value can read as a call** (`sub #(.W(` ⏎ `u0 (.a(x))`) — the greedy expression grammar swallows the next instance's name before any error fires, so the whole instantiation still degrades to an item-level `Error` node instead of getting header recovery's benefit. Found by §32's QA; the fix is a lookahead in the override grammar (an identifier followed by `(` on a later line is the next instance, not a call).~~ — **delivered 2026-09-04 by small-items-3 (TODO §36)** | header-recovery (QA) | vlog_parser |
|
||||
| ~~25~~ | ~~The parser **refuses** a module-scope `begin … end` and a bare `begin` inside a `generate` region (an `ItemKind::Error`) rather than recovering them as an unnamed generate block, so `module-begin-block` and `v2001-generate-begin` (TODO §35) fire on an error leaf and the rest of the unit is lost to recovery. Wanted: tolerant-mode recovery that keeps the block's items.~~ — **delivered 2026-09-04 by small-items-3 (TODO §36)** | linter-expansion-3 (dev) | vlog_parser |
|
||||
@@ -643,8 +643,8 @@ update the filing README(s) and this file.
|
||||
| ~~26~~ | ~~**Same-target atomic writers share a temp path.** `atomic::temp_path` uses canonical target + process ID; parallel workers following distinct symlink spellings can reach that same name, while CLI dedup is lexical. A bounded direct helper probe (100 rounds, two threads, 1 MiB each) returned 100 write errors in 200 calls; no mixed final bytes observed in that probe. Use exclusive per-operation temp creation and coordinate/deduplicate target writes. See repository-analysis.md for limits.~~ — **closed by §41 (0.43.0):** unique `O_EXCL` temps (`.{name}.{pid}.{n}.lucisv-tmp`), dedup on `fs::canonicalize`; two *processes* remain last-writer-wins by design, stated in `atomic.rs` | repository audit, 2026-09-04 | lucisv_core / lucisv |
|
||||
| ~~27~~ | ~~**Net-delay comment slot**: parser-skips records a pre-existing refusal for a comment immediately before `#` in a net declaration. The regression cases mark it `#SKIP`; preserve the verifier's rejection until a parser/formatter comment slot handles it.~~ — **delivered 2026-09-05 by walk-cycles (TODO §43.2):** `NetDelay::{before_hash, after_hash}` own the gaps around `#`; the `#SKIP` is retired; the RTL gap fuzzer covers it. The gaps inside `#(1:2:3)` remain §2.9-22's. | parser-skips (dev + QA) | vlog_parser / vlog_formatter |
|
||||
| ~~28~~ | ~~**Project lint selection is not consumed by the server.** `enabled_rules` reads `ClientSettings`; `configured` reads project rule options and line length only. `[lint] select/ignore` currently controls CLI runs, while the editor needs `lucisv.lint.select/ignore`. Decide and test a common precedence contract before claiming project-wide parity.~~ — **closed by §42 (0.43.0):** `enabled_rules` picks the editor's list when set, else the project's, key by key (the CLI's `pick`); rejected project entries logged once with file:line | repository audit, 2026-09-04 | lucisv_server |
|
||||
| 29 | An unknown rule name in the **editor's** `lucisv.lint.select`/`ignore` is still dropped silently, while §42 logs the same mistake in a project file (and `lucisv.lint.options` logs its bad entries). Wants the same once-only log through `notification.rs`. | lint-config-contract (QA) | lucisv_server |
|
||||
| 30 | **An unreadable directory aborts the whole walk.** `Walk::dir` propagates `read_dir`'s error with `?`, so one permission-denied directory anywhere under the start — reachable now that a symlink to an outside directory is followed once (§2.9-8's ruling) — drops every file already found and fails the run. Found by walk-cycles' QA on a link to `/`. Wanted: skip the directory and say so through a warning channel the walk does not have today (the filelist-missing-file precedent), which is also where a dangling source link's warning belongs. | walk-cycles (QA) | lucisv_core / lucisv / lucisv_server |
|
||||
| ~~29~~ | ~~An unknown rule name in the **editor's** `lucisv.lint.select`/`ignore` is still dropped silently, while §42 logs the same mistake in a project file (and `lucisv.lint.options` logs its bad entries). Wants the same once-only log through `notification.rs`.~~ — **delivered 2026-09-05 by small-items-4 (TODO §45.1):** `settings::rules` records every dropped name in `ClientSettings::lint_name_warnings` as `lucisv.lint.<select|ignore>: unknown rule: <name>`; `apply_settings` logs what the previous settings value did not already say — once per (setting, name), re-armed by a changed list. | lint-config-contract (QA) | lucisv_server |
|
||||
| ~~30~~ | ~~**An unreadable directory aborts the whole walk.** `Walk::dir` propagates `read_dir`'s error with `?`, so one permission-denied directory anywhere under the start — reachable now that a symlink to an outside directory is followed once (§2.9-8's ruling) — drops every file already found and fails the run. Found by walk-cycles' QA on a link to `/`. Wanted: skip the directory and say so through a warning channel the walk does not have today (the filelist-missing-file precedent), which is also where a dangling source link's warning belongs.~~ — **delivered 2026-09-05 by small-items-4 (TODO §45.2):** `walk::collect_files` takes a `&mut dyn FnMut(Warning)` sink; an unreadable directory, an unreadable `.gitignore` and a dangling source link are warned about (`warning: <path>: <message>` on the CLI's stderr before the report, exit code unchanged; logged once per scan by the server through `report_scope`) and the walk continues. | walk-cycles (QA) | lucisv_core / lucisv / lucisv_server |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -5,6 +5,16 @@ for you. The extension and its bundled language server share one version
|
||||
number; the full engineering notes live in the
|
||||
[project changelog](https://git.luci.ooo/lucio/lucisv/src/branch/master/CHANGELOG.md).
|
||||
|
||||
## 0.44.0 — 2026-09-05
|
||||
|
||||
- **Opening a file no longer stalls.** A lint rule was asking the
|
||||
workspace about every declaration before checking the obvious; large
|
||||
files opened 15× faster, typical ones 10×.
|
||||
- A typo in `lucisv.lint.select`/`ignore` is reported in the lucisv log
|
||||
instead of silently switching rules off.
|
||||
- Workspaces with an unreadable directory or a broken symlink index with
|
||||
a logged warning instead of failing the scan.
|
||||
|
||||
## 0.43.0 — 2026-09-05
|
||||
|
||||
- **Project lint settings apply in the editor.** `[lint] select` and
|
||||
|
||||
@@ -30,7 +30,7 @@ Install **lucisv — Verilog/SystemVerilog** from the VS Code Extensions view,
|
||||
then open a Verilog or SystemVerilog file. There is no separate server or CLI
|
||||
setup.
|
||||
|
||||
The current release is **0.43.0**. Its platform packages include both
|
||||
The current release is **0.44.0**. Its platform packages include both
|
||||
`lucisv-server` and the `lucisv` command-line tool:
|
||||
|
||||
| Package target | Machines |
|
||||
@@ -365,6 +365,12 @@ Every nesting color is a proper VS Code theme color:
|
||||
}
|
||||
```
|
||||
|
||||
## Release 0.44.0 highlights
|
||||
|
||||
Version 0.44.0 makes opening a file 10–15× faster (one lint rule was
|
||||
asking the workspace too early), warns instead of failing on unreadable
|
||||
directories, and closes four small parser and editor items.
|
||||
|
||||
## Release 0.43.0 highlights
|
||||
|
||||
Version 0.43.0 closes the repository analysis's three findings: atomic
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "lucisv",
|
||||
"displayName": "lucisv — Verilog/SystemVerilog",
|
||||
"description": "Fast Verilog/SystemVerilog formatting, linting, navigation, refactoring, semantic highlighting and RTL design intelligence.",
|
||||
"version": "0.43.0",
|
||||
"version": "0.44.0",
|
||||
"publisher": "guoliangchen",
|
||||
"author": "Guoliang Chen",
|
||||
"license": "MIT",
|
||||
|
||||
Reference in new issue
Block a user