skip to main content
10.1145/3453483.3454060acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article
Open access

Concurrent deferred reference counting with constant-time overhead

Published: 18 June 2021 Publication History

Abstract

We present a safe automatic memory reclamation approach for concurrent programs, and show that it is both theoretically and practically efficient. Our approach combines ideas from referencing counting and hazard pointers in a novel way to implement concurrent reference counting with wait-free, constant-time overhead. It overcomes the limitations of previous approaches by significantly reducing modifications to, and hence contention on, the reference counts. Furthermore, it is safer and easier to use than manual approaches. Our technique involves using a novel generalization of hazard pointers to defer reference-count decrements until no other process can be incrementing them, and to defer or elide reference-count increments for short-lived references.
We have implemented the approach as a C++ library and compared it experimentally to several methods including existing atomic reference-counting libraries and state-of-the art manual techniques. Our results indicate that our technique is faster than existing reference-counting implementations, and competitive with manual memory reclamation techniques. More importantly, it is significantly safer than manual techniques since objects are reclaimed automatically.

References

[1]
Dan Alistarh, Patrick Eugster, Maurice Herlihy, Alexander Matveev, and Nir Shavit. 2014. Stacktrack: An automated transactional approach to concurrent memory reclamation. In European Conference on Computer Systems (EUROSYS). https://doi.org/10.1145/2592798.2592808
[2]
Dan Alistarh, William Leiserson, Alexander Matveev, and Nir Shavit. 2017. Forkscan: Conservative memory reclamation for modern operating systems. In European Conference on Computer Systems (EUROSYS). https://doi.org/10.1145/3064176.3064214
[3]
Dan Alistarh, William Leiserson, Alexander Matveev, and Nir Shavit. 2018. Threadscan: Automatic and scalable memory reclamation. ACM Trans. Parallel Comput., 4, 4 (2018), 1–18. https://doi.org/10.1145/3201897
[4]
David F Bacon, Clement R Attanasio, Han B Lee, VT Rajan, and Stephen Smith. 2001. Java without the coffee breaks: A nonintrusive multiprocessor garbage collector. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/378795.378819
[5]
Henry G Baker. 1994. Minimizing reference count updating with deferred and anchored pointers for functional data structures. SIGPLAN Not., 29, 9 (1994), 38–43. https://doi.org/10.1145/185009.185016
[6]
Oana Balmau, Rachid Guerraoui, Maurice Herlihy, and Igor Zablotchi. 2016. Fast and robust memory reclamation for concurrent data structures. In ACM Symposium on Parallelism in Algorithms and Architectures (SPAA). https://doi.org/10.1145/2935764.2935790
[7]
Stephen M Blackburn and Kathryn S McKinley. 2003. Ulterior reference counting: Fast garbage collection without a long wait. In ACM SIGPLAN Conference on Object-oriented programming, systems, languages, and applications (OOPSLA).
[8]
Guy E. Blelloch and Yuanhao Wei. 2020. Concurrent Reference Counting and Resource Management in Wait-free Constant Time. arxiv:2002.07053.
[9]
Guy E Blelloch and Yuanhao Wei. 2020. LL/SC and Atomic Copy: Constant Time, Space Efficient Implementations using only pointer-width CAS. In 34rd International Symposium on Distributed Computing (DISC 2020). https://doi.org/10.4230/LIPIcs.DISC.2020.5
[10]
Anastasia Braginsky, Alex Kogan, and Erez Petrank. 2013. Drop the anchor: lightweight memory management for non-blocking data structures. In ACM Symposium on Parallelism in Algorithms and Architectures (SPAA). https://doi.org/10.1145/2486159.2486184
[11]
Trevor Alexander Brown. 2015. Reclaiming Memory for Lock-Free Data Structures: There has to be a Better Way. In ACM Symposium on Principles of Distributed Computing (PODC). https://doi.org/10.1145/2767386.2767436
[12]
Nachshon Cohen. 2018. Every data structure deserves lock-free memory reclamation. ACM SIGPLAN Conference on Object-oriented programming, systems, languages, and applications (OOPSLA), https://doi.org/10.1145/3276513
[13]
Nachshon Cohen and Erez Petrank. 2015. Efficient memory management for lock-free data structures with optimistic access. In ACM Symposium on Parallelism in Algorithms and Architectures (SPAA). https://doi.org/10.1145/2755573.2755579
[14]
Andreia Correia, Pedro Ramalhete, and Pascal Felber. 2021. OrcGC: automatic lock-free memory reclamation. In ACM Symposium on Principles and Practice of Parallel Programming (PPoPP). https://doi.org/10.1145/3437801.3441596
[15]
Tudor David, Rachid Guerraoui, and Vasileios Trigonakis. 2015. Asynchronized concurrency: The secret to scaling concurrent search data structures. In ACM SIGARCH Computer Architecture News. 43, 631–644. https://doi.org/10.1145/2786763.2694359
[16]
David Detlefs, Paul Alan Martin, Mark Moir, and Guy L. Steele Jr. 2002. Lock-free reference counting. Distributed Computing, 15, 4 (2002), 255–271. https://doi.org/10.1007/s00446-002-0079-z
[17]
L Peter Deutsch and Daniel G Bobrow. 1976. An efficient, incremental, automatic garbage collector. Commun. ACM, 19, 9 (1976), 522–526. https://doi.org/10.1145/360336.360345
[18]
Dave Dice, Maurice Herlihy, and Alex Kogan. 2016. Fast Non-Intrusive Memory Reclamation for Highly-Concurrent Data Structures. SIGPLAN Not., 51, 11 (2016), 36–45. https://doi.org/10.1145/2926697.2926699
[19]
Aleksandar Dragojević, Maurice Herlihy, Yossi Lev, and Mark Moir. 2011. On the power of hardware transactional memory to simplify memory management. In ACM Symposium on Principles of Distributed Computing (PODC). https://doi.org/10.1145/1993806.1993821
[20]
J. Evans. 2019 (accessed November 5, 2019). Scalable memory allocation using jemalloc. https://www.facebook.com/notes/facebook-engineering/scalable-memory-allocation-using-jemalloc/480222803919
[21]
Facebook. 2020 (accessed June 5, 2020). Facebook Open Source Library. https://github.com/facebook/folly
[22]
Keir Fraser. 2004. Practical lock-freedom. University of Cambridge, Computer Laboratory. https://doi.org/10.48456/tr-579
[23]
Michal Friedman, Naama Ben-David, Yuanhao Wei, Guy E Blelloch, and Erez Petrank. 2020. NVTraverse: in NVRAM data structures, the destination is more important than the journey. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/3385412.3386031
[24]
Anders Gidenstam, Marina Papatriantafilou, Håkan Sundell, and Philippas Tsigas. 2009. Efficient and Reliable Lock-Free Memory Reclamation Based on Reference Counting. IEEE Trans. Parallel Distrib. Syst., 20, 8 (2009), https://doi.org/10.1109/TPDS.2008.167
[25]
D. Guniguntala, P. E. McKenney, J. Triplett, and J. Walpole. 2008. The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with Linux. IBM Syst. J., 47, 2 (2008), 221–236. issn:0018-8670 https://doi.org/10.1147/sj.472.0221
[26]
Timothy L. Harris. 2001. A Pragmatic Implementation of Non-blocking Linked-Lists. In International Symposium on Distributed Computing (DISC). https://doi.org/10.1007/3-540-45414-4_21
[27]
Thomas E. Hart, Paul E. McKenney, Angela Demke Brown, and Jonathan Walpole. 2007. Performance of memory reclamation for lockless synchronization. J. Parallel Distrib. Comput., 67, 12 (2007), 1270–1285. https://doi.org/10.1016/j.jpdc.2007.04.010
[28]
Maurice Herlihy, Victor Luchangco, Paul Martin, and Mark Moir. 2005. Nonblocking Memory Management Support for Dynamic-sized Data Structures. ACM Trans. Comput. Syst., 23, 2 (2005), May, https://doi.org/10.1145/1062247.1062249
[29]
Maurice Herlihy, Victor Luchangco, and Mark Moir. 2002. The Repeat Offender Problem: A Mechanism for Supporting Dynamic-Sized, Lock-Free Data Structures. In International Symposium on Distributed Computing (DISC). https://doi.org/10.1007/3-540-36108-1_23
[30]
Maurice Herlihy and Nir Shavit. 2008. The Art of Multiprocessor Programming. Morgan Kaufmann Publishers Inc., San Francisco, CA, USA. isbn:0123705916, 9780123705914
[31]
Maurice P Herlihy and Jeannette M Wing. 1990. Linearizability: A correctness condition for concurrent objects. ACM Trans. Program. Lang. Syst., 12, 3 (1990), 463–492. https://doi.org/10.1145/78969.78972
[32]
Richard Jones, Antony Hosking, and Eliot Moss. 2011. The Garbage Collection Handbook: The Art of Automatic Memory Management (1st ed.). Chapman & Hall/CRC. isbn:1420082795
[33]
Jeehoon Kang and Jaehwang Jung. 2020. A marriage of pointer-and epoch-based reclamation. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/3385412.3385978
[34]
Alex Kogan and Erez Petrank. 2012. A methodology for creating fast wait-free data structures. SIGPLAN Not., 47, 8 (2012), 141–150. https://doi.org/10.1145/2370036.2145835
[35]
Hyonho Lee. 2010. Fast local-spin abortable mutual exclusion with bounded space. In International Conference on Principles of Distributed Systems (OPODIS). https://doi.org/10.1007/978-3-642-17653-1_27
[36]
Yossi Levanoni and Erez Petrank. 2001. An on-the-fly reference counting garbage collector for Java. In ACM SIGPLAN Conference on Object-oriented programming, systems, languages, and applications (OOPSLA). https://doi.org/10.1145/504282.504309
[37]
The GNU C++ Library. 2019 (accessed November 5, 2019). The GNU C++ Library. https://gcc.gnu.org/onlinedocs/libstdc++/
[38]
Alisdair Meredith. 2017. Revising atomic_shared_ptr for C++20. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0718r2.html
[39]
Maged M Michael. 2002. High performance dynamic lock-free hash tables and list-based sets. In ACM Symposium on Parallelism in Algorithms and Architectures (SPAA). https://doi.org/10.1145/564870.564881
[40]
Maged M Michael. 2004. Hazard pointers: Safe memory reclamation for lock-free objects. IEEE Trans. Parallel Distrib. Syst., 15, 6 (2004), 491–504. https://doi.org/10.1109/TPDS.2004.8
[41]
M. M. Michael and M. L. Scott. 1995. Correction of a memory management method for lock-free data structures. Computer Science Department, University of Rochester.
[42]
Maged M. Michael, Michael Wong, Paul McKenney, Geoffrey Romer, Andrew Hunter, Arthur O’Dwyer, David S. Hollman, JF Bastien, Hans Boehm, David Goldblatt, Frank Birbacher, and Mathias Stearn. 2019. Hazard Pointers: Proposed Interface and Wording for Concurrency TS 2. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1121r1.pdf
[43]
Maged M. Michael, Michael Wong, Paul McKenney, Geoffrey Romer, Andrew Hunter, Arthur O’Dwyer, David S. Hollman, JF Bastien, Hans Boehm, David Goldblatt, Frank Birbacher, and Mathias Stearn. 2017. Proposed Wording for Concurrent Data Structures: Hazard Pointer and Read-Copy-Update (RCU). http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0566r3.pdf
[44]
Aravind Natarajan and Neeraj Mittal. 2014. Fast concurrent lock-free binary search trees. In ACM Symposium on Principles and Practice of Parallel Programming (PPoPP). https://doi.org/10.1145/2555243.2555256
[45]
Ruslan Nikolaev and Binoy Ravindran. 2020. Universal Wait-Free Memory Reclamation. In ACM Symposium on Principles and Practice of Parallel Programming (PPoPP). https://doi.org/10.1145/3332466.3374540
[46]
Dan Plyukhin. 2015 (accessed November 5, 2019). Distributed Reference Counting for Asynchronous Shared Memory. http://rucs.ca/theory-of-computation/distributed-reference-counting-for-asynchronous-shared-memory
[47]
Pedro Ramalhete and Andreia Correia. 2017. Brief announcement: Hazard eras-non-blocking memory reclamation. In ACM Symposium on Parallelism in Algorithms and Architectures (SPAA). https://doi.org/10.1145/3087556.3087588
[48]
Håkan Sundell. 2005. Wait-Free Reference Counting and Memory Management. In International Parallel and Distributed Processing Symposium (IPDPS). https://doi.org/10.1109/IPDPS.2005.451
[49]
John D. Valois. 1995. Lock-free Linked Lists Using Compare-and-swap. In ACM Symposium on Principles of Distributed Computing (PODC). https://doi.org/10.1145/224964.224988
[50]
Haosen Wen, Joseph Izraelevitz, Wentao Cai, H Alan Beadle, and Michael L Scott. 2018. Interval-based memory reclamation. SIGPLAN Not., 53, 1 (2018), 1–13. https://doi.org/10.1145/3200691.3178488
[51]
Anthony Williams. 2012. C++ concurrency in action: practical multithreading. Manning Publ.
[52]
Anthony Williams. 2019 (accessed November 5, 2019). just::thread Concurrency Library. https://www.stdthread.co.uk

Cited By

View all

Index Terms

  1. Concurrent deferred reference counting with constant-time overhead

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    PLDI 2021: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation
    June 2021
    1341 pages
    ISBN:9781450383912
    DOI:10.1145/3453483
    This work is licensed under a Creative Commons Attribution International 4.0 License.

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 18 June 2021

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. automatic memory reclamation
    2. concurrent algorithms
    3. wait-free

    Qualifiers

    • Research-article

    Funding Sources

    Conference

    PLDI '21
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 406 of 2,067 submissions, 20%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)1,267
    • Downloads (Last 6 weeks)89
    Reflects downloads up to 01 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Login options

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media