Lock-free SPSC ring buffer

Lock-free SPSC ring buffer: the queue under every trading system

A single-producer/single-consumer ring buffer is the fastest way to move data between two threads — and the canonical low-latency interview question. We build one in C++, prove it correct with acquire/release ordering, and then watch a textbook false-sharing ‘fix’ make it slower before the real optimisation takes it 14× faster. All numbers measured and ThreadSanitizer-clean.

June 20, 2026 · 9 min · HFT Engineer's Roadmap
Multi-producer lock-free queues

Multi-producer lock-free queues: CAS, sequence numbers, and why they don't scale

The SPSC ring buffer was easy because each cursor had exactly one writer. Add a second producer and that assumption — and the whole design — breaks. We fix it with Vyukov’s per-cell sequence-number queue, prove it correct under ThreadSanitizer, and then measure something every low-latency engineer should internalise: making it ’lock-free’ does not make it scale.

June 20, 2026 · 9 min · HFT Engineer's Roadmap
Mechanical sympathy: cache, branches, and false sharing

Mechanical sympathy: cache, branches, false sharing

Three hardware ideas that decide whether your low-latency code is fast or pretending to be: how the cache hierarchy works, why branch prediction can change runtime by 5×, and how false sharing makes lock-free code slower than mutexes.

May 3, 2026 · 8 min · HFT Engineer's Roadmap