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.
| Original language | English |
|---|---|
| Title of host publication | Euro-Par 2024 |
| Subtitle of host publication | Parallel Processing - 30th European Conference on Parallel and Distributed Processing, Proceedings |
| Editors | Jesus Carretero, Javier Garcia-Blas, Sameer Shende, Ivona Brandic, Katzalin Olcoz, Martin Schreiber |
| Publisher | Springer |
| Pages | 103-118 |
| Number of pages | 16 |
| ISBN (Electronic) | 978-3-031-69583-4 |
| ISBN (Print) | 978-3-031-69582-7 |
| DOIs | |
| Publication status | Published - 26 Aug 2024 |
| Event | 30th International Conference on Parallel and Distributed Computing, Euro-Par 2024 - Madrid, Spain Duration: 26 Aug 2024 → 30 Aug 2024 |
Publication series
| Name | Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) |
|---|---|
| Volume | 14803 LNCS |
| ISSN (Print) | 0302-9743 |
| ISSN (Electronic) | 1611-3349 |
Conference
| Conference | 30th International Conference on Parallel and Distributed Computing, Euro-Par 2024 |
|---|---|
| Country/Territory | Spain |
| City | Madrid |
| Period | 26/08/24 → 30/08/24 |
Bibliographical note
Publisher Copyright:© The Author(s), under exclusive license to Springer Nature Switzerland AG 2024.
Keywords
- Concurrency
- Reference counting
- Wait-free