CQS: A Formally-Verified Framework for Fair and Abortable Synchronization
Nikita Koval, Dmitry Khalanskiy, Dan Alistarh
Abstract
Writing concurrent code that is both correct and efficient is notoriously difficult. Thus, programmers often prefer to use synchronization abstractions, which render code simpler and easier to reason about. Despite a wealth of work on this topic, there is still a gap between the rich semantics provided by synchronization abstractions in modern programming languages—specifically, fair FIFO ordering of synchronization requests and support for abortable operations—and frameworks for implementing it correctly and efficiently. Supporting such semantics is critical given the rising popularity of constructs for asynchronous programming, such as coroutines, which abort frequently and are cheaper to suspend and resume compared to native threads. This paper introduces a new framework called CancellableQueueSynchronizer (CQS), which enables simple yet efficient implementations of a wide range of fair and abortable synchronization primitives: mutexes, semaphores, barriers, count-down latches, and blocking pools. Our main contribution is algorithmic, as implementing both fairness and abortability efficiently at this level of generality is non-trivial. Importantly, all our algorithms, including the CQS framework and the primitives built on top of it, come with formal proofs in the Iris framework for Coq for many of their properties. These proofs are modular, so it is easy to show correctness for new primitives implemented on top of CQS. From a practical perspective, implementation of CQS for native threads on the JVM improves throughput by up to two orders of magnitude over Java’s AbstractQueuedSynchronizer, the only practical abstraction offering similar semantics. Further, we successfully integrated CQS as a core component of the popular Kotlin Coroutines library, validating the framework’s practical impact and expressiveness in a real-world environment. In sum, CancellableQueueSynchronizer is the first framework to combine expressiveness with formal guarantees and solid practical performance. Our approach should be extensible to other languages and families of synchronization primitives.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext ecc653e6-44b2-48f7-91aa-0e3a0a9f19f3Builds on4
- RustBelt meets relaxed memoryHoang-Hai Dang, Jacques-Henri Jourdan, Jan-Oliver Kaiser, Derek DreyerPOPL 2020 · 68 citations
- GoJournal: a verified, concurrent, crash-safe journaling systemTej Chajed, Joseph Tassarotti, Mark Theng, Ralf Jung et al.OSDI 2021 · 31 citations
- Verifying concurrent search structure templatesSiddharth Krishna, Nisarg Patel, Dennis E. Shasha, Thomas WiesPLDI 2020 · 19 citations
- Fast and Scalable Channels in Kotlin CoroutinesNikita Koval, Dan Alistarh, Roman ElizarovPPoPP 2023 · 12 citations
Related papers
- The State-of-the-Art LCRQ Concurrent Queue Algorithm Does NOT Require CAS2Raed Romanov, Nikita KovalPPoPP 2023 · 8 citations
- A Design Space Exploration of Async/AwaitGavin Gray, Shriram Krishnamurthi, Will CrichtonOOPSLA 2026
- Simuliris: a separation logic framework for verifying concurrent program optimizationsLennard Gäher, Michael Sammler, Simon Spies, Ralf Jung et al.POPL 2022 · 33 citations
- Veracity: declarative multicore programming with commutativityAdam Chen, Parisa Fathololumi, Eric Koskinen, Jared PincusOOPSLA 2022 · 2 citations
- Concurrent Data Structures Made EasyCallista Le, Kiran Gopinathan, Koon Wen Lee, Seth Gilbert et al.OOPSLA 2024 · 2 citations
