Connectivity-Based Garbage Collection Martin Hirzel University of Colorado at Boulder Collaborators: Amer Diwan, Michael Hind, Hal Gabow, Johannes Henkel,

Slides:



Advertisements
Similar presentations
1 Write Barrier Elision for Concurrent Garbage Collectors Martin T. Vechev Cambridge University David F. Bacon IBM T.J.Watson Research Center.
Advertisements

Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html.
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
Object Field Analysis for Heap Space Optimization ISMM 2004 G. Chen, M. Kandemir, N. Vijaykrishnanan and M. J. Irwin The Pennsylvania State University.
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++)
Run-time organization  Data representation  Storage organization: –stack –heap –garbage collection Programming Languages 3 © 2012 David A Watt,
Garbage Collection CSCI 2720 Spring Static vs. Dynamic Allocation Early versions of Fortran –All memory was static C –Mix of static and dynamic.
An On-the-Fly Mark and Sweep Garbage Collector Based on Sliding Views Hezi Azatchi - IBM Yossi Levanoni - Microsoft Harel Paz – Technion Erez Petrank –
JOLT: REDUCING OBJECT CHURN AJ Shankar, Matt Arnold, Ras Bodik UC Berkeley, IBM Research | OOPSLA
ABCD: Eliminating Array-Bounds Checks on Demand Rastislav Bodík Rajiv Gupta Vivek Sarkar U of Wisconsin U of Arizona IBM TJ Watson recent experiments.
Heap Shape Scalability Scalable Garbage Collection on Highly Parallel Platforms Kathy Barabash, Erez Petrank Computer Science Department Technion, Israel.
NUMA Tuning for Java Server Applications Mustafa M. Tikir.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
CS 536 Spring Automatic Memory Management Lecture 24.
Using Prefetching to Improve Reference-Counting Garbage Collectors Harel Paz IBM Haifa Research Lab Erez Petrank Microsoft Research and Technion.
Free-Me: A Static Analysis for Individual Object Reclamation Samuel Z. Guyer Tufts University Kathryn S. McKinley University of Texas at Austin Daniel.
Online Performance Auditing Using Hot Optimizations Without Getting Burned Jeremy Lau (UCSD, IBM) Matthew Arnold (IBM) Michael Hind (IBM) Brad Calder (UCSD)
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
This presentation: Sasha GoldshteinCTO, Sela Group Garbage Collection Performance Tips.
Connectivity-Based Garbage Collection Presenter Feng Xian Author Martin Hirzel, et.al Published in OOPSLA’2003.
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.
Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Garbage Collection Without Paging Matthew Hertz, Yi Feng, Emery Berger University.
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.
1 Reducing Generational Copy Reserve Overhead with Fallback Compaction Phil McGachey and Antony L. Hosking June 2006.
Comparison of JVM Phases on Data Cache Performance Shiwen Hu and Lizy K. John Laboratory for Computer Architecture The University of Texas at Austin.
Compiler Optimizations for Nondeferred Reference-Counting Garbage Collection Pramod G. Joisha Microsoft Research, Redmond.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
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.
Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.
Adaptive Optimization in the Jalapeño JVM M. Arnold, S. Fink, D. Grove, M. Hind, P. Sweeney Presented by Andrew Cove Spring 2006.
Taking Off The Gloves With Reference Counting Immix
An Adaptive, Region-based Allocator for Java Feng Qian, Laurie Hendren {fqian, Sable Research Group School of Computer Science McGill.
Lecture 10 : Introduction to Java Virtual Machine
Java Virtual Machine Case Study on the Design of JikesRVM.
Dynamic Object Sampling for Pretenuring Maria Jump Department of Computer Sciences The University of Texas at Austin Stephen M. Blackburn.
Copyright (c) 2004 Borys Bradel Myths and Realities: The Performance Impact of Garbage Collection Paper: Stephen M. Blackburn, Perry Cheng, and Kathryn.
Free-Me: A Static Analysis for Automatic Individual Object Reclamation Samuel Z. Guyer, Kathryn McKinley, Daniel Frampton Presented by: Dimitris Prountzos.
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.
Mark Marron 1, Deepak Kapur 2, Manuel Hermenegildo 1 1 Imdea-Software (Spain) 2 University of New Mexico 1.
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.
Runtime System CS 153: Compilers. Runtime System Runtime system: all the stuff that the language implicitly assumes and that is not described in the program.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
Immix: A Mark-Region Garbage Collector Curtis Dunham CS 395T Presentation Feb 2, 2011 Thanks to Steve Blackburn and Jennifer Sartor for their 2008 and.
1 Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT) Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss (UMass),
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Introduction to Garbage Collection. Garbage Collection It automatically reclaims memory occupied by objects that are no longer in use It frees the programmer.
1 GC Advantage: Improving Program Locality Xianglong Huang, Zhenlin Wang, Stephen M Blackburn, Kathryn S McKinley, J Eliot B Moss, Perry Cheng.
® 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.
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.
1 The Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT), Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss.
Compositional Pointer and Escape Analysis for Java Programs
Seminar in automatic tools for analyzing programs with dynamic memory
Concepts of programming languages
Strategies for automatic memory management
Adaptive Code Unloading for Resource-Constrained JVMs
Garbage Collection Advantage: Improving Program Locality
Reference Counting.
Presentation transcript:

