Repository navigation
Conversation
|
Reviewed the diff. I didn't run the tests. The memoization looks correct. Both the chrome flag and the link position are "first self-answer on the path to the root", so caching the answer on every element passed gives the same result as the old walks. The 600-page seeded parity test against the kept oracle covers that well.
No security concerns. The memo maps are per call and keyed by element, so nothing site-controlled is used as a key. |
…t, not per link Profiling parsePage on a 20,000-deep page named the step: both link extractors walked every anchor's ancestors to the root, for its sitewide chrome flag (and, in extractors/links.ts, its position). A page of nested links walked the tree once per link: 20,000 levels took 12.5 s to parse, and the crawler's extractLinks 64 s. Each walk now stops at the first element an earlier anchor answered for. Every anchor gets the answer it got before. squirrelscan/repo#3356 Signed-off-by: Nik Cubrilovic <[email protected]>
a27fd75 to
f12e92d
Compare
Auto-review did not completeThe
Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal): Show partial reviewYou've hit your session limit · resets 7:40am (UTC) |
… page is never kept alive CI's page-rule-residency-2343 read 1.82 MB for the bounded arm on f12e92d (budget 1.5 MB, about one 384 KB page's DOM). It passes locally on macOS and on Linux arm64 at 0.07-0.09 MB, and main and this PR's earlier head passed CI, but a memo Map keyed by elements is exactly what a stale conservative stack slot can pin, with the page's whole DOM behind it. Both memos are WeakMaps now. A test keeps the memos alive past their page and asserts the page is collected; with a Map it fails. Signed-off-by: Nik Cubrilovic <[email protected]>
Auto-review did not completeThe
Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal): Show partial reviewYou've hit your session limit · resets 7:40am (UTC) |
…passed A stale slot from the latest call can pin its own page in any test, the same conservative scan the test guards against; a memo holding its keys strongly keeps every page, so asserting the first two of three is as sharp and cannot flake on the last. Signed-off-by: Nik Cubrilovic <[email protected]>
Auto-review did not completeThe
Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal): Show partial reviewYou've hit your session limit · resets 7:40am (UTC) |
parsePagewas quadratic in nesting depth (squirrelscan/repo#3356). It runs on every audited page, in the CLI and in the cloud.The step that grew faster than linear
I timed each step of
parsePageon 5,000 to 20,000-deep pages. The HTML parse itself stays near linear: 38 ms at 20,000 levels. The cost is in the link extraction.extractLinks(html.ts) asks every anchor whether it sits in sitewide chrome (isInSiteChrome, rules(links): pages with zero CONTEXTUAL inbound links pass orphan-pages #109). It answers by walking the anchor's ancestors up to the root.linkstook 34 s of a 35 s parse.extractors/links.ts) makes that walk twice per link: once for the chrome flag, and once fordetectLinkPosition.Changes
createSiteChromeTest()(extractors/chrome.ts) andcreateLinkPositionTest()(extractors/links.ts) memoize the two walks for one document.isInSiteChromekeeps its single-element form.detectLinkPosition's precedence moved unchanged intoownLinkPosition, which is what one element says about itself.Results
parsePagebeforeextractLinksbeforerole="text"spansrole="text"spansaria-hiddendivsBoth sets of numbers were measured at a load average around 12. Method:
benchmarks/2026-10-parse-depth.md, with the harness inbenchmarks/harness/parse-depth.ts.Tests
packages/parser/tests/parse-depth-3356.test.ts:tests/fixtures/reference-3356/.extractLinksalso takes 20,000 nested links in under 1 s. Atorigin/mainthe first budget fails: 18 s.The existing parser suites pass: link-chrome, attribute-case, contact-links, dom-text, headings, noscript-resources, visible-meta, soft404, hreflang, fonts and schema-graph.
Docs and skill
The CHANGELOG has an entry. No docs or skill change is needed: output is unchanged.
Gates
packages/parserscripts/test-suites.ts --check