Skip to content

perf(pty): make delivery pressure tracking constant time - #10113

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-pty-delivery-diagnostics
Jul 24, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-pty-delivery-diagnostics

Conversation

@nwparker

@nwparker nwparker commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Track queued PTY characters by exact deltas whenever the pending-delivery map changes.
  • Update delivery-pressure peaks from the aggregate total and only the PTY touched by an enqueue or
    send, instead of rescanning every tracked terminal.
  • Keep full scans in explicit debug snapshots and reset seeding as an independent cold-path behavior
    oracle.
  • Add a production-path operation budget for 100 pending plus 100 in-flight PTYs across 1,000 ACKs.

ELI5

Orca used to recount every package in two warehouses whenever any terminal acknowledged one delivery.
Now it updates one ledger line for the terminal that changed. It still performs a full inventory when
someone explicitly asks for diagnostics or resets the counters.

Proof of zero regression

  • Three independent final reviews—correctness, performance, and platform/integration—found no issues.
  • PTY behavior suite: 340/340 tests passed.
  • Related terminal/provider/relay/renderer slice: 7 files and 695/695 tests passed.
  • Full Node/CLI/web TypeScript check passed.
  • Touched-file oxlint and oxfmt, max-lines ratchet, and git diff --check passed.
  • Pending-map set/delete/clear mutations are centralized with exact data.length deltas. Partial drain
    keeps its delete-then-set ordering and fairness. ACK/resync/heal, dropped-output sentinels,
    transformed rawLength, producer flow control, exit final flush, lifecycle/reset, and destroyed
    window cleanup retain their existing behavior.
  • Native, daemon, Windows ConPTY, and WSL output share this path. Direct SSH delivery uses its existing
    separate path and is unchanged.
  • Local full suite: 3,266 files and 34,798 tests passed; 8 files and 60 tests skipped. The two failures
    observed on the pre-rebase base were audited: the transcript watcher passed 28/28 alone, and the
    worktree-removal assertion failed identically on clean origin/main.
  • Main PR test(worktree): fix main CI red from #10106 (teardown + watch tests) #10115 corrected that worktree-removal test fixture. After rebasing onto it, the formerly
    failing assertion passed locally and GitHub verify passed in full. Windows terminal restart and
    packaged crash-survival checks also pass.
  • Full pnpm run lint reaches the same unrelated released orca-cli revision-9 manifest blocker after
    all lint, reliability, max-lines, and bundled-guide stages pass. This diff changes no skill files.

Proof of performance improvement

  • Deterministic production-path test state: 100 queued PTYs and 100 positive in-flight accounting
    entries.
  • Before: each ACK consumed both 100-entry iterators. Across 1,000 ACKs that is 2,000 full scans and
    exactly 200,000 map-entry visits.
  • After: the same 1,000 production ACK callbacks make zero Map.values() calls and therefore zero
    diagnostic map-entry visits.
  • Hot delivery-pressure bookkeeping is now O(1): one scalar aggregate and keyed lookups for only the
    touched PTY. Full scans remain only when a debug snapshot is explicitly read or reset.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

PTY renderer-delivery pressure accounting now maintains pending character totals and peak counters incrementally through dedicated mutation helpers. Lifecycle, flush, exit, hidden-delivery, and interactive paths use these helpers, while ACK and renderer state handlers no longer recompute pressure by scanning delivery maps. A regression test covers 1,000 ACKs across 100 tracked PTYs and verifies only the targeted PTY’s counters change.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning Useful summary is present, but the required screenshots, testing checklist, AI review, security audit, and notes sections are missing. Add the template sections with screenshot status, checklist items, AI review findings including cross-platform checks, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 Title is concise and accurately summarizes the constant-time PTY delivery-pressure tracking change.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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/perf-pty-delivery-diagnostics branch from 79fd4be to 9776f0b Compare July 23, 2026 06:34
@nwparker
nwparker merged commit c8a2512 into main Jul 24, 2026
3 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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