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.

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.
Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html.
On-the-Fly Garbage Collection Using Sliding Views Erez Petrank Technion – Israel Institute of Technology Joint work with Yossi Levanoni, Hezi Azatchi,
Incorporating Generations into a Modern Reference Counting Garbage Collector Hezi Azatchi Advisor: Erez Petrank.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Garbage Collection What is garbage and how can we deal with it?
Copying GC and Reference Counting Jonathan Kalechstain Tel Aviv University 11/11/2014.
Garbage Collection  records not reachable  reclaim to allow reuse  performed by runtime system (support programs linked with the compiled code) (support.
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,
Efficient Concurrent Mark-Sweep Cycle Collection Daniel Frampton, Stephen Blackburn, Luke Quinane and John Zigman (Pending submission) Presented by Jose.
Heap Shape Scalability Scalable Garbage Collection on Highly Parallel Platforms Kathy Barabash, Erez Petrank Computer Science Department Technion, Israel.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
CPSC 388 – Compiler Design and Construction
Increasing Memory Usage in Real-Time GC Tobias Ritzau and Peter Fritzson Department of Computer and Information Science Linköpings universitet
Mark and Sweep Algorithm Reference Counting Memory Related PitFalls
CS 536 Spring Automatic Memory Management Lecture 24.
An Efficient Machine-Independent Procedure for Garbage Collection in Various List Structures, Schorr and Waite CACM August 1967, pp Curtis Dunham.
Using Prefetching to Improve Reference-Counting Garbage Collectors Harel Paz IBM Haifa Research Lab Erez Petrank Microsoft Research and Technion.
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.
An On-the-Fly Reference Counting Garbage Collector for Java Erez Petrank Technion – Israel Institute of Technology Joint work with Yossi Levanoni – Microsoft.
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.
Connectivity-Based Garbage Collection Presenter Feng Xian Author Martin Hirzel, et.al Published in OOPSLA’2003.
Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland.
Damien Doligez Georges Gonthier POPL 1994 Presented by Eran Yahav Portable, Unobtrusive Garbage Collection for Multiprocessor Systems.
Uniprocessor Garbage Collection Techniques Paul R. Wilson.
G1 TUNING Shubham Modi( ) Ujjwal Kumar Singh(10772) Vaibhav(10780)
Reference Counters Associate a counter with each heap item Whenever a heap item is created, such as by a new or malloc instruction, initialize the counter.
Compiler Optimizations for Nondeferred Reference-Counting Garbage Collection Pramod G. Joisha Microsoft Research, Redmond.
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.
1 Overview Assignment 6: hints  Living with a garbage collector Assignment 5: solution  Garbage collection.
SEG Advanced Software Design and Reengineering TOPIC L Garbage Collection Algorithms.
Flexible Reference-Counting-Based Hardware Acceleration for Garbage Collection José A. Joao * Onur Mutlu ‡ Yale N. Patt * * HPS Research Group University.
Taking Off The Gloves With Reference Counting Immix
Ulterior Reference Counting: Fast Garbage Collection without a Long Wait Author: Stephen M Blackburn Kathryn S McKinley Presenter: Jun Tao.
1 Real-Time Replication Garbage Collection Scott Nettles and James O’Toole PLDI 93 Presented by: Roi Amir.
Incremental Garbage Collection Uwe Kern 23. Januar 2002
OOPLs /FEN March 2004 Object-Oriented Languages1 Object-Oriented Languages - Design and Implementation Java: Behind the Scenes Finn E. Nordbjerg,
Compilation (Semester A, 2013/14) Lecture 13b: Memory Management Noam Rinetzky Slides credit: Eran Yahav 1.
Fast Garbage Collection without a Long Wait Steve Blackburn – Kathryn McKinley Presented by: Na Meng Ulterior Reference Counting:
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.
University of Washington Wouldn’t it be nice… If we never had to free memory? Do you free objects in Java? 1.
More Distributed Garbage Collection DC4 Reference Listing Distributed Mark and Sweep Tracing in Groups.
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.
2/4/20161 GC16/3011 Functional Programming Lecture 20 Garbage Collection Techniques.
® 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.
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.
Naming CSCI 6900/4900. Unreferenced Objects in Dist. Systems Objects no longer needed as nobody has a reference to them and hence will not use them Garbage.
GARBAGE COLLECTION Student: Jack Chang. Introduction Manual memory management Memory bugs Automatic memory management We know... A program can only use.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Garbage Collection What is garbage and how can we deal with it?
Seminar in automatic tools for analyzing programs with dynamic memory
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,
Ulterior Reference Counting Fast GC Without The Wait
David F. Bacon, Perry Cheng, and V.T. Rajan
Strategies for automatic memory management
José A. Joao* Onur Mutlu‡ Yale N. Patt*
Reference Counting.
Garbage Collection What is garbage and how can we deal with it?
Reference Counting vs. Tracing
Presentation transcript:

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 K. Kolodner - IBM Haifa Research Lab

2 Garbage Collection Manual de-allocation may cause notorious bugs (memory leaks, dangling pointers). Garbage collection (GC): automatic recycling of dynamically allocated memory. Garbage: objects that are not live, but are not free either.

3 Reference Counting Each object has an rc field. New objects get o.rc:=1. When p that points to o 1 is modified to point to o 2 we do: o 1.rc--, o 2.rc++. if o 1.rc==0: Decrement rc for all sons of o 1. Recursively delete objects whose rc is decremented to 0. Delete o 1. o1o1 o2o2 p

4 Three Main Drawbacks of RC High overhead Costly parallelism Inability to reclaim cycles Drastic improvement by Levanoni-Petrank 2001 This work

5 Cyclic Structures Reclamation Problem A garbage cycle denotes a strongly connected component in the objects graph which is unreachable from the program roots. Garbag e cycle p a b c 21

6 Collecting Garbage Cycles in Reference Counting Systems Reference counting collectors employ one of 2 avenues to collect garbage cycles: A backup tracing collector. A cycle collector. This work proposes a new concurrent cycle collection. Contributions: More efficient than previous concurrent cycle collector. Solves termination problem. First throughput comparison between cycle collection and a backup tracing collector.

7 Cycle Collection Basic Idea - 1 Observation 1: Garbage cycles can only be created when a rc is decremented to a non- zero value.  Objects whose rc is decremented to a non-zero value become candidates.

8 Cycle Collection Basic Idea - 2 Observation 2: In a garbage cycle all the reference counts are due to internal pointer of the cycle.  For each candidate ’ s sub-graph, check if external pointers point to this sub-graph.  Terms:  Sub-graph of O: graph of objects reachable from O.  External pointer (to a sub-graph): a pointer from a non sub-graph object to a sub-graph object.  Internal pointer (of a sub-graph): a pointer between 2 sub-graph objects. o o1o2 o4o5 a o3

9 Goal: Compute Counts for External Pointers Only 1 r 2 a 1 b c 2 d 2 Not a garbage cycle a garbage cycle 1 r 1 a 1 b c 2 d 2 edge r->a deleted 1 r 0 a 0 b c 0 d 1 rc ’ s when ignoring internal edges

10 Implementing the Cycle Collector Idea 1 r 2 a 1 b c 2 d Object is colored black/ gray/ white.  Whenever a rc of an object ‘ a ’ is decremented to a non-zero value, perform 3 local traversals over the graph of objects of ‘ a ’. Mark: Updates rc ’ s to reflect only pointers that are external to the graph of ‘ a ’, marking nodes in gray. Scan: Restores rc ’ s of the externally reachable objects, coloring them in black. Rest of the nodes are marked as garbage (white). Collect: collects garbage objects (the white ones).

11 Concurrent Cycle Collection A concurrent collector: a collector that runs concurrently with the program threads. Concurrent cycle collection is more complex: objects graph may be modified while the collector scans it. Cannot rely on repeated traversals of a graph to read the same set of nodes and edges.  Using the algorithm above may produce incorrect results. Concurrent program GC

12 Safety Problem - Example A mutator deletes the edge c->d, between the MarkGray and Scan procedures. b d c e a  The Scan phase incorrectly infers live objects (a & b) to be garbage.

13 Confronting Drawbacks in Previous Work Previous concurrent cycle collector by Bacon & Rajan added overhead to achieve safety in light of inconsistent view of the heap. Overhead reduces efficiency. Completeness could not be achieved. Our solution: use a fixed-view of the heap! Multiple heap traces consider the same graph each time.

14 Getting a Snapshot of the Heap A snapshot of the heap could be taken by a concurrent collector. Levanoni-Petrank ’ s snapshot: Copy-on-first-write mechanism: for each pointer modified for the first time after a collection: Save its snapshot value in a buffer. Mark the pointer “ dirty ” (no need to be logged again). The cycle collector traverses each object according to the pointers ’ values as existed in the snapshot time. Concurrent program GC

15 Cycle Collection on Heap ’ s Snapshot The standard (non-concurrent) cycle collection correctly identifies garbage cycles on a snapshot. It is not disturbed by mutator activity. All garbage cycles are collected. A garbage cycle created, must exist in next snapshot. Only garbage cycles are collected. A non reachable cycle in the snapshot is indeed a garbage cycle. Concurrent program GC

16 Levanoni-Petrank ’ s RC Consider a pointer p that takes the following values between GC’s: O 0,O 1, O 2, …, O n. All RC algorithms perform 2n operations: O 0.rc--; O 1.rc++; O 1.rc--; O 2.rc++; O 2.rc--; … ; O n.rc++; p O1O1 O2O2 O3O3 OnOn..... O4O4 O0O0 But only 2 operations are needed:O 0.rc--,O n.rc++

17 Less Cycle Candidates Previous algorithms: object whose rc is decremented to a non-zero value is considered as a candidate. The Levanoni-Petrank ’ s write-barrier does not log most of the decrements. Does it “ miss ” cycles? The new cycle collection algorithm collects all cycles, although performing less work. p O1O1 O2O2 O3O3 OnOn..... O4O4 O0O0

18 More in the Paper Reducing pauses further by stopping each thread separately (instead of all together). Care with new races … More techniques to reduce the number of traced objects. Concurrent On-the-Fly program GC

19 Measurements Implemented in Jikes with two collectors: The sliding-views reference-counting collector. The age-oriented collector: Uses mark and sweep for the young generation and reference counting for the old generation. Measurements: Throughput comparison between cycle collection and a backup tracing collector. Characteristic comparison to the previous on-the- fly cycle collector.

20 Work Reduction

21 Work Reduction with the Age-Oriented Collector

22 Throughput Comparison of Cycle- Collection with Backup Tracing

23 Throughput Comparison of Cycle- Collection with Backup Tracing

24 Related Work Cycle collection: Cyclic reference counting with local mark-scan. Martinez, Wachenchauzer and Lins [1990]. Cyclic reference counting with lazy mark-scan. Lins [1992]. Concurrent cycle collection in reference counted systems. Bacon and Rajan [2001]. Other: An on-the-fly reference counting garbage collector for Java. Levanoni and Petrank [2001]. Age-Oriented Concurrent Garbage Collection. Paz, Petrank, and Blackburn [2005].

25 Conclusions Cycle collection may be efficiently executed on-the-fly by using Levanoni-Petrank ’ s RC with the efficient standard cycle collector. Today ’ s benchmarks: Reference counting for full heap: prefer a backup tracing. Reference counting for old generation: slight preference to cycle collection. Eyes for the future: with large heaps cycle collection may outperform backup tracing.