Skip to content

perf(wsl): skip re-hashing unchanged orcad artifacts and guest Node runtime on the WSL wake path (C4c) - #27941

Merged
nwparker merged 3 commits into
mainfrom
nwparker/wsl-c4c-wake-path-perf
Oct 13, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/wsl-c4c-wake-path-perf

Conversation

@nwparker

@nwparker nwparker commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​303 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​302
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​476 $\color{#cf222e}{\Huge{\mathbf{−}}}$​83 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​393

Stacked on #27923 (C4b). Do not merge.

ELI5

Each time Orca starts its server inside a WSL distro, it re-checked about 20 MB of its own files and a 110 MB Node program by reading every byte. Those files almost never change. Orca now writes down each file's size and timestamps when it checks the file. On the next start it reads every byte again only if one of those details changed. A warm restart now takes about 2.8 s instead of 3.9 s.

What Changed

  • Orca's server files on the desktop (orcad-artifact-materializer.ts, new orcad-artifact-source-verification.ts and orcad-artifact-verification-record.ts).
    • Before, every start read the packaged files three times: once to check them against the manifest, once to compute the slot version, and once to check the cached copy.
    • Now one read of each file does both the manifest check and the version.
    • After a successful check, Orca writes <cacheRoot>/<target>/.verified-sources.json. It lists each source file's path, digest and stat signature (device, inode, size, mtime and ctime in ns), and the cached slot's file signatures.
    • On the next start, a file whose signature still matches reuses its recorded digest. The recorded digest must also still equal the manifest's.
    • Anything else falls back to a full hash: an app update, a repair, an in-place edit (which moves ctime), a different template path, or an unreadable record.
    • A file changed less than 2 s before the check is never recorded, because a coarse filesystem clock could miss a second write.
    • Cache retention already ignores entries whose names start with a dot.
  • Node runtime check inside the WSL distro (new orcad-remote-node-runtime-recorded-probe.ts).
    • Only WSL deploys turn this on (recordedNodeRuntimeProbe: true in deployAndLaunchWslOrcad).
    • The first runtime check compares the executable's stat signature with .verified-stat next to .verified. That file records <pin sha>:<signature>.
    • When they match, the check reports the runtime as ready. Otherwise it runs the full sha256sum as before, and records the signature only when the hash matches the pin.
    • A republished runtime gets a new inode, and an in-place write changes ctime, so either one forces the full hash. A different pin never matches the record.
    • The check that runs under the store lock still hashes.
  • SSH is unchanged. SSH deploys don't set the flag, so ensureRemoteOrcadNodeRuntime sends the same probeRemoteNodeRuntimeCommand text as before. Tests check both that the command is byte-identical and that SSH never sets the flag.

Why

The C4b profile blamed about 1.3 s on the materializer and 0.3 s on the guest runtime hash. Each one re-read files that had already been verified.

  • Persistent record, not an in-memory memo. Every warm relaunch starts a fresh process, so a memo kept in memory would never get a hit.
  • Full stat signature, not mtime alone. ctime can't be set from user space, and inode catches an atomic replace.
  • Guest-side record for the runtime. It lives with the bytes it describes and needs no state on the client.
  • WSL only for the runtime check. SSH hosts can sit on NFS or shared storage, where stat caching makes ctime less trustworthy. Their command text also had to stay byte-identical.

orcad startup is left as it was.

  • The startup preflight child (about 1.2 s) is the gate that runs before the server touches the profile index, the data-root lock or any import. Running main work alongside it would weaken that gate.
  • Deferring profile-state startup would change when state becomes available for SSH as well as WSL.

Linked Issue

Internal WSL-via-orcad tracker, step C4 follow-up (C4c).

Visual Proof

N/A: no UI change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

win-lowspec (Windows 11). I created a throwaway Ubuntu 24.04 distro orca-c4c-probe with systemd=false. The template was the CI orcad-template artifact with the C4b orcad build layered on top. I ran deployAndLaunchWslOrcad under the installed Orca.exe with ELECTRON_RUN_AS_NODE, a fresh process for each run, after killing orcad. Before = C4b; after = this branch.

warm relaunch before (C4b) after
total, app native process-table addon (5 runs) 3.86 / 3.87 / 3.91 / 3.93 / 3.96 s 2.79 / 2.80 / 2.80 / 2.81 / 2.82 s
total, harness without the addon (3 runs, as C4b measured) 4.95 / 4.98 / 5.51 s 3.33 / 3.34 / 3.36 s
materializeOrcadArtifact alone (3 runs) 376–389 ms 15–17 ms
guest runtime probe 323–355 ms 13–16 ms
orcad start → ready (guest) 1.98–2.02 s 1.98–2.01 s
  • First run on the after side. The first run after switching hashed once and wrote both records (3.38 s). The cold first deploy was 12.0 s.
  • Holder in the C4b numbers. About 0.5 s of C4b's holder time is the harness's PowerShell process-table fallback, which reports unverifiable. With the app's native addon on the module path it takes 26 ms.
  • Cleanup. The distro, the holder, the temp directory and the terminal were all removed afterwards.

Automated:

  • Materializer tests cover:
    • a single template pass with no record;
    • zero file reads with a settled record;
    • no record while files are unsettled;
    • a same-size in-place rewrite of a template file, which is still caught;
    • a manifest that no longer matches the recorded digest;
    • repair of a recorded slot rewritten in place;
    • a corrupt record.
  • Runtime-probe tests run in a real shell with a sha256sum that counts its calls. They cover:
    • hashing once, then trusting the record;
    • an in-place rewrite, which hashes again;
    • another pin, which never matches;
    • a missing .verified;
    • the SSH default staying byte-identical and hashing every time.
  • Suites: src/main/{ssh,wsl,orcad} pass. orcad-activation-fence-generation failed once under full parallel load and passes alone.
  • Gates: pnpm tc, oxlint, the anti-slop pass, process-host imports, check:code-quality:changed, the max-lines / ts-nocheck / runtime-electron ratchets, reliability gates, the node pin, compat-boundary imports, audit:code-quality:{native,type-aware} and smoke:orcad-terminal all pass.

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

  • SSH:
    • Command text and semantics are unchanged.
    • The desktop-side materializer record also speeds up SSH deploys. It changes no command.
  • Windows desktop: the stat signature uses bigint stat. On Windows that gives the volume serial, the file index and the change time.
  • Security:
    • Both records sit next to the files they describe and are owned by the same user, so anyone who can forge a record can already replace those files.
    • The hash protects against corruption, not against an attacker on the same account.
  • Remaining hotspots (after):
    • The readiness wait, about 2.07 s. Inside it, the startup preflight child (separate bundle load, artifact identity and profile-state preflight) and profile-state startup in the server.
    • About 60 ms reading the registry and about 26 ms for the holder.

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)

