Uniprocessor Garbage Collection Techniques Paul R. Wilson.

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.
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Garbage Collection What is garbage and how can we deal with it?
Automatic Storage Management Patrick Earl Simon Leonard Jack Newton.
Lecture 21 Dynamic Memory Allocation:- *Allocation of objects in program ’ s heap _e.g. C ’ s malloc/free or Pascal ’ s new/dispose _e.g. C ’ s malloc/free.
Garbage Collection  records not reachable  reclaim to allow reuse  performed by runtime system (support programs linked with the compiled code) (support.
Memory Management Tom Roeder CS fa. Motivation Recall unmanaged code eg C: { double* A = malloc(sizeof(double)*M*N); for(int i = 0; i < M*N; i++)
Garbage Collection CSCI 2720 Spring Static vs. Dynamic Allocation Early versions of Fortran –All memory was static C –Mix of static and dynamic.
By Jacob SeligmannSteffen Grarup Presented By Leon Gendler Incremental Mature Garbage Collection Using the Train Algorithm.
Parallel Garbage Collection Timmie Smith CPSC 689 Spring 2002.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
CPSC 388 – Compiler Design and Construction
Memory Management. History Run-time management of dynamic memory is a necessary activity for modern programming languages Lisp of the 1960’s was one of.
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
G Robert Grimm New York University Cool Pet Tricks with… …Virtual Memory.
Garbage Collection Mooly Sagiv html://
© Richard Jones, Eric Jul, mmnet GC & MM Summer School, July A Rapid Introduction to Garbage Collection Richard Jones Computing Laboratory.
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
Incremental Garbage Collection
Compilation 2007 Garbage Collection Michael I. Schwartzbach BRICS, University of Aarhus.
An Adaptive, Region-based Allocator for Java Feng Qian & Laurie Hendren 2002.
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.
Garbage collection (& Midterm Topics) David Walker COS 320.
Garbage Collection Mooly Sagiv
Damien Doligez Georges Gonthier POPL 1994 Presented by Eran Yahav Portable, Unobtrusive Garbage Collection for Multiprocessor Systems.
Jangwoo Shin Garbage Collection for Real-Time Java.
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.
SEG Advanced Software Design and Reengineering TOPIC L Garbage Collection Algorithms.
Ulterior Reference Counting: Fast Garbage Collection without a Long Wait Author: Stephen M Blackburn Kathryn S McKinley Presenter: Jun Tao.
A Real-Time Garbage Collector Based on the Lifetimes of Objects Henry Lieberman and Carl Hewitt (CACM, June 1983) Rudy Kaplan Depena CS395T: Memory Management.
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
Runtime Environments. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
Memory Management II: Dynamic Storage Allocation Mar 7, 2000 Topics Segregated free lists –Buddy system Garbage collection –Mark and Sweep –Copying –Reference.
11/26/2015IT 3271 Memory Management (Ch 14) n Dynamic memory allocation Language systems provide an important hidden player: Runtime memory manager – Activation.
Garbage Collection and Memory Management CS 480/680 – Comparative Languages.
Concurrent Garbage Collection Presented by Roman Kecher GC Seminar, Tel-Aviv University 23-Dec-141.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
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 -Memory allocation -Garbage collection.
Consider Starting with 160 k of memory do: Starting with 160 k of memory do: Allocate p1 (50 k) Allocate p1 (50 k) Allocate p2 (30 k) Allocate p2 (30 k)
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
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.
An Efficient, Incremental, Automatic Garbage Collector P. Deutsch and D. Bobrow Ivan JibajaCS 395T.
Runtime Environments Chapter 7. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
Memory Management What if pgm mem > main mem ?. Memory Management What if pgm mem > main mem ? Overlays – program controlled.
Garbage Collection What is garbage and how can we deal with it?
Dynamic Compilation Vijay Janapa Reddi
Concepts of programming languages
Smart Pointers.
Strategies for automatic memory management
Memory Management Kathryn McKinley.
Created By: Asst. Prof. Ashish Shah, J.M.Patel College, Goregoan West
CS703 - Advanced Operating Systems
Automating Memory Management
Reference Counting.
Garbage Collection What is garbage and how can we deal with it?
Mooly Sagiv html:// Garbage Collection Mooly Sagiv html://
Reference Counting vs. Tracing
Presentation transcript:

Uniprocessor Garbage Collection Techniques Paul R. Wilson

FromSapce/Tospace before

Ft after

Too much

3mb vs. 6mb

The Two-Phase Abstraction 1. Detection 2. Reclamation

Why Garbage Collect at All? Safety Memory leaks Continued use of freed pointers Simplicity

Why Garbage Collect at All? Flexibility Hard coded program limits Efficiency! Who is responsible for deletion? Extraneous copies

Liveness and Garbage There is a root set which is defined as live. Anything reachable from a live pointer is also live Everything else is garbage

The Root Set Static global and module variables Local Variables Variables on any activation stack(s) Everyone else Anything Reachable From a live value

Reference Counting Advantages Implicitly distributes garbage collection Real Time guarantees with deferred reclamation Keep a list of zeroed objects not yet processed Memory efficiency, can utilize all available memory with no work room

Reference Counting Pitfalls Conservative- needs a separate GC technique to reclaim cycles Expensive- pointer reassignment requires: Increment Decrement Zero Check Stack Variables frequent creation/destruction Can be optimized to some extent

Reference Counting

Ref counting, unreclaimable

Deferred Reference Counting Defer deletion of zero counted objects Periodically scan the stack for pointers

Mark-Sweep Collection Starting From the root set traverse all pointers via depth/breadth first search. Free everything that is not marked.

Non-Copying issues Same as for traditional allocators Fragmentation Memory block size management Locality of reference- interleaved new/old General issues- work proportional to heap size

Copying Advantages Memory locality preserved Disadvantages Lots of copying! “Scavenging”

Stop and Copy How to update multiple pointers to the same object? Forwarding Pointers Mark/Sweep is proportional to the amount of live data. Assuming this stays roughly constant, increasing memeory will increase efficiency.

Non Copying Version Facts Allocated with a color Fragmentation Advantages Does not require pointer rewriting Supports obscure pointer formats, C friendly

In place collection Conservative estimates Useful for languages like C Pointers can be safely passed to foreign libraries not written with Garbage Collection in mind

Incremental Tracing Collectors The ‘Mutator’ The reachability graph may change From the garbage collectors point of view the actual application is merely a coroutine ir cuncurrent process with an unfortunate tendency to modify data structures that the collector is trying to traverse Floating Garbage Can’t survive more than one extra round

Real Time Garbage Collection Incremental Tracing Collectors In Place Collection Many readers single writer(mutator) As a Copying Collector Multiple Readers Multiple Writers

Tricolor Marking White Initial color for an object subject to collection Black Objects that will be retained after the current round gray Object has been reached, but not its descendents Wave front effect

A violation of the Coloring Invariant

Read Barrier Detects an attempt to read a white object and immediately colors it gray

Write Barrier Traps attempts to write a pointer into an object

Some algorithms Snapshot-at-beginning write barrier Black-only read barrier Baker’s read barrier Dijkstra’s write Barrier Steele’s write Barrier

Baker’s Read Barrier Allocates Black Grey Objects cannot be reverted to white Immediately Invalidates fromspace Any pointer access to fromspace causes the GC to grey the target object by copying it to tospace if necessary and updating the pointer.

Baker’s Non Copying Scheme Real Time Friendly

Treadmill

Black Only Read Barrier When a white object in fromspace is touched it is scanned completely.

Replication Copying Collection Until copying from from space to to space is completed, the mutator continues to read from from space. Write updates must be trapped to update tospace. Single simultaneous ‘flip’ where all pointers are updated. Expensive for standard hardware, but cheap for functional languages

Real time considerations Read Barriers add an unpredictable cost per pointer access Nilson background scavenger, reserve only Write barrier may be more expensive overall, but the cost per access is well bounded Guaranteeing progress allocation clock, frees per allocation Statically allocate troublesome objects

Results Writer barrier more efficient on standard hardware

Snapshot at the Beginning Catches pointers which try to escape from white objects If a pointer is replace in a black object, the replaced pointer is first stored. All overwritten pointers are saved via a write barrier. All objects that are live at the beginning of collection remain live Allocate Black during collection round Incremental Update Reverts black to gray when an object is written to, or else grays they new pointed to object

Incremental Update with Write- Barrier(Dijkstra)g Catches pointers that try to hide in black objects Reverts Black to gray If the overwritten pointer is not pointed to elsewhere then it is garbage Allocated white. Newly allocated objects assumed unreachable

Motivationfor a new Strategy Most objects are short lived 80% to 90% die within a few million instructions Objects that don’t die quickly are more likely to live a while Long lived objects are copied over and over Excessive Paging in Scanning if the heap must exceed available physical memory

Generational Garbage Collection

Generational gc before

Generational gc after

Gc memory usage

Variations of generational collection Intergenerational references Write barrier Old to younger Young to old Collection Advancement policies Advance always Advance after 2 rounds Counter in the header field? Advance always? Semispace in the last generation 3 spaces Bucket brigade Mark compact in the oldest generation for memory efficiency