Connectivity-Based Garbage Collection Martin Hirzel University of Colorado at Boulder Collaborators: Amer Diwan, Michael Hind, Hal Gabow, Johannes Henkel, Matthew Hertz

2 Garbage Collection Benefits Garbage collection leads to simpler Design  no complex deallocation protocols Implementation  automatic deallocation Maintenance  fewer bugs Benefits are widely accepted Java, C#, Python, …

3 Garbage Collection: Haven’t we solved this problem yet? For a state-of-the-art garbage collector: –time ~14% of execution time –space 3x high watermark –pauses 0.8 seconds Can reduce any one cost Challenge: reduce all three costs

4 o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 14 o 12 o 13 Example Heap Boxes: heap objects Arrows: pointers Long box: stack + global variables s1s1 s2s2 g

5 o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 14 o 12 o 13 Thesis 1.Objects form distinct data structures 2.Connected objects die together 3.Garbage collectors can exploit 1. and 2. to reclaim objects efficiently stack + globals

6 Experimental Infrastructure JikesRVM Research Virtual Machine –From IBM Research –Written in Java –Application and runtime system share heap  Good garbage collection even more important Benchmarks –SPECjvm98 suite and SPECjbb2000 –Java Olden suite –xalan, ipsixql, nfc, jigsaw

7 Outline Garbage Collector Design Principles Family of Garbage Collectors Design Space Exploration Pointer Analysis for Java

8 Garbage Collector Design Principles “Do partial collections.” Don’t collect the full heap every time  Shorter pause times o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 14 o 12 o 13 stack + globals

9 Garbage Collector Design Principles “Predict lifetime based on age.” Generational hypothesis: Most objects die young Generational garbage collection: –Partition by age –Collect young objects most often  Low time overhead That’s the state of the art. o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 14 o 12 o 13 stack + globals young generationold generation

10 Garbage Collector Design Principles Generational GC Problems o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 14 o 12 o 13 stack + globals young generationold generation Regular full collections  Long peak pause Old-to-young pointers  Need bookkeeping ~37.5% long-lived objects  Pig in the python

11 Garbage Collector Design Principles “Collect connected objects together.” Likelihood that two objects die at the same time: ConnectivityExampleLikelihood Any pair33.1% Weakly connected46.3% Strongly connected72.4% Direct pointer76.4% o2o2 o1o1 ? o2o2 o1o1 o2o2 o1o1 o2o2 o1o1

12 Garbage Collector Design Principles “Focus on objects with few ancestors.”  Shortlived objects are easy to collect Lifetime Median number of ancestor objects Short2 objects Long83,324 objects

13 Garbage Collector Design Principles “Predict lifetime based on roots.” o1o1 o2o2 o3o3 stack + globals Lifetime Objects reachable …ShortLong indirectly from stack25.6%16.2% only directly from stack32.9%0.8% from globals4.0%20.5% Total62.5%37.5% o4o4 g s For details, see our [ISMM’02] paper.

