A Fast Wait-Free Solution to Read-Reclaim Races in Reference Counting

Publication date

2024-08-26

Authors

de Wolff, Ivo GabeISNI 000000051252583X
Anderson, Daniel
Keller, GabrieleORCID 0000-0003-1442-5387ISNI 0000000353696972
Seletskiy, Aleksei

Editors

Carretero, Jesus
Garcia-Blas, Javier
Shende, Sameer
Brandic, Ivona
Olcoz, Katzalin
Schreiber, Martin

Advisors

Supervisors

Document Type

Part of book
Open Access logo

License

taverne

Abstract

Reference counting is a safe alternative to manual memory management for multithreaded programs, and is supported by the standard libraries of several major programming languages (e.g., Arc in Rust, shared_ptr and atomic<shared_ptr> in C++). In concurrent reference counting, read-reclaim races, where a read of a mutable variable races with a write that deallocates the old value, require special handling: use-after-free errors occur if the object is deallocated by the writing thread before the reading thread can increment the reference count. Existing solutions are not wait-free, have a space overhead and/or take time linear in the number of threads for updates. We introduce an implementation for concurrent reference counting with no delayed reclamation, which is wait-free, easy to implement and fast in practice. Writes operate in constant time and reads usually in constant time, and in the worst-case, linear with respect to the number of threads that actually work with the variable. Our algorithm is based on the split reference count technique, which is used in production but is only lock-free. We re-explain this technique as a special case of weighted reference counting, to arrive at a simpler explanation of this technique that is often claimed to be difficult. We show that our algorithm works well in practice by benchmarking it against other implementations.

Keywords

Concurrency, Reference counting, Wait-free, Taverne, Theoretical Computer Science, General Computer Science

Citation

de Wolff, I G, Anderson, D, Keller, G K & Seletskiy, A 2024, A Fast Wait-Free Solution to Read-Reclaim Races in Reference Counting. in J Carretero, J Garcia-Blas, S Shende, I Brandic, K Olcoz & M Schreiber (eds), Euro-Par 2024 : Parallel Processing - 30th European Conference on Parallel and Distributed Processing, Proceedings. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), vol. 14803 LNCS, Springer, pp. 103-118, 30th International Conference on Parallel and Distributed Computing, Euro-Par 2024, Madrid, Spain, 26/08/24. https://doi.org/10.1007/978-3-031-69583-4_8, conference