A Principled Approach to Nondeferred Reference-Counting Garbage Collection † Pramod G. Joisha HP Labs, Palo Alto † This work was done when the author was.

Slides:



Advertisements
Similar presentations
An Implementation of Mostly- Copying GC on Ruby VM Tomoharu Ugawa The University of Electro-Communications, Japan.
Advertisements

Paging: Design Issues. Readings r Silbershatz et al: ,
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Lecture 10: Heap Management CS 540 GMU Spring 2009.
MC 2 : High Performance GC for Memory-Constrained Environments - Narendran Sachindran, J. Eliot B. Moss, Emery D. Berger Sowmiya Chocka Narayanan.
5. Memory Management From: Chapter 5, Modern Compiler Design, by Dick Grunt et al.
Garbage Collection CSCI 2720 Spring Static vs. Dynamic Allocation Early versions of Fortran –All memory was static C –Mix of static and dynamic.
Resurrector: A Tunable Object Lifetime Profiling Technique Guoqing Xu University of California, Irvine OOPSLA’13 Conference Talk 1.
By Jacob SeligmannSteffen Grarup Presented By Leon Gendler Incremental Mature Garbage Collection Using the Train Algorithm.
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
Using Prefetching to Improve Reference-Counting Garbage Collectors Harel Paz IBM Haifa Research Lab Erez Petrank Microsoft Research and Technion.
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.
© Richard Jones, Eric Jul, mmnet GC & MM Summer School, July A Rapid Introduction to Garbage Collection Richard Jones Computing Laboratory.
21 September 2005Rotor Capstone Workshop Parallel, Real-Time Garbage Collection Daniel Spoonhower Guy Blelloch, Robert Harper, David Swasey Carnegie Mellon.
Generational Stack Collection And Profile driven Pretenuring Perry Cheng Robert Harper Peter Lee Presented By Moti Alperovitch
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Run time vs. Compile time
Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland.
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
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.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
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.
SEG Advanced Software Design and Reengineering TOPIC L Garbage Collection Algorithms.
Fast, Effective Code Generation in a Just-In-Time Java Compiler Rejin P. James & Roshan C. Subudhi CSE Department USC, Columbia.
Ulterior Reference Counting: Fast Garbage Collection without a Long Wait Author: Stephen M Blackburn Kathryn S McKinley Presenter: Jun Tao.
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.
1/36 by Martin Labrecque How to Fake 1000 Registers Oehmke, Binkert, Mudge, Reinhart to appear in Micro 2005.
Copyright (c) 2004 Borys Bradel Myths and Realities: The Performance Impact of Garbage Collection Paper: Stephen M. Blackburn, Perry Cheng, and Kathryn.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
1 Real-Time Replication Garbage Collection Scott Nettles and James O’Toole PLDI 93 Presented by: Roi Amir.
OOPLs /FEN March 2004 Object-Oriented Languages1 Object-Oriented Languages - Design and Implementation Java: Behind the Scenes Finn E. Nordbjerg,
C++ Memory Overview 4 major memory segments Key differences from Java
Compilation (Semester A, 2013/14) Lecture 13b: Memory Management Noam Rinetzky Slides credit: Eran Yahav 1.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Garbage Collection and Memory Management CS 480/680 – Comparative Languages.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
GARBAGE COLLECTION IN AN UNCOOPERATIVE ENVIRONMENT Hans-Juergen Boehm Computer Science Dept. Rice University, Houston Mark Wieser Xerox Corporation, Palo.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
® 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.
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.
Simple Generational GC Andrew W. Appel (Practice and Experience, February 1989) Rudy Kaplan Depena CS 395T: Memory Management February 9, 2009.
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
An Efficient, Incremental, Automatic Garbage Collector P. Deutsch and D. Bobrow Ivan JibajaCS 395T.
Just-In-Time Compilation. Introduction Just-in-time compilation (JIT), also known as dynamic translation, is a method to improve the runtime performance.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Dynamic Compilation Vijay Janapa Reddi
Names and Attributes Names are a key programming language feature
Dynamic Memory Allocation
Rifat Shahriyar Stephen M. Blackburn Australian National University
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Strategies for automatic memory management
Adaptive Code Unloading for Resource-Constrained JVMs
Memory Management Kathryn McKinley.
Closure Representations in Higher-Order Programming Languages
José A. Joao* Onur Mutlu‡ Yale N. Patt*
Created By: Asst. Prof. Ashish Shah, J.M.Patel College, Goregoan West
Dynamic Binary Translators and Instrumenters
Reference Counting.
Presentation transcript:

