Skip to content

perf(orcad): keep SSH hosts on the 10-minute scanner idle, give WSL hosts 3 - #33897

Merged
nwparker merged 2 commits into
mainfrom
nwparker/orcad-scanner-idle-scope
Oct 26, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/orcad-scanner-idle-scope

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14

ELI5

#33845 made the Orca server shut its session-history helper down after 1 minute of idle, on every host. That saves memory, but on a large history it makes the next session-list scan about 14 s slower. That's worth it for WSL, where memory is tight, but not for SSH hosts. Now WSL hosts wait 3 minutes and SSH hosts go back to the original 10 minutes.

What Changed

  • Before (since perf(orcad): retire an idle session scanner after a minute on host servers #33845): every orcad host retired the idle AI session scanner child after 60 s.
  • After:
    • WSL hosts: the scanner retires after 3 min idle. These are detected with the existing isWslHostOrcadProcess check: only WSL launches set ORCA_WSL_ORCAD_HOST=1, and the process must actually be running in WSL.
    • SSH hosts: back to the scanner's own 10-min default; orcad no longer overrides it.
  • The choice lives in a new orcad-session-scanner-idle.ts, so it can be tested without booting orcad.

Why

I measured the cost of a retire on a large real history (2 years of Claude and Codex sessions, more than 1000 sessions, on a heavily loaded Mac), using the pinned runtime and the built scanner bundle:

case fork → ready session-list scan
warm child (no retire) — 29.7 s
cold fork after a retire, with the persisted parse cache 138 ms 43.5 s

A retire adds about 14 s (×1.46) to the next scan on a big history.

  • SSH hosts never had a memory complaint, so that cost is a pure regression there.
  • WSL hosts have a per-distro memory bar, and the idle scanner holds about 60 MB (measured on Linux). A 3-minute window keeps the scanner warm across normal back-to-back use of the session list, and still frees the memory during real idle.

Not addressed here: closing the cold-scan gap itself by persisting more scan state. The warm child also holds in-memory indexes (for example the Codex title index, cursor chat meta and project cwd caches) on top of the persisted parse cache. Finding which of them account for the 14 s needs a CPU profile of a cold scan; that's a follow-up.

Linked Issue

Internal WSL host memory work; follow-up to #33845.

Visual Proof

N/A: no UI change. Only how long an idle background process lives on a host server.

Testing

  • New orcad-session-scanner-idle.test.ts: WSL hosts get 180 s, SSH hosts get no override (null).

  • session-scanner-service-spawn.test.ts, which checks the configured timeout reaches the shared client, and main-preflight-order.test.ts pass under pnpm test.

  • pnpm lint and pnpm tc:node pass.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

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

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)

@coderabbitai

coderabbitai Bot commented Oct 26, 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: dd902c8f-0769-41b9-a148-1ab69dcd8efd
Commits

Reviewing files that changed from the base of the PR and between 61c1cd3 and 4e1b3fe.

Files selected for processing: 1
  • src/main/runtime/rpc/methods/workspace-layout-paired-desktop.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.

Walkthrough

The runtime obtains the session-scanner idle timeout from orcadSessionScannerIdleTimeoutMs(). When the host check identifies a WSL host, the selector returns 180,000 ms and the runtime sets that timeout on the AI Vault service. Otherwise, the selector returns null, and the runtime does not set the timeout. Tests cover both selector outcomes. The paired-desktop test suite now runs switchedBuild(true) once before its tests, with a 120-second timeout.

Priority: Low

Merge Risk: Minimal · up to 4e1b3

No actionable merge-blocking risk remains; the timeout behavior and test initialization are consistent with the stated intent.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. 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 main change: SSH hosts keep the 10-minute scanner idle timeout while WSL hosts use a 3-minute timeout.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, testing, platform scope, and checklist. It references issue #33845 and leaves some optional or CI-covered checklist i…
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 detailed and covers the user impact, implementation, rationale, testing, platform scope, and checklist. It references issue #33845 and leaves some optional or CI-covered checklist items incomplete, but it is mostly complete and relevant.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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.

@nwparker
nwparker force-pushed the nwparker/orcad-scanner-idle-scope branch from c54f6e2 to 61c1cd3 Compare October 26, 2026 11:34
…y tests

The first test paid the cold transform of the whole runtime graph inside its
30 s budget and timed out whenever a shard placed it without warm neighbors.
…osts 3

Retiring the idle session scanner after a minute cost the next scan of a
large history ~14 s. SSH hosts have no memory budget to justify that, so
they return to the scanner's default; WSL hosts, which do, wait 3 minutes.
@nwparker
nwparker force-pushed the nwparker/orcad-scanner-idle-scope branch from 61c1cd3 to 4e1b3fe Compare October 26, 2026 11:54
@nwparker
nwparker merged commit 90493a9 into main Oct 26, 2026
54 checks passed
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