Skip the web streams polyfill when the browser can pipe natively
What does this MR do and why?
The web streams polyfill was used even in browsers that support native streams, adding a promise hop per chunk and patching the global stream classes. This MR passes native streams through when the browser supports them, and builds the writable side from the same implementation as the readable side so the two always match. 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 | 791 ms (within noise) | 319 ms | 343 ms (within noise) | 5.0 s | 5.0 s |
| Firefox 152 | 2,518 ms | 2,710 ms (within noise, run spread about 300 ms) | 1,024 ms | 795 ms | 5.7 s | 6.2 s (within noise) |
No measurable win alone. This removes a per-chunk indirection and the global patching, and it is part of the set of changes that together measured 748 ms to 316 ms blocked in Chromium and 2,518 ms to 853 ms blocked in Firefox.
Reproduction steps
- Open a large MR and go to the Changes tab. Confirm it streams fully in Chrome, Firefox, and Safari.
- Open the blame page on a large file and confirm it still streams.
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
- !253737 (closed) - Cut redundant per-file scans while streaming Rapid Diffs
- !253739 (closed) - Keep streamed HTML tasks short in the chunk writer
- !253740 (closed) - Render identical diff file header buttons once per request
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.