14 Outline Garbage Collector Design Principles Family of Garbage Collectors Design Space Exploration Pointer Analysis for Java

15 CBGC Family of Garbage Collectors: Connectivity-Based Garbage Collection o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 12 o 13 p1p1 p2p2 p3p3 p4p4 o 14 stack + globals Do partial collections. Collect connected objects together. Predict lifetime based on age. Focus on objects with few ancestors. Predict lifetime based on roots.

16 Family of Garbage Collectors Components of CBGC Before allocation: 1.Partitioning Decide into which partition to put each object Collection algorithm: 2.Estimator Estimate dead + live objects for each partition 3.Chooser Choose “good” set of partitions 4.Partial collection Collect chosen partitions

17 Find fine-grained partitions, where Partition edges respect pointers Objects don’t move between partitions o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 12 o 13 p1p1 p2p2 p3p3 p4p4 Family of Garbage Collectors Partitioning Problem o 14 stack + globals

18 Pointer analysis Type-based [Harris] –o 1 may point to o 2 if o 1 has a field of a type compatible to o 2 Constraint-based [Andersen] –We will discuss this later in the talk o2o2 o1o1 o4o4 o3o3 o5o5 o 10 o6o6 o8o8 o9o9 o7o7 o 11 o 15 o 12 o 13 p1p1 p2p2 p3p3 p4p4 Family of Garbage Collectors Partitioning Solutions o 14 stack + globals

19 Family of Garbage Collectors Estimator Problem For each partition guess dead –Objects that can be reclaimed –Pay-off live –Objects that must be traversed –Cost 3 dead + 3 live 1 dead + 2 live 2 dead + 0 live p1p1 p2p2 p3p3 p4p4 2 dead + 2 live stack + globals

20 Family of Garbage Collectors Estimator Solutions Heuristics Connected objects die together Most objects die young Objects reachable from globals live long The past predicts the future 3 dead + 3 live 1 dead + 2 live 2 dead + 0 live p1p1 p2p2 p3p3 p4p4 2 dead + 2 live stack + globals

21 Family of Garbage Collectors Chooser Problem Pick subset of partitions Maximize total dead Minimize total live Closed under predecessor relation  No bookkeeping for external pointers p3p3 p1p1 p2p2 p3p3 p4p4 7 dead + 5 live 3 dead + 3 live 1 dead + 2 live 2 dead + 0 live 2 dead + 2 live stack + globals

22 Family of Garbage Collectors Chooser Solutions Optimal algorithm based on network flow [TR] Simpler, greedy algorithm p3p3 p1p1 p2p2 p3p3 p4p4 7 dead + 5 live 3 dead + 3 live 1 dead + 2 live 2 dead + 0 live 2 dead + 2 live stack + globals

23 o5o5 o 10 o8o8 o 11 Family of Garbage Collectors Partial Collection Problem o2o2 o6o6 o9o9 o7o7 o5o5 o 10 o8o8 o 11 o 12 o 13 o 15 p2p2 p3p3 p4p4 rest of heap o 14 Look only at chosen partitions Traverse reachable objects Reclaim unreachable objects stack + globals o o

24 o5o5 o 10 o8o8 o 11 Family of Garbage Collectors Partial Collection Solutions o2o2 o6o6 o9o9 o7o7 o5o5 o 10 o8o8 o 11 o 12 o 13 o 15 p2p2 p3p3 p4p4 rest of heap o 14 stack + globals Generalize canonical full-heap algorithms Mark and sweep [McCarthy’60] Semi-space copying [Cheney’70] Treadmill [Baker’92]

25 Outline Garbage Collector Design Principles Family of Garbage Collectors Design Space Exploration Pointer Analysis for Java

26 Design Space Exploration Questions How good is a naïve CBGC? How good could CBGC be in 20 years? How well does CBGC do in a JVM?

27 Design Space Exploration Simulator Methodology Garbage collection simulator (under GPL) –Uses traces of allocations and pointer writes from our benchmark runs Simulator advantages –Easier to implement variety of collector algorithms –Know entire trace beforehand: can use that for “in 20 years” experiments Simulator disadvantages –No bottom-line performance numbers Currently adding CBGC to JikesRVM

