- On the web a turn yields through a MessageChannel task: a chain of
zero-length timers is clamped to 4 ms each, which left the emulator
idle for a third of a burst.
- Slices are cut to what the measured speed writes in the budget left,
so a turn ends near 6 ms however costly the output is to parse; the
first write takes 4 Ki units to measure.
- Writes no longer notify the view each: the feed shows the emulator's
state once everything queued is written, and while output still waits
after a turn at most every 32 ms, so a flood draws its final state per
frame instead of a frame per turn.
- Stream bench: producer follows a flow window (256 KiB past drawn, 32 KiB
frames, rate by elapsed time), reports time spent parsing, ?show=each
for the old per-write notify; tool/perf/terminal_stream_profile.mjs
prints a CPU profile of one workload.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Machine terminals no longer skip output for live viewers. Each connection's
subscription is a cursor into the 1 MiB retained tail, drained by the
connection's writer as soon as the PTY reader writes (no 50 ms tick; a
streaming frame gathers for at most 2 ms). A subscription opened with
flow: true gets window (256 KiB) in its reply and acknowledges drawn output
with terminal_ack; while one is full the reader stops reading the PTY, so
the program waits. A subscription full for 3 s without acking stops holding
the terminal and later sees a gap; a gone connection drops its
subscriptions. Clients that never ask for flow keep the old pacing (newest
64 KiB per 50 ms). terminal_open/terminal_output replies precede the frames
that follow them, which start exactly at the reply's output_end.
Chat shell runs share the buffer code: output is pushed as it arrives,
oldest first, while the chat's watchers keep short queues; 256 KiB unpushed
stops the reader, and watchers behind for 3 s get the old pacing.
The app asks for flow, takes offsets from the server (frame end, reply
output_end) instead of re-encoded text length, acks per quarter window, and
writes replays and bursts into the emulator in slices that yield to the
event loop (ChatShellTerminalFeed, shared with chat shells).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>