You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminal output window serializes every chunk twice — once only to measure it #24175
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
Stream terminal output through withTerminalOutputWindow.
Count JSON.stringify calls per chunk: one to measure the chunk for the ack window, plus the protocol's own encode for the wire.
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
Activity