A check a quarter faster: analysis 209 ms to 149 ms and the pass 527 ms to 395 ms on a large entry, findings unchanged, with a guard that sees work growing #139
Loading…
Reference in a new issue
No description provided.
Delete branch "speed-two"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A check runs in an agent's edit loop, in the editor and in the lint plugin, so how long it takes is part of the product. #126 took the whole-program pass on an adopter's largest entry from 1,120 ms to 465 ms. Then ten pieces landed in one day, each reviewed at "about 1 to 3%", and together they made a check a fifth slower. This takes that back and more, with every finding unchanged.
On that entry, shipped profile, minimum of 25 interleaved runs:
My own measurement with the fast profile agrees: analysis 223 ms to 155 ms and the pass 567 ms to 431 ms, both now below where they stood before the ten pieces (191 ms and 489 ms).
Where the time had gone
There is no
perfon the machine this was done on, and its load swings wall times by a third, so the attribution was made with callgrind: instruction counts on one thread, which do not depend on load. From the tree before the ten pieces tomain: analysis +27%, the pass +18%. The three largest shares were the spelling normalisation's second scope analysis of every file, the per-function look of the newest rules, and the reference index and scan of files forunused-code.Two things turned that work into wall time, and they are what was cut:
Pathhashes byte by byte through SipHash;resolve_calleealone is asked 233,547 times on that entry and nearly always hits its memo. The memos now hash with the crate's existing fast hasher, and path keys as their bytes.The cuts
Nine commits, each with its measured effect in its message:
package.json, not once per directory (manifests were parsed 22 times).sentinel-error's 121 package files run beside other work instead of in front of it.Three attempted cuts showed no gain and removed no repeated work, and were dropped. On one thread the pass's work fell 10% and its serial part 32%; most of the gain in analysis is scheduling, and the per-file work of the newest rules is as it was.
Nothing changed in what is reported
Byte-identical output against
mainafter every cut: 592 cases (the adopter's entries one by one and together, its directories, the three examples, all 129 fixture directories, with and without--idiomatic), each as text, as--jsonand as stderr with the exit code, with the new binary run twice so that parallel work cannot make order depend on timing. I repeated it independently on the adopter, the examples and 21 held-out projects (210 runs): identical.safe-ts emit, the rewrite list and the soundness corpus are unchanged.So that it shows next time
The work guard counted repeated questions, and new rules brought new work with counters of their own. It gains four counts on its fixed project:
memo_questions: every question asked of the four big memos, hits included.allocations: fresh allocations of a whole check on one thread, stable to 10 in 250,000 between runs; the test fails above 1% over its ceiling. A rule that takes one more look at every function moves it by several percent.feature_sets_loadedandalias_bodies_copied.Reverting the pack cut, reverting the alias cut, adding a second per-function look, and asking again what every call runs each make the test fail. The hashing and scheduling cuts cannot be seen by a count; their revert is a visible change of a type in a diff.
Found and left, each needing a decision
sentinel-errorreads: they need calls, imports and one summary, and get all forty collectors. About half of the pass's parallel work.unused-answer,misplaced-argument,unbalanced-update): about 5% of per-file work, a refactor across three rules.Created with Claude Opus 5.5 (implementation) and Claude Fable 5.2 (review and verification) in Claude Code.
`json::value`'s evaluator reads a value's members through the aliases naming its type (`Eval::unalias`), following a body that is a name, an array or a tuple, and stopping at any other. To be told, it opened the alias with `written::open_one`, which copied the whole body out of the shared declaration first: for an alias of an object type (`type State = { ... }`, the common case) a copy of every field, made and dropped to learn it isn't followed. On an adopter's largest entry that was 5,584 openings, 205 M instructions of the pass's one thread and 118 M more to drop them. `written::step` is now `peek` (the declaration as found, with its type parameters bound) and the copy; `open_one` takes what the caller follows and copies only that. Measured (fast profile, 15 interleaved runs, min / median ms): pass 459.5 / 470.1 -> 439.2 / 445.1, analysis unchanged. Findings byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>`tests/work.rs` counts work done from scratch: a question asked again where a memo was missed, a file parsed again. Between the pass's speed work and the ten pieces after it the pass grew by 15% on an adopter's largest entry with every count held, because new work came as new walks, copies and questions a memo answers, which no count saw. - `memo_questions`: the questions asked of the pass's shared memos (`Run::resolve_callee`, `Run::file`, `Run::resolve_binding`, `Run::type_at`), answered from them or not. A rule that asks again about every call counts here. - `allocations`: the allocations of the whole check, on one thread so that they come out the same each run (to about 10 in 250,000; growths aren't counted, which depend on the length of the temporary path), against a ceiling it may pass by 1%. A new walk over every function, a summary per function, a copy made to read a field all allocate. - `feature_sets_loaded` and `alias_bodies_copied`, the work two cuts of this branch took out. Counting is off unless a test turns it on (`work::reset`): `memo_questions` is asked hundreds of thousands of times a pass. The generated project gains an alias of an object type read by member (`Limits`, `cap{i}`), so that aliases are opened where they are read; the counts it adds (calls, names, types, propagations, package calls) are in the new ceilings. Co-Authored-By: Claude Opus 5.5 <[email protected]>