Repository navigation
Stop waiting for remove selectors and wait for the DOM to settle - #1291
clementbiron wants to merge 3 commits into
Conversation
The browser fetcher awaited every selector of a source document, `select` and `remove` alike, until it matched an element with non-empty text, up to waitForElementsTimeout (10 seconds). A `remove` absent from the page, or targeting an element without text such as an image, made every fetch wait for the whole timeout. Waiting for an element that will be removed serves no purpose. Nothing documents that choice: #183 only passed `select`, #189 merged both lists without explanation, #1159 then required a non-empty text. Measured on 50 documents from 7 collections, no version changed and the average fetch went from 9.7 to 5.0 seconds.
341a7a1 to
3326acf
Compare
The accidental delay removed by the previous commit gave scripts time to finish rendering some pages: on TikTok "Human Rights Policy", 2 fetches out of 11 captured the page before a navigation block was injected, yielding the same content with two lines swapped. The content is now read once the DOM has not changed for domIdleDelay milliseconds (500), up to domIdleTimeout (2 seconds). Measured cost: 0.5 to 0.9 seconds per fetch, and the block captured every time. The observer is installed from within the awaited function so that the wait survives a navigation triggered by the page.
3326acf to
526bba2
Compare
I disagree. The current behaviour enables consistency of snapshots. Such an optimisation would make Using |
|
Based on #1290 (comment), wouldn't we already see significant gains by changing the way we wait for |
Validating a collection in CI took 18 minutes for a Facebook declaration (user-rights, 46 documents in a combine) and 64 minutes for Instagram, with the vlopses collections cancelled at the 10-minute cap. Every browser fetch took about 11 seconds, whatever the page.
The browser fetcher awaited every CSS selector of a source document,
selectandremovealike, until it matched an element with non-empty text, up towaitForElementsTimeout(10 seconds). A singleremoveabsent from the page, or targeting an element without text such asimg[alt=""], made every fetch wait for the whole timeout. Nothing documents that choice: the first browser fetcher (#183) only passedselect, #189 merged both lists without explanation, and #1159 then required a non-empty text, which an image can never satisfy. Waiting for an element that will be removed serves no purpose: if it is there, extraction removes it; if it is not, there is nothing to remove.The first commit awaits only the
selectselectors. Measured on 50 browser-fetched documents from 7 collections, each fetched twice with and without theremoveselectors: average fetch down from 9.7 to 5.0 seconds, no version differed between the two modes. On the 3-document Facebook sample, validation went from 2 minutes to 29 seconds.That accidental delay did give scripts time to finish rendering on some pages: on TikTok "Human Rights Policy", 2 fetches out of 11 captured the page before a navigation block was injected, yielding a version with the same content but two lines in a different order. The second commit replaces the accident with a deliberate, bounded wait: once the selectors exist, the content is read when the DOM has not changed for
fetcher.domIdleDelaymilliseconds (500), up tofetcher.domIdleTimeout(2000). It costs 0.5 to 0.9 seconds per fetch and captured that block in 16 fetches out of 16. A network-idle wait of the same length cost 1.6 to 2 seconds without capturing more. The observer is installed from within the awaited function so that the wait survives a navigation triggered by the page.