Repository navigation
perf(editor): reuse model owner keys in closed-tab cleanup - #34691
Conversation
Each openFiles change (e.g. a dirty toggle) re-resolved every tab's owner route twice. Cache owner keys per tab until an owner input changes, so a single-tab update resolves only that tab.
|
No actionable comments were generated in the recent review.
|
Summary
Workstream 1 of the Oct 27 app-wide lag investigation (build
1.4.243-hourly.202610272224). That profile recorded 499 owner-key calculations in closed-editor cleanup per catalog transition (~498 ms sampled).attachClosedEditorTabCleanupre-resolved every open tab's model owner route twice (old and new state) on eachopenFileschange, including a single tab's dirty toggle and catalog/timestamp updates. Its cost grew with open tabs × catalog size.Owner keys are now cached per
OpenFileobject and reused until an owner input (the existingEDITOR_BUFFER_ROUTE_INPUT_KEYS+editorBufferIdOf) changes by reference:Ownership semantics are unchanged. The cache invalidates on the same inputs the subscriber's early return already treated as complete, so behavior is the same for local, SSH, runtime, folder workspaces and detach/rejoin. This is a free win: same output, less work.
Proof
Benchmark at the reported census: 251 edit tabs across 171 worktrees, ~1,600 worktree rows, real store and controller. Results compare
HEADwith this branch:A regression test (
closed-editor-owner-key-reuse.test.ts) asserts the work count. It fails onHEADwith 40 resolutions for 20 tabs and passes with 1. It also checks that closing a tab still disposes only that tab's model.Not covered here: removing catalog churn itself (workstream 2, a semantic projection of runtime environments). That fix is larger and needs mixed-version validation.
Testing
pnpm check:changed --maxWorkers=2: 28/28 passed