@nwparker
nwparker force-pushed the nwparker/wsl-c4b-wake-path-perf branch from fa0b90e to a17d5b1 Compare October 12, 2026 10:38
@nwparker
nwparker force-pushed the nwparker/wsl-c4c-wake-path-perf branch from 7b788be to c745dd1 Compare October 12, 2026 10:39
@nwparker
nwparker force-pushed the nwparker/wsl-c4b-wake-path-perf branch from a17d5b1 to fbc7021 Compare October 12, 2026 12:00
@nwparker
nwparker force-pushed the nwparker/wsl-c4c-wake-path-perf branch 2 times, most recently from a0524da to cd98e85 Compare October 12, 2026 16:25
@nwparker
nwparker force-pushed the nwparker/wsl-c4b-wake-path-perf branch 6 times, most recently from b852950 to 8eddaf4 Compare October 13, 2026 10:54
@nwparker
nwparker changed the base branch from nwparker/wsl-c4b-wake-path-perf to main October 13, 2026 11:29
@nwparker
nwparker marked this pull request as ready for review October 13, 2026 11:29
@nwparker
nwparker force-pushed the nwparker/wsl-c4c-wake-path-perf branch from cd98e85 to 5881524 Compare October 13, 2026 11:29
@nwparker

Copy link
Copy Markdown
Contributor Author

Merge-train review (blast radius outside WSL): the stat-signature verification record (.verified-sources.json) was trusted by every materializer caller, so editing it could let SSH deploy and local serve skip hashing orcad artifacts. Now only the WSL deploy opts in (trustVerificationRecord). Every other caller hashes every launch, neither reads nor writes the record, and skips the extra stat calls. A browser name that collides with a required slot file is now rejected, because it would otherwise replace that file's manifest digest. Regression tests added.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 12bff44a-faaf-426b-8134-e94e4c0f0e91
📥 Commits

Reviewing files that changed from the base of the PR and between 588152484e61c014b49f0255d2ec78d96f170df3 and c6338e9.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5731e068-6a41-4e79-9bcf-dee5edd054b1
📥 Commits

Reviewing files that changed from the base of the PR and between e09d732 and 588152484e61c014b49f0255d2ec78d96f170df3.

📒 Files selected for processing (12)
  • src/main/orcad/orcad-artifact-materializer.test.ts
  • src/main/orcad/orcad-artifact-materializer.ts
  • src/main/orcad/orcad-artifact-source-verification.ts
  • src/main/orcad/orcad-artifact-verification-record.ts
  • src/main/ssh/orcad-remote-deploy.ts
  • src/main/ssh/orcad-remote-install.ts
  • src/main/ssh/orcad-remote-node-runtime-recorded-probe.test.ts
  • src/main/ssh/orcad-remote-node-runtime-recorded-probe.ts
  • src/main/ssh/orcad-remote-node-runtime.ts
  • src/main/ssh/orcad-runtime-deployment.test.ts
  • src/main/wsl/wsl-orcad-deploy.test.ts
  • src/main/wsl/wsl-orcad-deploy.ts

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

📝 Walkthrough

Orcad artifact assembly now supports opt-in verification records for source digests and cached-slot signatures. Remote POSIX runtime setup can also use a recorded probe that reuses a saved runtime signature when it matches the pinned hash. WSL deployment enables both options. Tests cover artifact record handling, source and slot changes, runtime probe reuse, and the unchanged default SSH probe.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 58815

The WSL wake-path optimization has no identified issue requiring a fix before merge. Follow the stated requirement to merge it with its prerequisite PR, not independently.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
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.
Title check Passed The title clearly and concisely identifies the main WSL performance change: avoiding repeated hashing of unchanged Orca artifacts and the guest Node runtime.
Description check Passed The description is detailed, structured, and aligned with the changes. It covers the user impact, implementation, rationale, testing, platform considerations, security, and scope. The linked issue is …
✨ 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.

…de runtime on the wake path

materializeOrcadArtifact now reads each template file once (manifest check and slot identity
in one pass) and remembers the digests in <cacheRoot>/<target>/.verified-sources.json keyed
by each file's device, inode, size, mtime and ctime; any change re-hashes. WSL deploys probe
the guest runtime against a recorded stat signature beside .verified, hashing only on
mismatch. SSH probe commands are unchanged.
…ke path

SSH deploy and local serve hashed every launch before; a record anyone
with userData access could edit must not let them skip that. Only the
WSL deploy opts in, and untrusted callers neither read nor write it.
…when untrusted

A browser digest keyed like orcad.js replaced the common digest it must also match; callers that keep no record no longer stat every source.
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