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): hold the distro alongside the read-only context probes - #35037
When a WSL distro restarts, the WSL host has to start a small "holder" process that keeps the distro running. Before this PR it waited for the holder to finish (~110–130 ms on CI) and only then started reading basic facts from the distro (platform, home directory, libc). Those reads don't need the holder, so now both happen at the same time. The holder is still in place before anything can start Orca's server.
What Changed
deployAndLaunchWslOrcad now calls holdWslDistroWithContext (new wsl-orcad-held-context.ts). That function runs the uname -r WSL 1 check as before, then Promise.all([holder.ensureHeld, resolveOrcadRemoteContext]).
Recovery (recoverInterruptedOrcadActivation, which can launch an orcad), adoption, deploy and wake still run only after the holder resolves. If the holder fails, the connect fails before recovery, as before.
isWsl1KernelRelease moved to the new module along with its test. This keeps wsl-orcad-deploy.ts under the line cap.
The Windows registry GUID read now starts just before the kernel probe instead of right after the holder. It is a local read and is awaited much later.
Why
The #35005 lane breakdown puts the holder at 111 / 117 / 132 ms (ubuntu / debian / fedora medians). It sat in series with the four read-only context probes (~60–100 ms). I chose this shape over starting the holder alongside the boot (uname -r). Measured, that could save at most the holder's ~120 ms, well below the 300 ms bar. And while the distro is still booting, the holder's "is it running" check would poll wsl.exe --list --running several times, adding wsl.exe spawns on EDR-scored machines. Here the kernel probe has already started the distro, so the holder's first check succeeds and nothing extra is spawned.
Flag-off: no change. deployAndLaunchWslOrcad runs only for WSL hosts (ORCA_INTERNAL_WSL_HOSTS). User-risk: low. The holder is still acquired before anything may launch or wake orcad. The only change in order is that the read-only context probes no longer wait for it. The E9 no-boot path is unchanged: the manager's running gate still comes before the first spawn, and the deploy's second running check before a re-wake is untouched.
Linked Issue
Internal WSL-via-orcad tracker, D3 bar (restart → first usable prompt). Phase breakdown: #35005.
Visual Proof
N/A: no UI.
Testing
New: the context reads finish while the holder is still pending, and recovery doesn't start until the holder resolves (uname, hold-start, context, held, recover). A failing holder fails the connect with no recovery or deploy.
Existing ordering and WSL 1 refusal tests pass. The WSL 1 refusal still happens before any hold.
STATUS: ready. Head d02db23. Checks run: pnpm tc, typecheck:ci, the src/main/wsl suite (547 passed), code-quality:changed, anti-slop, ast-grep. Open question: none. The WSL2 lane will show the holder/context overlap in the #35005 phase receipt once that PR is in main.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: ba9f7f04-e111-4807-8366-76a1acef5835
Commits
Reviewing files that changed from the base of the PR and between a54e31b and df5845d.
Files selected for processing: 4
src/main/wsl/wsl-orcad-deploy.test.ts
src/main/wsl/wsl-orcad-deploy.ts
src/main/wsl/wsl-orcad-held-context.test.ts
src/main/wsl/wsl-orcad-held-context.ts
Walkthrough
The deployment flow now uses holdWslDistroWithContext to obtain the distro hold and remote context. The helper checks the kernel release and rejects WSL 1 with a conversion command. For supported releases, it runs context probes while the holder starts and aborts those probes if holding fails. Tests cover these outcomes and verify that deployment recovery waits for the holder to succeed.
Priority: Low
Merge Risk: Low · previous review a54e3
A failed WSL connection can still start its distro afterward. This is a narrow lifecycle issue that should be fixed before merge, though it does not block other connections.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% 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 "perf(wsl): hold the distro alongside the read-only context probes" matches the main change. The PR runs the distro holder in parallel with the read-only context probes, using the new holdWs…
Description check
The description follows the template. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Checklist, and Notes sections. It explains the mechanism, the reason for the chosen appro…
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: Title check
Explanation
The title "perf(wsl): hold the distro alongside the read-only context probes" matches the main change. The PR runs the distro holder in parallel with the read-only context probes, using the new holdWslDistroWithContext helper, instead of waiting for the holder first. The title is specific and concise, and it uses the conventional commit prefix.
Full details: Description check
Explanation
The description follows the template. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Checklist, and Notes sections. It explains the mechanism, the reason for the chosen approach over the alternatives, the flag-off and user-risk status, and the measured saving. Two gaps exist. The Linked Issue section names only an internal tracker and phase breakdown (#35005) and has no 'Fixes #' issue reference, even though the template says an issue must always be linked for outside contributors. The AI Disclosure and Review sections are missing and the 'Agent skill upstream boundary' check is not marked. The Testing section does not name the platforms actually tested (macOS, Linux, Windows, SSH), and the pnpm lint, typecheck, test, and build checkbox is unchecked.
Resolution
Mostly complete. For a stronger submission, link a real issue in the Linked Issue section (for example, 'Fixes #NNNN'), state which platforms were tested, and tick or explain the remaining checklist items. The AI Disclosure section is optional for internal contributors and can be left out. The agent skill boundary item should be ticked or explained.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% 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 2 functions across 4 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-holder-overlap
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.
STATUS: reviewer B's E9 fix is pushed. Head a54e31b.
What changed: the context probes now run under a child AbortController. It is linked to the connect's signal and aborted when ensureHeld rejects or when Promise.all rejects for any other reason.
New test: after the hold fails, the next probe exec is refused before it spawns, and nothing runs after the rejection. The test fails without the fix.
Checks run: pnpm tc, typecheck:ci, the src/main/wsl suite (554 passed), code-quality:changed, anti-slop, oxlint, ast-grep.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 86500d07-8431-4dc4-9854-91d3793cdf3c
Commits
Reviewing files that changed from the base of the PR and between 2459222 and a54e31b.
Files selected for processing: 4
src/main/wsl/wsl-orcad-deploy.test.ts
src/main/wsl/wsl-orcad-deploy.ts
src/main/wsl/wsl-orcad-held-context.test.ts
src/main/wsl/wsl-orcad-held-context.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Stability & Availability · Quick win
Supported by static analysis
Script executed:
sed -n '1,115p' src/main/wsl/wsl-distro-holder.ts
sed -n '225,335p' src/main/wsl/wsl-distro-holder.ts
sed -n '120,170p' src/main/wsl/wsl-orcad-deploy.ts
sed -n '1,115p' src/main/wsl/wsl-orcad-held-context.ts
Repository: stablyai/orca
Length of output: 14174
Script executed:
nl -ba src/main/wsl/wsl-distro-holder.ts | sed -n '200,330p'
nl -ba src/main/wsl/wsl-orcad-deploy.ts | sed -n '80,120p'
git show 2459222db1422d836524fffe7ca482d6a8319450:src/main/wsl/wsl-orcad-deploy.ts | nl -ba | sed -n '115,155p'
Repository: stablyai/orca
Length of output: 9879
Wait for the holder promise before propagating a context failure.
Promise.all can reject while ensureHeld(name) is still pending. The holder can then spawn after the failed connect has returned and the transport has been disposed. Await the holder promise before rethrowing the context error.
Do not release the holder here. ensureHeld can adopt an existing holder, and the previous sequential flow already retained a successful holder when context resolution failed.
This is a localized minor stability fix. It may delay the failed connect until the holder operation settles, but it prevents a new holder spawn after rejection without requiring cancellation or release.
The kernel probe has already started the distro, so the holder now runs alongside the four
read-only context reads instead of before them; it is still held before recovery, which may
launch orcad. No new wsl.exe spawns. The WSL 1 check and the parallel hold move to
wsl-orcad-held-context.ts.
# Conflicts:
# src/main/wsl/wsl-orcad-deploy.ts
A failed hold left the context probes running; after the deploy disposes its transport they fall
back to fresh wsl.exe execs, which could boot a distro that just went away (E9). The probes now
run under a child signal of the connect's, aborted on a hold failure or any other rejection.
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, the WSL host has to start a small "holder" process that keeps the distro running. Before this PR it waited for the holder to finish (~110–130 ms on CI) and only then started reading basic facts from the distro (platform, home directory, libc). Those reads don't need the holder, so now both happen at the same time. The holder is still in place before anything can start Orca's server.
What Changed
deployAndLaunchWslOrcadnow callsholdWslDistroWithContext(newwsl-orcad-held-context.ts). That function runs theuname -rWSL 1 check as before, thenPromise.all([holder.ensureHeld, resolveOrcadRemoteContext]).recoverInterruptedOrcadActivation, which can launch an orcad), adoption, deploy and wake still run only after the holder resolves. If the holder fails, the connect fails before recovery, as before.isWsl1KernelReleasemoved to the new module along with its test. This keepswsl-orcad-deploy.tsunder the line cap.Why
The #35005 lane breakdown puts the holder at 111 / 117 / 132 ms (ubuntu / debian / fedora medians). It sat in series with the four read-only context probes (~60–100 ms). I chose this shape over starting the holder alongside the boot (
uname -r). Measured, that could save at most the holder's ~120 ms, well below the 300 ms bar. And while the distro is still booting, the holder's "is it running" check would pollwsl.exe --list --runningseveral times, adding wsl.exe spawns on EDR-scored machines. Here the kernel probe has already started the distro, so the holder's first check succeeds and nothing extra is spawned.Flag-off: no change.
deployAndLaunchWslOrcadruns only for WSL hosts (ORCA_INTERNAL_WSL_HOSTS).User-risk: low. The holder is still acquired before anything may launch or wake orcad. The only change in order is that the read-only context probes no longer wait for it. The E9 no-boot path is unchanged: the manager's running gate still comes before the first spawn, and the deploy's second running check before a re-wake is untouched.
Linked Issue
Internal WSL-via-orcad tracker, D3 bar (restart → first usable prompt). Phase breakdown: #35005.
Visual Proof
N/A: no UI.
Testing
uname, hold-start, context, held, recover). A failing holder fails the connect with no recovery or deploy.src/main/wsl/suite: 547 passed.pnpm tc,typecheck:ci, code-quality, anti-slop and ast-grep pass locally.Status
Ready. Expected saving is roughly min(holder, context probes) ≈ 60–100 ms per connect.
Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (CI runs the rest)