Repository navigation
perf(repo-diff): draw plain diff rows through the pool's windowed path - #974
Conversation
RepoDiff passed disableWorkerPool={!colored} and wrapped only colored
diffs in DiffWorkerPool. Without a pool, @pierre/diffs' DiffHunksRenderer
renders a plain (massive) diff by running renderDiffWithHighlighter over
the whole diff on the page, and again on every render pass, since
forcePlainText re-renders unconditionally. With a pool present it takes
the manager's getPlainDiffAST, which builds only the rows in the window.
Plain diffs never reach a worker: tokenizeMaxLength 0 keeps them massive,
so no highlight is queued. Same fix as 867e802 for VirtualSource.
Measured on the 10 000-line diff of repo-diff-browser-qa, CPU throttled
4x, longest long task per step over three runs: open 248-280 ms -> 82-91
ms, each scroll step 132-272 ms -> 57-127 ms, wrap 117-169 -> 68-84 ms,
split 143-228 -> 95-118 ms.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Follow-up to #951.
Problem
A diff drawn without colors (past the highlight bound, or highlighting off) rebuilt every one of its rows on the main thread on each render: every scroll step, wrap, split or resize. On the 10 000-line diff from
repo-diff-browser-qa, at a 4x CPU slowdown, each scroll step held the page 130-270 ms.Root cause
RepoDiffpasseddisableWorkerPool={!colored}and wrapped only colored diffs inDiffWorkerPool. Without a pool,@pierre/diffs'DiffHunksRenderertakes its no-pool path:renderDiffWithHighlighterover the whole diff, re-run on every render becauseforcePlainText(a massive diff) re-renders unconditionally. With a pool it uses the manager'sgetPlainDiffAST(diff, startingLine, totalLines, ...), which builds only the rows in view.VirtualSourcehad the same problem, fixed in 867e802.Change
RepoDiffalways renders insideDiffWorkerPooland dropsdisableWorkerPool. Plain diffs never reach a worker:tokenizeMaxLength: 0keeps them massive, so no highlight is queued.DiffWorkerPool.tsxandsourceTheme.ts.changelog.d/repo-diff-windowed-plain-rows.md(Fixed).Validation
Measured with a scratch Playwright script (not committed) on the 10 000-line plain diff, desktop 1440px, CDP
Emulation.setCPUThrottlingRate4. The numbers are the longest long task per step across 3 runs:The fold step still costs about the same. Most of it is
trimPatchContextand re-parsing the patch on the page, which this change does not touch.CI=1 bun run check run --build bun scripts/repo-diff-browser-qa.ts: passes (all widths and themes, remote, demo)bun run check fast: passes🤖 Generated with Claude Code