Skip to content

Move saved server reads and writes off the main thread - #42253

Merged
brennanb2025 merged 64 commits into
mainfrom
brennanb2025/env-store-sync-io
Nov 15, 2026
Merged

brennanb2025 merged 64 commits into
mainfrom
brennanb2025/env-store-sync-io

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Orca can freeze while reading or saving remote server connections. Desktop and persistent server processes now send complete saved-server operations to one background worker, keeping disk reads and durable writes off their event loops. Short CLI commands use the same serialized operations in-process to avoid worker startup overhead.

Saved filenames, formats, private-file permissions and durable replacement order are preserved. Reads remain fresh across completed changes from another process or older build, including records this version cannot understand. Callers now await fresh connection state while retaining pairing, subscription, publication and cancellation ownership.

Fresh reviews repaired repeated shared-host lookups, phone requests losing replies when their connection retired, and snapshot/subscriber ownership during async preparation. Delayed WSL callbacks no longer overwrite a confirmed stopped-distro state or hide Start; new Ready callbacks retain their pairing save and notification. Main is merged through 7f38c5d0042, preserving its startup extraction, shutdown drains and shared-contract moves. The final conflict resolution changes only a type import path. Fresh Claude/Codex reviews and performance screens are clean; the startup conflict resolution also has a clean fresh Codex high review.

Validation

  • Exact final head cec94663a692988659331f3161eaae536080f820: full typecheck and 52 tests across ten named store, cache, WSL, quit/teardown and sender-association owner files pass. Earlier full owner coverage passed 540 tests across 49 named files with seven intentional skips. Counterfactual runs reproduce the original lookup, reply-retirement, publication and WSL ordering failures.
  • The mandatory pre-push pnpm check:changed passed 36 non-unit gates. Its broad unit fallback timed out at five minutes; that timeout is not a pass. Final-head CI is green: 81 checks pass with 18 skips, including all unit shards, changed E2Es, SSH/WSL, Windows packaging and performance contracts.
  • Real isolated orcaqa WSL QA passed: saved-host upgrade, credential ACLs, both real native-agent replies, actual distro termination → stopped notice with Start → reconnect → new terminal command output, and graceful KeepRun restart → another new terminal command. Screenshots and limitations are in the PR status comment.
  • SSH saved-host terminal output, reconnect, upgrade, graceful restart and both native-agent replies passed earlier. macOS and Windows packaged desktop/CLI/server checks also passed. Main merges preserve completed QA.
  • Exact WSL transition latency was not captured. The pre-disconnect terminal lost earlier output and showed a bare prompt after reconnect; new terminals worked. The required terminal-command checks use new terminals.

Performance

Production-store workload Before After
100 hosts, 1,000 concurrent lookups: synchronous reads 4,000 on main 80 in worker; zero on main
100 hosts, 1,000 sequential triggers: wall time, five interleaved runs 501–531 ms 282–392 ms
Sequential workload: total CPU across threads 584–613 ms 370–493 ms
Sequential workload: largest main-loop gap 28.9–29.4 ms 1.3–2.2 ms
Main filesystem syscalls in the synthetic workload 40,470 0
Fresh-process CLI resolver: median child wall time 113 ms 107 ms

The CLI sample measures the production resolver with startup/import/close, rather than a complete packaged command. The shared Linux host produced noisy timing samples (110 ms after-run spread). Sequential reads still inspect exact bytes per operation for external-write visibility; synthetic disk-flush delays do not reproduce every loaded-disk condition. The measured production store is unchanged in the final merge. The earlier 100/1,000-row counterfactual reproduced shared-server lookup amplification. Main’s later test cleanup removed that spy-count suite; the request-scoped lookup map remains unchanged and was inspected again in merge review.

Risk and compatibility

The broad caller migration makes asynchronous ownership the main risk. Formats and remote protocols are unchanged. An inaccessible profile reports a storage error rather than an empty list, preventing failed reads from authorizing an overwrite. Independent simultaneous writers retain the existing last-publisher behavior. Frequent durable last-used updates still rewrite the registry and can queue later reads while main stays responsive. Reverting this PR preserves readable store files and completed user edits.

The standalone retirement diagnostic now awaits saved-server lookups and uses the existing inline executor; its pre-existing connection-constructor mismatch remains a separate limitation.

No controls, copy or layout change. Phone UI was not exercised; the retired-request behavior has a focused protocol regression.

Retained macOS before/after evidence:

Before upgrade After upgrade
Saved hosts before Saved hosts after
Files Added Deleted Net
Test 252 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3191 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1453 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1738
Prod 320 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6834 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3739 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3095

