Skip to content

Terminal performance initiative: pipeline fixes + term-speed-2 revival + PTY flow control (integration branch)#7214

Merged
Jinwoo-H merged 401 commits into
mainfrom
orca-performance
Jul 11, 2026
Merged

Terminal performance initiative: pipeline fixes + term-speed-2 revival + PTY flow control (integration branch)#7214
Jinwoo-H merged 401 commits into
mainfrom
orca-performance

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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_DRAIN 2→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 🐋

nwparker added 30 commits June 16, 2026 16:48
…wparker/term-speed-2-skip-grammar-removal

# Conflicts:
#	src/renderer/src/components/terminal-pane/pty-connection.ts
… nwparker/term-speed-2-rich-hidden-model-pressure
…nwparker/term-speed-2-rich-hidden-model-default
…wparker/term-speed-2-remote-multiplex-e2e-pressure
…to nwparker/term-speed-2-sleep-revisit-pressure
…rker/term-speed-2-runtime-ws-multiplex-pressure
…wparker/term-speed-2-subscribe-overflow-snapshot
… nwparker/term-speed-2-scale-hidden-skip-assertion
… nwparker/term-speed-2-hidden-sync-state-reset
…wparker/term-speed-2-skip-grammar-removal

# Conflicts:
#	src/renderer/src/components/terminal-pane/pty-connection.test.ts
AmethystLiang added a commit that referenced this pull request Jul 13, 2026
…laky specs, profile switcher gate) (#8486)

* fix(e2e): repair release e2e suite — parking regression tests, stale/flaky specs, profile switcher gate

Diagnosed 20 failing tests across the release e2e shards. Most are test debt,
plus two genuine product-side issues.

Product fixes:
- OrcaProfileSwitcher: the PROD gate hid the "Switch profile" button in the
  e2e build (electron-vite build bakes NODE_ENV=production). Exempt
  MODE==='e2e' so the specs render it while packaged prod builds stay hidden.

Parking cluster (8 tests): #8262 intentionally keeps the most-recently-hidden
tab warm (exempt from cold-park). The specs hid exactly one tab — always the
exempt one — so it never parked. Open a throwaway decoy tab that absorbs the
last-active exemption so the target parks. (terminal-hidden-view-parking,
terminal-pane-close-layout-consistency)

Stale tests updated to match intended product behavior:
- rich-markdown-link-bubble: match Edit link by aria-label (title dropped in #8307)
- terminal-codex-hidden-startup-background: drop the dead hiddenRendererSkipCount
  poll (Phase-4 main-side delivery gate #7214 bypasses that renderer path)

Brittle threshold/geometry/timing hardening (no product regression):
- agent-session-log-tail-stability: assert full-model length instead of a
  machine-specific word-wrap pixel baseline
- artificial-opencode revisit: dedicated under-backpressure latency bound
- terminal-history-size-typing-latency: gate p90 not max (tolerate one
  checkpoint-in-window spike; median stays strict)
- combined-diff-scroll-restore: assert viewport barely moved vs exact anchor key
- terminal-shortcuts: idempotent kitty-flag reset instead of a racing stack pop
- agent-session-live-force-exit-resume: drive the product quit-capture path
- renderer-crash-recovery-terminal-input: poll the transport probe over the
  recovery budget (still flags a permanently frozen pane)

terminal-push-delivery-loss-recovery left unchanged (no safe test-only
improvement; recovery is wall-clock bounded with ample slack).

* Extract shared parking helpers into terminal-hidden-parking.ts for e2e s

- Deduplicate waitForTabParked/parkHiddenTabBehindDecoy, previously
  copy-pasted across the parking and layout-consistency specs
- Parameterize parkDelayMs so the helper no longer depends on a
  file-local PARKING_DELAY_MS constant
AmethystLiang added a commit that referenced this pull request Jul 13, 2026
* fix(e2e): repair release e2e suite — parking regression tests, stale/flaky specs, profile switcher gate

Diagnosed 20 failing tests across the release e2e shards. Most are test debt,
plus two genuine product-side issues.

Product fixes:
- OrcaProfileSwitcher: the PROD gate hid the "Switch profile" button in the
  e2e build (electron-vite build bakes NODE_ENV=production). Exempt
  MODE==='e2e' so the specs render it while packaged prod builds stay hidden.

Parking cluster (8 tests): #8262 intentionally keeps the most-recently-hidden
tab warm (exempt from cold-park). The specs hid exactly one tab — always the
exempt one — so it never parked. Open a throwaway decoy tab that absorbs the
last-active exemption so the target parks. (terminal-hidden-view-parking,
terminal-pane-close-layout-consistency)

Stale tests updated to match intended product behavior:
- rich-markdown-link-bubble: match Edit link by aria-label (title dropped in #8307)
- terminal-codex-hidden-startup-background: drop the dead hiddenRendererSkipCount
  poll (Phase-4 main-side delivery gate #7214 bypasses that renderer path)

Brittle threshold/geometry/timing hardening (no product regression):
- agent-session-log-tail-stability: assert full-model length instead of a
  machine-specific word-wrap pixel baseline
- artificial-opencode revisit: dedicated under-backpressure latency bound
- terminal-history-size-typing-latency: gate p90 not max (tolerate one
  checkpoint-in-window spike; median stays strict)
- combined-diff-scroll-restore: assert viewport barely moved vs exact anchor key
- terminal-shortcuts: idempotent kitty-flag reset instead of a racing stack pop
- agent-session-live-force-exit-resume: drive the product quit-capture path
- renderer-crash-recovery-terminal-input: poll the transport probe over the
  recovery budget (still flags a permanently frozen pane)

terminal-push-delivery-loss-recovery left unchanged (no safe test-only
improvement; recovery is wall-clock bounded with ample slack).

* Extract shared parking helpers into terminal-hidden-parking.ts for e2e s

- Deduplicate waitForTabParked/parkHiddenTabBehindDecoy, previously
  copy-pasted across the parking and layout-consistency specs
- Parameterize parkDelayMs so the helper no longer depends on a
  file-local PARKING_DELAY_MS constant

* fix(e2e): second pass — fix link-editor Escape regression + deeper test failures

CI validated round 1 (parking + 5 areas green). This fixes the tests that were
still red because the first fix cleared only the first assertion or the root
cause was deeper.

Product fix (real regression found by the test):
- RichMarkdownLinkBubble: Escape while editing a link dismissed the whole bubble
  instead of cancelling the edit. #8307 added a container-level Escape→onDismiss
  with stopPropagation, but the edit input's older Escape→onEditCancel never
  stopped propagation, so both fired. Add e.stopPropagation() in the input's
  Escape branch so editing Escape only cancels the edit.

Test fixes:
- agent-session-live-force-exit-resume: wait for hydrationSucceeded (not just
  workspaceSessionReady) before persisting — shouldPersistWorkspaceSession gates
  the writer on it, so the record write was a silent no-op until hydration.
- terminal-shortcuts: clear the shell line deterministically (Ctrl-U + Ctrl-C)
  then send the kitty flag reset as its own settled command, so the reset byte
  isn't swallowed mid line-edit.
- agent-session-log-tail-stability: allow a 25MB GC-noise margin on the
  append-vs-replacement peak comparison. The append path provably allocates less
  than the replacement control (which also encode/decode/setValue), so a peak
  above it is uncollected-transient noise, not a regression; the deterministic
  retention budget and bench are untouched.
- artificial-opencode hidden-restore: 1500→2000ms for whole-buffer serialize-poll
  overhead under reveal (still 2x stricter than main's 4s).
- terminal-push-delivery-loss-recovery: assert the observable watchdog healCount>0
  instead of 'wedged-123' in the pane. In headless e2e a desktop-only local pty
  has no main headless emulator, so getMainBufferSnapshot falls back to the
  blackholed renderer xterm and the repaint cannot carry the wedged bytes.

* fix(e2e): third pass — harden the last 4 chronic/flaky e2e gates

- agent-session-live-force-exit-resume: raise persisted-record poll 15s→30s
  (two-stage debounced write + main scheduleSave needs headroom under the CI
  event-loop starvation that also drifts renderer timers ~1s in this shard);
  on miss, dump store vs disk state to distinguish a lost write from slow flush.
- artificial-opencode-terminal-load: add MAX_TIMER_DRIFT_UNDER_LOAD_MS (2.5s)
  for the injected-load scenarios, mirroring MAX_WORST_KEY_LATENCY_UNDER_LOAD_MS;
  baseline single-terminal gate stays at 250ms.
- combined-diff-scroll-restore: converge the after-tab-switch anchor via bounded
  retry (Monaco restores scroll over several layout passes) before asserting;
  a genuine restore miss still fails since the last anchor is returned on timeout.
- terminal-reattach-mouse-mode-leak: poll rAFs until the enable-mouse-events
  class lands after re-arming instead of a single frame (batched xterm render).

Co-authored-by: Orca <help@stably.ai>

* Widen timer-drift and scroll-restore budgets for loaded/slow e2e scenari

- Add maxTimerDriftUnderLoadMs budget so multi-pane opencode redraw
  scenarios aren't judged against the unloaded timer-drift ceiling
- Start the combined-diff scroll-restore poll window after the initial
  viewport anchor settles, since that settle can itself take up to 15s

* fix(e2e): round-2 — gate mouse-probe on arm capability; align revisit budgets

- terminal-reattach-mouse-mode-leak: xterm binds the enable-mouse-events class
  and the motion listener together in one _handleProtocolChange; some headless CI
  renderers never bind it on a warm reattach (core mouseTrackingMode still flips),
  so the positive control cannot arm. Poll a bounded window for arming, then skip
  when it never arms (matching the pane-manager/shell guards) instead of failing.
- artificial-opencode-terminal-load: the worktree-revisit scenario sampled worst-key
  and timer drift under ACK-gate-held load but asserted the strict unloaded budgets
  (worst seen ~2s); switch it to the under-load budgets like its siblings.

Co-authored-by: Orca <help@stably.ai>

* Expand timer-drift budget test coverage to all scenario branches

- Splits the pass/fail assertions into separate it blocks and adds
  it.each over all four isUnderLoadTimerDriftScenario matches (two
  exact, two prefix) so a predicate regression can't silently fall
  back to the unloaded 150ms ceiling for any of them.

---------

Co-authored-by: Orca <help@stably.ai>
andrewyatesai pushed a commit to andrewyatesai/orc that referenced this pull request Jul 14, 2026
…ts (Bug 2)

serializeBudgetedMobileSnapshot / serializeBudgetedRequestedSnapshot composed
data = scrollbackAnsi + serialized.data while requesting scrollbackRows>0 — but
serialize_ansi(Some(rows)) already PREPENDS min(rows,history) into snapshotAnsi
and scrollbackAnsi is always the FULL history, so the recent rows were sent
twice on every mobile-subscribe / client-requested snapshot (regression from
stablyai#7214, which only set the non-mobile branch to scrollbackRows:0). The descending
byte-budget candidate loop was also inert since scrollbackAnsi never shrank.

Serialize the visible grid once with scrollbackRows:0 (scrollbackAnsi is the sole
history source — no doubling), then bound history with boundScrollbackAnsi
(most-recent tail, cut on a CRLF boundary), restoring real payload-bounding.
scrollbackRows now reports the retained history count and truncatedByByteBudget
flags only budget-forced drops. +no-doubling + byte-truncation tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012LGpNcEy85AUt3sc5V23jD
andrewyatesai pushed a commit to andrewyatesai/orc that referenced this pull request Jul 16, 2026
…ild admission, perf-proof lane, Orca Dark themes

Ports the novel clusters of wip/webgl-osc133-perfproof-20260707 (authored
2026-07-06/07 against 9ca33b4) onto current main, reconciled with the
terminal-performance refactor (stablyai#7214) and the main side-effect-authority
architecture:

- Wayland WebGL enablement: terminal-webgl-auto-policy narrows the blanket
  'linux-wayland' auto-deny to the NVIDIA-proprietary-on-Wayland config only
  (stablyai#5319 remnant pending a rig re-test), with tests and a reference doc.
- aterm worker prewarm: idle-time shared-render-worker warm-up with a bounded
  hold, released the moment a real pane acquires a slot.
- Pane-build admission queue + never-blank first paint: staggered engine
  builds (FIFO, wedge fallback), 300ms busy-cursor cue, theme-background
  container seeding kept in sync on re-theme via engineColorToCss. Upstream's
  attach-edge additions (rain-pulse flush, spill pane-key binding) preserved.
- perf-proof benchmark lane: terminal-perf-marks interactive-present stamps in
  the presenter, tools/benchmarks/perf-proof-* (run/compare/check/metrics,
  criterion parse), trends baseline, e2e spec, bench:perf/bench:check scripts.
- Orca Dark/Graphite theme family (orca-dark.ts, engine-color-css.ts) merged
  into the theme catalog; Terminal Engine settings: live renderer-status row
  (GPU/CPU path + adapter + worker presentation) and scene-availability gating
  (scene registry feature-detected; the vendored engine ships no scene export).

DROPPED from the WIP (kept parked on wip/webgl-osc133-perfproof-20260707):
- Engine-decoded OSC-133 command lifecycle (attachEngineOscConsumer + replay
  backlog latch): upstream moved command-finished authority to MAIN process
  pty:sideEffect facts (shared scanner; renderer byte path retained only for
  remote-runtime/kill-switch-off), which the engine-consumer model double-fires
  against. Superseded architecture, not re-reconcilable as written.
- aterm-effects-settings default flips + test: upstream already ships ON
  defaults with matching pre-hydration fallbacks and equivalent tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012SCdtyKtmwPW3iRsWCtBwV
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.

3 participants