Free-Me: A Static Analysis for Automatic Individual Object Reclamation Samuel Z. Guyer, Kathryn McKinley, Daniel Frampton Presented by: Dimitris Prountzos.

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

Steve Blackburn Department of Computer Science Australian National University Perry Cheng TJ Watson Research Center IBM Research Kathryn McKinley Department.
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.
Garbage Collection What is garbage and how can we deal with it?
Michael Bond Kathryn McKinley The University of Texas at Austin Presented by Na Meng Most of the slides are from Mike’s original talk. Many thanks go to.
MC 2 : High Performance GC for Memory-Constrained Environments - Narendran Sachindran, J. Eliot B. Moss, Emery D. Berger Sowmiya Chocka Narayanan.
Garbage Collection  records not reachable  reclaim to allow reuse  performed by runtime system (support programs linked with the compiled code) (support.
1 Error-Free Garbage Collection Traces: How to Cheat and Not Get Caught ACM SIGMETRICS, 2002.
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.
Hastings Purify: Fast Detection of Memory Leaks and Access Errors.
By Jacob SeligmannSteffen Grarup Presented By Leon Gendler Incremental Mature Garbage Collection Using the Train Algorithm.
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.
Heap Shape Scalability Scalable Garbage Collection on Highly Parallel Platforms Kathy Barabash, Erez Petrank Computer Science Department Technion, Israel.
CPSC 388 – Compiler Design and Construction
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
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.
Free-Me: A Static Analysis for Individual Object Reclamation Samuel Z. Guyer Tufts University Kathryn S. McKinley University of Texas at Austin Daniel.
Pointer and Shape Analysis Seminar Context-sensitive points-to analysis: is it worth it? Article by Ondřej Lhoták & Laurie Hendren from McGill University.
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
Connectivity-Based Garbage Collection Presenter Feng Xian Author Martin Hirzel, et.al Published in OOPSLA’2003.
Scaling CFL-Reachability-Based Points- To Analysis Using Context-Sensitive Must-Not-Alias Analysis Guoqing Xu, Atanas Rountev, Manu Sridharan Ohio State.
Run-Time Storage Organization
Run time vs. Compile time
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
An Adaptive, Region-based Allocator for Java Feng Qian & Laurie Hendren 2002.
Compile-Time Deallocation of Individual Objects Sigmund Cherem and Radu Rugina International Symposium on Memory Management June, 2006.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Garbage Collection Without Paging Matthew Hertz, Yi Feng, Emery Berger University.
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.
Flexible Reference-Counting-Based Hardware Acceleration for Garbage Collection José A. Joao * Onur Mutlu ‡ Yale N. Patt * * HPS Research Group University.
Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.
Taking Off The Gloves With Reference Counting Immix
11 Values and References Chapter Objectives You will be able to: Describe and compare value types and reference types. Write programs that use variables.
An Adaptive, Region-based Allocator for Java Feng Qian, Laurie Hendren {fqian, Sable Research Group School of Computer Science McGill.
Ulterior Reference Counting: Fast Garbage Collection without a Long Wait Author: Stephen M Blackburn Kathryn S McKinley Presenter: Jun Tao.
Putting Pointer Analysis to Work Rakesh Ghiya and Laurie J. Hendren Presented by Shey Liggett & Jason Bartkowiak.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Dynamic Object Sampling for Pretenuring Maria Jump Department of Computer Sciences The University of Texas at Austin Stephen M. Blackburn.
Chameleon Automatic Selection of Collections Ohad Shacham Martin VechevEran Yahav Tel Aviv University IBM T.J. Watson Research Center Presented by: Yingyi.
Runtime Environments. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses Michael D. Bond University of Texas at Austin Graham Z. Baker Tufts / MIT.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 Automatic Heap Sizing: Taking Real Memory into Account Ting Yang, Emery Berger,
Finding Your Cronies: Static Analysis for Dynamic Object Colocation Samuel Z. Guyer Kathryn S. McKinley T H E U N I V E R S I T Y O F T E X A S A T A U.
September 11, 2003 Beltway: Getting Around GC Gridlock Steve Blackburn, Kathryn McKinley Richard Jones, Eliot Moss Modified by: Weiming Zhao Oct
380C lecture 19 Where are we & where we are going –Managed languages Dynamic compilation Inlining Garbage collection –Opportunity to improve data locality.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
1 Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT) Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss (UMass),
University of Washington Wouldn’t it be nice… If we never had to free memory? Do you free objects in Java? 1.
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)
Object-Relative Addressing: Compressed Pointers in 64-bit Java Virtual Machines Kris Venstermans, Lieven Eeckhout, Koen De Bosschere Department of Electronics.
Introduction to Garbage Collection. Garbage Collection It automatically reclaims memory occupied by objects that are no longer in use It frees the programmer.
Pointer and Escape Analysis for Multithreaded Programs Alexandru Salcianu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
1 GC Advantage: Improving Program Locality Xianglong Huang, Zhenlin Wang, Stephen M Blackburn, Kathryn S McKinley, J Eliot B Moss, Perry Cheng.
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
Runtime Environments Chapter 7. Support of Execution  Activation Tree  Control Stack  Scope  Binding of Names –Data object (values in storage) –Environment.
1 The Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT), Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss.
Memory Management What if pgm mem > main mem ?. Memory Management What if pgm mem > main mem ? Overlays – program controlled.
Object Lifetime and Pointers
Seminar in automatic tools for analyzing programs with dynamic memory
Concepts of programming languages
Jipeng Huang, Michael D. Bond Ohio State University
Strategies for automatic memory management
José A. Joao* Onur Mutlu‡ Yale N. Patt*
Created By: Asst. Prof. Ashish Shah, J.M.Patel College, Goregoan West
Garbage Collection Advantage: Improving Program Locality
Program-level Adaptive Memory Management
Presentation transcript:

Free-Me: A Static Analysis for Automatic Individual Object Reclamation Samuel Z. Guyer, Kathryn McKinley, Daniel Frampton Presented by: Dimitris Prountzos Some slides adapted from the original PLDI talk

Motivation Automatic memory reclamation (GC) No need for explicit “free” Garbage collector reclaims memory Eliminates many programming errors Problem: when do we get memory back? Frequent GCs: Reclaim memory quickly (minimize memory footprint), with high overhead Infrequent GCs: Lower overhead, but lots of garbage in memory Can we combine the software engineering advantage of garbage collection with the low-cost incremental reclamation of explicit memory management ?

Example Notice: String idName is often garbage Memory: void parse(InputStream stream) { while (not_done) { String idName = stream.readToken(); Identifier id = symbolTable.lookup(idName); if (id == null) { id = new Identifier(idName); symbolTable.add(idName, id); } computeOn(id); }} Read a token (new String) Look up in symbol table If not there, create new identifier, add to symbol table Compute on identifier

Explicit Reclamation as the solution Garbage does not accumulate Memory: void parse(InputStream stream) { while (not_done) { String idName = stream.readToken(); Identifier id = symbolTable.lookup(idName) if (id == null) { id = new Identifier(idName); symbolTable.add(idName, id); } else free (idName); computeOn(id); }} String idName is garbage, free immediately

FreeMe as the solution Adds free() automatically FreeMe compiler pass inserts calls to free() Preserve software engineering benefits Can’t determine lifetimes for all objects Works with the garbage collector Implementation of free() depends on collector Goal: Incremental, “eager” memory reclamation Results: reduce GC load, improve performance Potential: 1.7X performance malloc / free vs GC in tight heaps (Hertz & Berger, OOPSLA 2005)

Outline Motivation Analysis Runtime support Experimental evaluation Conclusions

FreeMe Analysis Goal: Determine when an object becomes unreachable Not a whole-program analysis * Idea: pointer analysis + liveness Pointer analysis for reachability Liveness analysis for when Within a method, for allocation site “ p = new A ” where can we place a call to “ free(p) ”? I’ll describe the interprocedural parts later

Pointer Analysis idName symbolTable readToken String Identifier (global) id String idName = stream.readToken(); Identifier id = symbolTable.lookup(idName); if (id == null) { id = new Identifier(idName); symbolTable.add(idName, id); } computeOn(id); Connectivity graph Variables Allocation sites Globals (statics) Analysis algorithm Flow-insensitive, field-insensitive

Pointer Analysis in more depth (1) Data Structures

void function(A p1, A p2, A p3) { v1 = new O p1.f = v1 p2 = p1.f p3 = p1 } Pointer Analysis in more depth (2) Calculating the Points-To relation p1 N p1 N I1 p2 N p2 N I2 p3 N p3 N I3 v1 O1

