Repository navigation
test(lint): bound lint growth by counted string work, not a busy runner's clock - #8858
miguel-heygen wants to merge 2 commits into
Conversation
terencecho
left a comment
There was a problem hiding this comment.
P2 · Keep coverage of the source-position regression independent of its string API. The counter in packages/lint/src/rules/gsap.test.ts:3299–3305 misses direct string indexing. In a test-only mutation of the source-position helper, a per-finding prefix rescan visited 16.06× as many code units on the larger timeline fixture, while the current counter reported 4.12× and both tests passed. The slice-and-split version of the same regression is caught. Please keep a deterministic assertion that guards the source-position traversal itself so an equivalent quadratic implementation also fails.
I verified the original CI failure in the named script-tag test, at 8.92 against 8. The build, lint typecheck, all 1,359 lint tests, and ten contention runs passed on this head.
— tai (automated review)
|
Addressed at
Stand-ins, each a per-lookup prefix rescan inside the helper:
On the current code, all 7 tests in these two files pass, three runs in a row. The work counter in Analyze (python): on |
terencecho
left a comment
There was a problem hiding this comment.
The source-position test now closes the direct-indexing coverage gap. It measured 4.00× growth on this head and rejected the quadratic rescan at 16.01× against the 6× bound. The named original timing test failed in CI before the change. All 1,361 lint tests passed, along with typecheck, lint, and formatting.
— tai (automated review)
What
The two linear-time tests in
packages/lint/src/rules/gsap.test.tsnow measure how much work lint does, not how long it takes:lints script tags naming one file in linear timelints timeline scripts beside named elements in linear timeThey still fail when lint goes quadratic. A busy runner can no longer fail them.
Why
Both tests compared wall-clock time at n and 4n tags and allowed a ratio up to 8. Linear lint grows about 4x and quadratic about 16x. On a loaded merge-queue runner, the script-tags test measured 8.92 and ejected a release from the queue, although lint itself had not changed. A ratio of two timings moves with whatever else the machine is doing.
How
growthnow counts work. While lint runs, the test wraps the string and regex methods lint scans with (charCodeAt,slice,split,indexOf,match,replace,exec,testand the like). It counts each call plus the characters the call returns, then restores every method. For a given page the count is the same on every run, whatever the load. The test runs each size once and compares the two counts.The bound is now 6, not 8. A deterministic count needs no headroom for noise, so the bound only has to separate linear and
n log ngrowth (about 4.8x here) from quadratic growth (about 16x).I measured the ratios on the same two pages:
Two runs of the same page differ by less than 0.1%. In the same before-#8551 tree, the old wall-clock measurement read 16.06 for the script-tags page.
Test plan
fails without the fix: this PR changes tests only. The regressions they guard against were checked by making lint quadratic: the stand-in that re-collects document ids for every script fails
lints script tags naming one file in linear timeat 9.01 against 6. The lint code from before #8551 grows 15.67 and 15.06 on the two pages.On main both tests pass three runs in a row. They also passed 10 of 10 runs with eight CPU-bound processes running beside them. The full lint suite passes (30 files, 1,359 tests) and lint
tscis clean.