Skip to content

perf(wsl): fold a connect's remaining read-only guest probes - #35690

Merged
nwparker merged 2 commits into
mainfrom
nwparker/wsl-connect-probe-fold
Oct 29, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/wsl-connect-probe-fold

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​913 $\color{#cf222e}{\Huge{\mathbf{−}}}$​504 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​409
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​264 $\color{#cf222e}{\Huge{\mathbf{−}}}$​40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​224

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:

  1. 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.
    • After: the one-command snapshot from perf(wsl): read a connect's pre-fence activation state in one command #35591 also reads that identity for the pid in the lock. Adoption uses it only when the snapshot's pid matches the pid it parsed from the lock. Otherwise it asks the guest as before.
    • Adoption's re-check under the fence still reads both the lock and the identity from the host.
  2. 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.
  3. 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)

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest change appears safe to merge; the earlier bad-lock-path issue remains non-blocking.

Findings

  1. P2 Bad lock paths stall connections ▶

Summary

This PR combines three groups of WSL guest reads to reduce connection round trips:

  • WSL checks liveness, readiness, and the pid in one guest call.
  • WSL can check the runtime and install slot with one guest call.
  • WSL reads the lock holder's identity with its connect snapshot.
  • App-update tests have their own file, and the WSL lane uses more restart runs.

Since the previous review, it adds byte-budget coverage for cachedOrcadSlotProbeCommand. No new actionable issues were found in that change.

Reviews (3) · Last reviewed commit: "test(managed-server): measure the cached..." · Reviewed by Greptile

const lock = quotePosixShell(paths.instanceLock)
// The pid as digits only; the parser drops the identity unless it matches the parsed lock.
const holderIdentity =
`orca_lock_pid=$(sed -n 's/.*"pid"[[:space:]]*:[[:space:]]*\\([0-9][0-9]*\\).*/\\1/p' ${lock} 2>/dev/null | head -n 1); ` +

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 3b3c4b4f-3f64-4d22-a0fe-e8df783bf801
Commits

Reviewing files that changed from the base of the PR and between 22aba3b and 4718e54.

Files selected for processing: 17
  • src/main/managed-server/install/orcad-remote-install-cached-probe.test.ts
  • src/main/managed-server/install/orcad-remote-install-cached-probe.ts
  • src/main/managed-server/install/orcad-remote-install.ts
  • src/main/managed-server/posix-host-op-byte-budget.test.ts
  • src/main/ssh/orcad-active-readiness.ts
  • src/main/wsl/wsl-guest-process-identity.ts
  • src/main/wsl/wsl-orcad-active-probe.test.ts
  • src/main/wsl/wsl-orcad-active-probe.ts
  • src/main/wsl/wsl-orcad-connect-state-snapshot.test.ts
  • src/main/wsl/wsl-orcad-connect-state-snapshot.ts
  • src/main/wsl/wsl-orcad-deploy-app-update.test.ts
  • src/main/wsl/wsl-orcad-deploy.test.ts
  • src/main/wsl/wsl-orcad-deploy.ts
  • src/main/wsl/wsl-orcad-instance-adoption.test.ts
  • src/main/wsl/wsl-orcad-instance-adoption.ts
  • src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts
  • src/main/wsl/wsl-orcad-update-move-hold-driver.test.ts
Walkthrough

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the WSL performance change: combining remaining read-only guest probes into fewer executions.
Description check Passed 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 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.
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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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: e818f380-d012-4fa9-8eb7-066dd01a1650
Commits

Reviewing files that changed from the base of the PR and between a7ec7d1 and 22aba3b.

Files selected for processing: 16
  • src/main/managed-server/install/orcad-remote-install-cached-probe.test.ts
  • src/main/managed-server/install/orcad-remote-install-cached-probe.ts
  • src/main/managed-server/install/orcad-remote-install.ts
  • src/main/ssh/orcad-active-readiness.ts
  • src/main/wsl/wsl-guest-process-identity.ts
  • src/main/wsl/wsl-orcad-active-probe.test.ts
  • src/main/wsl/wsl-orcad-active-probe.ts
  • src/main/wsl/wsl-orcad-connect-state-snapshot.test.ts
  • src/main/wsl/wsl-orcad-connect-state-snapshot.ts
  • src/main/wsl/wsl-orcad-deploy-app-update.test.ts
  • src/main/wsl/wsl-orcad-deploy.test.ts
  • src/main/wsl/wsl-orcad-deploy.ts
  • src/main/wsl/wsl-orcad-instance-adoption.test.ts
  • src/main/wsl/wsl-orcad-instance-adoption.ts
  • src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts
  • src/main/wsl/wsl-orcad-update-move-hold-driver.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

const host: Awaited<ReturnType<typeof restartThroughHost>>[] = []
const bridge: Receipt[] = []
for (let i = 0; i < 3; i++) {
for (let i = 0; i < RESTART_RUNS; i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Stability & Availability · Quick win

Supported by static analysis

Script executed:

set -eu
file='src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts'
printf '%s\n' '--- diff ---'
git diff --unified=40 d3341196b80b59ba1009523eef46772780d0194c 22aba3bd0827bce7e7667e8944898440e86fd4a -- "$file"
printf '%s\n' '--- test context ---'
nl -ba "$file" | sed -n '430,560p'
printf '%s\n' '--- workflow references ---'
rg -n -F --glob '.github/**' -e 'wsl-orcad-real-distro-idle-release-lane' -e 'idle-release-lane' -e '30 * 60' -e '1800' .github || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 16291


Script executed:

set -eu
file='src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts'
printf '%s\n' '--- helper definitions and callers ---'
rg -n -F -- -e 'async function restartThroughHost' -e 'async function restartThroughBridgeExec' -e 'async function terminatePlain' -e 'async function waitFor' -e 'function waitFor' "$file" || test "$?" -eq 1
printf '%s\n' '--- helper implementation context ---'
nl -ba "$file" | sed -n '250,455p'
printf '%s\n' '--- workflow job and invocation ---'
nl -ba .github/workflows/wsl-orcad-e2e.yml | sed -n '315,380p'
printf '%s\n' '--- timeout configuration references ---'
rg -n -F --glob 'config/**' --glob 'package.json' --glob '.github/workflows/**' -e 'testTimeout' -e 'timeout:' -e 'timeout-minutes' -e '24 * 60' -e '30 * 60' wsl-orcad-e2e.yml config package.json .github/workflows || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 3794


Script executed:

set -u
file='src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.ts'
printf '%s\n' '--- helper locations ---'
rg -n -F -e 'async function restartThroughHost' -e 'async function restartThroughBridgeExec' -e 'async function terminatePlain' -e 'async function waitFor' -e 'function waitFor' -- "$file" || true
printf '%s\n' '--- helper implementation context ---'
nl -ba "$file" | sed -n '250,455p'
printf '%s\n' '--- workflow invocation context ---'
nl -ba .github/workflows/wsl-orcad-e2e.yml | sed -n '315,380p'
printf '%s\n' '--- relevant timeout settings ---'
rg -n -F -e 'testTimeout' -e 'timeout:' -e 'timeout-minutes' -e '24 * 60' -e '30 * 60' -- config package.json .github/workflows || true

Repository: stablyai/orca

Length of output: 45668


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.
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