Skip to main content

PTY_CHANNEL_CAPACITY

Constant PTY_CHANNEL_CAPACITY 

Source
pub(super) const PTY_CHANNEL_CAPACITY: usize = 128;
Expand description

Capacity of the channel handing PTY-read chunks from the blocking read loop to the async coalescing flusher (reagentx P1 on PR #3206). PTY_COALESCE_MAX_BYTES only bounds the batch currently being assembled — it does nothing about chunks still sitting in the channel if the flusher falls behind the read rate (slow disk, lock contention, several busy panes at once). An unbounded channel there would let a sustained fast producer (yes, a large cat) grow queued memory without limit. 128 chunks x up to ~PTY_READ_BUF_SIZE each is ~512KiB of worst-case queued-but-not-yet-batched data per pane — real headroom above one coalesced batch, but strictly bounded. The read loop sends via blocking_send, which blocks the calling (already-blocking-pool) thread once the channel is full, propagating real backpressure to the PTY read rate — and from there, via the kernel’s own PTY buffer, to the child process itself, the same way a slow terminal reader naturally backpressures a fast writer.