Repository navigation
perf(audit-engine): read two columns for the link scan, not every page's HTML - #236
Merged
Merged
Conversation
nc9
force-pushed
the
perf/site-query-link-scan-projection-1860
branch
from
September 7, 2026 11:12
f4706c1 to
48f866e
Compare
…e's HTML `createSiteQuery`'s incoming-link scan walks the pages table twice and reads `normalizedUrl` and `parsedData`. It did that through `getPages`, which is `SELECT *`: every page's HTML was materialized, and pulled back out of the content store when the column was empty, so the loop could look at `parsedData.links`. The HTML is dropped at the end of each batch and the JS heap barely moves, which is why this never looked like a memory problem. The allocator keeps the pages it grew for it. Measured over 150 real 959 KB pages, batch 50, three runs, RSS growth across the call: before 431 MB (230 / 431 / 492) after 88 MB (68 / 88 / 103) The JS heap grew ~0.3 MB either way. This is the ~294 MB step a production run showed at rules_site_query, and it is allocator residency rather than anything the audit is holding. `getPageLinkRows` is the projection: same table, same order, same pagination, two columns. tests/page-link-rows-projection.test.ts pins it row for row against `getPages` across three page sizes and asserts it never touches the content store, with the full read as the control. Byte identity unchanged: the five site-query goldens plus the v1-vs-v2 canonical and streaming goldens pass. Signed-off-by: Nik Cubrilovic <[email protected]>
…ization #1860 Signed-off-by: Nik Cubrilovic <[email protected]>
… not a peak Review findings on the link-scan projection (#1860). The benchmark's timer sampler claimed a peak. The scan's batches do not reliably yield to the event loop, and a review reproduced ZERO timer callbacks across a 280 ms scan, so the number was the endpoint delta wearing a peak's name. It now reports `rssDeltaMB` and says what it is. The header also said the heap and RSS figures move together; they do not, and the separation between them is the entire finding, so it now names them apart. The equivalence test could not have caught three of the things it claimed: one crawl cannot catch a dropped `crawl_id` filter, all-lowercase URLs cannot catch a collation change, and the paging loop never reached limit 0 or an offset past the end. It now runs a second crawl holding the same two URLs, orders a mixed-case pair BINARY-first, walks the paging edges comparing OUTCOMES (a nonzero offset with no LIMIT is the same SQLite error in both reads, and agreeing to fail counts as agreement), and pins an empty stored parse as "" against a missing one as null. The `PageLinkRow` doc said the walk never touches these two fields when it is the HTML it never touches, and both measured comments quoted a single run; they now quote the three-run medians the commit reports. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
perf/site-query-link-scan-projection-1860
branch
from
September 7, 2026 11:19
48f866e to
768fed1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1860 / the OOM incident. Independent of the detach PRs.
createSiteQuery's incoming-link scan walks the pages table twice and readsnormalizedUrlandparsedData. It did that throughgetPages, which isSELECT *: every page's HTML was materialized, and pulled back out of the content store when the column was empty, so the loop could look atparsedData.links.The HTML is dropped at the end of each batch and the JS heap barely moves, which is why this never looked like a memory problem. The allocator does not give the pages back. Measured over 150 real 959 KB pages, batch 50, three runs, RSS across the call:
This is the ~294 MB step a production run showed at
rules_site_query, and it is allocator residency rather than anything the audit holds. Shrinking the batch does not help: batch 500 was 581 MB and batch 50 was 431 MB, the same order.getPageLinkRowsis the projection: same table, sameORDER BY, sameLIMIT/OFFSETsemantics, two columns.tests/page-link-rows-projection.test.tspins it againstgetPagesrow for row, with a second crawl holding the same URLs (so a droppedcrawl_idfilter fails), a mixed-case pair (so a collation change fails), the paging edges compared by outcome (a nonzero offset with noLIMITis the same SQLite error in both), an empty stored parse against a missing one, and an assertion that it never touches the content store with the full read as the control.Byte identity unchanged: the five site-query goldens plus the v1-vs-v2 canonical and streaming goldens pass.