Interprocedural component Detection of factory methods Return value is a new object Can be freed by the caller Effects of methods called Describes how parameters are connected Compilation strategy: Summaries pre-computed for all methods Free-me only applied to hot methods String idName = stream.readToken(); symbolTable.add(idName, id); Hashtable.add : (0 → 1) (0 → 2)

Generating summaries in more depth p1 Np1Np1 Np1Np1 N I1 p2 Np2Np2 Np2Np2 N I2 p3 Np3Np3 Np3Np3 N I3 v1 O1 void function(A p1, A p2, A p3) { v1 = new O p1.f = v1 p2 = p1.f p3 = p1 } Getfield is needed because a single pointer link in summary may represent multiple pointers in the callee

The need for liveness analysis Liveness identifies when objects become unreachable, not just whether or not they escape idName symbolTable readToken String Identifier (global) id

Adding Liveness Key : idName readToken String Identifier (global) An object is reachable only when all incoming pointers are live From a variable:Live range of the variable From a global:Live from the pointer store onward Live from the pointer store until source object becomes unreachable From other object: Reachability is union of all these live ranges

Liveness Analysis Computed as sets of edges Variables Heap pointers String idName = stream.readToken(); id = new Identifier(idName); computeOn(id); if (id == null) Identifier id = symbolTable.lookup(idName); symbolTable.add(idName, id); idName (global) readToken String Identifier

Where can we free it? Where object exists -minus- Where reachable String idName = stream.readToken(); id = new Identifier(idName); computeOn(id); if (id == null) Identifier id = symbolTable.lookup(idName); symbolTable.add(idName, id); readToken String Compiler inserts call to free(idName)

Free placement issues Select earliest point A, eliminate all B: A dom B Deal with double free’s

Limitations & Extensions Free-me frees short-lived objects with explicit pointers to them in the code Factory variability Potential extensions: – Container internals interprocedural liveness & pointer analysis || shape analysis – Large data structures Global context sensitive heap model interprocedural liveness & pointer analysis

Runtime support for FreeMe Run-time: depends on collector Mark/sweep Free-list: free() operation Generational mark/sweep Unbump: move nursery “bump pointer” backward (LIFO frees) Unreserve: reduce copy reserve Very low overhead Run longer without collecting Size to free defined statically/dynamically (query object)

Experimental Evaluation

Volume freed – in MB 100% 50% 0% compress 105 jess 263 raytrace 91 mtrt 98 javac 183 jack 271 pseudojbb 180 xalan 8195 antlr bloat fop 103 hsqldb 515 jython 348 pmd 822 ps 523 db 74 SPEC benchmarks DaCapo benchmarks Increasing alloc size

Volume freed – in MB 100% 50% 0% compress 105 jess 263 raytrace 91 mtrt 98 javac 183 jack 271 pseudojbb 180 xalan 8195 antlr bloat fop 103 hsqldb 515 jython 348 pmd 822 ps 523 db FreeMe Mean: 32%

Comparing FreeMe & other approaches Stack-like free() allocations of same method Restrict free instrumentation to end of method No factory methods No conditional freeing Uncond Prove objects dead on all paths Influence of free on some paths

Mark/sweep – time 20% 15% 6% All benchmarks

Mark/sweep – GC time All benchmarks 30% 9%

GenMS – time All benchmarks Brings into question all techniques that target short-lived objects

GenMS – GC time Why doesn’t this help? Note: the number of GCs is greatly reduced FreeMe mostly finds short- lived objects All benchmarks Nursery reclaims dead objects for free (cost ~ survivors)

Bloat – GC time 12%

Conclusions FreeMe analysis – Finds many objects to free: often 30% - 60% – Most are short-lived objects GC + explicit free() – Advantage over stack/region allocation: no need to make decision at allocation time Generational collectors – Nursery works very well Mark-sweep collectors – 50% to 200% speedup – Works better as memory gets tighter Embedded applications: Compile-ahead Memory constrained Non-moving collectors

Discussion Are the percentages of freed memory good enough ? Is compile-time memory management inherently incompatible with generational copying collection? Abandon techniques that replace nursery? How close is the actual gap between compiler analysis + ‘weaker’ GC aglorithms vs. generational collection