Every tracked file that can carry a comment (880 of them) now opens with "Author: Guoliang Chen, a Senior Digital Design Engineer" and closes with "Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com", in the file's own comment syntax. No behaviour change: the diff outside the version bump and changelogs is comment lines only. - tools/stamp_author.py: writes the lines; idempotent, `--check` lists what is missing. Headers go under a shebang and under Markdown front matter. - Left alone: test fixtures, cases and snapshots (byte-exact inputs), JSON and JSONL, logs, images, lockfiles, docs/site/dist (regenerated) and the LICENSE files (already carry the copyright line). - tools/linux_check.sh: --help reads its header from line 3, now that the author line sits under the shebang. - tools/gates.sh green on this tree: 5 545 tests, corpus 814/6 as before. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
984 lines
56 KiB
Markdown
984 lines
56 KiB
Markdown
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
|
||
|
||
# perf5r-publication — what a startup scan costs while requests keep arriving
|
||
|
||
Review round §R4 (TODO §61.4). `docs/performance_take5_review.md` §4 and its
|
||
"Startup throughput and responsiveness must be judged separately".
|
||
|
||
## Goal
|
||
|
||
A scan that answers messages between its files pays a **publication** for each
|
||
burst: the staged records merged into the index, the completion tables
|
||
re-derived, the include graph folded in, every open buffer's overlay refreshed
|
||
(`Workspace::publish_scan`). The review could not say what that costs, because
|
||
the only probe it had (`scanserve`) sends the next request 200 ms *after the
|
||
previous response* — so a more responsive server is asked more often and its
|
||
session-completion time is not comparable with anything. This lane builds the
|
||
controlled probe the review asked for — a **fixed arrival rate**, the same
|
||
offered load whatever the server does with it — reads the publication cost off
|
||
the server's own trace beside the request latencies, and then reduces what the
|
||
probe names without touching the coherent-prefix contract. It also carries two
|
||
items the lead assigned here because they live on the same drain path: the
|
||
empty-answer rule §61.3 filed, and the `HEAD_WALK_MAX` test §61.3's QA found
|
||
missing.
|
||
|
||
## Assumptions
|
||
|
||
- **The three tables are published together or not at all.** Nothing here
|
||
changes that; the cadence changes *how often* a publish happens, never what
|
||
one contains (`docs/features/scan-interleave/README.md`).
|
||
- **A prefix is allowed to be old, never inconsistent.** A request answered
|
||
between two publishes reads an index that is at most `PUBLISH_EVERY` files
|
||
behind the one it could have had. That was always true between two interleave
|
||
points; the cadence widens the gap and does not change its nature.
|
||
- **`[]` from a navigation request is not information while the index is
|
||
growing.** The empty-answer rule rests on this: a definition, a
|
||
typeDefinition and a references answer with a *list of places* and with an
|
||
empty list when they find none, so `[]` cannot be told apart from "not
|
||
scanned yet". A hover's `null`, a completion's empty list and an empty
|
||
code-action menu mean what they say, and are untouched.
|
||
- **`textDocument/implementation` is not answered by this server**, so it is
|
||
not on the navigation list even though it would belong there.
|
||
- The corpus is opentitan `0098135264` with its three known modifications, read
|
||
only. Every number is from `tools/perf/bench.py` under
|
||
`tools/guard.sh -m 8 -t 1800`.
|
||
|
||
## Handshakes
|
||
|
||
### `lucisv_server::state` — the publication cadence
|
||
|
||
```rust
|
||
pub(crate) const PUBLISH_EVERY: usize = 512; // state/scan.rs
|
||
|
||
impl Scan {
|
||
/// Whether enough has been staged since the last publish for another one
|
||
/// to be worth the merge it costs.
|
||
pub fn publish_is_due(&self) -> bool;
|
||
}
|
||
```
|
||
|
||
Additive. `publish_scan` is unchanged — same signature, same contract, same
|
||
three tables — and so is every other entry on `Scan`. The only caller of
|
||
`publish_is_due` is `server/index.rs::answer_what_is_waiting`, which is the one
|
||
place a mid-scan publish is decided.
|
||
|
||
`state::discover` and `HEAD_WALK_MAX` went from `pub(super)` to `pub(crate)`, so
|
||
`server/tests/startup.rs` can write a fixture *against the bound* rather than
|
||
against the number 512 written out again. No line was added to `state/mod.rs`
|
||
for it.
|
||
|
||
### `lucisv_server::server` — a request may be asked again
|
||
|
||
```rust
|
||
struct Server {
|
||
/// Navigation requests a scan answered empty while it was still growing
|
||
/// the index, to be asked again at its next publish.
|
||
deferred: Vec<Message>,
|
||
}
|
||
|
||
impl Server {
|
||
pub(super) fn ask_again_if_empty(&self, request: &Request) -> Option<Request>;
|
||
pub(super) fn say_deferred(&self, request: &Request);
|
||
}
|
||
pub(super) fn names_nowhere(response: &Response) -> bool;
|
||
```
|
||
|
||
**`deferred` is deliberately not part of `must_wait`.** `held` is the order
|
||
contract — nothing newer may overtake what is waiting there. `deferred` is not
|
||
a queue at all: the answer was computed, found to name nowhere, and set aside
|
||
because the reason may be that the file has not been scanned. Nothing is owed
|
||
anything by it, so a hover, a completion or a code action behind one is answered
|
||
exactly as before. That is the difference the two names are for.
|
||
|
||
### `docs/features/scan-interleave/README.md`
|
||
|
||
A dated entry records both, with the rules they amend stated in that README's
|
||
own terms. Neither is a contract change: the coherence contract, the order
|
||
contract and `INTERLEAVE_ABOVE` are all untouched.
|
||
|
||
### `docs/features/perf5r-first-answer/README.md`
|
||
|
||
That lane's cross-folder `[]` — pinned openly and filed as request 5 — is
|
||
answered here. Its test moved with it; the "honest limit" it pinned is now the
|
||
rule's own regression test.
|
||
|
||
### Requests for the lead (`docs/topo.md` is not edited by this lane)
|
||
|
||
1. `lucisv_server ──▶ vlog_semantic`: nothing new. `WorkspaceIndex::absorb` is
|
||
called with the same arguments, fewer times.
|
||
2. A new edge inside `lucisv_server`: `server::index ──▶ state::scan`
|
||
(`publish_is_due`) and `server::mod ──▶ server::dispatch` (`names_nowhere`,
|
||
`ask_again_if_empty`).
|
||
3. `state::discover` is now `pub(crate)` — a visibility widening for a test,
|
||
not an interface.
|
||
4. **A finding for a future lane, not a request:** `WorkspaceIndex::absorb`
|
||
ends in `merge(None)`, a pass over every record the index holds, while
|
||
`update_facts` has a targeted `merge(Some(&affected))` beside it. Under load
|
||
that whole-index merge is the single largest publication cost. An additive
|
||
`absorb` that takes an `Affected` would be a `vlog_semantic` change, which
|
||
this lane's file list excludes; the cadence reduces how often it is paid
|
||
rather than what it costs. Numbers below.
|
||
|
||
## How it works
|
||
|
||
### The probe: `scanload`
|
||
|
||
`tools/perf/phases_r4.py`, schema 2, registered in `bench.py` like every other
|
||
phase.
|
||
|
||
- **The clock, not the answers.** A `textDocument/definition` goes out every
|
||
`rate` ms of wall time counted from the session's own start, whether or not
|
||
the previous one has been answered. Requests pipeline; a server that stalls
|
||
accumulates them, which is the queue latency the probe exists to see.
|
||
- **A fixed count, so the load is the same for both binaries.** The first draft
|
||
stopped sending when the server stopped saying things, and that reintroduced
|
||
`scanserve`'s confound in a new place: a mid-scan lull in the progress
|
||
chatter stopped the probe at 14 requests where the session ran for 20 ticks.
|
||
The window is now fixed per cache state (`WINDOW_MS`: cold 9 000 ms, warm
|
||
3 500 ms — long enough to cover the reference's whole loaded session), so both
|
||
binaries are asked exactly the same number of times and a binary that finishes
|
||
sooner shows it as requests answered **after** settle, never as requests never
|
||
sent.
|
||
- **Every request's own wait.** `Session.poll_answers` (new, additive, in
|
||
`lspclient.py`) takes every response that has arrived without blocking on the
|
||
oldest, and the arrival instant is stamped in the reader thread, so a request
|
||
answered while the probe is busy sending the next one is not charged for the
|
||
probe's poll interval.
|
||
- **The publication split beside the latencies.** The session runs `--verbose`,
|
||
so `publishes`, `published` and the four `publish_*` stages come off the very
|
||
session whose requests are in the row.
|
||
- **A quiet control in the same series**: the same cells with no requests at
|
||
all, so a settle time that moved can be told apart from one that moved
|
||
*because requests arrived*.
|
||
- **Cells:** rate ∈ {100, 250} ms × cache ∈ {cold, warm} × extra open buffers
|
||
∈ {0, 1, 10, 100}, three fresh sessions each, plus the quiet control per
|
||
(cache, buffers). Buffer counts are *extra*: the cursor's own file is always
|
||
open, so "0" is one buffer and "100" is 101 — `scanprofile`'s convention.
|
||
- **Recorded per cell:** every request's wall latency (median and max, and the
|
||
same two over the mid-scan subset), how many were answered before settle,
|
||
`mismatched_answers` and `unsettled_answers` against the settled answer,
|
||
settle time, the publish counts and stage split, `tick_jitter_ms` (the largest
|
||
slip between a tick's due instant and its write — how a reader checks the
|
||
arrival discipline the row claims), and requests offered vs answered.
|
||
|
||
### The cadence
|
||
|
||
`answer_what_is_waiting` published whenever anything at all was waiting — one
|
||
whole-index merge per burst of requests. It now publishes when
|
||
|
||
* something was **waiting** — the startup's held requests, drained the moment
|
||
the neighbourhood is in. That publish is the session's first useful answer
|
||
and is never deferred (`perf5r-first-answer`); or
|
||
* `Scan::publish_is_due()` — `PUBLISH_EVERY` (512) records staged since the
|
||
last publish.
|
||
|
||
A count rather than a clock, for three reasons: a merge's cost is the index's
|
||
size and its value is the records it makes answerable, so files staged is the
|
||
currency both are in; what a scan does is then the same on a fast machine and a
|
||
slow one; and a test can assert it. 512 is deliberately `HEAD_WALK_MAX`'s
|
||
number — both answer "how much of this workspace may a user wait for", and 512
|
||
warm steps is ~100 ms of scanning on this corpus.
|
||
|
||
**A quiet scan still pays nothing at all.** The cadence is asked only when there
|
||
is something for a publish to be *for*: the drain returns before it, as it
|
||
always did, when nothing is held, nothing has arrived and nothing is deferred.
|
||
|
||
### The empty-answer rule
|
||
|
||
Inside `process_batch`, at the one place a request's response is sent:
|
||
|
||
1. `ask_again_if_empty` takes a copy of the request when a scan is running and
|
||
the method is one of the three in `NAVIGATION`;
|
||
2. the answer is computed through the **ordinary handler**, exactly as before;
|
||
3. if it `names_nowhere` — an `Ok` result that is an empty array — the copy goes
|
||
on `deferred` and nothing is sent;
|
||
4. the next publish puts `deferred` at the front of that drain's batch, behind
|
||
whatever was already `held` and ahead of everything newer, and they are asked
|
||
again;
|
||
5. `scan_until_settled` ends with `answer_what_was_deferred`, which runs
|
||
whatever is left through `process_batch` with `scanning` already false — so
|
||
the rule defers nothing that time round and an empty answer goes out.
|
||
|
||
The re-computation is bounded **by publishes, not by steps**: a deferred request
|
||
is asked again once per publish, so at most a handful of times in a whole scan,
|
||
and a request that keeps coming back empty costs one evaluation per publish and
|
||
is answered when the scan ends.
|
||
|
||
## Measured
|
||
|
||
Machine and method are `docs/perf/README.md`'s: Apple M1 Max, macOS 27.0,
|
||
release binaries built with `cargo build --release --locked`, opentitan
|
||
`0098135264` with its three known modifications, everything under
|
||
`tools/guard.sh -m 8 -t 1800`, three fresh sessions a cell, no cargo command
|
||
during a timed run. Reference `REF` = trunk `eb54042`; candidate `CAND` = that
|
||
tree plus this lane's diff. `~/.cache/lucisv-perf/take5r-4/`.
|
||
|
||
### What a publish costs, and how it scales — the R4 baseline
|
||
|
||
The reference under a definition every 100 ms of wall clock, warm, one open
|
||
buffer: **34 publishes in one scan**, and
|
||
|
||
| stage | ms | share of publication |
|
||
|---|---:|---:|
|
||
| `publish_absorb` | 2 433 | **78 %** |
|
||
| `publish_candidates` | 623 | 20 % |
|
||
| `publish_includes` | 47 | 1.5 % |
|
||
| `publish_overlay` | 2.4 | 0.08 % |
|
||
| **total** | **3 105** | of a **4 206 ms** scan — **74 %** |
|
||
|
||
The same scan with no requests at all takes **1 005 ms**. So under this load the
|
||
scan is four times longer, and essentially all of the difference is
|
||
publication. Cold is the same shape and worse: 88 publishes, **7 973 ms** of
|
||
publication in a **10 675 ms** scan, against a **2 766 ms** quiet cold scan.
|
||
|
||
Three things the split says, and only one of them is what the brief guessed:
|
||
|
||
1. **`index.absorb` is the cost.** It is 78 % of publication because it ends in
|
||
`merge(None)`, a pass over every record the index holds — so a publish costs
|
||
the size of the *index*, not the size of the batch, and the index grows all
|
||
the way to the end of the scan. `vlog_semantic`'s own doc comment says a
|
||
per-file merge would be quadratic; under load the drain was doing one per
|
||
burst of requests, which is the same shape at a coarser grain.
|
||
2. **The candidates rebuild is real but second.** `Candidates::absorb` ends in
|
||
`take_index_tables`, which re-derives the unit, module and macro tables from
|
||
the whole index every publish — 20 % of publication, ~18 ms a publish on
|
||
this corpus.
|
||
3. **The overlay refresh is not a lever.** It is **0.08 %** at one open buffer
|
||
and **9.6 %** at 101 (291 ms of 3 037), i.e. about 0.09 ms per buffer per
|
||
publish. At the buffer counts an editor actually has it is noise. This is
|
||
the item the work order expected to matter; the measurement says it does
|
||
not, and the reduction it asked for — deciding per buffer whether the
|
||
absorbed records could have moved its external resolutions — would cost a
|
||
name-set intersection per buffer per publish to save a tenth of a
|
||
millisecond. **Not done, and the numbers are why.**
|
||
|
||
Scaling: publication is flat in the number of open buffers except for the
|
||
overlay term (2.4 ms at 1 buffer → 291 ms at 101), and roughly linear in the
|
||
number of publishes, which is set by how often requests arrive. That is the
|
||
whole finding: *the client's request rate, not the workspace, decides what a
|
||
scan spends on publication.*
|
||
|
||
### The cadence, under the same offered load
|
||
|
||
Warm, every cell three fresh sessions, the same fixed number of requests
|
||
offered to both binaries (`requests answered` is equal in every row, so nothing
|
||
here is a speedup bought by serving less).
|
||
|
||
| cell (warm) | | latency p50 | latency max | publishes | publication ms | scan ms |
|
||
|---|---|---:|---:|---:|---:|---:|
|
||
| 100 ms, 1 buffer | REF | 112.3 | 168.0 | 34.3 | 3 105 | 4 206 |
|
||
| | **CAND** | **1.9** | 421.9 | **4.7** | **588** | **2 188** |
|
||
| 250 ms, 1 buffer | REF | 243.4 | 256.5 | 14.0 | 2 824 | 3 852 |
|
||
| | **CAND** | **1.9** | **203.5** | **3.0** | **378** | **1 417** |
|
||
| 100 ms, 2 buffers | REF | 308.9 | 2 109.5 | 33.0 | 3 082 | 4 117 |
|
||
| | **CAND** | **2.4** | **680.7** | **4.0** | **688** | **1 725** |
|
||
| 100 ms, 11 buffers | REF | 175.6 | 1 912.6 | 33.3 | 3 101 | 4 142 |
|
||
| | **CAND** | **2.3** | **708.6** | **3.7** | **580** | **1 654** |
|
||
| 100 ms, 101 buffers | REF | 1 960.1 | 3 672.0 | 33.0 | 3 037 | 4 254 |
|
||
| | **CAND** | **10.4** | **823.1** | **4.0** | **669** | **1 873** |
|
||
|
||
**Publication down 78–87 %, the scan down 48–63 %, the median request wait down
|
||
98–99.5 %, and the same number of requests answered.**
|
||
|
||
The **tail** is the one place this is not a clean sweep, and the count across
|
||
all sixteen loaded cells (warm and cold, both rates, four buffer counts) is:
|
||
**improved in ten, level in two, higher in four.** Three of the four are
|
||
single-open-buffer cells — the case where the reference is at its best, because
|
||
publishing after every burst keeps the index so fresh that no request waits
|
||
long for one, and the worst of them is warm 100 ms, **168 → 422 ms**. The
|
||
fourth is warm 250 ms at 11 buffers, 760 → 777 ms, which is 2 %. Against that:
|
||
3 672 → 823 ms at 101 buffers warm and 9 308 → 1 583 ms cold, and a median that
|
||
went from 112 ms to 1.9. The trade is legible — four merges instead of
|
||
thirty-four means a request that lands inside one waits for it — and it is
|
||
one request in thirty-five.
|
||
|
||
Cold is the same shape and larger, because a cold scan is longer and every
|
||
publish merges a bigger index by the time it happens:
|
||
|
||
| cell (cold) | | latency p50 | latency max | publishes | publication ms | scan ms |
|
||
|---|---|---:|---:|---:|---:|---:|
|
||
| 100 ms, 1 buffer | REF | 137.7 | 210.6 | 87.7 | 7 973 | 10 675 |
|
||
| | **CAND** | **1.5** | 395.5 | **7.0** | **922** | **3 686** |
|
||
| 250 ms, 1 buffer | REF | 225.3 | 255.0 | 36.7 | 6 816 | 9 569 |
|
||
| | **CAND** | **1.3** | 313.1 | **5.0** | **552** | **3 301** |
|
||
| 100 ms, 2 buffers | REF | 4 705.9 | 9 160.5 | 89.7 | 7 979 | 10 778 |
|
||
| | **CAND** | **2.1** | **1 440.0** | **7.0** | **922** | **3 602** |
|
||
| 100 ms, 11 buffers | REF | 4 724.7 | 9 194.9 | 89.7 | 7 980 | 10 801 |
|
||
| | **CAND** | **1.9** | **1 412.2** | **6.0** | **880** | **3 626** |
|
||
| 100 ms, 101 buffers | REF | 4 832.2 | 9 308.4 | 89.3 | 7 959 | 10 947 |
|
||
| | **CAND** | **2.2** | **1 583.3** | **6.0** | **932** | **3 829** |
|
||
|
||
**Publication −88 %, the traced scan −65 %, and at two or more open buffers the
|
||
tail improves by six times.** The overlay term at 101 buffers goes 812 → 56 ms
|
||
with it. Note the reference's cold median at two or more open buffers: **4.7
|
||
seconds**. That is not publication — it is `must_wait`'s `held` clause, and it
|
||
is the finding the probe made before a line of this lane's code existed: the
|
||
first held request holds every request behind it, so a whole session's stream
|
||
drains in one burst when the neighbourhood lands. The candidate's median is
|
||
2 ms because its session is over less than halfway through the offered window,
|
||
so most of the same requests meet a settled server.
|
||
|
||
**Two numbers in these tables mean different things and should not be added
|
||
up.** `scan ms` is the server's own traced scan wall time and is the honest
|
||
"completion under load". The probe's own `settled_ms` is **floored by the
|
||
request window** whenever the session finishes inside it — the last chatter the
|
||
probe sees tracks its own last request — so it understates the improvement
|
||
(warm 1 buffer: settle 4 215 → 3 417, −19 %, against the scan's −48 %). For the
|
||
same reason `mid_scan_*` misclassifies post-settle answers as mid-scan in the
|
||
candidate's rows and is not quoted here. The comparison the tables rest on is
|
||
sound without either: **both binaries are offered the identical number of
|
||
requests over the identical window and answer all of them.**
|
||
|
||
### The empty-answer rule, at a cursor the head cannot answer
|
||
|
||
`scanload`'s cursor names a module in `hw/ip/aes/rtl`, which the head walks
|
||
first, so it is non-empty from the first publish and the rule never fires on
|
||
it. `scanloadcross` asks the same fixed load at `tl_if` in the same buffer —
|
||
an interface declared in `hw/dv/sv/tl_agent`, which the open buffer's folder
|
||
does not hold. `unsettled_answers` counts every answer that was not the settled
|
||
one, empty ones included: it is the review §2 gate, and it is what the rule is
|
||
for.
|
||
|
||
| cell | | latency p50 | latency max | answered | **unsettled** |
|
||
|---|---|---:|---:|---:|---:|
|
||
| cold, 1 buffer | REF | 105.1 | **215.8** | 270 | **12** |
|
||
| | **CAND** | **1.3** | 486.4 | 270 | **0** |
|
||
| cold, 11 buffers | REF | 4 735.8 | 9 217.8 | 270 | **270** |
|
||
| | **CAND** | **1.5** | **1 884.0** | 270 | **0** |
|
||
| warm, 1 buffer | REF | 120.6 | **212.1** | 105 | **12** |
|
||
| | **CAND** | **1.7** | 380.6 | 105 | **0** |
|
||
| warm, 11 buffers | REF | 1 822.3 | 3 624.8 | 105 | **105** |
|
||
| | **CAND** | **2.0** | **891.0** | 105 | **0** |
|
||
|
||
**The reference answers this cursor wrongly 12 times in 270 with one buffer
|
||
open and *every single time* with eleven** — because with eleven the whole
|
||
request stream is held until the neighbourhood lands and is then drained in one
|
||
burst off a prefix that does not reach `hw/dv`. The candidate is wrong zero
|
||
times in all four cells.
|
||
|
||
**What that costs, said plainly:** in the two single-buffer cells the tail rises
|
||
(216 → 486 ms cold, 212 → 381 warm), because a request whose target the scan
|
||
has not reached now waits for the publish that holds it instead of being told
|
||
`[]` immediately. That is the trade the lead's ruling asks for, and it is the
|
||
right way round — the review's gate is *"do not withhold useful answers"*, and
|
||
`[]` when the answer exists is not a useful answer. In the eleven-buffer cells
|
||
even the tail improves, by four times.
|
||
|
||
### Everything the cadence must not have cost
|
||
|
||
The quiet startup matrix, three fresh sessions a cell, medians:
|
||
|
||
| `scan` cell | REF | CAND |
|
||
|---|---:|---:|
|
||
| workspace, cold | 2 747.5 | 2 715.9 |
|
||
| workspace, warm | 981.0 | 983.7 |
|
||
| workspace cold, **first useful answer** | 78.2 | 80.8 |
|
||
| workspace warm, **first useful answer** | 115.1 | 115.8 |
|
||
| default scope, cold / warm | 95.1 / 50.7 | 101.9 / 48.5 |
|
||
| `{"index":{}}`, cold / warm | 111.0 / 48.8 | 106.3 / 48.9 |
|
||
| `scopeDepth 0`, cold / warm | 10.5 / 8.7 | 11.3 / 12.5 |
|
||
|
||
Memory, which the review's gate says must be *retained*: idle RSS after the
|
||
workspace scan **502 736 → 501 872 KiB cold** and **427 200 → 426 448 KiB
|
||
warm** (−0.2 % both, peak equal to idle), and the index store on disk **45 404
|
||
KiB in both** — byte-for-byte the same size, because nothing about what a scan
|
||
writes changed. The cadence holds records staged for longer, which is the one
|
||
place it could have cost memory: at most `PUBLISH_EVERY` `FileFacts` instead of
|
||
one burst's worth, and the numbers say that is not visible.
|
||
|
||
Nothing moved outside its spread. The two that had to be checked by name are
|
||
the **warm quiet scan** — still under a second, which is the milestone §61.3
|
||
reached for the first time — and the **first useful answer**, which is §61.3's
|
||
whole result and which the cadence could have delayed by deferring the head
|
||
publish. It does not: that drain is the one the cadence exempts, and the number
|
||
says so.
|
||
|
||
### `scanserve` — the review's own probe, unchanged and re-run
|
||
|
||
The response-paced probe the review used, three fresh sessions a cell. It
|
||
served the **same number of requests per session for both binaries** here (13
|
||
cold, 5 warm), so its confound does not bite in this comparison:
|
||
|
||
| | REF | CAND |
|
||
|---|---:|---:|
|
||
| cold, median mid-scan definition | 122.2 ms | **45.6 ms** |
|
||
| cold, worst | 334.0 ms | 334.8 ms |
|
||
| cold, session completion | 4 506 ms | **3 938 ms** |
|
||
| warm, median | 114.0 ms | 114.2 ms |
|
||
| warm, worst | 290.2 ms | **279.4 ms** |
|
||
| warm, session completion | 1 692 ms | 1 697 ms |
|
||
| `mismatched_answers` / `unsettled_answers` | 0 / 0 | 0 / 0 |
|
||
|
||
Warm is flat and that is the expected reading, not a disappointment: at one
|
||
request per 200 ms *of response* a warm session only gets five of them in, so
|
||
the reference pays five publishes and there is nothing for a cadence to
|
||
remove. The cadence is for the case where a client asks faster than the server
|
||
finishes, which is what `scanload` offers and what the cold column already
|
||
shows.
|
||
|
||
The quiet control did not move: warm quiet scan **1 004.7 → 984.7 ms** at one
|
||
buffer (and 1 020 → 1 065, 1 029 → 1 041, 1 201 → 1 156 at 2 / 11 / 101), so
|
||
the ≤ 1 s the last round reached is kept and none of this was bought from the
|
||
quiet case. A quiet session's mid-scan publishes go **1 → 0**: nothing is
|
||
waiting, so nothing is published, which is the promise `scan-interleave` made
|
||
and this keeps.
|
||
|
||
## Status / TODO
|
||
|
||
- [x] R4a — the fixed-arrival-rate probe (`tools/perf/phases_r4.py::scanload`,
|
||
`scanloadcold`, `scanloadcross`), cold and warm, 1 / 2 / 11 / 101 open
|
||
buffers, with the quiet control and the publication split; R4 baseline
|
||
cells filled from `eb54042`
|
||
- [x] the publication cadence (`Scan::publish_is_due`, `PUBLISH_EVERY`)
|
||
- [x] the empty-answer rule (`Server::deferred`, `ask_again_if_empty`,
|
||
`names_nowhere`, `answer_what_was_deferred`)
|
||
- [x] the `HEAD_WALK_MAX` fixture §61.3's QA asked for — and sabotage-checked
|
||
(the bound's branch disabled, the test fails with
|
||
`515 files (the folder first)`)
|
||
- [x] the candidates rebuild and the selective overlay refresh: **measured,
|
||
not built.** The cadence takes both down with it, and the overlay is
|
||
0.08 % of publication at one open buffer
|
||
- [x] measured: `scanload` both rates and all buffer counts, `scanloadcold`,
|
||
`scanloadcross`, `scanserve`, quiet `scan` cold/warm, `rss`, the 24 scope
|
||
cells; R4 row and experiment record `R4-2026-09-08` in
|
||
`docs/perf/take5-tracking.md`
|
||
|
||
### Gates
|
||
|
||
- `cargo fmt` clean; guarded `cargo clippy --all-targets` clean with no new
|
||
`#[allow]`; guarded `cargo test --workspace` green, **4 360 → 4 365**, none
|
||
dropped. Six test functions written, one of which replaces the §61.3 test
|
||
whose subject the rule changed, so the count rises by five: the cadence's
|
||
exact boundary (in `state`), the cross-folder definition (the replacement),
|
||
the cross-folder typeDefinition, the genuinely-empty answer, the hover that
|
||
is never deferred, and the `HEAD_WALK_MAX` fixture.
|
||
- Under the same offered load: publishes and publication time down, settle down
|
||
or held, latency not worse, **served requests equal**.
|
||
- `mismatched_answers` 0 and `unsettled_answers` 0 on `scanload` and
|
||
`scanserve`, both binaries, cold and warm.
|
||
- The quiet warm scan does not regress past 1.0 s.
|
||
- opentitan's three known modifications, unchanged, after every phase.
|
||
|
||
## Work log
|
||
|
||
### 2026-09-08 — dev (Opus), §61.4
|
||
|
||
**Order of work: the probe first, and it changed the plan twice.**
|
||
|
||
1. **The probe, written before anything was touched.** The first run of it was
|
||
the finding: under a definition every 100 ms the reference answered
|
||
*nothing* until the scan was 74 % over, because `must_wait`'s `held` clause
|
||
makes the first held request hold every request behind it — so the whole
|
||
session's stream drains in one burst at the head publish. That is
|
||
`perf5r-first-answer`'s territory, not this lane's, but the probe says it,
|
||
so it is written down.
|
||
2. **The probe was wrong the first time, and the way it was wrong is the
|
||
review's own confound.** It stopped sending when the server stopped saying
|
||
things; a lull in the progress chatter stopped it at 14 requests where the
|
||
session ran for 20 ticks, which makes the offered load a function of the
|
||
server. Rewritten around a **fixed request count** over a fixed window per
|
||
cache state. The first (uncontrolled) series is kept as
|
||
`paired-partial-firstattempt.jsonl` and no number in this README comes from
|
||
it.
|
||
3. **The split named a different lever than the work order expected.**
|
||
`publish_absorb` is 78 % and the overlay refresh is 0.08 % at one open
|
||
buffer. The work order's first two reductions were the candidates rebuild
|
||
and a selective overlay refresh; the measurement says the overlay is noise
|
||
at every buffer count an editor has, so **it was not built** and the numbers
|
||
are in [Measured](#measured) instead.
|
||
4. **The cadence is the reduction that fits this lane's files.** `absorb` ends
|
||
in a whole-index merge inside `vlog_semantic`, which this lane may not
|
||
change; how *often* that merge is paid is `server/index.rs`'s decision, and
|
||
it was "once per burst of requests". `Scan::publish_is_due` makes it once
|
||
per 512 staged records, with the drain that has something *waiting* — the
|
||
session's first useful answer — exempt.
|
||
5. **The empty-answer rule**, the lead's §61.3 ruling, went in beside it
|
||
because the two interact: the cadence makes a mid-scan prefix older, and the
|
||
rule is what stops that being visible as a wrong `[]`. It is a rule in the
|
||
drain and not a second computation — the answer is computed once through the
|
||
ordinary handler and either sent or set aside — and a set-aside request is
|
||
asked again **once per publish**, which the cadence now bounds to a handful
|
||
per scan.
|
||
6. **A test that already pinned the old behaviour had to move, and it is the
|
||
right kind of move.** `a_buffer_opened_from_the_workspace_root_is_no_
|
||
neighbourhood_to_lead_with` asserted that its definition was answered
|
||
*inside* the scan; it was answered `[]`. It now asserts the answer is
|
||
`ip/aes/rtl/aes.sv`, which arrives later and is right. Said plainly here
|
||
because "a test changed" is the sentence a reviewer should be suspicious of.
|
||
|
||
**Deviations, stated:**
|
||
|
||
- **`tools/perf/lspclient.py` was changed**, which the work order's file list
|
||
describes as "`tools/perf/` (new phase file + README rows)". Two additive
|
||
hunks: a response's arrival instant stamped in the reader thread, and
|
||
`Session.poll_answers`, which takes every response that has arrived without
|
||
blocking on the oldest. A probe that pipelines cannot be written without it —
|
||
`await_id` blocks — and measuring each request's own wait through a polling
|
||
loop instead would put the poll interval in every number. No existing phase's
|
||
behaviour changes; `await_id` gained one line that drops a stamp it does not
|
||
read.
|
||
- **`scanload` is two phases** (`scanload` warm, `scanloadcold`). A cold cell
|
||
under this load is a ten-second session and eight of them do not fit inside
|
||
the 1 800-second guard. The first paired attempt was **stopped by hand**
|
||
before it reached that limit rather than allowed to be killed; splitting the
|
||
run is the answer, and the guard was not touched.
|
||
- **`state::discover` and `HEAD_WALK_MAX` widened from `pub(super)` to
|
||
`pub(crate)`** so the new fixture is written against the bound rather than
|
||
against the number 512 spelled out again. `state/mod.rs` gained no line for
|
||
it (`mod discover;` → `pub(crate) mod discover;`).
|
||
- **A `scanloadcross` cell was added that the work order did not ask for.** The
|
||
cursor `scanload` measures resolves inside the open buffer's own folder, so
|
||
the empty-answer rule never fires on it and the row would say nothing about
|
||
what that rule costs. The cross-folder cell is what makes the cost visible
|
||
rather than asserted.
|
||
|
||
**Gates.** `cargo fmt` clean; guarded `cargo clippy --all-targets` clean with
|
||
no new `#[allow]`; guarded `cargo test --workspace` green at **4 365**, from
|
||
4 360, none dropped. opentitan's three known modified files unchanged after
|
||
every phase. **No guard kill.**
|
||
|
||
**File sizes** (non-blank, non-comment, before the trailing test module):
|
||
`server/index.rs` **225**, `server/dispatch.rs` **485** (from 464),
|
||
`server/mod.rs` **169** (from 158), `state/scan.rs` **128** (from 124),
|
||
`state/discover.rs` 329, `candidates.rs` 405, `includes.rs` 605 (untouched).
|
||
`state/mod.rs` is **976 production lines, exactly what it was**: the module
|
||
visibility change costs no line and the only thing added to it is a test.
|
||
|
||
**A limitation of the probe, for QA and for whoever reads the rows next.** The
|
||
probe's `settled_ms` is the session's last notification, and the session keeps
|
||
producing notifications while requests arrive — so when the scan finishes
|
||
inside the offered window, `settled_ms` tracks the *window* rather than the
|
||
scan, and `mid_scan_median_ms` / `mid_scan_max_ms` then count post-settle
|
||
answers as mid-scan. Neither is quoted in this README for that reason: `scan
|
||
ms` (the server's own trace) is the completion figure and the latency columns
|
||
are over the whole fixed load, which is identical for both binaries. The
|
||
notification the requests provoke was not chased down; it is a probe question,
|
||
not a server one, and it is written here rather than left for a reader to
|
||
notice.
|
||
|
||
## QA log
|
||
|
||
### 2026-09-08 — QA (Sonnet), §61.4 R4
|
||
|
||
Read CLAUDE.md, TODO §61.4, `docs/performance_take5_review.md` §4 and its
|
||
"Startup throughput and responsiveness must be judged separately", this
|
||
README in full, `docs/features/perf5r-first-answer/README.md`'s Review (the
|
||
ruling that sent the empty-answer rule here), `docs/features/scan-interleave/
|
||
README.md`'s 2026-09-08 §61.4 entry, `docs/features/cancel-request/README.md`
|
||
in full, the tracker's `R4-2026-09-08` record, the working-tree diff, and the
|
||
evidence in `~/.cache/lucisv-perf/take5r-4/`. Experiments in a fresh clone at
|
||
scratchpad `qa-61-4/repo` (HEAD `eb54042` + the working diff applied,
|
||
byte-identical to the working tree — verified `diff -rq` clean except the
|
||
tests I added). A second clone `qa-61-4/repo-ref` at bare `eb54042` was built
|
||
for the per-binary test comparison. All cargo and all perf commands ran
|
||
through `tools/guard.sh -m 8 -t 1800`; no guard kill anywhere; no lingering
|
||
background loops (all launched via `run_in_background`/`Monitor`, all exited
|
||
on their own and were confirmed dead).
|
||
|
||
**1. Gates (main tree, guarded).** `cargo fmt --all -- --check` clean.
|
||
`cargo clippy --all-targets` clean, zero warnings, no new `#[allow]` (checked
|
||
the diff directly). `cargo test --workspace`: **4 365 passed, 0 failed**,
|
||
exactly the dev's number. Per-binary diff against the `repo-ref` clone at bare
|
||
`eb54042` (4 360 passed there): every binary's count is identical except
|
||
`lucisv_server`'s `unittests src/main.rs` (1 645 → 1 650, +5) — matching the
|
||
dev's own accounting exactly (one test rewritten in place — the §61.3 test
|
||
`a_target_outside_the_head_is_answered_when_the_head_is_published_and_is_empty`
|
||
→ `a_target_outside_the_head_is_asked_again_rather_than_answered_nowhere`,
|
||
read and judged correct: it now asserts the settled location instead of an
|
||
inside-the-scan `[]`, which is exactly right given the rule this lane ships —
|
||
plus five new tests). Nothing lost anywhere. Production line counts:
|
||
`server/index.rs` 225, `dispatch.rs` 485, `server/mod.rs` 169, `state/scan.rs`
|
||
128, `state/discover.rs` 329 — all match the README exactly.
|
||
`state/mod.rs` **976**, unchanged, confirmed (counting stops one line before
|
||
the `#[cfg(test)]` attribute, not `mod tests {` itself — the same off-by-one
|
||
also explains `candidates.rs`, 405 vs my raw 406). **One inaccuracy found and
|
||
noted, not fixed** (it is in a Work log entry, not the Status/Handshakes
|
||
sections QA may touch): `includes.rs` is cited as "605 (untouched)" but its
|
||
actual non-blank/non-comment production count before its first `#[cfg(test)]`
|
||
is **273**, under any counting convention I could construct (with or without
|
||
doc comments, with or without blank-only stripping). The file is genuinely
|
||
untouched by this diff and 273 is nowhere near any CLAUDE.md threshold either
|
||
way, so this is a citation slip in the prose, not a gate or a size problem —
|
||
flagged for the lead to correct in the work log if they choose.
|
||
|
||
**2. The probe.** Read `tools/perf/phases_r4.py` and the `lspclient.py` diff
|
||
in full.
|
||
- `offer()`'s send loop is `while sent < ticks`, ticks fixed
|
||
(`WINDOW_MS[cache] // rate`), computed once up front — no early exit on
|
||
server silence. The shipped probe cannot reproduce "stopped in a lull";
|
||
confirmed by reading the loop, there is no path back to the caller before
|
||
`sent == ticks`.
|
||
- `lspclient.py`'s `_dispatch` (called only from `_read_loop`, the reader
|
||
thread — confirmed by grep) stamps `self._arrived[id] = time.perf_counter()`
|
||
the instant a response is parsed, before any caller could see it.
|
||
`poll_answers` reads that stamp and never blocks — it only pops entries
|
||
already in `self._inbox` matching a pending id. This is the arrival-time
|
||
fix the review's confound needed.
|
||
- Same offered load to both binaries: confirmed directly off the evidence —
|
||
every REF/CAND pair I read had identical `requests_offered` and
|
||
`requests_answered` (e.g. 35 offered / 105 answered across 3 tries, both
|
||
binaries, warm 100 ms 1-buffer cell).
|
||
- `mismatched_answers`/`unsettled_answers` are computed in `summary()` against
|
||
`run["settled_answer"]`, which is a **final same-params request sent at the
|
||
end of the same session** (`s.request("textDocument/definition", params)`)
|
||
— same request, same cursor, correct comparison target.
|
||
- The probe's own limitation (`settled_ms` floored by the fixed window) is
|
||
understood and does not taint any quoted number: every table in the README
|
||
uses `scan_total`/`scan ms` (the server's own trace), never `settled_ms`,
|
||
and `mid_scan_*` is explicitly not quoted for the same reason. Confirmed by
|
||
reading `publication()` (`out["scan_total"] = stages.get("total", 0.0)`)
|
||
and by re-deriving the README's own numbers from the raw evidence (below).
|
||
|
||
**3. Coherence under load, and the sabotage.** `publish_scan`
|
||
(`state/mod.rs:1167`) absorbs the index, the candidates table and the include
|
||
graph in one synchronous call with no interleave point inside it — a
|
||
structural guarantee, not a tested-and-hoped one, since this is a
|
||
single-threaded event loop. `answer_what_is_waiting` (`server/index.rs`)
|
||
calls `publish_scan` to completion *before* splicing `self.deferred` or
|
||
`arrived` into the batch that gets dispatched, so no request can ever observe
|
||
a batch published mid-way through. I wrote and ran the direct witness the
|
||
task asked for (`state::tests::a_cadence_publish_never_lets_the_index_and_the_
|
||
candidates_table_disagree`, in the scratch clone only — a 513-file tree,
|
||
scanned exactly to the `PUBLISH_EVERY` boundary, one `publish_scan` call, then
|
||
asserting every one of the 512 just-published module names is in *both*
|
||
`index().units()` and `candidates().has_module()`, and the 513th is in
|
||
*neither*). It passes on the real candidate. **Sabotage**: commented out
|
||
`self.candidates.absorb(&self.index, words)` inside `publish_scan` — the test
|
||
fails immediately (`cohmod0000 published: candidates`), then reverted (byte-
|
||
diff against the pre-sabotage copy confirmed clean).
|
||
|
||
`scanload`/`scanloadcross` re-run, independently, on the dev's own release
|
||
binaries (hashes verified: REF `f7a5a27e…`, CAND `4af863c1…`, both match the
|
||
tracker record exactly) against the same read-only opentitan corpus, fresh
|
||
storage under my scratchpad:
|
||
- warm 100 ms, 1 buffer: REF p50 102.7 / p90 182.4 / max 209.6 ms; CAND p50
|
||
0.8 / p90 177.4 / max 419.9 ms. `mismatched_answers` 0, `unsettled_answers`
|
||
0, offered = answered = 105, both binaries.
|
||
- warm 100 ms, 11 buffers: REF p50 1970.2 / p90 3367.8 / max 3699.6 ms; CAND
|
||
p50 0.9 / p90 396.7 / max 700.7 ms. Same zero/zero, same offered=answered.
|
||
- `scanloadcross`, all 8 cells (cold/warm × 1/11 buffers × REF/CAND):
|
||
`mismatched_answers` 0 in every cell; `unsettled_answers` — REF 12/270,
|
||
270/270, 9/105, 105/105 (the 9 vs the archived 12 at warm/1-buffer is
|
||
ordinary run-to-run timing noise around the head-publish boundary — the
|
||
*shape* is identical); **CAND 0/0/0/0 in every one of the 8 cells**, on a
|
||
completely independent run.
|
||
|
||
This reproduces the archived record's own numbers closely (warm/1-buffer
|
||
REF p50 112.3→102.7, CAND max 421.9→419.9; warm/11-buffer REF p50
|
||
1960.1→1970.2, max 3672.0→3699.6, both within a few percent) and confirms
|
||
`mismatched_answers`/`unsettled_answers` are 0/0 everywhere for the candidate,
|
||
never withholding or coherence-breaking a single answer, on data this session
|
||
generated itself rather than only reading the dev's own.
|
||
|
||
**4. The empty-answer rule.** Three methods (`GotoDefinition`,
|
||
`GotoTypeDefinition`, `References`) — confirmed directly in
|
||
`server/dispatch.rs`'s `NAVIGATION` const, and the handler match arms confirm
|
||
`Hover` is not among them. Dev's shipped tests cover: cross-folder definition
|
||
asked again and answered right, exactly once; the same for typeDefinition;
|
||
hover never deferred (answered inside the scan); a genuinely-empty answer
|
||
(`nowhere`) answered `[]` at settle; `HEAD_WALK_MAX` pinned. Three cases the
|
||
shipped tests do not cover, which I wrote in the scratch clone
|
||
(`server/tests/startup.rs`, using `process_batch`/`Server::deferred` directly
|
||
— both reachable from `server::tests::*` by ordinary Rust module privacy,
|
||
since they are plain-private items in an ancestor module):
|
||
- `a_cancel_sharing_a_publish_with_a_deferred_request_still_cancels_it` — a
|
||
cancel in the **same** batch as a deferred request still cancels it
|
||
(`cancelled_in` scans the whole batch regardless of position). Passes.
|
||
- `a_cancel_that_arrives_while_its_request_is_still_deferred_does_not_reach_it`
|
||
— **a real gap, found and pinned, not a hard-invariant violation.** A
|
||
cancel that arrives in its *own* batch, while its request is sitting in
|
||
`Server::deferred` (not yet reunited with a publish), is consumed by
|
||
`process_batch`'s local `consumed_cancels` for that call and does not
|
||
survive to the next one. The deferred request is later answered normally —
|
||
a **real, uncancelled answer** — as if the cancel never happened. This
|
||
costs nothing under the hard invariants QA is bound to (exactly one
|
||
response is still sent, no request is lost, no answer is wrong), so it is
|
||
**not** a REWORK finding by the letter of this task's own criteria. But
|
||
`docs/features/cancel-request/README.md`'s own stated reasoning for
|
||
dropping a late cancel — *"by then the request has been answered"* — is
|
||
false for a request sitting in `deferred`: it has not been answered at all
|
||
yet. `deferred` is a new kind of "not yet answered but no longer in a
|
||
burst" state that predates neither README knew about the other. **Filed as
|
||
a handshake request below**, not fixed by QA (touches `cancel-request`'s
|
||
own Assumptions section, outside this feature's scope).
|
||
- `two_deferred_requests_are_answered_in_the_order_they_arrived` — `deferred`
|
||
is append-only (`Vec::push`, `std::mem::take`, never reordered), so two
|
||
requests deferred in the same scan are answered in arrival order. Passes.
|
||
|
||
All three compiled and ran clean against the real candidate
|
||
(`cargo test -p lucisv_server --bin lucisv-server deferred`, 4 passed).
|
||
|
||
**5. Sabotage: "never re-ask."** Commented out
|
||
`self.answer_what_was_deferred()` in `finish_scan` (`server/index.rs`) — the
|
||
shipped cross-folder test
|
||
(`a_target_outside_the_head_is_asked_again_rather_than_answered_nowhere`)
|
||
fails with "a result, not a failure" (the request is never answered at all —
|
||
a lost request, exactly the REWORK class this task names). Reverted; byte-
|
||
diff against the pre-sabotage copy confirmed clean; test passes again.
|
||
|
||
**6. `HEAD_WALK_MAX`.** Read the bound (`state/discover.rs:450`,
|
||
`head.len() > HEAD_WALK_MAX`) and the dev's fixture
|
||
(`a_folder_bigger_than_the_head_bound_is_scanned_exactly_as_it_always_was`,
|
||
513 files in one folder). Sabotaged the branch (`if false && head.len() >
|
||
HEAD_WALK_MAX`) — the test fails exactly as the README claims:
|
||
`"515 files (the folder first)"` (513 in the neighbourhood folder + 2 more
|
||
from `a_block_and_a_crowd`'s fixed padding). Reverted; clean.
|
||
|
||
**7. The tail — characterized, not failed.** Re-derived the R4 baseline split
|
||
straight from `~/.cache/lucisv-perf/take5r-4/paired.jsonl`'s per-try
|
||
`publication` records for the warm/100 ms/1-buffer cell: REF averages
|
||
scan 4206.14 ms / publication 3105.27 ms across 34.3 publishes; CAND averages
|
||
scan 2188.36 ms / publication 587.99 ms across 4.67 publishes — both exactly
|
||
the README's headline numbers, independently recomputed from the raw
|
||
per-request arrays rather than trusted from the prose.
|
||
|
||
*Attributing the CAND max (421.9 ms, warm/1-buffer, this cell is not
|
||
cross-folder so the empty-answer rule never fires on it — the wait is purely
|
||
cadence).* Average publish spacing here is scan/publishes ≈ 2188/4.67 ≈
|
||
469 ms; a request landing just after a publish waits close to the full next
|
||
interval. 421.9 ms is consistent with exactly that — a request arriving
|
||
right after a publish, waiting almost the whole way to the next one — not a
|
||
deferral (none possible on this cursor) and not the startup's `held` clause
|
||
(the first useful answer already landed at ~80–115 ms, long before most of
|
||
this cell's requests are sent).
|
||
|
||
*What T = 100 ms would cost, estimated from the trace.* `absorb`'s cost is a
|
||
**whole-index merge**, i.e. roughly proportional to the index's size at the
|
||
moment of the call, not to the batch just staged (the README's own finding,
|
||
confirmed by reading `WorkspaceIndex::absorb`'s doc comment and
|
||
`update_facts`'s targeted-merge counterexample beside it). For K evenly
|
||
spaced publishes over a scan that reaches a fixed final size S, each publish
|
||
i costs roughly c·i·(S/K), so total absorb cost is c·S·(K+1)/2 — **linear in
|
||
the number of publishes, for a fixed corpus**. Going from the cadence's
|
||
current K≈4.7 (this cell) to a clock bound that fires roughly every 100 ms —
|
||
which, given requests arrive every 100 ms and something is almost always
|
||
waiting, would mean roughly one publish per 100 ms of wall clock, i.e. K on
|
||
the order of 20+ over a ~2 s scan — would raise total publication cost
|
||
*roughly in proportion*, back up toward the 2 000–3 000 ms range: most of
|
||
this cell's −78 % publication win given back. This is not a coincidence: the
|
||
**reference's own pre-cadence behaviour already published once every
|
||
4206/34.3 ≈ 123 ms on average** — almost exactly a T=100 ms clock bound. A
|
||
secondary time bound at T=100 ms would reproduce close to the *reference's*
|
||
publication cost for exactly the load this cell offers, while presumably
|
||
still helping a slower (250 ms) or quieter client. That trade is the lead's
|
||
to rule on; the count-based `PUBLISH_EVERY` alone does not have this failure
|
||
mode because it is insensitive to how fast the client asks.
|
||
|
||
**8. Controls, re-run** (dev's own REF/CAND release binaries, hashes
|
||
verified, fresh storage under my scratchpad, `tools/guard.sh -m 8 -t 1800`):
|
||
|
||
| cell | archived median | QA re-run median | Δ |
|
||
|---|---:|---:|---:|
|
||
| quiet scan, warm, REF | 981.0 | 1033.2 | +5.3% |
|
||
| quiet scan, warm, CAND | 983.7 | 1051.7 | +6.9% |
|
||
| quiet scan, cold, REF | 2747.5 | 2831.6 | +3.1% |
|
||
| quiet scan, cold, CAND | 2715.9 | 2826.2 | +4.1% |
|
||
| first useful answer, cold, REF | 78.2 | 82.0 | +4.8% |
|
||
| first useful answer, cold, CAND | 80.8 | 81.3 | +0.7% |
|
||
| first useful answer, warm, REF | 115.1 | 113.0 | −1.9% |
|
||
| first useful answer, warm, CAND | 115.8 | 113.4 | −2.1% |
|
||
| idle RSS, cold, REF (KiB) | 502736 | 502528 | −0.04% |
|
||
| idle RSS, cold, CAND (KiB) | 501872 | 504240 | +0.5% |
|
||
| idle RSS, warm, REF (KiB) | 427200 | 427984 | +0.2% |
|
||
| idle RSS, warm, CAND (KiB) | 426448 | 426688 | +0.06% |
|
||
|
||
All twelve within the requested ±10 % (the widest is +6.9 %, general machine-
|
||
load noise — the session's one-minute load was higher during this QA rerun
|
||
than the dev's own session start). Store 45 404 KiB, identical, both re-runs.
|
||
The 24-of-24 scope cells were checked against the archived evidence directly
|
||
(every `scopes` row's `result_count` equal REF vs CAND) rather than re-run,
|
||
since nothing about scope resolution is in this diff's file list.
|
||
|
||
**Traceability (item 8): 17 numbers independently reproduced from
|
||
`~/.cache/lucisv-perf/take5r-4/` and matched exactly to the README/tracker
|
||
prose**, beyond the twelve controls above: 4206, 3105 (REF scan/publication
|
||
ms), 2188, 588 (CAND scan/publication ms), 112.3, 168.0 (REF latency
|
||
median/max), 1.9, 421.9 (CAND latency median/max), 4506, 3938 (scanserve cold
|
||
session completion REF/CAND), 122.2, 45.6 (scanserve cold median REF/CAND),
|
||
12/270 and 270/270 (REF cross-folder unsettled counts), 0 (CAND, every
|
||
cross-folder cell). One small nuance, not a finding: `scanserve`'s quoted
|
||
"1 692 → 1 697" (warm session completion) matches REF's **median** but CAND's
|
||
**mean** (median of that row is 1704.7); both readings say "flat," which is
|
||
the only claim resting on it, so this is noted rather than filed.
|
||
|
||
**Verdict: PASS.** No coherence violation (sabotage-tested), no lost request
|
||
under the shipped code (the "never re-ask" sabotage is the one that produces
|
||
a lost request, and it is not what shipped), no wrong mid-scan answer
|
||
(`mismatched_answers` 0 everywhere, in the dev's evidence and in two
|
||
independent re-runs this session generated). The tail's four higher cells are
|
||
characterized, attributed and estimated, not treated as a failure, per the
|
||
task's own framing. One real, non-blocking gap found and pinned by a new test
|
||
(`$/cancelRequest` against a `deferred` request outside its own batch is
|
||
silently ineffective — exactly-one-response is preserved, nothing is lost or
|
||
wrong) and one documentation inaccuracy (`includes.rs`'s cited line count).
|
||
|
||
**Handshakes/topo, for the lead:**
|
||
1. `server::index ──▶ state::scan` (`publish_is_due`) and
|
||
`server::mod ──▶ server::dispatch` (`names_nowhere`, `ask_again_if_empty`)
|
||
— as the dev already filed.
|
||
2. **New, from QA:** `docs/features/cancel-request/README.md`'s Assumptions
|
||
section ("a cancel arriving in a later burst than its request is dropped
|
||
… by then the request has been answered") is now incomplete: a request in
|
||
`Server::deferred` is neither `held` nor answered, and a cancel that
|
||
arrives in a batch that does not also carry a publish reuniting it with
|
||
`deferred` is dropped without effect, same as the general rule, but the
|
||
*reason* stated for that rule no longer covers every case it's applied to.
|
||
No code change needed (LSP allows ignoring a cancel; exactly-one-response
|
||
holds) — a one- or two-sentence dated amendment to `cancel-request`'s
|
||
Assumptions, cross-linked from `perf5r-publication`'s Handshakes, closes
|
||
the gap in the documentation rather than the code.
|
||
3. `lspclient.py`'s two hunks (`_arrived` timestamp map, `poll_answers`) are
|
||
additive and confirmed not to change `await_id`'s existing behaviour
|
||
(one line added that writes a stamp `await_id` never reads).
|
||
4. The cadence constant is `PUBLISH_EVERY = 512` (`state/scan.rs`),
|
||
deliberately equal to `HEAD_WALK_MAX`; both are now `pub(crate)`, tested
|
||
directly rather than against the number spelled out again.
|
||
|
||
TODO §61.4's QA line ticked below.
|
||
|
||
### 2026-09-09 — independent 0.52.0 review: load-probe corrections needed
|
||
|
||
The publication improvement was independently reproduced against 0.51.0:
|
||
with two open buffers and 35 requests every 100 ms per process, three properly
|
||
warmed processes per version, median server scan duration fell 4,247 → 1,771 ms,
|
||
publishes 34 → 4, all 105 requests answered and all equal to the settled
|
||
target. The full-window request median fell 1,947 → 2.03 ms; this includes
|
||
post-scan responses. Cross-folder probes returned the settled target in all
|
||
750 candidate responses, versus 399 premature empty answers in the reference.
|
||
|
||
**Two harness findings, F2/F3 (P2), open:** `load_cell` labels a fresh store
|
||
warm without priming it (a separate proof measured 3,974 misses and 1,684 ms
|
||
parsing on the first nominally warm run, versus 3,974 hits and zero misses on
|
||
the second). Also, `settled_at` mistakes `wait_quiet`'s positive entry-time
|
||
delta for new scan activity. Candidate `settled_ms` follows the 3.4-second
|
||
request window even though the scan ends at about 1.77 seconds, and all 105
|
||
responses are mislabeled mid-scan. The review therefore uses a warmed rerun
|
||
and `publication.scan_total`, not the erroneous completion/partition fields.
|
||
|
||
No implementation was changed. [Full review and repair gates](../../performance_052_review.md),
|
||
[raw evidence](../../perf/review-052-20260909/README.md). These findings do not
|
||
assert that all previous warm runs were unprimed or invalidate the measured
|
||
publication-count reduction.
|
||
|
||
**2026-09-09, later — F2 and F3 are fixed** (dev, in the F1 lane; the harness
|
||
half of the same round). `phases_r4.prime` runs one untimed session before a
|
||
warm cell's first timed trial and `cell_status` refuses a warm cell whose trial
|
||
found nothing in the store: with a brand-new `--storage`, both timed trials now
|
||
report 3 975 hits and 0 misses. `Session.scan_completed_at` is stamped in the
|
||
reader thread on the indexing bar's own `$/progress` `end`, so `settled_ms`
|
||
reads 1 774 ms for a scan the server's own trace calls 1 768 ms — not the
|
||
3 406 ms of the request window — and the responses partition 32 mid-scan /
|
||
38 after-settle instead of every one of them mid-scan. Widening the window
|
||
3 500 → 5 000 ms leaves completion at 1 781/1 791 ms and grows only the
|
||
after-settle count (38 → 64), which is the review's own check. Details and
|
||
numbers: `docs/perf/take5-tracking.md`, the F2/F3 rows.
|
||
|
||
### 2026-09-09 — QA (Sonnet), TODO §62.2: PASS
|
||
|
||
**Verdict: PASS.** Read the diff (`tools/perf/lspclient.py`,
|
||
`tools/perf/phases_r4.py`) and reran both harness fixes against the
|
||
candidate server on opentitan, guarded, from the main tree.
|
||
|
||
**F2, a brand-new `--storage`, 2 independent tries (fresh directories
|
||
both times), `scanloadprobe` (the fast one-warm-cell loop):**
|
||
|
||
| Try | cache_hits | cache_misses | status |
|
||
|---|---|---|---|
|
||
| 1 | [3975, 3975] | [0, 0] | ok |
|
||
| 2 | [3974, 3974] | [0, 0] | ok |
|
||
|
||
Both timed trials hit on both tries — `phases_r4.prime`'s untimed session
|
||
does fill the store before the first timed measurement, and `cell_status`
|
||
found nothing to refuse. (I did not additionally force a warm cell to
|
||
report a real miss to see the "error" path fire — the diff's own
|
||
`cell_status` branch is a direct, three-line read: `if cache == "warm" and
|
||
any(hits == 0 ...)`, unambiguous by inspection.)
|
||
|
||
**F3, the same runs' scan-completion accounting:**
|
||
|
||
| Try | scan_completed_ms | server trace `scan_total` | scan_ends | mid_scan / after_settle |
|
||
|---|---|---|---|---|
|
||
| 1 | 1494.31 / 1494.86 | 1485.73 / 1486.24 | 1 / 1 | 30 / 40 |
|
||
| 2 | 1753.85 / 1745.77 | 1744.80 / 1736.47 | 1 / 1 | (not recorded) |
|
||
|
||
`scan_completed_ms` sits within 9 ms of the server's own reported
|
||
`scan_total` in both tries (well inside the ±20 ms the task asked to
|
||
check), exactly one `end` per session, and responses split sanely between
|
||
mid-scan and after-settle rather than all landing in one bucket.
|
||
|
||
**The widened window.** Copied `tools/perf/phases_r4.py` into my scratchpad
|
||
and changed `WINDOW_MS["warm"]` 3500 → 5000 only there (never in the main
|
||
tree), reran `scanloadprobe` against the candidate with a third fresh
|
||
`--storage`: `scan_completed_ms` ≈ 1745–1751 ms — unmoved in kind from the
|
||
3500 ms-window runs above (same corpus, same cursor, unrelated to how long
|
||
the offered-load window ran) — while `after_settle_answers` grew 40 → 64,
|
||
`mid_scan_answers` stayed in the same 30s band (36). Matches the review's
|
||
own acceptance: completion stable, after-settle count grows with the
|
||
window.
|
||
|
||
**The quiet-control row.** `load_cell`'s `record(**dict(got, ms=...))`
|
||
call for `rate=0` was exercised as a side effect of every `scanloadprobe`
|
||
run above's cell status line (`quiet control` is not itself a separate
|
||
call in `scanloadprobe`, so I additionally re-read the `record(...)` call
|
||
site at `tools/perf/phases_r4.py` — the merge is `dict(got, ms=...)` then
|
||
splatted, and `got` (from `summary()`) carries no key that collides with
|
||
the explicit `phase=`/`row=`/`fresh_process=`/`result_count=`/`rate_ms=`/
|
||
`open_buffers=`/`note=` keywords also passed, so the `record(**got)`
|
||
duplicate-keyword bug the tracker names as historical cannot recur here);
|
||
no exception in any of the runs above, which all reach that call.
|
||
|
||
**Gates.** Covered under the §62.1 entry above (same guarded `cargo fmt`/
|
||
`clippy`/`test --workspace` run; this feature's own files —
|
||
`tools/perf/*.py` — are not compiled). **opentitan** unchanged
|
||
throughout (checked alongside the §62.1 runs). **Guard**: every bench
|
||
invocation ran through `tools/guard.sh -m 8 -t 1800 --`; no kills; no
|
||
lingering processes.
|
||
|
||
**TODO §62.2's QA line is ticked.**
|
||
|
||
## Review
|
||
|
||
**2026-09-08 (lead).** Accepted, with one fix made by the lead and one
|
||
ruling.
|
||
|
||
- The probe came first and its first draft was thrown away for exactly
|
||
the reason the review warned about (it stopped sending in a lull). The
|
||
shipped one offers the same fixed load to both binaries, and what it
|
||
found is the number that mattered: a publish costs the size of the
|
||
index, not the batch, because `absorb` ends in a whole-index merge —
|
||
3.1 s of publication in a 4.2 s loaded warm scan whose quiet form is
|
||
1.0 s.
|
||
- The cadence is the boring answer and it lands: one merge per 512 files
|
||
instead of one per burst, the waiting drain exempt so the first useful
|
||
answer never moves; publication −78 to −88 %, loaded scans −48 to
|
||
−65 %, median wait 112 → 1.9 ms warm, served requests equal in every
|
||
cell, coherence intact (QA's sabotage of the candidates absorb fails
|
||
the agreement test).
|
||
- **Ruling on the tail.** Four single-buffer cells have a higher max
|
||
(worst 168 → 422 ms warm), attributed by QA to cadence spacing, not to
|
||
the deferral. A time bound on the cadence (T ≈ 100 ms while a request
|
||
waits) would give most of the publication win back, since the old
|
||
spacing was already ~120 ms. Not taken: the median and the completion
|
||
are what a user feels across a scan, and the max is one request per
|
||
session at a cost that stays under half a second. Recorded in the
|
||
tracker as the trade.
|
||
- The empty-answer rule closes §61.3's honest limit: `unsettled_answers`
|
||
0 in every cell, the cross-folder request answered with the right
|
||
location before or at settle, exactly once, and hover untouched.
|
||
- **Fixed by the lead (QA's finding):** a `$/cancelRequest` naming a
|
||
request in the deferred set was dropped, and the request later
|
||
answered normally. `process_batch` now takes a deferred request out and
|
||
answers it cancelled where the cancel lands; pinned by
|
||
`a_cancel_for_a_deferred_request_answers_it_cancelled_and_forgets_it`
|
||
(the request is planted, since a real deferral lives only inside a
|
||
running scan).
|
||
- `HEAD_WALK_MAX` is now pinned (QA's request from §61.3).
|
||
- Deviations accepted: the two additive `lspclient.py` hunks; the warm/
|
||
cold split of the probe for the guard; the `scanloadcross` phase.
|
||
|
||
Docs applied at merge: topo (the cadence, the `deferred` state and its
|
||
cancel rule, `HEAD_WALK_MAX`); the cancel-request README's dated entry;
|
||
the tail trade in the tracker.
|
||
|
||
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
|