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

Ivo Gabe de Wolff*, Daniel Anderson, Gabriele K. Keller, Aleksei Seletskiy

*Corresponding author for this work

Research output: Chapter in Book/Report/Conference proceedingConference contributionAcademicpeer-review

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 languageEnglish
Title of host publicationEuro-Par 2024
Subtitle of host publicationParallel Processing - 30th European Conference on Parallel and Distributed Processing, Proceedings
EditorsJesus Carretero, Javier Garcia-Blas, Sameer Shende, Ivona Brandic, Katzalin Olcoz, Martin Schreiber
PublisherSpringer
Pages103-118
Number of pages16
ISBN (Electronic)978-3-031-69583-4
ISBN (Print)978-3-031-69582-7
DOIs
Publication statusPublished - 26 Aug 2024
Event30th International Conference on Parallel and Distributed Computing, Euro-Par 2024 - Madrid, Spain
Duration: 26 Aug 202430 Aug 2024

Publication series

NameLecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
Volume14803 LNCS
ISSN (Print)0302-9743
ISSN (Electronic)1611-3349

Conference

Conference30th International Conference on Parallel and Distributed Computing, Euro-Par 2024
Country/TerritorySpain
CityMadrid
Period26/08/2430/08/24

Keywords

  • Concurrency
  • Reference counting
  • Wait-free

Fingerprint

Dive into the research topics of 'A Fast Wait-Free Solution to Read-Reclaim Races in Reference Counting'. Together they form a unique fingerprint.

Cite this