Repository navigation
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This change reuses unchanged PR links and caches derived PR summaries during streaming. Its effects are confined to client-side computation and presentation, with no product-default or persistent-data changes. You can add or adjust custom eligibility rules. Learn more. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
A streaming thread resends its whole shell on each tick, with every linked pull request decoded into new objects. A thread with hundreds of links then re-compared every link, re-resolved its current pull request, and rebuilt the saved summaries by re-parsing every link URL in the environment, on each tick from any thread. The shell reducer now keeps the prior links array when the links are unchanged, the current pull request is cached per links array, and saved summaries are cached per link.
3a58a7e to
b90e6ad
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The automated pipeline stopped on this pull request and will not merge it: in the real app the problem is still there, and the rework changed nothing: No code change: I found no defect. The report says the problem still happens but gives no numbers and names no wrong behavior. I checked the mechanism directly. A throwaway benchmark (not committed) used the proof's fixture shape (312 threads, 1,340 links, 322 on the streaming thread) and ran 200 thread.updated ticks, each carrying freshly copied links. On main the streaming row's links array was replaced on all 200 ticks. On this branch it was kept on all 200, and resolving the current PR for every row fell from about 430 ms to 14 ms; reducer cost was the same on both sides, about 95 ms. I traced the real app's paths. Stream deltas carry each thread's full row with its links (ShellStream) and go through applyShellStreamEvents. resolveThreadCurrentPullRequest is one shared instance for every web and mobile caller. threadShellsAtom and quietThreadShellAtomFamily reuse the source rows' links arrays. So the caches are reached in the real app. Main has not touched the involved files since the last merge, so no merge was needed. The PR never claimed to remove the streaming slowdown: its own profile showed main-thread busy time per streamed turn going from about 1,230 to 1,020 ms (decode, Schema equivalence and rendering remain). A total-busy-time comparison on a synthetic fixture with few shell ticks per turn can see that gain as noise. If the bar is removing the slowdown, that needs a separate, larger change, not a fix to this branch. Nothing was pushed, so I did not re-watch the PR; its checks had already passed on this head. It stays open for a person to finish or close. |
savedPullRequestSummariesAtom rebuilt its map from every linked pull request on any thread's streaming tick, so every mounted saved-summary atom re-ran its JSON equality each tick. It now returns the previous map while no thread's links array, project or environment changed. This replaces the per-link summary cache, which only trimmed that rebuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clank context (clickme)
Follow-up to #37001 and #37002.
Problem
Streaming in a thread with many linked pull requests repeats work over every link on each shell tick. While a run streams, the server resends the thread's whole shell several times a second, and every linked pull request arrives as a freshly decoded object. Each tick then:
sameThreadShell,sameApartFromStreaming),SidebarThreadRow,ThreadStatusIndicators,threadReference,pullRequestDetail.logic),savedPullRequestSummariesAtomfrom every link in the environment. Each link's URL is parsed inthreadPullRequestLinkToSummary, and its key is normalized again becausesavedPullRequestKeywraps it in a fresh object, so theWeakMapkey cache misses. This atom rebuilds on any thread's tick, not just the streaming one.The thread this came from has 322 linked PRs; the environment has 1,340 links across 312 threads.
Change
shellReducer: athread.updateddelta, or a snapshot row, whose links equal the prior row's keeps the prior links array. Later equivalence checks then stop at identity, and per-link caches stay warm.resolveThreadCurrentPullRequest: cached per links array in aWeakMap(arrays are immutable).savedPullRequestSummariesAtom: keys by the link itself, so the existing key cache hits, and caches each link's summary per link object.Behavior is unchanged: a changed link yields a new array, so every cache recomputes.
Scope
A real performance problem for long-running threads that link many PRs (stacks, sweeps).
client-runtimeandsource-control-coreare shared with mobile, so the reducer and current-PR changes apply there too.savedPullRequestSummariesAtomis web-only.Verification
Real data, not fixtures: a copy of the actual 322-PR thread (22,900 items, 486-thread family) and its environment, made with
migrate-dev-db. The server and browser ran inside a sandbox (bubblewrap with no network, read-only filesystem, provider credentials hidden), so nothing could reach the real worktree or a provider. The app was a production build of currentmainwith sourcemaps. In Playwright I switched the thread's composer to theReplay (dev)Showcase model, streamed one turn, and captured a CDP trace with the V8 CPU profiler. Base and branch builds ran alternately, 3 runs each, with CPU profiles symbolicated through the build's sourcemaps:toEquivalence)SchemaParser)resolveThreadCurrentPullRequestsavedPullRequestSummariesAtomA reducer-only build reached about 1,150 ms busy and left the summaries rebuild at about 37 ms and current-PR resolution at about 35 ms. So all three changes carry weight.
shellReducer.test.tsgets one case: a changed row with equal links keeps the prior array on both the single and batched paths, and a changed link replaces it. It fails onmainand passes here.vp run check:changedpasses (19 packages typechecked).