Repository navigation
[Perf-LH] Stop re-probing ordinary workspace folders every poll - #13437
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe worktree base poller now supports configurable pending 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Summary
This PR stops Orca from repeatedly asking the operating system whether long-lived ordinary workspace folders contain a
.gitmarker.A
.gitmarker is the file or directory Git puts at the root of a repository or worktree. Orca watches for that marker so it can notice worktrees created outside the app.The poller already had two intended modes:
The bug was that each full scan forgot which directories had already exhausted the fast window. It removed an expired directory from the pending map, then a later full scan saw the same marker-less directory and added it back as “new.” In steady state, ordinary folders therefore received
.gitfilesystem probes on 95.33% of visible poll cycles.New state transitions
.git<directory>/.giton non-backstop cyclesnull(“backstop only”).gitThe implementation uses one map instead of a pending map plus a second collection. A numeric value means “still in the fast window”;
nullmeans “only inspect this path during a full backstop scan.”The regression test covers all three important behaviors:
.gitmarker created much later is still detected by a backstop scan;Benchmark
Harness:
node config/scripts/worktree-base-pending-marker-benchmark.mjsThe harness imports the real production poller, creates 64 ordinary directories with no
.gitmarker, accelerates the poll interval to zero, and records real calls tofs.promises.statfor those 64 marker paths. It runs 900 visible poll cycles and treats the final 300 as the steady-state window.Both arms used the same harness and fixture. The only switched input was the poller implementation:
f3ea376b6b26, poller blob2f65e0fc28219488aeeb385f49532f4475553b3bb5076c2ed7ffe326a5286af327c4a960e0b24ecf.gitmarker stats across 900 cyclesThe after value, 0.0667, is the expected backstop floor: one full scan every 15 cycles. The total-run reduction is smaller because the benchmark intentionally includes the initial fast-probe window.
The benchmark also prints elapsed wall time as a diagnostic, but this PR does not claim a wall-time speedup from that number. A zero-delay timer is useful for reproducing syscall counts quickly, but its scheduling overhead is not representative of the production two-second cadence. The deterministic filesystem-operation count is the performance claim.
Screenshots
No visual change.
Testing
pnpm lint— full repository lint was not run;pnpm run check:code-quality:changedpassed with 0 new standard, type-aware, or React Doctor findings across all 3 changed files.pnpm typecheck— the affected Node target passed withpnpm run typecheck:node; CLI and web targets are untouched.pnpm test— the complete repository suite was not run; the detected-worktree reliability group passed 177/177 tests across 7 files.pnpm build— not run; this does not change packaging, native modules, renderer code, or build configuration.Additional checks:
pnpm run check:max-lines-ratchet: passed with no new bypasses.pnpm run check:reliability-gates: reliability manifest passed for all 73 gates.git diff --check: passed.AI Review Report
The final review traced each marker state from initial discovery through expiry, periodic scanning, marker creation, deletion, recreation, hidden-window parking, and unsubscribe cleanup.
The first review found that the initial two-collection implementation pushed the production file over the repository’s 300-line limit. No lint disable or limit increase was added. The implementation was simplified to one nullable map, and the max-lines gate now passes.
The review also flagged that a test using the production 300-cycle cooldown would need roughly 660 zero-delay timer turns and could be slower on heavily loaded Windows CI. The test now uses an explicit test-only 30-cycle window while production keeps the unchanged 300-cycle value. It exercises the same expiry and backstop boundaries in fewer timer turns.
A final independent review found no remaining actionable issues. It explicitly checked:
.gitdiscovery;No keyboard shortcut, shortcut label, shell invocation, or Electron platform-specific behavior changed. Existing
path.joinhandling remains the only path construction used for marker paths.Security Audit
This is a reduction in existing filesystem reads and does not add a new authority boundary.
<candidate>/.gitpaths as before, using the existingpath.joinandstatfunctions. It performs fewer checks after cooldown.No security follow-up is required.
Notes
The deliberate tradeoff is narrow: if a directory has remained marker-less beyond the roughly ten-minute fast window and someone later adds
.gitinside that same still-existing directory, detection can take until the next full scan—up to roughly 30 seconds while the window is visible—instead of the next two-second fast poll. Normal worktree creation is unaffected because Git creates the marker during directory creation, well inside the fast window. If the old directory is observed disappearing first, recreating that path starts a fresh fast window.Scope is intentionally limited:
provider.watch;git-commontargets continue to use their separate watcher;