Cut redundant per-file scans while streaming Rapid Diffs
What does this MR do and why?
Several per-file jobs scanned far more than they needed while diff files streamed in: line links were rewritten for every mounted file even though only visible files need it, the page-wide lazy-image observer rescanned the whole document on every mutation batch, the viewed-state lookup queried the whole document per file, and each adapter rebuilt its context on every event. This MR scopes line-link rewriting to visible files, pauses the lazy-image observer during streaming and rescans once afterwards, scopes the viewed-state lookup to the document head, and caches the adapter context. No UI change.
Measurements
Local 1,000-file merge request (998 streamed files, about 85k elements), Overview tab then Changes tab, headless 1440x900, no extensions, master and the branch served by the same local stack, 3 runs each, medians.
| Browser | Blocked before | Blocked after | Longest task before | Longest task after | Last file before | Last file after |
|---|---|---|---|---|---|---|
| Chromium 151 | 748 ms | 798 ms (within noise) | 319 ms | 352 ms (within noise) | 5.0 s | 5.0 s (within noise) |
| Firefox 152 | 2,518 ms | 2,176 ms | 1,024 ms | 996 ms | 5.7 s | 5.7 s (within noise) |
On its own this is a modest Firefox-only win. It mostly removes wasted work that is more visible once the larger costs addressed in !253736 (merged) and !253645 are gone.
Reproduction steps
- Open a large MR that includes images in the diff.
- Go to Overview, then click the Changes tab.
- Confirm lazy images still load after streaming finishes.
- Confirm line links still work on visible files: click a line number and check that the URL updates.
- Confirm the viewed checkbox state still renders correctly.
References
Split out of !253645 (original umbrella MR, now the complete-file streaming MR).
Sibling MRs from the same investigation:
- !253645 - Insert complete diff files while streaming Rapid Diffs
- !253736 (merged) - Stop re-rendering the file browser per streamed diff file
- !253738 (closed) - Skip the web streams polyfill when the browser can pipe natively (closed, no measurable effect on Rapid Diffs)
- !253739 (closed) - Keep streamed HTML tasks short in the chunk writer (closed, no measurable effect on Rapid Diffs)
- !253740 (closed) - Render identical diff file header buttons once per request (closed, no measurable effect on Rapid Diffs)
Feedback thread: #596236
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.