Skip to content

test(wsl): break the WSL host restart into phases in the lane receipt - #35005

Merged
nwparker merged 1 commit into
mainfrom
nwparker/wsl-ensure-phase-trace
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/wsl-ensure-phase-trace

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​263 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​254
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​205 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​196

ELI5

After a WSL distro is restarted, the WSL host takes 4–6 s before a terminal can print anything. The old path takes under 1 s. This PR splits that wait into named pieces in the real-WSL test's receipt, so we know which part to speed up. Users see no change.

Builds on #34864, which is merged.

What Changed

  • Lane receipt phases (test-only). For each measured restart, the real-distro idle-release lane wraps the host connect's holder, deploy, bridge listen and pairing-identity calls. It also logs the start time of every guest command. A new pure helper, wsl-orcad-ensure-phase-trace.ts, turns these into:

    • gateMs
    • firstExecAndBootMs (the first uname -r, which boots the distro)
    • holderMs
    • preLaunchChecksMs and preLaunchCommands
    • launchMs
    • orcadStartupMs (on-host readiness wait)
    • postReadinessMs and postReadinessCommands
    • bridgeMs, pairingMs and unattributedMs

    Per-run values and per-phase medians go to distroRestartToFirstOutput.host[i].phases and medianHostPhases.

  • orcad startup timing (inert in production). orcad-startup-timing.ts times a few existing startup awaits in orcad-entry.ts: CLI launcher, secret store, profile, login-env wait, daemon, orchestration, terminal reconcile and RPC start. orcad writes one [orcad] startup timing {...} line to its slot log at readiness, and only when ORCA_E2E_ORCAD_STARTUP_TIMING=1. Only the lane sets that, through its own transport's orcadLaunchEnv. The lane copies the line into the receipt as orcadStartup.

Why

From #34864's receipts, ensure costs 3.3–4.8 s. About 57% of that is one on-host readiness wait while orcad starts. The rest is the distro boot, the holder, and about 39 serial guest commands. A command log alone can't see inside orcad's startup, and it can't separate the holder from the boot. Wrapping injected dependencies keeps production connect code untouched; wsl-orcad-deploy.ts and wsl-orcad-connection.ts are already at the line cap. Inside orcad, wrapping existing awaits inline adds no new control flow.

Flag-off: no change. The phase trace exists only in the lane test. The orcad timing is a no-op unless ORCA_E2E_ORCAD_STARTUP_TIMING=1 is in orcad's launch env, and nothing in the product sets it.
User-risk: none expected. With the variable unset, timed() just returns the awaited call. The timing line goes to stderr (the slot log), never to the readiness stdout. SSH launches never set the variable.

Linked Issue

Internal WSL-via-orcad tracker, D3 bar (restart → first usable prompt).

Visual Proof

N/A: measurement only, no UI.

Testing

  • New unit tests: wsl-orcad-ensure-phase-trace.test.ts (launch, repeated readiness waits, already serving, missing marks, failed spans, medians) and orcad-startup-timing.test.ts (silent when unset, one line when set, failed phases recorded).
  • The orcad startup tests pass on their own: push startup, duplicate-pty repair, stop-terminal admission. orcad-forked-child-paths fails on macOS from the /private/tmp realpath, which this PR doesn't touch.
  • The numbers come from this PR's WSL2 lane run.
  • Automated tests added/updated

Status

Pushed. Waiting for the WSL2 lane receipts. The phase breakdown will be posted as a STATUS comment.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A for visuals with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact considered (SSH never sets the variable; the readiness payload is unchanged)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (pnpm tc, typecheck:ci, touched tests, code-quality, anti-slop and ast-grep pass locally; CI runs the rest)

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: d32ed9da-4865-457d-b003-f449b2f8f6f2
Commits

Reviewing files that changed from the base of the PR and between fceb475 and cc977a1.

Files selected for processing: 7
  • .github/workflows/wsl-orcad-e2e.yml
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-startup-timing.test.ts
  • src/main/orcad/orcad-startup-timing.ts
  • src/main/wsl/wsl-orcad-ensure-phase-trace.test.ts
  • src/main/wsl/wsl-orcad-ensure-phase-trace.ts
  • src/main/wsl/wsl-orcad-real-distro-idle-release-lane.test.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.

Walkthrough

The changes add opt-in timing for Orcad startup operations and tracing for WSL ensure phases. The real-distro lane adds a restart-to-first-output baseline that alternates host and bridge-exec runs and records medians. The WSL workflow job and phase timeouts increase.

Priority: Low

Merge Risk: Minimal · up to cc977

No actionable merge-blocking issue is established; the WSL2 lane still needs its normal validation.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 37.50% 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.
Description check Warning The description is detailed and covers ELI5, What Changed, Why, Visual Proof, Testing, and most checklist items. However, the Linked Issue section does not provide an actual issue link or Fixes # re… Add a valid linked issue, preferably using Fixes #<issue-number> or the repository's accepted issue-link format. Complete the Review, Agent skill upstream boundary, and Notes sections, or state why they are not applicable. Update the chec…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title names a real part of the changeset: the lane receipt for the real-WSL idle-release test now splits the host restart into phases. It does not mention the orcad startup timing hooks, which the…
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: Title check

Explanation

The title names a real part of the changeset: the lane receipt for the real-WSL idle-release test now splits the host restart into phases. It does not mention the orcad startup timing hooks, which the changeset also adds. The title is specific, short, and accurately describes the main change, which is test-only.

Full details: Docstring Coverage

Explanation

Docstring coverage is 37.50% 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 8 functions across 6 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Description check

Explanation

The description is detailed and covers ELI5, What Changed, Why, Visual Proof, Testing, and most checklist items. However, the Linked Issue section does not provide an actual issue link or Fixes # reference, and the Review, Agent skill upstream boundary, and Notes sections are missing.

Resolution

Add a valid linked issue, preferably using Fixes #&lt;issue-number&gt; or the repository's accepted issue-link format. Complete the Review, Agent skill upstream boundary, and Notes sections, or state why they are not applicable. Update the checklist to reflect all required validation results, including the remaining CI checks and any known test failure.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch nwparker/wsl-ensure-phase-trace
  • 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.

The real-distro lane now times each restart's ensure by phase (first exec and boot, holder,
pre-launch checks, launch, orcad startup, post-readiness, bridge, pairing) from wrapper marks and
guest-command start times. orcad logs its own startup phases to its slot log only when the
lane's launch env sets ORCA_E2E_ORCAD_STARTUP_TIMING; the lane reads that line into the receipt.
@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: measurement in. Head a7e4bdd. WSL2 lane run 40676281327 passed on all 3 families.

Medians of 3 restarts, ubuntu / debian / fedora:

  • ensure: 4806 / 3650 / 4451 ms. Of that, orcad startup is 2758 / 2400 / 2529, first exec + boot 628 / 403 / 538, pre-launch checks (24 commands) 608 / 340 / 634, post-readiness (12 commands) 202 / 133 / 258, holder ~110-130, bridge ~100, pairing ~120-150.
  • Inside orcad: about 1.45-1.9 s goes to Node boot plus loading the bundle and its serial imports, before the first timed startup step. The login-env wait is 0 ms, the daemon takes ~250-320 ms, and readiness lands at ~1.9-2.6 s.
  • First output: 5834 / 4552 / 5493 ms, against an old-bridge exec floor of 769 / 458 / 655 ms.

Checks run: pnpm tc, typecheck:ci, touched tests, code-quality:changed, anti-slop, ast-grep.

Open question: whether orcad's load time is mostly disk reads or compile time. The next step is to measure Node's compile cache in the lane.

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