I · The linear primitives

Ring buffer

A fixed-size queue that never allocates.

The story

Older than the field. Present in every UART, every DMA controller, every audio buffer. Computer science formalised what hardware engineers already had: a queue that wraps around in a fixed array, no allocation, ever.

How it works

Two indices (head, tail) modulo the array size. Empty when head == tail; full when (tail + 1) mod n == head. Wastes one slot to disambiguate; some variants use a separate counter.

Where it lives

Linux kernel's kfifo. Audio buffers (always). Network packet rings. The LMAX Disruptor handles 25M ops/sec on a single core because it's "just" a ring buffer with magic.

The key insight

No allocation = no GC pauses, no malloc, no fragmentation. The right choice when you cannot afford to call the allocator inside a hot path — which is most hot paths.