Adventures with Memory Barriers and Seastar on Linux
Blog post from ScyllaDB
Seastar provides a programming environment that simplifies multi-threaded programming by using a thread-per-core model, eliminating the need for locks and atomic variables, and instead offering a single facility for inter-core communication. This design allows for advanced optimizations in inter-core communications, particularly beneficial for scaling on many-core machines. Traditional inter-thread communication methods using locks face scaling challenges in data-intensive applications, whereas Seastar employs a shared-nothing, asynchronous model where data structures are owned by specific cores, eliminating the need for locks. The text explores various lock-free techniques and optimizations, such as single-producer/single-consumer queues and memory barriers, to improve efficiency and reduce complexity in inter-core communications. Seastar also implements strategies to manage sleeping threads and memory barriers, initially using signals and later transitioning to more efficient methods like the Linux system call membarrier() for better performance across different architectures, ultimately showcasing Seastar's ability to adapt to and benefit from operating system advancements.