@brennanb2025

brennanb2025 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Reading or saving server connections could freeze Orca. Saved-server operations now run in one background worker on desktop and persistent servers. Short CLI commands run the same serialized operations inline. Saved formats, private-file permissions, unreadable records and durable replacement are preserved.

The full fresh reviewer pair is clean through c502f168b85f3aecdb70ebe0a4d7a25ff9cd7f23, including performance screens and the earlier full implementation/reference reviews. Main merges retain its deleted tests and all branch async setup. The latest startup extraction is preserved, with the awaited environment lookup carried into the moved VM wake callback; a fresh Codex high resolution-only review is clean through 844b98f57f755d77e62985d447294b04efd70886. The earlier repairs cover request-scoped host lookup reuse, replies surviving connection retirement, snapshot/subscriber ownership during async preparation, and stale WSL Ready callbacks superseded by stopped-distro observations. The import-only quit repair clears the full-lint line budget without changing shutdown behavior; a fresh Claude/Codex repair pair is clean through 74398996224502170dc765eaa5bb20c39bd80704. The later main merges preserve its install-park shutdown drain and shared-contract moves. The final manual resolution changes only the sender-association type import path; the branch’s extracted dependency type stays in its owning module. A rename-aware import scan found no stale paths, and 561 branch-only plus 1,104 main-only paths are preserved exactly. No confirmed P0/P1 is open.

Validation: final head cec94663a692988659331f3161eaae536080f820 passes the full typecheck and 52 tests across ten named worker/inline/publication/cache/WSL-service/removal, quit/teardown and sender-association owner files. This session also ran full local typechecks and named tests through tc-gate before the mechanical main merges. The final pre-push pnpm check:changed passed 36 non-unit gates; its broad unit selection hit the configured five-minute timeout. That timeout is not a pass. Earlier full owner validation passed 540 tests across 49 named files with seven intentional skips; the four WSL counterfactual failures and async-publication regression controls remain documented in the lane evidence. Final-head CI is green: 81 passing checks and 18 skips, including all unit shards, changed E2Es, both managed-SSH shards, all real WSL distro/terminal checks, Windows packaging/serve switching and performance contracts.

Required real QA is complete. SSH saved-host terminal output, reconnect, upgrade, graceful restart and real Claude Opus medium/Codex high replies passed earlier. WSL baseline-to-target upgrade, credential ACLs and both real agent replies also passed earlier. The missing real WSL disconnect → Start/reconnect and graceful-restart command flows now pass under isolated orcaqa ticket 5745, using a newly rebuilt 5f0b2d152cf057c89bd6000d80698aff5d7a73d9 app and matching verified server template. Later main merges preserve that QA under the review rules. Real distro termination was typed through the app's Local Windows terminal as orcaqa; the rendered stopped state offered Start, Start reconnected exactly one host, and a new saved-host terminal printed the WSL hostname, project path and kernel. After a graceful KeepRun restart, another new terminal printed a distinct durability marker. Both Codex high drivers exited 0 with no policy events and verified app identities. Both stops were graceful, no terminal daemons or port-9444 listener remained, and the idle distro never started. The lead is closed and the ticket released.

WSL stopped state and Start:

WSL stopped state with Start

WSL command output after reconnect:

WSL terminal after reconnect

WSL command output after graceful restart:

WSL terminal after graceful restart

Performance: with 100 hosts and 1,000 production-store triggers, the largest main-loop gap fell from about 29 ms to 1.3–2.2 ms and main filesystem calls fell to zero. All five sequential pairs improved wall time (501–531 ms before; 282–392 ms after). Limits: shared-host timing noise, synthetic durability delays and unmeasured Windows cold-worker latency.

Observations kept separate from passes: exact WSL transition latency was not captured (first samples were 10.5 s after termination and 9.3 s after Start). The old pre-disconnect terminal showed a bare prompt and lost its earlier output after reconnect; new terminals worked, matching the earlier need to open a new terminal after termination. After restart the host was already ready, so Start was exercised after the real disconnect. SSH startup read failure remains process-scoped as on main, worker-start failure retries on new work, and the existing standalone retirement diagnostic still has a PairingOffer/connection-constructor mismatch. Concurrent sessions changed neil's .claude.json; this isolated lead/driver/orcaqa app could not write it, and real settings/config/auth hashes were unchanged.

Earlier SSH restart and native-agent proof (the Claude/Codex chats in these two images ran locally with SSH hosts connected):

SSH terminal after restart

Claude native reply

Codex native reply

Earlier real agent replies on WSL:

Claude reply on WSL

Codex reply on WSL

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.

4 participants