Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lock-free SPSC Ring Buffer

This project is designed for high-throughput, low-latency real-time computing scenarios—such as audio signal processing and high-performance network packet forwarding—featuring zero memory allocation, cache-line alignment, and extreme copy optimizations.

Furthermore, adhering to modern C++ engineering practices, the project fully integrates Google Test for unit testing, Google Benchmark for micro-benchmarking, and a GitHub Actions CI pipeline supporting multiple platforms and compilers.


Lock-free SPSC Ring Buffer Models

SPSC Ring Buffer Schematic Diagram: spsc_ringbuffer

Data Race wihout Happens-Before: data_races

pictures from CppCon2023: Single Producer Single Consumer Lock-free FIFO From the Ground Up by Charles Frasch


Documents

To understand the lock-free mechanics and low-level optimizations implemented in this project, check out the engineering docs:

  • Concurrency & Atomic - analyse the danger of data race and discuss how to establish lock-free safey boundaries by using happens-before
  • Memory Order - discuss how to move away from costly seq_cst and leverage acquire, release semantics to squeeze out maximum hardware performance
  • Hardware & Cache - explain the chache line mechanism and how to make optimizations by using alignas to mitigate false sharing
  • Data Copy & Safety - compile-time assertions(static_assert) and how to maximize contiguous memory throughput by using memcpy

About

Designed a lock-free SPSC queue using C++ memory model principles, progressively replacing sequential consistency with acquire-release synchronization, and optimizing cache behavior through false-sharing mitigation.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages