skip to main content
10.1145/3243176.3243195acmconferencesArticle/Chapter ViewAbstractPublication PagespactConference Proceedingsconference-collections
research-article
Public Access

Biased reference counting: minimizing atomic operations in garbage collection

Published:01 November 2018Publication History

ABSTRACT

Reference counting (RC) is one of the two fundamental approaches to garbage collection. It has the desirable characteristics of low memory overhead and short pause times, which are key in today's interactive mobile platforms. However, RC has a higher execution time overhead than its counterpart, tracing garbage collection. The reason is that RC implementations maintain per-object counters, which must be continually updated. In particular, the execution time overhead is high in environments where low memory overhead is critical and, therefore, non-deferred RC is used. This is because the counter updates need to be performed atomically.

To address this problem, this paper proposes a novel algorithm called Biased Reference Counting (BRC), which significantly improves the performance of non-deferred RC. BRC is based on the observation that most objects are only accessed by a single thread, which allows most RC operations to be performed non-atomically. BRC leverages this by biasing each object towards a specific thread, and keeping two counters for each object --- one updated by the owner thread and another updated by the other threads. This allows the owner thread to perform RC operations non-atomically, while the other threads update the second counter atomically.

We implement BRC in the Swift programming language runtime, and evaluate it with client and server programs. We find that BRC makes each RC operation more than twice faster in the common case. As a result, BRC reduces the average execution time of client programs by 22.5%, and boosts the average throughput of server programs by 7.3%.

