Skip to content

perf: coalesce SSH git status reads - #11696

Merged
nwparker merged 2 commits into
mainfrom
nwparker/perf-coalesce-ssh-status
Aug 15, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/perf-coalesce-ssh-status

Conversation

@nwparker

@nwparker nwparker commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 +317 −22 +295
Prod 1 +89 −90 −1

Summary

Coalesce concurrent SSH Git status reads across callers with distinct cancellation signals.

Each caller gets an independent lease over one client-side git.status RPC. The RPC aborts only after its final live lease cancels, and SSH mutations fence status joins before and after execution. Leases are in-flight only — the entry is deleted on settle, so there is no result cache and no stale-badge failure mode.

The focused concurrency test measures 10 concurrent, separately signalled status calls collapsing to 1 SSH git.status RPC.

Fork-point key fix

The original revision of this PR had a defect that merged textually clean: the git.status request payload carries branchLineTotalMergeBase, but the lease key did not hash it. Two real callers disagree on that field — git-status-refresh.ts:121-138 (automatic poll) and :250-267 (strict user-triggered refresh) each read the gate independently — so a refresh asking for the branch-line total could join an in-flight poll that omitted it and render a response with no branchLineTotal, blanking the branch-header chip. After a commit moved the merge base, a refresh with the new base could also join an in-flight read using the old one and show a pre-commit number.

The key now includes the fork point, mirroring the guard already on the local path (src/main/git/status.ts:249-251, whose inline comment warns about exactly this).

Rebase notes

Mutation fencing

runWithGitReadInvalidation fences a strict superset of what main fenced as runWithDiffDedupeClear: all 16 of main's methods, plus stageFile, unstageFile, discardChanges, bulkStageFiles, bulkUnstageFiles, and bulkDiscardChanges — the mutations that change status output and therefore must not be joinable across a write.

Screenshots

No visual change.

Testing

  • pnpm typecheck (all three tsconfigs: node, cli, web)
  • Targeted Vitest: src/main/providers + src/main/git — 2,459 passed, 6 skipped
  • pnpm check:max-lines-ratchet, pnpm check:reliability-gates
  • Targeted oxlint + oxfmt
  • Added or updated high-quality tests that would catch regressions

The new fork-point test was verified non-vacuous: it fails against the source without the key fix (× isolates status reads by branch-line-total fork point) and passes with it.

Remote / cross-platform review

No new RPC method, payload field, command, path, authentication, secret, dependency, or persistence surface. The lease always passes a provider-owned shared AbortSignal to mux.request, but that only registers a local abort listener (ssh-channel-multiplexer.ts:277) — nothing goes on the wire and no relay upgrade is required, so mixed client/host versions are unaffected. No Git commands or options change, so the Git 2.25 floor is untouched. Lease state is scoped to one SshGitProvider instance and removed after settlement or invalidation.

Known residual: the key does not normalize Windows path casing, so two callers using different casing for the same worktree perform separate reads. That costs a duplicate read, never a wrong result, and matches the local path's existing behavior.

Notes

This is the third focused extraction from draft PR #11539.

@nwparker nwparker mentioned this pull request Jul 31, 2026
3 of 5 tasks
@nwparker
nwparker force-pushed the nwparker/perf-coalesce-ssh-status branch from 987a3d7 to b212c0b Compare August 15, 2026 09:08
@nwparker
nwparker marked this pull request as ready for review August 15, 2026 09:08
@nwparker
nwparker requested a review from brennanb2025 as a code owner August 15, 2026 09:08
@nwparker
nwparker changed the base branch from nwparker/perf-coalesce-git-status to main August 15, 2026 09:08
@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown

Too many files changed for review (1900 files, 100 file limit).

@nwparker

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and retargeted the base from nwparker/perf-coalesce-git-status (parent #11691, since merged) to main.

Correctness fix on top of the original change: the git.status request payload carries branchLineTotalMergeBase, but the lease key did not. A strict user-triggered refresh that asked for the branch-line total could join an in-flight automatic poll that omitted it — blanking the branch-header chip — or reuse a pre-commit fork point. The key now includes it, mirroring the guard already on the local path in git/status.ts:249-251.

Tests were carried across #14728's test-file split: the lease tests now live in ssh-git-provider-status-lease.test.ts, and the { signal: expect.any(AbortSignal) } assertion updates were applied to ssh-git-provider-status.test.ts and ssh-git-provider-worktree.test.ts. The env-gated benchmark test was dropped. Verified the new fork-point test fails without the key fix and passes with it.

Note: #11697 is stacked on this branch and will need rebasing/retargeting once this merges.

@nwparker nwparker closed this Aug 15, 2026
@nwparker nwparker reopened this Aug 15, 2026
The request payload carries branchLineTotalMergeBase but the lease key did
not, so a strict refresh asking for the total could join an in-flight poll
that omitted it (blanking the branch-header chip) or reuse a pre-commit
fork point. Mirrors the guard already on the local path in git/status.ts.
@nwparker
nwparker force-pushed the nwparker/perf-coalesce-ssh-status branch from b212c0b to 8474df1 Compare August 15, 2026 10:14
@coderabbitai

coderabbitai Bot commented Aug 15, 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: 6845ec2b-fa37-4d43-9752-feae315411b3

📥 Commits

Reviewing files that changed from the base of the PR and between 931cb03 and 8474df1.

📒 Files selected for processing (4)
  • src/main/providers/ssh-git-provider-status-lease.test.ts
  • src/main/providers/ssh-git-provider-status.test.ts
  • src/main/providers/ssh-git-provider-worktree.test.ts
  • src/main/providers/ssh-git-provider.ts

📝 Walkthrough

Walkthrough

SshGitProvider now shares keyed status requests through abort-aware leases. Caller cancellation is isolated, and the underlying RPC stops after the final lease aborts. Status requests include derived AbortSignal options. A unified invalidation wrapper clears diff and status read state before and after Git mutations, including clone and repository-mutating exec calls. Tests cover lease behavior, request-key isolation, mutation boundaries, and signal propagation.

Merge Risk: ⚪ Minimal · up to 8474d

The change coalesces concurrent SSH Git status reads while preserving cancellation, mutation fencing, and fork-point correctness; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the implementation, rationale, testing, and compatibility impact, but omits several required template sections and leaves the linked issue incomplete. Add the ELI5, Why, Linked Issue with an issue number, Review, Checklist, AI Disclosure, and Author sections; use the required N/A visual-proof format.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: coalescing concurrent SSH Git status reads.
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
nwparker merged commit e919f48 into main Aug 15, 2026
45 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* perf: coalesce SSH git status reads

* fix(ssh): key status leases by branch-line-total fork point

The request payload carries branchLineTotalMergeBase but the lease key did
not, so a strict refresh asking for the total could join an in-flight poll
that omitted it (blanking the branch-header chip) or reuse a pre-commit
fork point. Mirrors the guard already on the local path in git/status.ts.
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