Frame-count backstop for the same queue (the tokio channel’s capacity).
The byte budget is the real bound; this one only matters for floods of tiny
or empty frames, which cost bookkeeping per frame rather than bytes. 32,768
frames times 128 bytes is exactly the 4 MiB budget, so for any mean frame of
128 bytes or more the byte budget binds first; below that (for example
21-byte empty frames, of which 4 MiB would be almost 200,000) the count
does. The channel allocates slots lazily, so a large capacity costs nothing
until it is used.
Let a reading client drain a short fanout burst, but never park a module’s
frame reader for more than 250 ms. The atomic backlog age is measured from
the enqueue time of the frame the writer is on, or of the frame that made
the queue non-empty. A blocked writer makes that age the stopped-reader
signal; between frames it may be one frame older than the true head, which
is acceptable for this bounded grace and avoids a lock on every frame.
A pending route.open holds one reserved slot in the connection’s egress
queue until its module answers, and its response is sent outside the byte
budget. Eight concurrent opens per connection keep a reconnect burst
parallel while bounding both the reserved slots and the bytes that bypass
the budget.