28 Design Space Exploration How good is a naïve CBGC? Cost in time Cost in space Pause times Full-heap Semi-space copying CBGC-naïve Type-based partitioning [Harris] Heuristics estimator Appel Copying generational jackxalanjbbjavacjackxalanjbbjavacjackxalanjbbjavac

29 Cost in time Cost in space Pause times Full-heap Semi-space copying CBGC-oracles Partitioning and estimator based on trace Appel Copying generational jackxalanjbbjavacjackxalanjbbjavacjackxalanjbbjavac Design Space Exploration How good could CBGC be in 20 years?

30 CBGC with oracles beats Appel –We did not find a “performance wall” –CBGC has potential The performance gap between CBGC with oracles and naïve CBGC is large –Research challenges Design Space Exploration How good could CBGC be in 20 years?

31 How well does CBGC do in a Java virtual machine? Implementation in progress Need a pointer analysis for the partitioning

32 Outline Garbage Collector Design Principles Family of Garbage Collectors Design Space Exploration Pointer Analysis for Java

33 Pointer Analysis for Java Which analysis do we need? jackxalanjbbjavacjackxalanjbbjavacjackxalanjbbjavacjackxalanjbbjavacjackxalanjbbjavac Cost in time Full-heapCBGCAppel Semi-space copying Type-based partitioning [Harris] Type-based partitioning (oracles) Allocation site partitioning (oracles) Copying generational [Andersen] 1.7 0

34 Pointer Analysis for Java Andersen’s Analysis What When Constraint generation Model flow of pointers Ahead-of-time compilation Constraint propagation Find fixed-point solution Ahead-of-time compilation Allocation-site granularity Set-inclusion constraints Flow and context insensitive can’t analyze Java ahead of time!

35 Pointer Analysis for Java Andersen for all of Java What When Constraint generation Model flow of pointers VM build and start-up Class loading Type resolution Method compilation (JIT) Execution of reflection Execution of native code Constraint propagation Find next fixed- point solution Points-to information used (before garbage collection) Do as little as possible as late as possible

36 Pointer Analysis for Java Correctness Properties Can not do any better for Java! time …… Constraint generation Constraint propagation Ifthere is a pointer thenthe results predict it

37 Pointer Analysis for Java Analysis Cost  Expensive, but once behavior stabilizes, costs diminish to zero ConstraintConstraint propagation generationEagerAt GCAt End SecondsCountSecondsCountSecondsCountSeconds compress db mtrt mpegaudio jack jess javac21.11, xalan20.11,

38 Pointer Analysis for Java Validation Lots of corner cases –Dynamic class loading –Reflection –Native code Missing any one leads to nasty bugs –CBGC relies on conservative results We performed validation runs –Check analysis results against pointers in heap during garbage collection

39 Wrapping Up

40 Related Work: Using Program Analysis for Garbage Collection Stack allocation [ParkGoldberg’92, …] Regions [TofteTalpin’97, …] Liveness analysis [AgesenDetlefsMoss’98, …] Early reclamation [Harris’99] Thread-local heaps [Steensgaard’00, …] Object inlining [DolbyChien’00] Write-barrier removal [ZeeRinard’02, Shuf’02] …

41 Related Work: Pointer analyses for Java Andersen’s analysis for “static Java” [RountevMilanovaRyder’01] [LiangPenningsHarrold’01] [WhaleyLam’02] [LhotakHendren’03] Weaker analyses with dynamic class loading DOIT – [PechtchanskiSarkar’01] XTA – [QianHendren’04] Ruf’s escape analysis – [BogdaSingh’01, King’03] Demand-driven / incremental analysis

42 Other Research Interests Accuracy of Garbage Collection [M.S.Thesis,ISMM’00,ECOOP’01,TOPLAS’02] Profiling [FDDO’01,Patent’01a] Dynamic Optimizations, Prefetching [PLDI’02,Patent’02b] Future directions: More techniques for performance improvement Reducing bugs, improving productivity

43 Contributions presented in this talk Connectivity-based GC design principles [ISMM’02] CBGC, a new family of garbage collectors; Design space exploration with simulator [OOPSLA’03] First non-trivial pointer analysis for Java [ECOOP’04 (to appear)]