Repository navigation
perf(wsl): take one activation fence on a same-version connect - #35708
Merged
Merged
Conversation
A same-version WSL connect fenced twice: the deploy took the activation fence only to read that the version was already active, released it, and the wake took it again to start the stopped slot. Now the deploy skips its fence for that case (WSL-only, when the connect snapshot saw the fence open), and one wake fence re-reads the record, checks liveness and starts the slot under its owner guard. Another version active by then, or a busy fence, runs the full deploy and wake as before. SSH is unchanged.
Contributor
|
Warning Review limit reachedYou'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 4 minutes. View limit details
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 |
[Medium impact] The PR appears safe to merge; no actionable new issue was found. SummarySame-version WSL connects can confirm the active version and start its stopped server under one activation fence.
|
…aim it The one-fence wake recorded its own token over an earlier interrupted wake's, so the full wake could no longer prove that fence its own and the host stayed fenced until stale recovery. With an interrupted wake on record, the one-fence path now answers 'fenced' and the full wake runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When a WSL distro restarts and you reconnect on the same Orca version, the host takes a lock on the distro twice. The first time is only to read "this version is already active". The second time is to start the server. Each lock costs several round trips into the distro. Now one lock does both jobs. Any case that isn't plain "same version, nothing else going on" still takes the old two-lock path.
What Changed
The lock is the activation fence: a directory inside the distro that serialises updates and starts.
deployOrcadacquired the fence, re-readorcad-active.json, saw "already active", and released the fence.wakeStoppedManagedOrcadthen re-read the record, checked liveness, probed the fence, and acquired it again to start the stopped slot, then released it.deployOrcadtakes a new WSL-only option,sameVersionFencedByCaller. With it, once the slot is confirmed installed, a deploy whose pre-read record already names this version returns "already active" without taking the fence. The caller promises the decision is re-checked under a fence. The option is dropped on the cleared-fence retry, likepreRead.wakeExpectedOrcadUnderOneFenceinorcad-managed-wake.tstakes one fence. Under it, it re-reads the record, checks the slot's liveness, and starts the slot if proven stopped. It uses the same per-host queue and interrupted-wake token bookkeeping aswakeStoppedManagedOrcad.replan.fenced.deployWslOrcadWithOneFenceruns the full deploy and wake, without hints.readRestoredRecordmoved unchanged intowsl-orcad-update-admission.ts, asreadRestoredWslOrcadRecord, to keepwsl-orcad-deploy.tsunder its line cap.Why
The first fence decided nothing the second fence doesn't re-check. Merging them removes one acquire, one release, the deploy's fenced record read, and the wake's three pre-fence reads. That is about six round trips per same-version restart.
The launch still happens only under a held fence, after a fenced record re-read and liveness check. We kept the rule that nothing launches before the fence: no speculative launch.
I chose to skip the deploy's fence rather than move the wake into
deployOrcad. That keeps SSH's deploy untouched, and confines the new behaviour to one opt-in option and one new function.Flag-off: the WSL host path only runs with ORCA_INTERNAL_WSL_HOSTS set; with it unset nothing here runs. SSH never sets the option and never calls the new wake, so its commands are unchanged.
User-risk: moderate code area (activation fence), low behaviour risk. Every decision and the launch stay under the guarded fence. Anything unexpected falls back to the existing two-fence path.
Linked Issue
N/A (internal performance work: fold B of the WSL cold-start plan).
Visual Proof
N/A: no UI.
Testing
New
orcad-managed-wake-one-fence.test.ts(fake host, with exclusive mkdir) pins the invariants:replan, no launch;serving, no launch;fenced, the other owner's fence untouched;Other tests:
orcad-activation-crash-recovery.test.ts:New
wsl-orcad-one-fence-deploy.test.ts:replanandfencedfall back to the full deploy without hints;All 22 test files that cover deploy, wake, admission and the WSL connect pass.
pnpm tc,pnpm run typecheck:ci, the changed-code quality gate, anti-slop oxlint and oxlint all pass.The lane run on this PR re-measures pre-launch round trips and ms per family.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)