Terminal performance initiative: pipeline fixes + term-speed-2 revival + PTY flow control (integration branch)
[!IMPORTANT] Long-lived integration branch — draft for visibility and review, not for immediate merge. This is the terminal-performance initiative branch. It is under extended testing (RC cut via
release-cut, daily-driving). Individual pieces may land on main as separate PRs where noted.
What this branch contains
Four bodies of work, each kill-switched and independently benchmarked (full findings log: notes/terminal-performance-initiative.md):
1. Throughput/latency fixes for the agent-TUI pipeline (the "51× loss")
Baseline (prod 1.4.91): agent-TUI throughput 2.0 MB/s vs 103 MB/s for bare xterm parse and daemon ingest; DSR-under-load p50 134 ms (vs Terminal.app 0.45 ms). Attributed by layered probing and fixed with three commits:
- Parse-clocked scheduler drains — high-priority drains re-arm from xterm write callbacks instead of fixed timer cadence;
HIGH_PRIORITY_MAX_WRITES_PER_DRAIN2→8 (isolation ceiling 27→117 MB/s). - Windowed retained-tail redraw (main process) — suffix window sized by max upward cursor reach instead of full-tail rebuild per chunk (0.888→0.073 ms/chunk; 500-case differential fuzz proves byte-identical outputs).
- Throttled wait-blocked check (main process) — 50 ms coalesced cadence with immediate keyword bypass for actionable prompts (was ~85% of remaining per-chunk cost).
Measured (dev, all three): agent-TUI 0.7→11.5 MB/s; DSR-under-load p50 161→18.8 ms, p99 624→24.9 ms. Prod projection ~9–10 ms; definitive number pending the RC bench.
2. term-speed-2 revival (nwparker's model/view contract chain)
The full ~20k-line chain (hidden view parking, hidden delivery gate, side-effect authority, model query authority) merged and validated — 2,776+ targeted tests green at revival, A/B latency gate passed (p50 tied, p99 better with the chain). All features kill-switched via settings, default ON. Chain docs: docs/reference/terminal-model-view-contract.md.
3. Producer-side PTY flow control (protocol v19)
pausePty/resumePty fire-and-forget notifications; main pauses the producer at >256 KB pending per pty, resumes below 32 KB; node-pty pause() stops reading the fd so the kernel buffer gives true backpressure (VS Code physics). Safety: 5 s daemon-side lost-resume failsafe, main-side pause re-assert, resume on every teardown/reconnect path, version-gated (v≤18/SSH no-op), kill switch PRODUCER_FLOW_CONTROL_ENABLED (src/main/ipc/pty.ts). 29 new tests.
4. Measurement rig + committed results
tools/benchmarks/terminal-pipeline-bench.mjs — cross-terminal DSR-latency + fenced-throughput rig (run inside any terminal; report mode aggregates). All benchmark JSONs backing the numbers above are committed under tools/benchmarks/results/.
Also carried: PR #7153's freeze/memory + cooperative-drain testing merge (its #7139 half has since landed on main independently), daemon scanner pre-filters.
Merge state vs main
Synced with origin/main @ v1.4.120 (includes #7205). Notable resolutions: stream opcode collision (Metadata keeps 12 as shipped to mobile; branch-only Ack → 13); kept the scheduler perf constant over #7139's original; grafted main's Windows/remote OSC7 cwd options into the chain's emulator structure; fixed a latent chain bug where the restore-reconciliation baseline survived suppressed pty exits and dropped revived-session output as duplicates (caught by main's revive test).
Validation
- Typecheck clean; 7,548 tests green across daemon/ipc/runtime/pane-manager/terminal-pane/shared/mobile-transport (1 documented pre-existing WSL failure, identical on main-base).
- Load-controlled alternating A/B protocol for all perf claims (documented in the findings log after one confounded measurement was caught and retracted).
Known follow-ups (tracked in findings log)
- Chain's hidden-pane e2e specs (
terminal-hidden-view-parking,terminal-parked-memory,terminal-sleep-wake-restore) not yet run — gate×drain interplay is the main untested risk. - Packaged-RC bench for the definitive prod headline number (RC cutting now).
- Codex startup color-reply smoke test (dual-answer risk flagged in revival review).
- Cadence tuning (daemon 8 ms batch, drain ticks, xterm 12 ms slices) toward the 4.5 ms goal line.
Made with Orca 🐋
Orca terminal-input regression — diagnostic report (read-only)
Headline: Two daemons are running side-by-side. The pre-update terminals are stranded under the old rc.1 / protocol-v18 daemon (PID 29996), while the updated app (rc.2.perf) spun up a new protocol-v19 daemon (PID 23136) instead of adopting the v18 one. The protocol-version bump (v18 → v19) is the structural signature of the failed adoption.
- Orca processes (verbatim)
Two daemon-entry.js daemons, plus the current visible app instance and its Chromium children:
ProcessId : 29996 ParentProcessId : 13980 CreationDate : 7/5/2026 1:07:54 PM CommandLine : C:\Users\neil\AppData\Local\Programs\orca\Orca.exe C:\Users\neil\AppData\Local\Programs\orca\resources\app.asar.unpacked\out\main\daemon-entry.js --socket \?\pipe\orca-terminal-host-v18-14cb7f94b511 --token C:\Users\neil\AppData\Roaming\orca\daemon\daemon-v18.token
ProcessId : 23136 ParentProcessId : 17764 CreationDate : 7/5/2026 1:38:21 PM CommandLine : C:\Users\neil\AppData\Local\Programs\orca\Orca.exe C:\Users\neil\AppData\Local\Programs\orca\resources\app.asar.unpacked\out\main\daemon-entry.js --socket \?\pipe\orca-terminal-host-v19-14cb7f94b511 --token C:\Users\neil\AppData\Roaming\orca\daemon\daemon-v19.token
ProcessId : 33548 ParentProcessId : 6556 CreationDate : 7/5/2026 1:47:25 PM CommandLine : "C:\Users\neil\AppData\Local\Programs\orca\Orca.exe" (plus --type=gpu-process PID 29844, --type=utility NetworkService PID 30232, and --type=renderer PID 19392 — all children of 33548, verbatim command lines captured but omitted here as unrelated.)
- v18 daemon PID 29996, parent 13980 (dead launcher), pipe \?\pipe\orca-terminal-host-v18-14cb7f94b511, token daemon-v18.token.
- v19 daemon PID 23136, parent 17764 (dead launcher), pipe \?\pipe\orca-terminal-host-v19-14cb7f94b511, token daemon-v19.token.
- Neither daemon's parent is the current visible app (33548) — both are detached/orphaned, as expected for persistent daemons.
- Daemon identity files (verbatim)
Name Length LastWriteTime
daemon-v18.pid 180 7/5/2026 1:07:54 PM daemon-v18.token 36 7/5/2026 1:07:54 PM daemon-v19.pid 198 7/5/2026 1:38:21 PM daemon-v19.token 36 7/5/2026 1:38:21 PM ----- daemon-v18.pid (180 bytes) ----- {"pid":29996,"startedAtMs":null,"entryPath":"C:\Users\neil\AppData\Local\Programs\orca\resources\app.asar.unpacked\out\main\daemon-entry.js","appVersion":"1.4.124-rc.1"}
----- daemon-v19.pid (198 bytes) ----- {"pid":23136,"startedAtMs":1783283901309.535,"entryPath":"C:\Users\neil\AppData\Local\Programs\orca\resources\app.asar.unpacked\out\main\daemon-entry.js","appVersion":"1.4.124-rc.2.perf"}
Note: v18 pid file records appVersion:"1.4.124-rc.1" with startedAtMs:null; v19 records appVersion:"1.4.124-rc.2.perf", startedAtMs → 1:38:21 PM.
- Console-host topology (verbatim)
Children of v18 daemon (PID 29996) — OpenConsole.exe run from ...\node-pty-runtime\1.4.124-rc.1\conpty\OpenConsole.exe, each paired with a powershell.exe:
28444 OpenConsole.exe ...\node-pty-runtime\1.4.124-rc.1\conpty\OpenConsole.exe 1:08:02 PM 7504 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 1:08:02 PM 33212 OpenConsole.exe ...\node-pty-runtime\1.4.124-rc.1\conpty\OpenConsole.exe 1:08:02 PM 36636 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 1:08:03 PM 4340 OpenConsole.exe ...\node-pty-runtime\1.4.124-rc.1\conpty\OpenConsole.exe 1:08:45 PM 34120 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 1:08:45 PM 34048 OpenConsole.exe ...\node-pty-runtime\1.4.124-rc.1\conpty\OpenConsole.exe 1:35:35 PM 2976 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 1:35:35 PM
Children of v19 daemon (PID 23136) — OpenConsole.exe run from ...\node-pty-runtime\1.4.124-rc.2.perf\conpty\OpenConsole.exe:
9652 OpenConsole.exe ...\node-pty-runtime\1.4.124-rc.2.perf\conpty\OpenConsole.exe 1:39:26 PM 21496 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 1:39:26 PM 2900 OpenConsole.exe ...\node-pty-runtime\1.4.124-rc.2.perf\conpty\OpenConsole.exe 1:50:27 PM 19912 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 1:50:27 PM 32816 OpenConsole.exe ...\node-pty-runtime\1.4.124-rc.2.perf\conpty\OpenConsole.exe 2:01:18 PM 31200 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 2:01:18 PM 26744 powershell.exe C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe 2:04:43 PM
Both daemons' console hosts run from the RELOCATED runtime dir (AppData\Roaming\orca\node-pty-runtime...), never from the install dir (AppData\Local\Programs\orca...). v18 hosts point at 1.4.124-rc.1\conpty\ (that on-disk dir is now renamed 1.4.124-rc.1.stale.stale — see §4; the live processes retain the pre-rename path string). v19 hosts point at the current 1.4.124-rc.2.perf\conpty.
- Relocated runtime state (verbatim highlights)
Two runtime trees exist:
- 1.4.124-rc.1.stale.stale — the old rc.1 runtime, double-.stale-suffixed (renamed twice). Contains a full conpty\ + pty.node / winpty set. This is the dir the still-running v18 OpenConsole.exe processes were launched from (before it was renamed).
- 1.4.124-rc.2.perf — the current runtime, marked complete: ...\node-pty-runtime\1.4.124-rc.2.perf.forge-meta 8 bytes ...\node-pty-runtime\1.4.124-rc.2.perf.relocation-complete 0 bytes
- (full conpty.node, pty.node, winpty.dll, OpenConsole.exe etc. present.)
The .stale.stale runtime has no .relocation-complete/.forge-meta markers — only rc.2.perf does.
- Main-process logs
File covering the first post-update launch: main.trace.ndjson (current; last write 2:06:33 PM today). It spans ~5:08 AM → 2:06 PM (8,413 lines); .1 ended at 5:08:32 AM, i.e. pre-update. The first post-update launch is at line 7515, a renderer_bootstrap_started breadcrumb at 1:38:21 PM (epoch 1783283901635) — matching the v19 daemon start.
5a & 5b — the requested markers do not exist in the trace logs. Per-keyword Select-String counts across main.trace.ndjson and .1, all 0:
daemon-init-start 0 daemon-current-ready 0 daemon-init-done 0 legacyAdapters 0 legacy 0 Failed to discover 0 createOrAttach 0 reattach 0 reconcile 0 SessionNotFound 0 protocol 0 hello 0 adopt 0 daemon 0 The trace ndjson contains only effect-span (git.exec) records and renderer.breadcrumb records. The only breadcrumb names in the launch window (lines 7500–7800) are: renderer_bootstrap_started (×1), renderer_bootstrap_rendered (×1), renderer_memory (×10), sidebar_worktree_activate (×7). There is no daemon-adoption / pty / terminal lifecycle logging in these files at all.
5c — error/warn/failed within +5 min of the 1:38:21 PM launch (lines 7515–7723): 48 matches, ALL are git.exec command failures, none pty/daemon/terminal-related. (My earlier "pty-related" bucket was a false positive — Socket/Pipe appear in the Node.js stack traces of failed git commands.) The 48 break down into these failing git subcommands, all with exit._tag":"Failure:
- git config --get user.username / branch.master.remote (cwd ...\OneDrive\Documents\as)
- git symbolic-ref --quiet refs/remotes/origin/HEAD
- git remote get-url upstream → No such remote 'upstream'; git remote get-url origin → No such remote 'origin'
- git rev-parse --verify --quiet refs/remotes/origin/main|master and refs/remotes/pr-brennanb2025-orca/...
- git merge-tree --write-tree --name-only -z --no-messages --merge-base ... (the bulk)
Representative verbatim lines (main.trace.ndjson):
L7529: {"type":"effect-span","name":"git.exec",...,"attributes":{"kind":"git","git.subcommand":"remote","git.arg_count":3,"cwd":"C:\Users\neil\source\orca"},"events":[],"exit":{"_tag":"Failure","cause":"Error: Command failed: git remote get-url upstream\nerror: No such remote 'upstream'\n ... at Pipe.
No log line indicating a daemon-adoption failure exists — because daemon adoption is not traced to these files. There are also no separate daemon/pty log files: logs\ holds only main.trace.ndjson.*. (Per-terminal scrollback lives under terminal-history<session>\output.log, which is output capture, not lifecycle logging.)
- Live-state observation — which daemon owns the still-streaming session
Walking the parent chain of all 29 powershell.exe/pwsh.exe processes, exactly 7 lead to a daemon (pid / parent pid / created):
Under v18 (rc.1) daemon 29996 — the PRE-UPDATE survivors (created before the 1:38:21 PM update): 7504 ppid 29996 1:08:02 PM 36636 ppid 29996 1:08:03 PM 34120 ppid 29996 1:08:45 PM 2976 ppid 29996 1:35:35 PM Under v19 (rc.2.perf) daemon 23136 — created AFTER the update: 21496 ppid 23136 1:39:26 PM 19912 ppid 23136 1:50:27 PM 31200 ppid 23136 2:01:18 PM 32156 ppid 17908 2:04:49 PM (chain: powershell 32156 <- claude.exe 17908 <- powershell 31200 <- Orca 23136 — this is the Claude Code CLI in a v19 terminal)
The still-streaming-but-input-dead counter is a pre-existing session, so it is owned by the v18 (rc.1) daemon, PID 29996 — those four shells (7504/36636/34120/2976) are the only terminals that predate the rc.2.perf update. CPU/liveness (read-only, no input sent) is low for all daemon-owned shells (v18: 0.3–0.9 s user), consistent with a Start-Sleep-paced counter rather than a busy loop:
Daemon ProcessId UserSec KernelSec WS_MB CreationDate v18 7504 0.3 0.5 48.5 1:08:02 PM v18 36636 0.8 1.5 50.6 1:08:03 PM v18 34120 0.9 1.1 52.7 1:08:45 PM v18 2976 0.5 0.4 61.9 1:35:35 PM v19 21496 0.5 1.2 53.9 1:39:26 PM v19 19912 0.9 0.8 90.0 1:50:27 PM v19 31200 0.4 0.3 83.5 2:01:18 PM
Supplementary (scrollback write activity, most-recent first): the actively-growing output.log right now is ...\source\orca@@b2194da2 (2:08:21 PM, 505 KB) — that is the live v19 Claude Code terminal, not a stuck one. The v18-era session logs (7301@@, 7361@@, win-crashes-7-1@@*) are all 9 bytes, last written 1:06–1:47 PM. Mapping scrollback files to specific PIDs isn't reliable, so treat this as corroborating context only, not a precise identification of the counter's PID.
Summary
- How many daemons / protocol versions: Two daemons running concurrently.
- v18 (protocol v18, pipe orca-terminal-host-v18-14cb7f94b511), PID 29996, appVersion 1.4.124-rc.1 — the old daemon, still holding the 4 pre-update PowerShell sessions.
- v19 (protocol v19, pipe orca-terminal-host-v19-14cb7f94b511), PID 23136, appVersion 1.4.124-rc.2.perf — the new daemon the updated app talks to; owns only post-update sessions.
- Where the console hosts run from: Both daemons' OpenConsole.exe run from the relocated runtime under AppData\Roaming\orca\node-pty-runtime\ (never the install dir). v18 → 1.4.124-rc.1\conpty\ (dir since renamed 1.4.124-rc.1.stale.stale, and note the odd double .stale.stale suffix); v19 → 1.4.124-rc.2.perf\conpty\ (has .relocation-complete).
- Any daemon-adoption failure log line: None found — daemon/adoption lifecycle is not written to main.trace.ndjson (all 14 requested markers = 0 matches across current + .1), and there is no separate daemon log file. The only failures in the post-update window are 48 unrelated git.exec failures (missing origin/upstream remotes, merge-tree, rev-parse, git config).
- Interpretation (structural, since logs are silent): The rc.2.perf launch started a brand-new protocol-v19 daemon rather than adopting the existing protocol-v18 daemon. Because the protocol pipe name bumped v18 → v19, the updated app cannot speak to the old daemon that still owns the pre-existing terminals — leaving those v18 sessions orphaned: their PTYs are alive so output still streams, but the app's input path is now wired to the v19 daemon, so keystrokes never reach them. That matches the symptom exactly.
No processes were killed/restarted and no files were modified or deleted — this was strictly read-only. Want me to pull the raw v18 pipe/handle state (e.g., whether the renderer still holds the v18 output pipe) or diff the rc.1→rc.2.perf daemon-adoption code path next?