- 1 : 1one producer, the filler thread; one consumer, the decode thread
- 10retries of 1 ms on a full ring, then a block; a batch is never dropped
- 0host threads between a publish and the GPU starting work
The batch filler writes a batch into memory the GPU can read directly, and the GPU's stream begins work the instant the batch is published, without a host thread noticing and launching anything. The CUDA driver has a primitive for exactly this, a stream operation that blocks until a 64-bit value in memory reaches a threshold, and the runtime's hot queue is built around it.
The fastest handoff from a CPU producer to a GPU consumer is one in which neither side waits on the other's clock.
The ring and the bell
Batches live in a ring of pinned host memory, mapped for direct GPU access and write-combined for fast CPU writes, with pages pre-faulted at warm-up so no first-touch fault lands on the hot path. The ring pads to the boundary so a batch is never split across the wrap, and its descriptors mirror the broker's packed-batch layout. Backpressure never drops a batch.
The doorbell is a cache-line-aligned slot in mapped pinned memory holding a sequence number, the payload offset and length, and the batch id.
Where it is used, and where it is not
The doorbell is the right design for the raw-TensorRT extraction backend in A second engine behind the same door, which reads its inputs on the device. The vendor's executor backend reads request data on the CPU, so for that backend the pinned path stays off. The accounting bug that once deadlocked the ring is in Ghost bytes in a zero-copy ring.
What this demonstrates
Using the driver's own synchronisation primitives to remove the CPU from a handoff, and matching the memory model to the consumer: a design that is right for one backend is stated as wrong for the other rather than switched on everywhere.
The handoff design and the backend rule were mine; AI coding agents, a mix of frontier and open-source models, implemented the ring and the doorbell under my governance system.