Ulterior Reference Counting: Fast Garbage Collection without a Long Wait
description
Transcript of Ulterior Reference Counting: Fast Garbage Collection without a Long Wait
![Page 1: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/1.jpg)
Ulterior Reference Counting:Fast Garbage Collection without a
Long Wait
Author: Stephen M BlackburnKathryn S McKinley
Presenter: Jun Tao
![Page 2: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/2.jpg)
Outline
• Introduction• Background• Ulterior Reference Counting• Methodology• Results• Conclusion
![Page 3: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/3.jpg)
Introduction
• A long-standing and unachieved goal for GC (garbage collector)– Short pause times– Excellent throughput
• Throughput and responsiveness of generational collector (BG-MS) and Reference counting
![Page 4: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/4.jpg)
Introduction• A new generational collector: Ulterior Reference
Counting (URC)– Copying nursery– Reference counting mature space– Use a deferred reference counting– Divides the heap into logical partitions of RC and non-
RC objects– Reference count only infrequently mutated fields– Defer the fields of highly mutated objects and
enumerate them• Trace the deferred pointers• Use a write barrier to remember them
![Page 5: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/5.jpg)
Introduction
• Object lifetime and mutation demographics combine well to fit that requirement– Young objects mutate frequently and die at a high
rate• Favor generational collection, with copying algorithm
using fast contiguous allocations for the young objects– Old objects mutate infrequently and die at a
slower rate• Favor a space efficient free-list allocator and a
reference counting algorithm
![Page 6: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/6.jpg)
Introduction
• BG-RC: a hybrid generational collector– BG: bounded copying nursery– RC: Reference counts the mature space– Ignores nursery pointer mutations– For surviving nursery objects• Enumerates live pointers during tracing• Copies them to RC space• Computes reference counts for the mature space• Reclaims objects with no reference
![Page 7: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/7.jpg)
Background
• Generational Collection– Use tracing to identify dead objects indirectly– Copying collector
• Copies all live objects into another space• Works well when few objects survive• Use bump-pointer allocation
– Mark-sweep collector• Marks live objects• Frees all unmarked objects• Uses free-list allocation• Needs no copy reserve• Poor memory utilization without compaction
![Page 8: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/8.jpg)
Background
• Generational Collection– How to organize nursery collection• Flexible-sized nursery• Fixed-size nursery• Bounded nursery
![Page 9: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/9.jpg)
Background
• Reference Counting– Advantage• The work of garbage detection is spread out over every
mutation
– Disadvantage• Additional algorithms must reclaim cycles• Tracking every pointer mutation is expensive
![Page 10: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/10.jpg)
Background
• Reference Counting (continued)– Mechanisms• Deferral
– Examines certain heavily mutated pointers periodically– Deferral phase in which RCs are not correct– RC phase in which they are
• Buffering– Do not perform RC increments and decrements immediately– Buffer and process them in RC phase
• Coalescing– The periodicity of deferred RC implies that only the initial
values and final values of pointer fields are relevant– Uses the differences to generate increments and decrements
![Page 11: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/11.jpg)
Background
• Reference Counting (continued)– RC Formal Definitions• Mutation event RCM(p)
– i.e., RC(p before)--, RC(p after)++– May be buffered or performed immediately
• Retain event RCR(p)• Deferral
– No mutation generates RCM(p)– Need a RCR(p) to preserve objects
![Page 12: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/12.jpg)
Ulterior Reference Counting
• Generalizing Deferral
A RC integrate event RCI(p) changes a deferred pointer to not-deferred is needed.
![Page 13: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/13.jpg)
Ulterior Reference Counting
• Deferral policies– Determines for each pointer whether or not to
perform mutation events– Three approaches to enumerates deferral set• Trace Deferred Fields
– Trace all live deferred fields just prior to every RC phase
• Record Mutated Deferred Fields• Record Mutated Deferred Objects
![Page 14: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/14.jpg)
Ulterior Reference Counting
• A Generational RC Hybrid Collector (BG-RC)– For young objects• Bump-pointer allocation• Copying collection
– For old objects• Free-list allocation• Reference counting collection
![Page 15: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/15.jpg)
Ulterior Reference Counting
• A Generational RC Hybrid Collector (BG-RC) (continued)
![Page 16: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/16.jpg)
Ulterior Reference Counting
• A Generational RC Hybrid Collector (BG-RC) (continued)– Write Barrier• Remembers pointers into the nursery from the non-
nursery spaces• An object remembering coalescing barrier
![Page 17: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/17.jpg)
Ulterior Reference Counting– Write Barrier (continued)
![Page 18: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/18.jpg)
Ulterior Reference Counting• Controlling Pause Times– Pause time : Nursery collection time + reference
counting time– Appropriate nursery size
• Large• Small
– Frequent collections– Diminishes the effect of coalescing in RC– Gives nursery objects less time to die
– Bound the accumulation of RC work between collections• Limit the growth of meta data
– Modified object buffer– Decrement buffer
![Page 19: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/19.jpg)
Ulterior Reference Counting
• Cycle Detection– Bacon and Rajan’s trial deletion algorithm• Colors the objects from all decrements which do not go
to zero purple and puts them on a list• If a purple still non-zero at the end of a RC phase,
computes the object and objects reachable from it gray and decrements their RCs• All gray objects with RC=0 are cyclic garbage
– The authors’ choice• Perform cycle detection with increasing probability
when the available heap space falls toward a user-defined limit
![Page 20: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/20.jpg)
Methodology
• Jikes RVM and JMTk• Collectors– RC: coalescing, deferred– BG-RC– MS– BG-MS: bounded copying nursery; MS mature
space
![Page 21: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/21.jpg)
Results
![Page 22: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/22.jpg)
Results
![Page 23: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/23.jpg)
Results
![Page 24: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/24.jpg)
Results
• Sensitivity to Heap size– Generational collectors perform better on both GC
time and mutator time• Benefit from bump-pointers
– As the heap size shrinks, BG-RC degrades more rapidly than BG-MS• Pause time guidelines prevent it from reclaiming cyclic
garbage promptly– Mutator time• Performance: MS > BG-MS > BG-RC
![Page 25: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/25.jpg)
Results
BG-RC Sensitivity to Variations in Collection Triggers (defaults are 4MB nursery, 60ms time cap, and 512KB cycle trigger)
![Page 26: Ulterior Reference Counting: Fast Garbage Collection without a Long Wait](https://reader036.fdocuments.us/reader036/viewer/2022062410/56815acd550346895dc8a05c/html5/thumbnails/26.jpg)
Conclusion
• Matches allocation and collection policies to the behaviors of older and younger objects– Copying collector on nursery– Reference Counting collector on mature space
• Achieves good performance on both throughput and responsiveness