Concurrent Garbage Collection Presented by Roman Kecher GC Seminar, Tel-Aviv University 23-Dec-141.

Slides:



Advertisements
Similar presentations
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
Advertisements

1 Write Barrier Elision for Concurrent Garbage Collectors Martin T. Vechev Cambridge University David F. Bacon IBM T.J.Watson Research Center.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Portable, mostly-concurrent, mostly-copying GC for multi-processors Tony Hosking Secure Software Systems Lab Purdue University.
Reducing Pause Time of Conservative Collectors Toshio Endo (National Institute of Informatics) Kenjiro Taura (Univ. of Tokyo)
Bounding Space Usage of Conservative Garbage Collectors Ohad Shacham December 2002 Based on work by Hans-J. Boehm.
Garbage Collection  records not reachable  reclaim to allow reuse  performed by runtime system (support programs linked with the compiled code) (support.
O N T HE F LY G ARBAGE C OLLECTOR Edger W. Dijkstra Leslie Lamport A. J. Martin C. S. Scholten E.F.M. Steffens Presented by: Dana Drachsler 1.
An On-the-Fly Mark and Sweep Garbage Collector Based on Sliding Views Hezi Azatchi - IBM Yossi Levanoni - Microsoft Harel Paz – Technion Erez Petrank –
On-the-Fly Garbage Collection: An Exercise in Cooperation Edsget W. Dijkstra, Leslie Lamport, A.J. Martin and E.F.M. Steffens Communications of the ACM,
By Jacob SeligmannSteffen Grarup Presented By Leon Gendler Incremental Mature Garbage Collection Using the Train Algorithm.
Efficient Concurrent Mark-Sweep Cycle Collection Daniel Frampton, Stephen Blackburn, Luke Quinane and John Zigman (Pending submission) Presented by Jose.
MC 2 : High Performance GC for Memory-Constrained Environments N. Sachindran, E. Moss, E. Berger Ivan JibajaCS 395T *Some of the graphs are from presentation.
Parallel Garbage Collection Timmie Smith CPSC 689 Spring 2002.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
OOPSLA 2003 Mostly Concurrent Garbage Collection Revisited Katherine Barabash - IBM Haifa Research Lab. Israel Yoav Ossia - IBM Haifa Research Lab. Israel.
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
Garbage Collection Mooly Sagiv html://
MOSTLY PARALLEL GARBAGE COLLECTION Authors : Hans J. Boehm Alan J. Demers Scott Shenker XEROX PARC Presented by:REVITAL SHABTAI.
Correctness-Preserving Derivation of Concurrent Garbage Collection Algorithms Martin T. Vechev Eran Yahav David F. Bacon University of Cambridge IBM T.J.
Incremental Garbage Collection
Memory Management Chapter 5.
1 An Efficient On-the-Fly Cycle Collection Harel Paz, Erez Petrank - Technion, Israel David F. Bacon, V. T. Rajan - IBM T.J. Watson Research Center Elliot.
Chapter 11 Operating Systems
Garbage Collection Mooly Sagiv
Chapter 12 File Management Systems
Damien Doligez Georges Gonthier POPL 1994 Presented by Eran Yahav Portable, Unobtrusive Garbage Collection for Multiprocessor Systems.
Uniprocessor Garbage Collection Techniques Paul R. Wilson.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
Garbage Collection Memory Management Garbage Collection –Language requirement –VM service –Performance issue in time and space.
A Parallel, Real-Time Garbage Collector Author: Perry Cheng, Guy E. Blelloch Presenter: Jun Tao.
1 Overview Assignment 6: hints  Living with a garbage collector Assignment 5: solution  Garbage collection.
Proxy Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
SEG Advanced Software Design and Reengineering TOPIC L Garbage Collection Algorithms.
Transactions and Reliability. File system components Disk management Naming Reliability  What are the reliability issues in file systems? Security.
CHP - 9 File Structures. INTRODUCTION In some of the previous chapters, we have discussed representations of and operations on data structures. These.
1 Chapter 12 File Management Systems. 2 Systems Architecture Chapter 12.
File I/O Applied Component-Based Software Engineering File I/O CSE 668 / ECE 668 Prof. Roger Crawfis.
A Mostly Non-Copying Real-Time Collector with Low Overhead and Consistent Utilization David Bacon Perry Cheng (presenting) V.T. Rajan IBM T.J. Watson Research.
1 Real-Time Replication Garbage Collection Scott Nettles and James O’Toole PLDI 93 Presented by: Roi Amir.
1 File Systems: Consistency Issues. 2 File Systems: Consistency Issues File systems maintains many data structures  Free list/bit vector  Directories.
Incremental Garbage Collection Uwe Kern 23. Januar 2002
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
OOPLs /FEN March 2004 Object-Oriented Languages1 Object-Oriented Languages - Design and Implementation Java: Behind the Scenes Finn E. Nordbjerg,
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Garbage Collection and Memory Management CS 480/680 – Comparative Languages.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
David F. Bacon Perry Cheng V.T. Rajan IBM T.J. Watson Research Center ControllingFragmentation and Space Consumption in the Metronome.
A REAL-TIME GARBAGE COLLECTOR WITH LOW OVERHEAD AND CONSISTENT UTILIZATION David F. Bacon, Perry Cheng, and V.T. Rajan IBM T.J. Watson Research Center.
Memory Management OS Fazal Rehman Shamil. swapping Swapping concept comes in terms of process scheduling. Swapping is basically implemented by Medium.
Concurrent Mark-Sweep Presented by Eyal Dushkin GC Seminar, Tel-Aviv University
® July 21, 2004GC Summer School1 Cycles to Recycle: Copy GC Without Stopping the World The Sapphire Collector Richard L. Hudson J. Eliot B. Moss Originally.
The Metronome Washington University in St. Louis Tobias Mann October 2003.
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
CS412/413 Introduction to Compilers and Translators April 21, 1999 Lecture 30: Garbage collection.
Reference Counting. Reference Counting vs. Tracing Advantages ✔ Immediate ✔ Object-local ✔ Overhead distributed ✔ Very simple Trivial implementation for.
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.
Garbage Collecting the World Presentation: Mark Mastroieni Authors: Bernard Lang, Christian Queinne, Jose Piquer.
CHP - 9 File Structures.
Memory Management © 2004, D. J. Foreman.
Concepts of programming languages
Cycle Tracing Chapter 4, pages , From: "Garbage Collection and the Case for High-level Low-level Programming," Daniel Frampton, Doctoral Dissertation,
Chapter 9: Virtual-Memory Management
David F. Bacon, Perry Cheng, and V.T. Rajan
Strategies for automatic memory management
Reference Counting.
Mooly Sagiv html:// Garbage Collection Mooly Sagiv html://
Presentation transcript:

Concurrent Garbage Collection Presented by Roman Kecher GC Seminar, Tel-Aviv University 23-Dec-141

Outline  General concurrent GC concepts  Incremental, mostly concurrent, “on-the-fly” collections  The lost object problem  Tricolor invariants  Barrier techniques for concurrent GC  Complete enumeration of techniques  Efficient implementation through card tables  Summary 23-Dec-142

Outline  General concurrent GC concepts  Incremental, mostly concurrent, “on-the-fly” collections 23-Dec-143

Concurrent GC  A concurrent GC is essentially a collector running in parallel to the mutator (in different threads)  It may stop the mutator at some points, to synchronize etc  Different from what we have seen by now  A collector must be able to operate incrementally  We will describe a number of different collection types  Suffering from similar limitations  Eventually leading to the concurrent collection 23-Dec-144

Incremental collection  First, on a Uniprocessor Time 23-Dec-145

Incremental collection  On a Multiprocessor: 23-Dec-146

Incremental collection  On a Multiprocessor:  Can also be parallelized: 23-Dec-147

Mostly concurrent collection 23-Dec-148

Mostly concurrent collection  Can also be incremental: 23-Dec-149

Concurrent (“on-the-fly”) collection 23-Dec-1410

Concurrent (“on-the-fly”) collection  Can also be incremental: 23-Dec-1411

Correctness of concurrent collection  Safety  Retains at least all reachable objects  May leave “floating garbage”  Liveness  Collector must eventually complete its collection cycle 23-Dec-1412

Atomicity  Each collector and mutator operation will be specified as operating atomically  Without loss of generality, can consider only a single mutator and a single collector  Actual implementation of the concurrency control  Left to the discretion of the implementer  Possibilities discussed in the “Concurrency Preliminaries” chapter 23-Dec-1413

Revisiting the tricolor abstraction  White objects  Have not (yet) been reached by the collector  Considered garbage at the end  Grey objects  Have been reached but not yet fully processed (may still point to white objects)  Black objects  Have been fully processed (don’t point to white objects immediately after the scan) 23-Dec-1414

Tricolor abstraction and grey wavefront Roots 23-Dec-1415

Tricolor abstraction and grey wavefront Roots 23-Dec-1416

Tricolor abstraction and grey wavefront Roots 23-Dec-1417

Tricolor abstraction and grey wavefront Roots 23-Dec-1418

Tricolor abstraction and grey wavefront Roots 23-Dec-1419

Tricolor abstraction and grey wavefront Roots 23-Dec-1420

Tricolor abstraction and grey wavefront Roots 23-Dec-1421

Tricolor abstraction and grey wavefront Roots 23-Dec-1422

Tricolor abstraction and grey wavefront Roots 23-Dec-1423

The grey wavefront  The boundary between black and white objects  Works great when there is no interleaving of collector and mutator  Recall the definition of a write operation:  atomic Write(src, i, new): old  src[i] src[i]  new 23-Dec-1424

Outline  General concurrent GC concepts  Incremental, mostly concurrent, “on-the-fly” collections  The lost object problem 23-Dec-1425

The lost object problem  Mutator can insert an object behind the wavefront  A reference to a white object is taken (ahead of the wavefront)  Moved to a black object (behind the wavefront)  Original path(s) to it deleted  Two examples:  Direct  The link to the object itself is deleted  Transitive  A link on the path to the object is deleted 23-Dec-1426

Hiding a reachable object – direct Roots XY a Z 23-Dec-1427

Hiding a reachable object – direct Roots XY a Z b  D1:  Write(X, b, Read(Y, a)) 23-Dec-1428

Hiding a reachable object – direct  D2:  Write(Y, a, null) Roots XY Z b 23-Dec-1429

Hiding a reachable object – direct  D3:  scan(Y) Roots XY Z b 23-Dec-1430

Hiding a reachable object – direct Roots XY Z b 23-Dec-1431

Hiding a reachable object – transitive Roots PQ c RS d 23-Dec-1432

Hiding a reachable object – transitive Roots PQ c RS d  T1:  Write(P, e, Read(R, d)) e 23-Dec-1433

Hiding a reachable object – transitive Roots PQ RS d  T2:  Write(Q, c, null) e 23-Dec-1434

Hiding a reachable object – transitive Roots PQ RS d  T3:  scan(Q) e 23-Dec-1435

Hiding a reachable object – transitive Roots PQ RS d e 23-Dec-1436

Outline  General concurrent GC concepts  Incremental, mostly concurrent, “on-the-fly” collections  The lost object problem  Tricolor invariants 23-Dec-1437

Losing objects Wilson [1994] states that an object can be lost only if the following two conditions hold: 1. Mutator stores a pointer to a white object into a black object, and 2. All paths from grey objects to that white object are destroyed 23-Dec-1438

Not losing any objects  Must ensure that both conditions don’t hold simultaneously  Weak tricolor invariant:  All white objects pointed to by black objects are “grey protected”  (reachable from some grey object, directly or through a white chain)  This invalidates the second condition  Strong tricolor invariant:  There are no pointers from black objects to white objects  This invalidates both conditions 23-Dec-1439

Maintaining the invariants  Our examples:  Wrote a pointer to a white object in a black object (D1/T1)  Broke the strong invariant  Deleted all paths from grey objects to that white object (D2/T2)  Broke the weak invariant  Therefore, a black object pointed to a (presumed garbage) white object, violating correctness  Solutions will have to operate at one of these steps 23-Dec-1440

Tradeoffs in the solution space  Solution properties  Precision: amount of “floating garbage”  Efficiency: throughput  Atomicity: degree of concurrency  Example:  A stop-the-world collector obtains:  Maximal precision  No concurrency with the mutator  Finer grained atomicity increases concurrency, at the expense of possibly accuracy and/or overhead of atomic operations 23-Dec-1441

Mutator color  Consider the mutator itself an object  Grey mutator  Has not yet been scanned by the collector, or  Roots have been scanned but have to be rescanned  Black Mutator  Scanned by the collector; roots won’t be rescanned  Under strong invariant: roots don’t point to white objects  Under weak invariant: can hold white objects IF “grey protected” 23-Dec-1442

Nuances of mutator color  Mutator color has implications for collection termination  If a grey mutator is permitted, it may be necessary to halt all mutator threads for a final scan of the roots  Real on-the-fly collectors distinguish among multiple mutator threads  Because they do not stop all at once to sample roots  Therefore, must operate with mutators of different colors  Also, may separate the roots to different groups (black/grey)  For example, by stack frames 23-Dec-1443

Allocation color  Mutator color influences color of allocated memory  Must satisfy the invariant that applies given the mutator color  Grey mutator can allocate white objects  Black mutator can not allocate white objects  Unless it knows that the reference will be stored ahead of wavefront  Allocating black objects is always safe  If an object is allocated grey/black, it will not be reclaimed in the current allocation cycle  Even if reference dropped right away 23-Dec-1444

Short recap 23-Dec-1445  Tricolor invariant types  Weak invariant  Every white object pointed by a black object, is “grey protected”  Strong invariant  No pointers from black objects to white objects  Mutator color  Grey mutator  Some of the roots haven’t been scanned yet  Black mutator  All roots scanned

Incremental update solutions  Address T1/D1 mutations (adding a white pointer to a black object)  Conservatively treat a white object inserted behind the wavefront as alive  Increase (increment) the set of objects known to be live  Use write barrier to re-color source/destination to prevent black to white pointers  Can use a read barrier to load references to a black mutator  Thus, preserve the strong invariant 23-Dec-1446

Snapshot-at-the-beginning solutions  Address T2/D2 mutations (deletion of a white pointer from a white/grey object)  Conservatively treat any white object ahead of the wavefront as alive  Use a write barrier to protect against deletion  Must snapshot the mutator and operate only with black mutator  Maintain the weak invariant  No way to delete all paths from grey objects to any object that was alive at the beginning of the collection cycle 23-Dec-1447

Outline  General concurrent GC concepts  Incremental, mostly concurrent, “on-the-fly” collections  The lost object problem  Tricolor invariants  Barrier techniques for concurrent GC  Complete enumeration of techniques 23-Dec-1448

Barrier techniques To maintain one of the two invariants, the following actions can be taken at barriers:  Add to the wavefront by shading a white object grey  Advance the wavefront by scanning an object (to black)  Retreat the wavefront by reverting a black object to grey Any other action would break the invariants 23-Dec-1449

Grey mutator incremental update (v1)  Steele [1975, 1976]  atomic Write(src, i, ref): src[i]  ref if isBlack(src) if isWhite(ref) revert(src) 23-Dec-1450

Grey mutator incremental update (v1)  Steele [1975, 1976]  atomic Write(src, i, ref): src[i]  ref if isBlack(src) if isWhite(ref) revert(src)  Maintains the strong invariant  No black to white pointers exist  Most precise barrier, at the cost of progress 23-Dec-1451

Grey mutator incremental update (v2)  Boehm et al [1991]  atomic Write(src, i, ref): src[i]  ref if isBlack(src) revert(src) 23-Dec-1452

Grey mutator incremental update (v2)  Boehm et al [1991]  atomic Write(src, i, ref): src[i]  ref if isBlack(src) revert(src)  Less precise  Uses virtual memory dirty bits to record modifications  Stop-the-world to rescan dirty pages 23-Dec-1453

Grey mutator incremental update (v3)  Dijkstra et al [1976, 1978]  atomic Write(src, i, ref): src[i]  ref if isBlack(src) shade(ref) 23-Dec-1454

Grey mutator incremental update (v3)  Dijkstra et al [1976, 1978]  atomic Write(src, i, ref): src[i]  ref if isBlack(src) shade(ref)  Original version even removed the condition check  In order to relax (remove) atomicity  And the original-original version.. 23-Dec-1455

Dijkstra, Owicki and Gries 23-Dec-1456  Dijkstra initially suggested the following (reordered) barrier  Write(src, i, ref): shade(ref) src[i]  ref  Does it work?

23-Dec-1457

Black mutator incremental update (v1)  Baker [1978]  atomic Read(src, i): ref  src[i] if isGrey(src) ref  shade(ref) return ref 23-Dec-1458

Black mutator incremental update (v1)  Baker [1978]  atomic Read(src, i): ref  src[i] if isGrey(src) ref  shade(ref) return ref  Maintains the strong invariant (after snapshotting mutator)  No pointers from black to white  Supports a copying-collector 23-Dec-1459

Black mutator incremental update (v2)  Appel et al [1988]  atomic Read(src, i): if isGrey(src) scan(src) return src[i] 23-Dec-1460

Black mutator incremental update (v2)  Appel et al [1988]  atomic Read(src, i): if isGrey(src) scan(src) return src[i]  Less precise (more coarse-grained) than before  Uses virtual memory page protection mechanisms to trap  Trapped instruction continues after scanning 23-Dec-1461

Black mutator snapshot-at-the-beginning  Abraham and Patel [1987] and Yuasa [1990]  atomic Write(src, i, ref): if isGrey(src) || isWhite(src) shade(src[i]) src[i]  ref 23-Dec-1462

Black mutator snapshot-at-the-beginning  Abraham and Patel [1987] and Yuasa [1990]  atomic Write(src, i, ref): if isGrey(src) || isWhite(src) shade(src[i]) src[i]  ref  Maintains the weak invariant  White objects that were alive at the beginning are grey protected  Less precise of all  Initially wasn’t conditioned (used virtual memory COW) 23-Dec-1463

Black mutator hybrid barrier  Pirinen [1998]  atomic Read(src, i): if isWhite(src) shade(src[i]) return src[i]  atomic Write(src, i, ref): if isGrey(src) shade(src[i]) src[i]  ref 23-Dec-1464

Black mutator hybrid barrier  Pirinen [1998]  atomic Read(src, i): if isWhite(src): shade(src[i]) return src[i]  atomic Write(src, i, ref): if isGrey(src): shade(src[i]) src[i]  ref  Maintains the weak invariant  Actually every black to white pointer has a direct grey father 23-Dec-1465

Completeness of barrier techniques  Pirinen [1998] claims that this is the complete list, other than possible short-circuiting/coarsening:  Scanning instead of shading  Scan origin in a deletion barrier rather than shading deleted ..  The given barrier techniques cover the minimum requirements to maintain their invariants 23-Dec-1466

Outline  General concurrent GC concepts  Incremental, mostly concurrent, “on-the-fly” collections  The lost object problem  Tricolor invariants  Barrier techniques for concurrent GC  Complete enumeration of techniques  Efficient implementation through card tables 23-Dec-1467

Concurrent write barrier mechanisms  Write barriers must detect and record all grey objects  To be inspected (and traced) by the collector  Mutators and collectors will access such data concurrently  Must work correctly and efficiently  One way is to add these grey objects to a log  Which we explored before (Chapter 13; queues etc)  Another solution is using card tables 23-Dec-1468

Card tables  A card table holds one byte for every 512bytes of memory  Marking only the dirty blocks  In our case, the card table is the work list of the collector  Mutators mark dirty blocks and collectors scan them for grey objects  They do it repeatedly; the collector’s job is to make all the cards clean in order to complete marking phase  Might require stop-the-world period to keep mutator from constantly updating 23-Dec-1469

Outline  General concurrent GC concepts  Incremental, mostly concurrent, “on-the-fly” collections  The lost object problem  Tricolor invariants  Barrier techniques for concurrent GC  Complete enumeration of techniques  Efficient implementation through card tables  Summary 23-Dec-1470

Summary  The solution space is huge  Strong/weak tricolor invariants  Grey/black mutators  Many different barrier flavors to consider  Will be useful in the following chapters  There is no free-lunch  Concurrent/incremental garbage collectors require synchronization and possibly do more work overall  But this is in order to reduce observable pause times  Which is important in many situations 23-Dec-1471