Repository navigation
Prevent continuous git status scanning in large repositories - #8005
Conversation
On repos where `git status --untracked-files=all` takes tens of seconds, the background status poll restarted a fresh scan 3s after the previous one finished, keeping a git process at high CPU almost continuously while the workspace sat idle (#7983). The coalesced poll runner now paces reruns by the previous run's duration, split by trigger class: - Evidence-free timer ticks wait 5x the last refresh duration (capped at 5 minutes), bounding idle polling to ~1/6 duty cycle. - Change signals (file-watch events, repo metadata pushes, finished terminal commands, window reveal after hidden) wait only 1x, so real changes in a slow repo still surface promptly; a change signal can pull an already-scheduled tick run earlier, and the strongest pending trigger wins for trailing reruns. - Backoff-deferred scans are skipped while the window is hidden; the becoming-visible run catches up on the short lane. Fast repos keep the exact 3s cadence (the multiplier never drops the gap below the existing floor), and user-triggered refreshes are unaffected (they bypass the poll runner). The stale-conflict poll gets the same pacing, which also spaces slow remote SSH probe chains. Fixes #7983
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughCoalesced polling now accepts trigger metadata and applies duration-based, capped backoff with separate timer and change-signal behavior. Visibility intervals can invoke a dedicated callback when the window becomes visible while retaining normal interval ticks. Git-status polling uses these capabilities to skip hidden-window work, route file-watch, push, visibility, and stale-conflict refreshes through change-signal triggers, and apply shared slow-task backoff settings. Tests cover scheduling, rescheduling, pacing, and visibility behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/right-sidebar/useGitStatusPolling.ts (1)
231-267: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winAdd visibility check to
pollStalefor consistency withrunFetchStatus.
runFetchStatusearly-returns when!isWindowVisible()to skip backoff-deferred runs that fire after the window hides.pollStalelacks this guard. A trailing run from the coalesced runner can fire while hidden (e.g., interval tick captured mid-flight → window hides → task completes → trailing timeout fires), executinggetRuntimeGitConflictOperationSSH/RPC work nobody can see. The PR objective states hidden-window backoff scans should be skipped.🛡️ Proposed fix
const pollStale = async (): Promise<void> => { + // Why: a backoff-deferred run can fire long after the window hides; skip + // the probe instead of running SSH/RPC work nobody can see. The + // becoming-visible run catches up via the change-signal lane. + if (!isWindowVisible()) { + return + } for (const { id, path } of staleConflictWorktrees) {
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bdb25978-e3f4-44b4-97be-44269968c68f
📒 Files selected for processing (5)
src/renderer/src/components/right-sidebar/coalesced-poll-runner.test.tssrc/renderer/src/components/right-sidebar/coalesced-poll-runner.tssrc/renderer/src/components/right-sidebar/useGitStatusPolling.tssrc/renderer/src/lib/window-visibility-interval.test.tssrc/renderer/src/lib/window-visibility-interval.ts
…i#8005) * Prevent continuous git status scanning in large repositories On repos where `git status --untracked-files=all` takes tens of seconds, the background status poll restarted a fresh scan 3s after the previous one finished, keeping a git process at high CPU almost continuously while the workspace sat idle (stablyai#7983). The coalesced poll runner now paces reruns by the previous run's duration, split by trigger class: - Evidence-free timer ticks wait 5x the last refresh duration (capped at 5 minutes), bounding idle polling to ~1/6 duty cycle. - Change signals (file-watch events, repo metadata pushes, finished terminal commands, window reveal after hidden) wait only 1x, so real changes in a slow repo still surface promptly; a change signal can pull an already-scheduled tick run earlier, and the strongest pending trigger wins for trailing reruns. - Backoff-deferred scans are skipped while the window is hidden; the becoming-visible run catches up on the short lane. Fast repos keep the exact 3s cadence (the multiplier never drops the gap below the existing floor), and user-triggered refreshes are unaffected (they bypass the poll runner). The stale-conflict poll gets the same pacing, which also spaces slow remote SSH probe chains. Fixes stablyai#7983 * Skip hidden-window stale-conflict probes like the status poll --------- Co-authored-by: Brennan Benson <[email protected]>
Fixes #7983
What changes
On repositories where a background
git status --untracked-files=allscan takes tens of seconds, Orca no longer restarts the next scan 3 seconds after the previous one finishes. The background poll now paces itself by how long the previous refresh actually took, so an idle workspace on a large monorepo drops from a near-continuous git process (~92% duty cycle) to roughly 1/6 duty, and the pacing is capped at 5 minutes so status can never go indefinitely stale.Refresh triggers are split into two lanes in the coalesced poll runner:
Additionally, a backoff-deferred scan that comes due while the window is hidden is skipped instead of burning tens of seconds of git work nobody can see; the becoming-visible run catches up on the short lane. The stale-conflict badge poll gets the same pacing, which also spaces slow remote SSH probe chains.
What does not change
--untracked-files=alloutput and sidebar behavior are identical.Validation
coalesced-poll-runner.tsto HEAD fails 6 of 11 runner tests; all 27 tests across the runner,useGitStatusPolling, andwindow-visibility-intervalpass with the fix.tsgotypecheck andoxlintclean.Review
Two independent review passes (an architecture/state-machine lane and a reproduction lane that re-ran the tests against the reverted implementation) plus a dedicated performance audit returned no actionable findings.