perf(chat): bound Pierre file-pair rendering - #8328
Open
Pearcekieser wants to merge 1 commit into
Open
Conversation
Pearcekieser
force-pushed
the
perf/pierre-file-pair-budget
branch
from
September 4, 2026 01:10
0fe7484 to
9fd5ea9
Compare
Bypass synchronous Pierre diff construction for oversized old/new source pairs while preserving complete content, editing, header controls, and responsive chat-row scrolling.
Pearcekieser
force-pushed
the
perf/pierre-file-pair-budget
branch
from
September 4, 2026 02:22
9fd5ea9 to
5cbc0f6
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.
Problem / Motivation
Large raw old/new file pairs can block the dashboard renderer before Pierre's worker pool or row virtualizer can help. A captured client trace showed three Pierre/Shiki main-thread tasks lasting 4.40 seconds, 2.49 seconds, and 2.41 seconds while entering Chat, switching sessions, and rendering paginated history.
Pierre 1.3.5 constructs file-pair metadata synchronously through
MultiFileDiff -> parseDiffFromFile -> createTwoFilesPatch -> processFile. Worker-backed highlighting does not bound that initial work.Why it matters
The measured tasks accounted for 90.2% of long-task time, produced a 4.55-second visible freeze, and delayed one interaction by 2,545 ms. Code-heavy chats become unresponsive during navigation even when the destination response has not arrived yet.
What changed (motivation → approach → change)
The public
PierreFilePairwrapper now owns a layout-independent input budget before its lazy Pierre chunk loads.Large file — simplified viewstatus explains why highlighting and line-level diff controls are absent.Relationship to #7916
PR #7916 overlaps
FileChangeChips,PlainCodeFallback, and the Pierre wrapper as part of a broader history-pagination, staged-rendering, and phone-scroll rewrite.This PR is intentionally based directly on
main, not on #7916. The two changes address different costs. #7916 changes when transcript and diff work becomes reachable; this PR places a measured hard bound on synchronous raw file-pair construction whenever a pair is rendered. Expanded rows, side panels, and live-diff editing still need that bound after staged mounting or history pagination lands.Shipping the guard directly keeps a separate regression and rollback boundary for the measured freeze. Waiting for or stacking on #7916 would couple a focused renderer safety limit to a much larger in-flight history rewrite and duplicate its review dependencies. Any textual conflict can be resolved when main moves without changing this PR's policy or tests.
Tests
pierre.renderBudget.test.tspins exact line and UTF-16 code-unit boundaries, uneven pairs, and new-file behavior.PierreFilePair.budget.test.tsxproves oversized pairs never mount Pierre while preserving both files, header defaults, collapsed controls, keyboard regions, separators, and caller sizing.PierreEditorImpl.test.tsxproves oversized live diffs remain editable.FileChangeChips.headerSlots.test.tsxpins the shared 376 px fallback scroller.Manual verification
A real Chromium fixture rendered a synthetic 401-line pair and verified:
Screenshots / video
Desktop split view
Narrow stacked view
Related Issues
Fixes #8241
Possible overlap: #7916, as described above.
Pattern harvest
Rule candidate: review-prompt
Pattern: Worker offload does not bound synchronous preprocessing that runs before the worker request; expensive renderers need an app-owned input budget at their public boundary.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)