References

  1. An Artificial Garbage Collection Benchmark. http://www.hboehm.info/gc/gc_bench.htmlGoogle ScholarGoogle Scholar
  2. CryptoSwift. https://github.com/krzyzanowskim/CryptoSwiftGoogle ScholarGoogle Scholar
  3. Kitura: A Swift Web framework and HTTP Server. http://www.kitura.io/Google ScholarGoogle Scholar
  4. Perfect: Server-side Swift. http://perfect.org/Google ScholarGoogle Scholar
  5. Server-side swift benchmarks. https://github.com/rymcol/Server-Side-Swift-Benchmarks-Summer-2017Google ScholarGoogle Scholar
  6. Swift Benchmark Suite. https://github.com/apple/swift/tree/master/benchmarkGoogle ScholarGoogle Scholar
  7. Swift Has Reached 1.0. https://developer.apple.com/swift/blog/?id=14Google ScholarGoogle Scholar
  8. Swift Programming Language. https://swift.org/.Google ScholarGoogle Scholar
  9. Swift Version of Ray Tracing. https://github.com/rnapier/raytraceGoogle ScholarGoogle Scholar
  10. SwiftyJSON. https://github.com/SwiftyJSON/SwiftyJSONGoogle ScholarGoogle Scholar
  11. T. H. Axford. 1990. Reference Counting of Cyclic Graphs for Functional Programs. Comput. J. 33, 5 (1990), 466--472. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. David F. Bacon, Clement R. Attanasio, Han B. Lee, V. T. Rajan, and Stephen Smith. 2001. Java Without the Coffee Breaks: A Nonintrusive Multiprocessor Garbage Collector. In Proceedings of the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation (PLDI '01). 92--103. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in Reference Counted Systems. In Proceedings of the 15th European Conference on Object-Oriented Programming (ECOOP '01). 207--235. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Jeffrey M. Barth. 1977. Shifting Garbage Collection Overhead to Compile Time. Commun. ACM 20, 7 (1977), 513--518. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Stephen M. Blackburn and Kathryn S. McKinley. 2003. Ulterior Reference Counting: Fast Garbage Collection Without a Long Wait. In Proceedings of the 18th Annual ACM SIGPLAN Conference on Object-oriented Programing, Systems, Languages, and Applications (OOPSLA '03). 344--358. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. David R. Brownbridge. 1985. Cyclic reference counting for combinator machines. In Conference on Functional Programming and Computer Architecture. 273--288. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. George E. Collins. 1960. A Method for Overlapping and Erasure of Lists. Commun. ACM 3, 12 (Dec. 1960), 655--657. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. L. Peter Deutsch and Daniel G. Bobrow. 1976. An Efficient, Incremental, Automatic Garbage Collector. Commun. ACM 19, 9 (1976), 522--526. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. David Dice, Mark Moir, and William Scherer III. 2003. Quickly Reacquirable Locks. Technical Report. Sun Microsystem Laboratories.Google ScholarGoogle Scholar
  20. José A. Joao, Onur Mutlu, and Yale N. Patt. 2009. Flexible Reference-counting-based Hardware Acceleration for Garbage Collection. In Proceedings of the 36th Annual International Symposium on Computer Architecture (ISCA '09). 418--428. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Pramod G. Joisha. 2006. Compiler Optimizations for Nondeferred Reference-Counting Garbage Collection. In Proceedings of the 5th International Symposium on Memory Management (ISMM '06). Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Pramod G. Joisha. 2007. Overlooking Roots: A Framework for Making Non-deferred Reference-counting Garbage Collection Fast. In Proceedings of the 6th International Symposium on Memory Management (ISMM '07). 141--158. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Pramod G. Joisha. 2008. A Principled Approach to Nondeferred Reference-counting Garbage Collection. In Proceedings of the 4th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments (VEE '08). 131--140. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Richard E. Jones and Rafael D. Lins. 1993. Cyclic Weighted Reference Counting Without Delay. In Proceedings of the 5th International PARLE Conference on Parallel Architectures and Languages Europe (PARLE '93). 712--715. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Kiyokuni Kawachiya, Akira Koseki, and Tamiya Onodera. 2002. Lock Reservation: Java Locks Can Mostly Do Without Atomic Operations. In Proc. of the 17th Annual ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications (OOPSLA '02). Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Yossi Levanoni and Erez Petrank. 2001. An On-the-fly Reference Counting Garbage Collector for Java. In Proceedings of the 16th ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications (OOPSLA'01). 367--380. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. A. D. Martínez, R. Wachenchauzer, and R. D. Lins. 1990. Cyclic Reference Counting with Local Mark-scan. Inf. Process. Lett. 34, 1 (1990), 31--35. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. John McCarthy. 1960. Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I. Commun. ACM 3, 4 (1960), 184--195. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Tamiya Onodera, Kikyokuni Kawachiya, and Akira Koseki. 2004. Lock Reservation for Java Reconsidered. In Proceedings of the 18th European Conference on Object-Oriented Programming (ECOOP '04).Google ScholarGoogle ScholarCross RefCross Ref
  30. Young Gil Park and Benjamin Goldberg. 1991. Reference Escape Analysis: Optimizing Reference Counting Based on the Lifetime of References. In Proceedings of the 1991 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation (PEPM '91). 178--189. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Harel Paz, David F. Bacon, Elliot K. Kolodner, Erez Petrank, and V. T. Rajan. 2007. An Efficient On-the-fly Cycle Collection. ACM Trans. Program. Lang. Syst. 29, 4 (2007). Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Harel Paz and Erez Petrank. 2007. Using Prefetching to Improve Reference-counting Garbage Collectors. In Proceedings of the 16th International Conference on Compiler Construction (CC'07). 48--63. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Harel Paz, Erez Petrank, David F. Bacon, Elliot K. Kolodner, and V. T. Rajan. 2005. An Efficient On-the-fly Cycle Collection. In Proceedings of the 14th International Conference on Compiler Construction (CC'05). 156--171. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Filip Pizlo, Daniel Frampton, and Antony L. Hosking. 2011. Fine-grained Adaptive Biased Locking. In Proceedings of the 9th International Conference on Principles and Practice of Programming in Java (PPPJ '11). 171--181. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Ian Rogers and Balaji Iyengar. 2011. Reducing Biased Lock Revocation by Learning. In Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems. 65--73. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Kenneth Russell and David Detlefs. 2006. Eliminating Synchronization-related Atomic Operations with Biased Locking and Bulk Rebiasing. In Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-oriented Programming Systems, Languages, and Applications (OOPSLA '06). 263--272. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Rifat Shahriyar, Stephen M. Blackburn, and Daniel Frampton. 2012. Down for the Count? Getting Reference Counting Back in the Ring. In Proceedings of the 2012 International Symposium on Memory Management (ISMM '12). 73--84. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Rifat Shahriyar, Stephen M. Blackburn, and Kathryn S. McKinley. 2014. Fast Conservative Garbage Collection. In Proceedings of the 2014 ACM International Conference on Object-oriented Programming Systems Languages, and Applications (OOPSLA '14). 121--139. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Rifat Shahriyar, Stephen Michael Blackburn, Xi Yang, and Kathryn S. McKinley. 2013. Taking off the Gloves with Reference Counting Immix. In Proceedings of the 2013 ACM SIGPLAN International Conference on Object-oriented Programming Systems Languages, and Applications (OOPSLA '13). 93--110. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. David Ungar. 1984. Generation Scavenging: A Non-disruptive High Performance Storage Reclamation Algorithm. In Proceedings of the First ACM SIGSOFT/SIGPLAN Software Engineering Symposium on Practical Software Development Environments (SDE 1). 157--167. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. David Ungar, David Grove, and Hubertus Franke. 2017. Dynamic Atomicity: Optimizing Swift Memory Management. In Proceedings of the 13th ACM SIGPLAN International Symposium on Dynamic Languages (DLS '17). 15--26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Nalini Vasudevan, Kedar S. Namjoshi, and Stephen A. Edwards. 2010. Simple and Fast Biased Locks. In Proceedings of the 19th International Conference on Parallel Architectures and Compilation Techniques (PACT '10). 65--74. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Biased reference counting: minimizing atomic operations in garbage collection

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in
      • Published in

        cover image ACM Conferences
        PACT '18: Proceedings of the 27th International Conference on Parallel Architectures and Compilation Techniques
        November 2018
        494 pages
        ISBN:9781450359863
        DOI:10.1145/3243176

        Copyright © 2018 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 1 November 2018

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate121of471submissions,26%

        Upcoming Conference

        PACT '24
        International Conference on Parallel Architectures and Compilation Techniques
        October 14 - 16, 2024
        Southern California , CA , USA

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader