Skip to content

perf(browser): reuse tab snapshots during extension enumeration - #35327

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/extension-tab-resolution-snapshot-independent
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/extension-tab-resolution-snapshot-independent

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​330 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​330
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58 $\color{#cf222e}{\Huge{\mathbf{−}}}$​28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​30

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 listBrowserExtensionTabs and the registered native tabs.query merge. 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.

Loaded tabs List native lookups before → after Query native lookups before → after
1 4 → 3 5 → 5
10 130 → 21 131 → 32
100 10,300 → 201 10,301 → 302
1,000 1,003,000 → 2,001 1,003,001 → 3,002

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.fromId calls. 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

  • Tests inserted on exact base: five operation-count regressions fail and three compatibility controls pass.
  • Final: 64 tests across eight relevant suites pass, covering tab resolution/model/query, registered namespaces, discarded tabs, navigation, page methods and capture.
  • Node typecheck passes. Format and all nine changed-code quality groups pass. The initial test assertion lint failure remains archived and was corrected with a checked extension fixture and narrowly justified session identity fixtures.
  • Required ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2 passed on author head 973eb62 (20/20 checks in 343.9s vs bbd635e1d7). After a clean rebase onto 5748d11d0a (no upstream changes to these files), reviewer rerun passed 21/21 checks in 363.3s; an earlier reviewer run hit one unrelated load-flaky orca-runtime.test.ts case 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 and extension-tab-snapshot-fix.bundle.

@OrcaWin
OrcaWin force-pushed the OrcaWin/extension-tab-resolution-snapshot-independent branch from 973eb62 to 6771a32 Compare October 29, 2026 00:19
@OrcaWin
OrcaWin marked this pull request as ready for review October 29, 2026 00:19
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67e400b9-af6b-490c-b95f-3bfb97cbd7a0
Commits

Reviewing files that changed from the base of the PR and between ad50070 and 6771a32.

Files selected for processing: 3
  • src/main/browser/extensions/api/tabs.ts
  • src/main/browser/extensions/browser-extension-tab-model.ts
  • src/main/browser/extensions/browser-extension-tab-resolution.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable issues were found.

Summary

This PR reuses tab indices and the active-tab result within each synchronous enumeration.

  • Extension tab lists and queries reuse lookups within each call.

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

@OrcaWin
OrcaWin merged commit b510cd1 into main Oct 29, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant