Bound the queue in front of the gate, and count the waits #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/bounded-queue"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The third thing the review named: the channel between the reader threads and the gate thread was unbounded, so a gate that fell behind held every frame in memory with no high-water mark, and the Stop button waited behind all of it.
What changes. A budget in front of the gate thread, 32 MiB on the wire and 512 jobs. A reader admits each record against it before sending and holds the ticket until the gate has applied the record. While the budget is spent the reader waits, its socket stops being drained, and the collector's own write blocks, which is where the slowness belongs. Nothing is dropped; a collector made to wait captures its next frame later, from the screen as it is then. Control readers do not admit against the budget, so a Stop is never more than the budget deep. The single channel and single thread stay, and with them the ordering argument in the daemon's header.
What is recorded. Slow was the one state the store never marked. Two counters now are that mark, written per heartbeat rather than per record:
ingest_backlog_waitsandingest_backlog_high_water_bytes.Proof. Three tests in
here_gate::backlog: a stalled consumer against eight producers sending sixteen thousand records stays inside the budget and loses nothing; an oversized record is admitted alone and the next waits for it; the job cap binds when records are small. The first fails against a budget that never waits, checked by making it one. Linux verifier green on the pinned toolchain: 278 Rust + 86 TypeScript = 364 tests, every stage, exit 0. The end-to-end suite that drives the real gate over real pipes is Windows-only and was not run here; the daemon wiring is compiled and linted.