← All work

2025

Cache-Aware Lock-Free Ring Buffer

Wait-free SPSC queue in C++17 for real-time sensor pipelines.

Year
2025
Stack
4 technologies
Source
GitHub ↗
Deep-dive
Read the essay →
C++17std::atomicThreadSanitizerperf

Highlights

  • 013.1× throughput vs. mutex-guarded equivalent
  • 02Sub-350 ns p99 write latency
  • 03Zero races across 50M+ operations under TSan

Engineered wait-free synchronisation using std::atomic with explicit acquire/release semantics, eliminating all mutex contention and priority inversion risks.

Applied 64-byte cache-line padding to head/tail indices to prevent false sharing, validated via perf stat L1-cache-miss reduction on x86-64.

Modelled producer/consumer state transitions with UML sequence and class diagrams before implementation, enforcing invariant correctness at the design stage.

Related essay

Why I Spent a Week Writing a 150-Line Header File (And What It Taught Me About Modern CPUs)

A wait-free SPSC ring buffer in 150 lines of C++17: 3.1× throughput over mutexes, sub-87 ns p99 latency, and the cache-line lesson that changed how I think about concurrency.

10 min · Read the deep-dive

Next project

Cochlear Implant Insertion Robotics