Repository navigation
perf(browser): reuse tab snapshots during extension enumeration - #35327
Conversation
973eb62 to
6771a32
Compare
|
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 1 minute. 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] This PR appears safe to merge; no actionable issues were found. SummaryThis PR reuses tab indices and the active-tab result within each synchronous enumeration.
No actionable issues were found. Tests were not run during this review. Reviews (1) · Last reviewed commit: "perf(browser): reuse tab resolution with..." · Reviewed by Greptile |
ELI5
When an extension lists browser tabs, Orca now reads the main tab inventory once for that synchronous operation. Previously it rebuilt and searched the full inventory for every returned tab. Tab order, profile isolation and active-tab results stay the same.
Change
Introduce an operation-scoped resolver shared by
listBrowserExtensionTabsand the registered nativetabs.querymerge. It builds a lazy first-index map and resolves the active page once, including a missing or discarded active page. List enumeration supplies the inventory it already read; query initializes the map only if a main-window tab needs it.Each row still checks the current native contents, destruction, popout ownership and caller session. Duplicate IDs retain their first index, all profiles still occupy the main window's index space, and an early unregistered main-window guest keeps the loaded-tab-count fallback. Standalone resolution always creates a fresh resolver. There is no persistent cache or invalidation machinery.
The native query still starts from Electron's supplied rows and preserves permission-sensitive fields, filtering, discarded tabs and sorting. It does not append loaded tabs omitted by Electron.
Measurements
Both variants run the same ten production modules. Every complete output is compared before operation counts are recorded.
The production-module comparator covers 80 rows at 1/10/100/1,000 tabs, including mixed profiles, destroyed members, popouts and discarded active pages. Registry reads fall from N+1 to one for listing and two for querying. At 1,000 loaded tabs with a discarded active page, saved-state reads fall from 1,000 to one for listing and from 1,002 to three for querying.
An additional 56-row Linux Electron 43.8.1 comparison uses real sessions, BrowserWindows, WebContentsViews and delegated native
webContents.fromIdcalls. It confirms the 1/10/100 counts above, full output equality, and discarded-active saved reads of 100→1 and 102→3 at N=100. Popouts-only queries keep zero main-registry reads. Orca registry/window/saved-store boundaries are controlled; no pages load and this is not a full Orca extension UI run. All windows remain hidden on an isolated display, with zero presentation events and zero live owned contents after cleanup; the private profile is removed.All ten baseline and final production input hashes match the committed author source. The native comparison validates those exact production bytes; the only subsequent edits correct test fixture typing and lint annotations.
Validation
ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2passed on author head973eb62(20/20 checks in 343.9s vsbbd635e1d7). After a clean rebase onto5748d11d0a(no upstream changes to these files), reviewer rerun passed 21/21 checks in 363.3s; an earlier reviewer run hit one unrelated load-flakyorca-runtime.test.tscase that passes in isolation.The independent author clone uses existing tmpfs after managed checkout creation stalled. Dependencies use the frozen lockfile and verified pinned Bun 1.4.4. Husky was not prepared, so there is no precommit-hook claim; format and quality checks ran explicitly. A Git bundle preserves the clean author commit.
Scope and evidence
The issue is present in pinned base
bbd635e1d7a74c27f0744135a57650bebed6e2d3. This changes internal shared Electron logic without IPC schemas, workspace paths, git-worktree assumptions or mobile UI changes. No native macOS/Windows, whole-app cadence, CPU, heap, latency or frame-rate improvement is claimed. The measured improvement is eliminated native calls and saved-state reads.Evidence:
/home/neil/.local/state/orca-electron-audit/extension-tab-list-snapshot-candidate/:report.md,shm-source-verification.json,actual-list-query-counts.json,native-count-results.json, baseline/final logs, source manifests andextension-tab-snapshot-fix.bundle.