Repository navigation
perf(editor): compare worktree owner rows by identity instead of a per-write JSON signature - #35824
Conversation
… signature Activity/unread/rank patches to worktreesByRepo still stringified every worktree's owner fields on each write to decide the route token. Walk buckets and rows identity-first against the last tokenized map instead; same order-sensitive owner-field semantics, no per-write allocation. 300 worktrees, 200 open files: route check per activity write ~40-70us -> ~0.8us.
|
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 51 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryReplaces the JSON signature in
No actionable issues found. nwparker explicitly acknowledges that a collected baseline may cause one extra conservative owner check. Reviews (1) · Last reviewed commit: "perf(editor): hold the last owner-rows b..." · Reviewed by Greptile |
ELI5
Every time a workspace's activity, unread or sort state changes, Orca checks whether the change affects which workspace owns each open editor file. That check rebuilt a text summary of every worktree on each update. Now it compares only the rows that actually changed.
What Changed
src/renderer/src/lib/worktree-owner-rows-token.tsworktreesByRepomap produced a JSON string built from every worktree's owner fields, which was then compared with the previous string.id,repoId,hostId ?? null,runtimeOwnerEnvironmentId ?? null. A change in bucket or row order still counts as a change.WeakRef, so a removed catalog isn't kept in memory. If the baseline has been garbage-collected, the next map gets a fresh token, which just means one extra conservative re-check.There are two consumers, and both get faster: the editor-buffer record middleware (
editor-buffer-identity-cache.ts) andStructuredAgentSessionStatusBridge.Why
Micro-benchmark with 200 open files, 300 worktrees and 1000 activity writes. The machine was heavily loaded, so the ratios matter more than the absolute numbers.
Where this came from
withEditorBufferRecordsmiddleware. It re-derived every open file's ownership on any write toworktreesByRepo,settings,reposand so on, and copied the full app state on each owner lookup. Agent activity writesworktreesByRepooften, so the cost grew with open files × write rate.This was one of the smaller contributors to the renderer stalls reported in #35660. The main cause there was the
body:has()rule from #33799, fixed by #34932.Linked Issue
Refs #35660
Visual Proof
N/A: performance-only change with no visual or interaction difference.
Testing
New
worktree-owner-rows-token.test.tschecks that:hostId: undefinedis treated the same as missinghostIdchange gets a new tokenTargeted editor, buffer-lifecycle, owner-key and native-chat suites pass. The one failure,
native-chat-composer-draft-store.test.ts, also fails on unmodified main.pnpm check:changed --maxWorkers=2: 22/22 checks pass.Adversarial reviews:
Platform: macOS. The change is pure renderer logic with no platform branches. Folder workspaces come from
folderWorkspaces, which this change doesn't touch. Remote hosts are covered by the host and runtime-owner fields.I manually tested these changes locally
Automated tests added/updated, or explained why not below
🤖 Generated with Claude Code