A Principled Approach to Nondeferred Reference-Counting Garbage Collection † Pramod G. Joisha HP Labs, Palo Alto † This work was done when the author was at Microsoft Research. VEE’08 (ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments)March 7, 2008

VEE’08 1 Classic RC Instrumentation local references global reference

VEE’08 2 Unique Advantages Prompt reuse –Cache effect gives performance benefits Low footprint –Can run in a smaller heap Useful in memory-constrained environments Incremental in time and space –No repeated traversals of long-lived data –Spatial locality usually no worse than mutator Can present simpler overall designs –No stack maps needed, at least in single-thread case

VEE’08 3 What is “Nondeferred” RC Collection? Three invariants should always hold: 1.All live data have positive reference counts 2.Reference count is zero when last reference disappears 3.Zero reference count implies dead data Classic reference counting is nondeferred –Deutsch & Bobrow’s reference counting is not There are subtleties in the definition –“Last reference” is from mutator’s standpoint –Reference count could be zero even before

VEE’08 4 Deutsch & Bobrow’s Reference Counting Approximate reference counts –Only heap references tallied –Zero-Count Table (ZCT) Threads paused to reconcile –Stacks scanned to purge ZCT –Remaining entries garbage Nondeferred invariants might not always hold stack x y z a 1 b 0 heap c 1 f.g globals

VEE’08 5 The Spectrum of RC Techniques

VEE’08 6 What is Different from Previous Efforts? Past work addressed optimizations: –Given a nondeferred app, how to make it faster? 2006 & 2007 ACM International Symposium on Memory Management This work addresses a different obstacle: –How to convert object-oriented apps to use nondeferred? The line of work has an overarching goal: –Making nondeferred RC garbage collection practical –Making general reference counting more efficient

VEE’08 7 Contributions of This Work Addresses main problems to conversion: –How to handle object-oriented instruction sets uniformly? –How to insert RC updates to achieve early reclamation? –How to do this in the midst of modern language features? Exceptions, object pinning, interior pointers –How to treat the run-time system? Interaction of conversion with other phases –Impact on downstream phases should be minimal –Conversion has implications on inlining

VEE’08 8 Talk Outline The RC update insertion phase –High-level process –Code templates Trading code quality with eagerness The scope of the insertion phase How does the technique fare? Summary Some Further Thoughts

VEE’08 9 The RC Update Insertion Phase

VEE’08 10 Motivation: Normalize the IR Key step: Subsume interior pointers –Interior pointers similar to conventional pointers –But can only be used in a few well-defined ways –Should be honored by the garbage collector Approach: Shadow interior pointer accesses Preprocessing Stage shadow interior ptr array object

VEE’08 11 Find dying references using liveness analysis –Supplementary decrements may be needed If references are both defined and live on entry to the statement s If other references could be defined in s Liveness modified for pinned references Analysis Stage

VEE’08 12 Injection Stage Three kinds of RC updates inserted –RC increment, standard and eager RC decrement Operates in three steps –Insert RC updates against definitions and deaths –Insert RC increments against explicit intrafunction throws –Insert standard RC decrements into exception headers Injection guided by code templates –Based on classifying a statement as call or “non-call”

VEE’08 13 Non-Call Statements

VEE’08 14 An Example

VEE’08 15 Issue with Representing the Eager Decrement

VEE’08 16 Trading Code Quality with Eagerness

VEE’08 17 Everything Shouldn’t be Converted! All code in the run-time isn’t converted Presently, C# attributes flag special code –[PreInitRefCounts] Bootstrap memory allocation, and static initializers –[RecursiveRefCounts] Code transitively reachable from addref and release –[ManualRefCounts] Methods that directly manipulate reference counts –[ZombieRefCounts] Code accessing zombie objects Affixation rules can be mechanized

VEE’08 18 Related Work The use of liveness in GC isn’t new –But past work considers it for a tracing collector This work considers reference deaths –Important distinction: Arises from a basic difference between tracing and reference counting One looks at live matter and the other at matter that is dead (see Bacon et al. OOPSLA’04). Certain complications are unique here –E.g. exceptions

VEE’08 19 How does Nondeferred Fare? Xlisp interpreter (SPEC CINT95 port)

VEE’08 20 Summary A systematic conversion algorithm –Instructions are treated in a uniform manner –Modern language features handled –Degree of eagerness can be varied Conversion has implications on other parts Has been implemented in a compiler –Many large programs have been successfully compiled

What remains for primetime? –Optimizing single-thread heap reference counting –Concurrent nondeferred reference counting –Cycle reclamation –Fragmentation An ecosystem of supporting tools required –Presently, a memory leak verifier and profiler exist –But more needed! VEE’08 21 decreasing importance Some Further Thoughts

VEE’08 22 Questions?