Skip to content

[perf-remote] perf(renderer): make visibility GitHub refresh linear - #13711

Closed
nwparker wants to merge 1 commit into
mainfrom
nwparker/perf-remote-visibility-github-scan
Closed

nwparker wants to merge 1 commit into
mainfrom
nwparker/perf-remote-visibility-github-scan

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

Summary

  • Skip the window-return GitHub workspace scan when no visible PR or linked-issue surface needs it.
  • Avoid publishing a new Zustand state when focus-time cache cleanup makes no semantic change.
  • Build one first-match repo index for visible refreshes and carry the resolved repo through candidate construction and remote-owner routing.

ELI5

When Orca became visible again, it walked every workspace and repeatedly searched the full project list—even when the UI was not showing PR or issue data. With many projects and remote-host workspaces, that work grew quickly. Now Orca skips the walk when nothing visible needs it; otherwise it builds one lookup table and reuses it.

Performance evidence

For W workspaces and R repos:

  • Before: repeated array searches made the visibility refresh O(W × R).
  • After: one repo index plus one pass makes it O(W + R).
  • A deterministic 20-repo/20-workspace test eliminates all 40 prior linear .find() calls while preserving all 20 refresh enqueues.
  • A hidden-surface test asserts zero workspace-catalog reads and zero redundant store publications when caches are already stable.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — 49,472 passed / 101 skipped; the only failed suite is the pre-existing unpinned cross-version harness trying to extract v799 from a missing staging checkout
  • pnpm build — not run; no build or packaging surface changed
  • Added high-quality traversal, publication-count, refresh-preservation, and owner-routing tests

Post-rebase focused suites: 193/193 passed.

AI Review Report

Adversarial review checked cache semantics, Zustand publication behavior, duplicate-ID ordering, local/SSH/runtime owner routing, concurrency, and mixed-version compatibility. No P0, P1, or P2 finding was proven.

The implementation preserves the old first-match behavior for corrupt duplicate repo IDs and retains cache eviction, comment clearing, and expired refresh-state pruning before the new early return.

Cross-platform review found no macOS, Linux, or Windows-specific behavior: no shortcuts, labels, paths, shells, native modules, filesystem operations, or Electron platform branches changed.

Security Audit

No input parsing, command execution, path handling, authentication, secrets, dependencies, IPC/RPC schemas, protocol frames, persistence, or network endpoints changed. The change only removes redundant renderer traversal/publication and reuses already-resolved repo objects.

Notes

This directly targets renderer work triggered when Orca returns to the foreground. Remote hosts amplify the cost because they add projects and workspaces, but local and SSH-owned repos retain identical routing behavior.

Residual risk: performance evidence is deterministic operation counting rather than a packaged renderer wall-clock profile.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 38902057-cc32-4e8c-8b02-71cb4ba6692e

📥 Commits

Reviewing files that changed from the base of the PR and between 96c2ceb and 14d496e.

📒 Files selected for processing (2)
  • src/renderer/src/store/slices/github.test.ts
  • src/renderer/src/store/slices/github.ts

📝 Walkthrough

Walkthrough

refreshAllGitHub now skips work when no PR or issue surface is visible, clears comment caches only when populated, and preserves unchanged cache references. It indexes repositories by ID and reuses resolved repositories during stale PR candidate construction and runtime targeting. Tests cover skipped refreshes, conditional cache clearing, state publication, repository lookup reuse, and visible workspace PR refreshes.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making the renderer GitHub visibility refresh linear.
Description check ✅ Passed The description covers the required sections, explains skipped checks and the pre-existing test failure, and documents testing, review, security, and platform considerations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

nwparker added a commit that referenced this pull request Aug 11, 2026
…changed

Every eviction helper already returns its input reference untouched when it
evicts nothing, so the opening sweep in refreshAllGitHub can compare identities
and return the previous state. Window resume then stops waking every store
subscriber on a no-op sweep.

Folds in the remaining unique optimization from #13711, which this PR
supersedes on the lookup-indexing side.

Co-authored-by: Orca <[email protected]>
nwparker added a commit that referenced this pull request Aug 11, 2026
* perf(renderer): index GitHub resume lookups

* perf(renderer): skip the resume cache sweep publication when nothing changed

Every eviction helper already returns its input reference untouched when it
evicts nothing, so the opening sweep in refreshAllGitHub can compare identities
and return the previous state. Window resume then stops waking every store
subscriber on a no-op sweep.

Folds in the remaining unique optimization from #13711, which this PR
supersedes on the lookup-indexing side.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor Author

Closing in favor of #13698 (merged as b44df2e), which supersedes this — with this PR's unique optimization folded in, so nothing here is lost.

I cross-applied both PRs' test suites against each other's implementation. Both carry the identical if (!shouldRefreshPRs && !shouldRefreshIssues) return early exit, but beyond that they fixed disjoint halves:

  • This PR de-duplicated lookups only within refreshAllGitHub. It left fetchPRForBranch and findRepoForGitHubOwner untouched, so each of the N dispatched fetches still re-scanned all N repos. Doubling repoCount 128 → 256 grew identity reads 51,072 → 200,448 — 3.9x for a 2x input, i.e. still quadratic on the dispatch path. perf(renderer): index GitHub resume lookups #13698 routes both through a shared index and fixes that.
  • Conversely, perf(renderer): index GitHub resume lookups #13698 lacked this PR's identity-compare on the opening cache sweep, so a no-op sweep still allocated a fresh snapshot and woke every zustand subscriber on window resume.

That guard plus this PR's two publication tests were ported onto #13698 in 5408439 before merge, verified by publishes no store update when the cache sweep changes nothing and still clears populated comments when no workspace refresh is needed.

Credit for the skip-publish insight and the hidden-surface early return belongs to this PR.

@nwparker nwparker closed this Aug 11, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* perf(renderer): index GitHub resume lookups

* perf(renderer): skip the resume cache sweep publication when nothing changed

Every eviction helper already returns its input reference untouched when it
evicts nothing, so the opening sweep in refreshAllGitHub can compare identities
and return the previous state. Window resume then stops waking every store
subscriber on a no-op sweep.

Folds in the remaining unique optimization from stablyai#13711, which this PR
supersedes on the lookup-indexing side.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Orca <[email protected]>
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