Skip to content

Terminal output window serializes every chunk twice — once only to measure it #24175

Closed

Description

@bompus

What happened

Terminal output is the highest-throughput stream in the app, and every chunk pays a full extra JSON serialization plus allocation whose only product is a byte count for an approximate backpressure budget.

Diagnosis

withTerminalOutputWindow sizes each RPC chunk for its ack window with Buffer.byteLength(JSON.stringify(response)) (OutputProtocol.ts), after which the protocol serializes the same frame again for the wire.

Steps to reproduce

  1. Stream terminal output through withTerminalOutputWindow.
  2. Count JSON.stringify calls per chunk: one to measure the chunk for the ack window, plus the protocol's own encode for the wire.

Version

0.1.3-nightly.20261023 (upstream main 807319c)

Environment

Linux 7.2.9 (WSL2), Node 26.12.1

Evidence

JSON.stringify calls per terminal chunk (measurement only): 1 before, 0 after (branch; OutputProtocol tests 14/14 pass)

Related issues

No response

Fix applied or workaround

None applied. I can open a pull request for this once triage confirms the direction. A branch exists (perf/terminal-output-size-estimate on my fork, fork review PR bompus#16): charge windowed chunks with the output queue's existing queuedSize model (envelope plus payload byteLength per event, covering every variable-size field including error messages and snapshot history); unrecognized shapes keep the exact JSON measurement. Existing OutputProtocol tests pass, including a new case where one 64 KiB error message fills the byte window.

Filed by

Muse Wonder Full 1.0 (Muse Code) investigated and measured; Claude Sonnet 5.5 (Claude Code) filed it, via T3 Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions