MOSTLY PARALLEL GARBAGE COLLECTION Authors Hans J Boehm
MOSTLY PARALLEL GARBAGE COLLECTION Authors : Hans J. Boehm Alan J. Demers Scott Shenker XEROX PARC Presented by: REVITAL SHABTAI
Introduction n A method for adapting garbage collectors designed to run sequentially with the client.
Overview n n n Problem introduction Basic idea Method components Implementation choices Empirical results Conclusions
Garbage Collectors Styles n Two basic styles of garbage collection algorithms: 1. Reference-counting collector 2. Tracing collector
Traditional Tracing n n n A set of root memory objects always accessible Mark - performing reachability from the roots and marking the accessible objects Sweep - reclaiming unmarked objects
The Problem n n n A straightforward implementation prevents any client action while tracing (stop-theworld) Sometimes the tracing is an intolerable long pause Two approaches to reduce pause times of tracing collectors: 1. Generational collectors 2. Parallel collectors
The Basic Idea n n n Most of the tracing algorithm runs in parallel with the client Small portion of the tracing is done during stop-the-world action Relying on virtual memory information about pages that have been updates during a given period of time
The Parallel Method n n n Define a set of dirty bits for a set of virtual pages Clear all virtual dirty bits Perform a parallel tracing Update the dirty bits to reflect client writes Stop-the-world and trace from all marked objects that lie on dirty pages Reclaim unreachable (unmarked) objects
Method - Comments n n n The parallel tracing phase provides an approximation to the true reachable set The stop-the-world tracing phase provides a full complete set of the reachable objects The duration of the final stop-theworld phase is related to the number of pages written during the parallel collection
Method -Comments 2 n n Not all unreachable objects are reclaimed, but will be reclaimed by a subsequent collection Copying collectors (moving objects) require a more careful treatment
The Mark Phase n n n Split the heap into blocks In each block objects of the same size A block size is the a physical page Set a bit for each accessible object Queue pages for sweeping in a separate queue for each object size
The Sweep Phase n n n Done with object allocation (not during a stop-the-world) The allocator keeps a free lists for each object size If an empty free list is found: Sweep the first page in the queue Remove the page from the queue Restore unreachable objects from this page to the free list
Consequences n n n Worst case of mark phase duration is as in the non-parallel tracing Worst case of allocating objects is when full pages are scanned in order to find free objects In practice both are noticeable
Partial Collector - Formal Definitions n n n Partial Collector - a collector that reclaims only a subset of all unreachable objects A set T (threatened) - potentially collectible objects A set I (immune) - the non-collectible objects
Formal Statements n C : Every object in I is marked and every object pointed to by a marked object is also marked n TR : Mark all objects in I and trace from them n F : Trace from all marked objects on dirty pages
Stop the world parallel n n Condition C holds Stop the world Clear all mark bits Perform TR Restart the world mostly n n Condition C does not hold n n Clear all mark bits Clear all virtual dirty bits Perform TR Stop the world Perform F Restart the world C’ : Every object in I is marked and every object pointed to by a marked object on a clean page is also marked
Reducing the stopthe-world Delay n n M - Atomically clear the virtual dirty bits from the pages P, and trace from the marked objects on the dirty pages of P. A Partial Generational Mostly Parallel Collection: 1. Perform M on the heap 2. Stop the world 3. Perform F 4. Restart the world
Reducing the stop-theworld Delay- Version 2 n M’ : 1. Atomically clear the dirty bits from the pages P 2. For all marked objects pointed to by marked objects on dirty pages of P mark them and dirty the pages on which they reside
Implementation Choices n n n Repeated applications of M’ instead of a single application of M Run M more that once before a partial collection Further variants of M are possible (such as M mark from other sets) When to run a full collection? When to expand the heap? How to control the scheduling of the client and collector threads
Empirical Results
Mostly Parallel Copying Collectors n n For each object, additional space is required forwarding links The collector copies fromspace to to-space and update the forwarding links
Mostly Parallel Copying Collector Implementation n n Additions to the copying collector: 1. Clear the forwarding links 2. Update dirty pages bits 3. Update forwarding links In the stop-the-world phase for any object O that lie on dirty page: 1. Copy any object O points at 2. Update pointers in copies 3. Copy O and update its fields
Conclusion n Mostly parallel partial generational tracing collector that run sequentially with the client Various implementation choices for various cases Reduced the stop-the-world phase time duration
THE END
- Slides: 24