Repository navigation
perf(wsl): read a connect's pre-fence activation state in one command - #35591
Conversation
A WSL connect read the activation record, the transaction journal, the activation fence and orcad's instance lock in separate guest commands, some of them twice, before taking the fence. Read them once, alongside the record the context already read, and hand that snapshot to recovery, adoption and the deploy's pre-upload checks as a hint. A hint only skips a read whose answer would let the step continue unchanged; anything else, and every fenced decision, still reads the host. SSH passes nothing.
|
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 16 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] This PR appears safe to merge; the saved answers do not replace the checks required before changing the host. SummaryThis PR batches WSL’s initial activation checks into one guest command.
No actionable issues were found. Tests were reviewed but not run.
|
|
STATUS: lane re-measure. Run 40803604529 at head d1bd812 is green on all three distros. Pre-launch guest commands per restart went from 20 to 15 on every distro. This is compared with #35530's run 40797934871 (medians of 3). The five reads removed are:
The millisecond changes are within runner noise; even the bare |
ELI5
Before the WSL host starts, Orca checks a few files inside the distro: what version is active, whether an update was interrupted, whether another Orca holds the update lock, and whether an orcad is already running. Each check was a separate command into the distro, and some ran twice. Now one command reads all of them. Later steps use the answers only to skip a check whose answer was "nothing going on". Anything else is re-checked as before.
What Changed
orcad-active.json;transaction.json, then probed the fence;orcad.lock;orcad-active.jsonand probed the fence again.The lane counted 20 pre-launch commands per restart.
orcad-active.jsonread, which the context already does, becomes one command. It reads the record, the journal, the fence and the instance lock (src/main/wsl/wsl-orcad-connect-state-snapshot.ts).orcad.lock. Its proof of liveness and its fenced re-check still read the host.Why
Each guest command costs a round trip through the stdio bridge, and those added up to roughly 270–600 ms per restart on the lane. Folding the reads into the command the context already makes removes about five round trips without adding one.
A hint only lets a step skip a read when the answer would have let it continue unchanged. So a stale hint can at worst delay a refusal until the fenced re-read. It can never authorise a step: every fenced decision is untouched.
I chose this over caching state across connects, which would trust answers from an earlier session, and over moving the checks under the fence, which would serialise every connect behind it.
Flag-off: the WSL host path only runs with ORCA_INTERNAL_WSL_HOSTS set; with it unset nothing here runs. SSH passes no snapshot and sends exactly the same commands as before.
User-risk: low. Wrong hints are bounded by the fenced re-reads; an unrecognised snapshot falls back to today's reads.
Linked Issue
N/A (internal performance work, batch (b) of the WSL cold-start plan).
Visual Proof
N/A: guest command batching, no UI.
Testing
New
wsl-orcad-connect-state-snapshot.test.tsruns the real command in/bin/shagainst a temporary home:orcad-activation-crash-recovery.test.ts: an idle snapshot sends no host commands, and any other answer still finds and commits an interrupted run.orcad-remote-deploy.test.ts: the snapshot removes exactly one record read and one fence probe, and a fence seen held is probed again.wsl-orcad-deploy.test.ts: the connect hands the snapshot to recovery, adoption and deploy, and with no snapshot the deploy gets no hint.All tests that cover the context, recovery, adoption and deploy for SSH and WSL pass.
pnpm tc,pnpm run typecheck:ci, the changed-code quality gate, anti-slop oxlint and oxlint pass.The lane re-measures pre-launch command count and time on this PR's run.
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)