Repository navigation
perf(web): typing, scrolling and switching threads re-render fewer components - #44833
maria-rcks wants to merge 6 commits into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
When switching from A to B and back, did you measure whether A’s timeline and scroll container were rebuilt? That would help distinguish the cost of remounting a timeline from the cost of re-rendering its rows. We tried retaining the two most recent timelines in a separate macOS prototype. When we ported it to stock source, one regression run found only one mounted timeline where we expected two. We haven’t benchmarked this PR or established a speedup on stock T3. Would a separate issue with a synthetic reproduction of the remount cost be useful? |
…r components The composer footer read the prompt inline, so every typed character rebuilt the footer and its voice controls. The sidebar's row click handler changed on every route, so a thread switch re-rendered every row. ChatView subscribed to the whole follow state, so each atEnd flip while scrolling re-rendered it, and a handler that was new on every render rebuilt the details panel and overlay hosts with it.
…or typed With --renders, the two 10 s windows that sample renderer CPU while a thread streams now also count React commits and component renders, so background redraws are measured and gated like interactions. The probe also walks past 800 hook slots, which had reported ChatView's later state changes as context.
…g windows Covers the new row in the existing summary test, the --renders help text and the performance doc.
…s its own thread The stable wrapper ran the latest render's setter, so a checkout started on one empty thread and resolved on another put its branch on the second. The setter now closes over a thread id read beside it, which the compiler caches on, so it is still the same function between renders.
The row key held the measured seconds, which could round a slow window into a second row. The doc says the windows' CPU includes the probe under --renders.
0b81adb to
d4bd5c2
Compare
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This reduces unnecessary chat UI re-renders and improves streaming performance measurements. The changes preserve existing product behavior and introduce no apparent material data or operational exposure. You can add or adjust custom eligibility rules. Learn more. |
Dismissing prior approval to re-evaluate b665b45
|
Note Written by Yes.
So the web app does rebuild the timeline on a revisit (one timeline is mounted at a time), and on the long thread that is about 29% of the renders. The rest are components that were already on screen rendering again, which is the part this PR and #48244 reduce. Neither changes what is mounted or kept. These are render counts, not time. I have not measured how many milliseconds of a revisit the remount accounts for, and nothing here says whether keeping a second timeline mounted would pay for its memory. Proposals from outside the team go to Ideas discussions (see CONTRIBUTING.md). A reproduction that isolates the remount cost in time, on stock source, would be the useful thing to bring there. |
Typing, scrolling, opening Settings and switching threads re-rendered components that had nothing new to show. Each typed character re-rendered 21 components and now re-renders 4. Scrolling the timeline re-renders 22% fewer, Settings 28% to 33% fewer, closing the terminal 22% fewer, thread switches 2% to 12% fewer. Nothing on screen changes. The causes are three, each a few lines:
atEndflip while scrolling re-rendered it. Only the mode is rendered, so that is now the snapshot.scrollToEndleaves the hook stable like its other callbacks.A fourth cause, the sidebar's row click handler, was part of this PR until main landed the same fix in #47105. The rebase onto
3067c498471dropped it from this diff, which is why switches gain less here than the 7% to 32% first measured againstb927b1fd936.report:client --rendersnow also counts renders in its two 10 s streaming windows, where nothing is clicked or typed, and its probe walks past 800 hook slots (ChatView has over 1,200, so its later state changes read ascontext).compareleaves out the CPU of a window that counted renders, since that CPU includes the probe.Measured on 2026-12-03 with
vp run report:client ab <main checkout> <this checkout> --rounds 3 --renders --cases short,long,working,medium,approval,scroll-long,settings,terminal --floors floors.json: production builds, Chromium headless shell 158, 16-core AMD EPYC 7B13 Linux VM, pinned to 8 cores, runs alternated. Floors come from main against main the same day (noise). Values are component renders per step, each run's median one sample, 3 runs a side. A row isbetteronly when the 95% interval of the difference clears both 5% and that metric's base-against-base floor. These are the tool's render rows, unedited:Client metrics (lower is better)
before
3067c498471(3 runs), afterb665b453862(3 runs)The typing rows come from a run of every case the same day, 2 runs a side:
No render row is worse. That run of every case ran at load average 40 to 50 and flagged three: palette open, the right panel switching to the pull request, and revisiting the pull request thread. Those steps have several modes on main itself (palette open reads 590, 899 or above 1,500; the panel switch about 1,000 or 1,400 to 2,600), depending on whether a late update lands inside the step, which it does more often on a busy machine. Run alone they do not differ: palette open has a median of 899 on main and 822 here over 4 runs a side; the panel switch 1,803 against 1,690 and the pull request revisit 3,057 against 3,386, both intervals across zero (3 runs against 2). The streaming windows are inconclusive: across the day's runs an idle thread read 142 to 866 renders per 10 s on main and 311 to 1,200 here, and watching the stream 3,400 to 6,700 on both.
The recording is one pass a side, recorded back to back on the same cores, so its totals show direction and the tables are the claim.
Timing, CPU and memory were measured on the head before the rebase (
0b81adbc677cagainstb927b1fd936), without the render probe, at load average 4 to 7: no row worse, one better (switch.diff.first.loafMs349 to 261 ms), a typed key painting in 32 ms with no long frame on both sides, renderer CPU and heap equal within their intervals, scroll long-frame time 109 ms against 110 ms over 24 samples a side. The machine was too busy on 2026-12-03 to repeat the timing run on the rebased head. Memory in that day's runs is unchanged: heap after every round 76.2 MB on main and 75.9 MB here, DOM nodes identical.Proof, by level (4 is real code executed, 5 is the running production build):
promptis not one, and the branch setter is cached on the thread id. Level 4.vp run check:changedon Blacksmith for this head: format, lint, knip, typecheck, 9 test files with 146 tests, React Compiler coverage of the 3 files.Not verified: frame rate on a display (headless Chromium only); timing on the rebased head; the alternate send shortcut label in the UI (same computation, moved; checked in the compiled output only); a branch checkout that resolves after a thread switch in the running app (traced in code by two reviewers, level 3); pending guest messages and resume scrolling to the end; the Electron shell; any gain while a thread streams (inconclusive). Mobile is untouched: it is separate React Native code with its own render counter, and this pass did not look at it.
Council review
Rounds: 4
comparegated the CPU of a window that counted renders, which includes the probe. Fixed in b665b45.compareandnoiseno longer use it.Fable 5.2 via Claude Code in T3 Code.
🤖 Generated with Claude Code