You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(wsl): fold a connect's remaining read-only guest probes - #35690
When a WSL distro restarts and a terminal opens, the host still asks the distro several small questions one at a time. Each question is a round trip through wsl.exe. This PR asks three groups of those questions in one go each, so a restart makes four fewer round trips. SSH hosts are not changed.
What Changed
Three folds, all on the WSL path only:
The lock holder's identity is read with the connect snapshot.
Before: when orcad.lock named a pid, adoption made a second exec to read the distro's boot id and that process's start ticks, to check whether the lock's owner is still alive.
Adoption's re-check under the fence still reads both the lock and the identity from the host.
The cached-runtime and complete-slot checks are one exec.
Before: the deploy asked "is the pinned Node runtime cached?" and then "is this version's slot complete?" in two execs.
After: under the existing WSL-only recordedNodeRuntimeProbe option, one exec asks both. The install is skipped only when both say yes, which is exactly where the separate checks return. Any other answer, or a failed exec, runs the separate checks as before.
The post-launch reads are one exec.
Before: after launch, the WSL connect read liveness, then readiness, then the pid file, in three execs.
After: one exec reads all three. The answers are judged by the same functions, now assertActiveOrcadLive and activeOrcadReadinessFromOutput, which SSH's probeActiveOrcadReadiness keeps calling with its two separate reads.
An answer of any other shape is reported as unverifiable, never as exited.
The lane now restarts each distro family five times instead of three, so the ms medians are steadier. The round-trip counts (preLaunchCommands, postReadinessCommands) are exact either way.
The E1 tests of wsl-orcad-deploy.test.ts moved, unchanged, to wsl-orcad-deploy-app-update.test.ts, because the original file had reached its line cap.
Why
Each guest exec costs a round trip through the stdio bridge, about 10–45 ms on the lane. After #35591, a same-version restart still made 15 pre-launch and 3 post-launch round trips. Folding read-only questions into commands that already run removes four of them without adding any.
None of these folds changes a decision: each skips a read only where the separate reads would have reached the same answer. The fenced steps (activation fence acquire, record re-read, launch) are untouched here. They come in the next PR.
Flag-off: the WSL host path only runs with ORCA_INTERNAL_WSL_HOSTS set; with it unset nothing here runs. SSH sends exactly the same commands; a test pins the SSH readiness probe's two commands, and the combined slot probe is never sent without the WSL option.
User-risk: low. Every fold falls back to the previous separate reads on any unexpected answer, and liveness failures keep their exited or unverifiable verdicts.
Linked Issue
N/A (internal performance work: folds A and C of the WSL cold-start plan).
Visual Proof
N/A: guest command batching, no UI.
Testing
New wsl-orcad-active-probe.test.ts:
one exec in liveness, readiness, pid order;
DEAD, UNKNOWN and wrong-build answers judged as the separate probes judge them;
an answer of another shape is unverifiable;
the SSH probe's two commands are byte for byte unchanged.
New orcad-remote-install-cached-probe.test.ts:
the install is skipped only when both answers say so;
failures and Windows hosts fall back;
without the option (SSH) the combined probe is never sent.
wsl-orcad-connect-state-snapshot.test.ts:
the holder identity is attached only when it parses;
a Linux-only test reads a real /proc identity for a live pid in the same command.
wsl-orcad-instance-adoption.test.ts: the snapshot's identity is used only for the matching pid, and a mismatched pid makes adoption ask the guest.
All 23 test files that cover context, recovery, adoption, deploy, install and readiness for SSH and WSL pass. pnpm tc, pnpm run typecheck:ci, the changed-code quality gate, anti-slop oxlint and oxlint all pass.
The lane re-measures round-trip counts and ms per family 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
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
SSH: command sequences unchanged.
Wire: no change.
E9: no new background path; every fold rides an exec that already runs on the connect, under its signal.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
The reason will be displayed to describe this comment to others. Learn more.
Bad lock paths stall connections
The new sed read bypasses the file checks immediately above it. If orcad.lock is a named pipe (FIFO), the earlier read reports UNREADABLE, but sed then waits for a writer until the command times out. Oversized files also reach sed without the size limit.
Extract the PID from the already checked lock contents instead of reopening the path.
The change adds a combined cached-install probe and uses it to skip separate checks when both runtime readiness and install completion are confirmed. WSL snapshots now include parsed lock-holder identity, and WSL active probing combines liveness, readiness, and PID reads. Deployment uses the returned readiness and reuses the PID when its version matches. The update also expands restart measurements in an idle-release test.
Priority: Low
Merge Risk: Low · previous review 22aba
The expanded WSL restart test may time out on a slow runner even when the restarts succeed. Adjust its timeout or confirm sufficient margin before merging.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly identifies the WSL performance change: combining remaining read-only guest probes into fewer executions.
Description check
The description is complete and covers the user impact, three implementation changes, rationale, fallback behavior, scope, testing, and checklist status. It also explains why no visual proof or linked…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description is complete and covers the user impact, three implementation changes, rationale, fallback behavior, scope, testing, and checklist status. It also explains why no visual proof or linked issue applies to this internal performance change.
Full details: Docstring Coverage
Explanation
Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 17 functions across 16 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 2
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
⚔️ Resolve merge conflicts: 💡
Resolve merge conflict in branch nwparker/wsl-connect-probe-fold
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Keep the restart timeout proportional to the run count.
RESTART_RUNS increases the measured pairs from three to five. distroRestartBaseline now performs ten measured restarts, one warm-up restart, and one profiled restart. The test timeout remains 24 minutes. Repeated slow-but-successful restarts can consume that timeout before the workflow’s 30-minute step timeout.
Derive the timeout from RESTART_RUNS, or measure the complete sequence and retain sufficient margin.
Three folds, each WSL-only:
- the connect snapshot also reads the lock holder's guest identity, so
adoption's liveness check needs no second exec for that pid;
- one exec asks whether the pinned runtime is cached and the slot complete,
under the existing WSL-only recordedNodeRuntimeProbe option;
- the active slot's liveness, readiness and pid are read in one exec after
launch, judged by the same functions SSH's separate probes use.
SSH sends exactly the commands it did. The lane now restarts five times per
family so round-trip counts and ms medians are both readable.
…op byte budget
It is sent only on WSL (wsl.exe argv, never SSH-framed), so like the bash
stdio bridge it carries a measured ceiling above the SSH budget.
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
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 a terminal opens, the host still asks the distro several small questions one at a time. Each question is a round trip through
wsl.exe. This PR asks three groups of those questions in one go each, so a restart makes four fewer round trips. SSH hosts are not changed.What Changed
Three folds, all on the WSL path only:
orcad.locknamed a pid, adoption made a second exec to read the distro's boot id and that process's start ticks, to check whether the lock's owner is still alive.recordedNodeRuntimeProbeoption, one exec asks both. The install is skipped only when both say yes, which is exactly where the separate checks return. Any other answer, or a failed exec, runs the separate checks as before.assertActiveOrcadLiveandactiveOrcadReadinessFromOutput, which SSH'sprobeActiveOrcadReadinesskeeps calling with its two separate reads.The lane now restarts each distro family five times instead of three, so the ms medians are steadier. The round-trip counts (
preLaunchCommands,postReadinessCommands) are exact either way.The E1 tests of
wsl-orcad-deploy.test.tsmoved, unchanged, towsl-orcad-deploy-app-update.test.ts, because the original file had reached its line cap.Why
Each guest exec costs a round trip through the stdio bridge, about 10–45 ms on the lane. After #35591, a same-version restart still made 15 pre-launch and 3 post-launch round trips. Folding read-only questions into commands that already run removes four of them without adding any.
None of these folds changes a decision: each skips a read only where the separate reads would have reached the same answer. The fenced steps (activation fence acquire, record re-read, launch) are untouched here. They come in the next PR.
Flag-off: the WSL host path only runs with ORCA_INTERNAL_WSL_HOSTS set; with it unset nothing here runs. SSH sends exactly the same commands; a test pins the SSH readiness probe's two commands, and the combined slot probe is never sent without the WSL option.
User-risk: low. Every fold falls back to the previous separate reads on any unexpected answer, and liveness failures keep their exited or unverifiable verdicts.
Linked Issue
N/A (internal performance work: folds A and C of the WSL cold-start plan).
Visual Proof
N/A: guest command batching, no UI.
Testing
New
wsl-orcad-active-probe.test.ts:New
orcad-remote-install-cached-probe.test.ts:wsl-orcad-connect-state-snapshot.test.ts:/procidentity for a live pid in the same command.wsl-orcad-instance-adoption.test.ts: the snapshot's identity is used only for the matching pid, and a mismatched pid makes adoption ask the guest.All 23 test files that cover context, recovery, adoption, deploy, install and readiness for SSH and WSL pass.
pnpm tc,pnpm run typecheck:ci, the changed-code quality gate, anti-slop oxlint and oxlint all pass.The lane re-measures round-trip counts and ms per family 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)