GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.

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.
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.
CSC 213 – Large Scale Programming. Today’s Goals  Consider what new does & how Java works  What are traditional means of managing memory?  Why did.
Data Structures: A Pseudocode Approach with C
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.
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.
An On-the-Fly Mark and Sweep Garbage Collector Based on Sliding Views Hezi Azatchi - IBM Yossi Levanoni - Microsoft Harel Paz – Technion Erez Petrank –
Resurrector: A Tunable Object Lifetime Profiling Technique Guoqing Xu University of California, Irvine OOPSLA’13 Conference Talk 1.
Guoquing Xu, Atanas Rountev Ohio State University Oct 9 th, 2008 Presented by Eun Jung Park.
Hastings Purify: Fast Detection of Memory Leaks and Access Errors.
CORK: DYNAMIC MEMORY LEAK DETECTION FOR GARBAGE- COLLECTED LANGUAGES A TRADEOFF BETWEEN EFFICIENCY AND ACCURATE, USEFUL RESULTS.
By Jacob SeligmannSteffen Grarup Presented By Leon Gendler Incremental Mature Garbage Collection Using the Train Algorithm.
Asynchronous Assertions Eddie Aftandilian and Sam Guyer Tufts University Martin Vechev ETH Zurich and IBM Research Eran Yahav Technion.
Efficient Concurrent Mark-Sweep Cycle Collection Daniel Frampton, Stephen Blackburn, Luke Quinane and John Zigman (Pending submission) Presented by Jose.
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.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
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.
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
Tutorial 6 & 7 Symbol Table
Connectivity-Based Garbage Collection Presenter Feng Xian Author Martin Hirzel, et.al Published in OOPSLA’2003.
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
LeakChaser: Helping Programmers Narrow Down Causes of Memory Leaks Guoqing Xu, Michael D. Bond, Feng Qin, Atanas Rountev Ohio State University.
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
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.
Chapter 3.7 Memory and I/O Systems. 2 Memory Management Only applies to languages with explicit memory management (C or C++) Memory problems are one of.
1 Reducing Generational Copy Reserve Overhead with Fallback Compaction Phil McGachey and Antony L. Hosking June 2006.
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.
Applying Dynamic Analysis to Test Corner Cases First Penka Vassileva Markova Madanlal Musuvathi.
Bell: Bit-Encoding Online Memory Leak Detection Michael D. Bond Kathryn S. McKinley University of Texas at Austin.
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.
Memory Management Last Update: July 31, 2014 Memory Management1.
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.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
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.
Dynamic Object Sampling for Pretenuring Maria Jump Department of Computer Sciences The University of Texas at Austin Stephen M. Blackburn.
Free-Me: A Static Analysis for Automatic Individual Object Reclamation Samuel Z. Guyer, Kathryn McKinley, Daniel Frampton Presented by: Dimitris Prountzos.
1 Real-Time Replication Garbage Collection Scott Nettles and James O’Toole PLDI 93 Presented by: Roi Amir.
Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses Michael D. Bond University of Texas at Austin Graham Z. Baker Tufts / MIT.
OOPLs /FEN March 2004 Object-Oriented Languages1 Object-Oriented Languages - Design and Implementation Java: Behind the Scenes Finn E. Nordbjerg,
Convergence of Model Checking & Program Analysis Philippe Giabbanelli CMPT 894 – Spring 2008.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
GARBAGE COLLECTION IN AN UNCOOPERATIVE ENVIRONMENT Hans-Juergen Boehm Computer Science Dept. Rice University, Houston Mark Wieser Xerox Corporation, Palo.
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)
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.
CS412/413 Introduction to Compilers and Translators April 21, 1999 Lecture 30: Garbage collection.
Tracking Bad Apples: Reporting the Origin of Null & Undefined Value Errors Michael D. Bond UT Austin Nicholas Nethercote National ICT Australia Stephen.
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
Seminar in automatic tools for analyzing programs with dynamic memory
Concepts of programming languages
Arrays and Linked Lists
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
Data Structures & Algorithms
Garbage Collection What is garbage and how can we deal with it?
Presentation transcript:

GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University

2 PLDI, June 16-18, 2009 Motivation Real-world programs are complex Programmer may not understand whole application Global knowledge required to understand seemingly local properties Mismatch between programmer’s expectation and actual behavior causes bugs

3 PLDI, June 16-18, 2009 I think I understand my program Example from SPEC JBB2000 Clients in a district enter orders Warehouses fullfill orders from their district When district is torn down, orders are deleted order appears to become unreachable here Enumeration orderIter = orderTable.elements(); Order order; while (orderIter.hasMoreElements()) { order = (Order)orderIter.nextElement(); orderTable.removeEntry(order.getId()); Factory.deleteEntity(order); } Factory.deleteEntity(orderTable); orderTable = null;

4 PLDI, June 16-18, 2009 I don’t understand my program Wrong! Customer object maintains reference to order Memory leak order customerorderTable

5 PLDI, June 16-18, 2009 Existing solutions Inspect the code Static analysis False positives Run-time invariant checking Slow: x overhead[Shankar 07] Heuristics (staleness, anomaly detection) False positives

6 PLDI, June 16-18, 2009 Our solution: GC assertions Programmer adds assertions to code Express expected program properties Piggyback on garbage collector to check expected properties More precise than static analysis More efficient then run-time invariant checking Less than 3% overhead More accurate than heuristics

7 PLDI, June 16-18, 2009 How GC assertions work Insert assertions into program code Assertions executed during program run Store metadata about each assertion Assertions batched and checked at next GC Multiple assertions can be checked in a single heap traversal – fast! Only checked at GC time We may miss transient errors Trade completeness for performance

8 PLDI, June 16-18, 2009 Implementation Jikes RVM Goal: fast during correct program execution Implemented in a pure mark-sweep collector Generational collector would perform better but have longer time-to-detection Basic strategies: Steal bits from object header, check during GC tracing Change order of heap traversal

9 PLDI, June 16-18, 2009 Kinds of properties we can check Lifetime properties Volume properties Shape properties

10 PLDI, June 16-18, 2009 Lifetime properties Problem: Object that appears to be unreachable may not actually be reclaimed No direct way to find out if a specific object is reclaimed Difficult to determine through program inspection Solution: assert-dead(p) *p should be reclaimed at next collection

11 PLDI, June 16-18, 2009 Lifetime properties Problem: Server app – all objects allocated while servicing a connection should die when the connection terminates How do we find out which objects were allocated for that connection? Solution: start-region(); … service connection … assert-alldead(); Any object allocated between these two calls should be reclaimed at the next collection

12 PLDI, June 16-18, 2009 Volume properties Problem: Only one instance of a class should be live at any time (singleton pattern) Multiple class loaders, subclassing, serialization, etc. make this difficult to enforce [Sun Developer Network] Solution: assert-instances(T, I) Number of live objects of type T should not exceed I

13 PLDI, June 16-18, 2009 Implementation assert-dead, assert-unshared Steal bit from object header, look for set bit during GC tracing assert-alldead Maintain a per-thread list of objects allocated inside a region. When region ends, mark all objects in list as dead. assert-instances RVMClass object tracks instance limit and instance count. Count updated during GC.

14 PLDI, June 16-18, 2009 Shape properties Problem: Nodes in a tree should never have more than one incoming pointer Solution: assert-unshared(p) At most one object points to *p

15 PLDI, June 16-18, 2009 Shape properties Problem: Objects in a collection are pointed to by a separate index. Index should never point to an object that is no longer in the collection. Index should not keep object alive Solution: assert-ownedby(p, q) Some path from root to p passes through q

16 PLDI, June 16-18, 2009 Implementing assert-ownedby Error! Main container Hash table

17 PLDI, June 16-18, 2009 Implementation assert-ownedby Phase 1: Perform a heap scan starting at each owner Don’t mark the owner yet – we don’t know if it is reachable If we encounter an ownee, check to make sure it belongs to the current owner. If not, error. If we encounter another owner, mark it and stop the scan Phase 2: Perform the normal heap scan starting at the roots If we encounter any ownee that is not marked, error

18 PLDI, June 16-18, 2009 Finding the error When assertion is triggered, how to find bug? Most assertions related to reachability and paths through the heap Provide full path through heap to object Sequence of references/objects from root to offending object Helps determine which data structure is keeping an object alive Small change to the object tracing code

19 PLDI, June 16-18, 2009 Example full-path output Warning: an object that was asserted dead is reachable. Type: Lspec/jbb/Order; Path to object: Lspec/jbb/Company; -> Lspec/jbb/infra/Collections/StringStaticBTree; -> Lspec/jbb/infra/Collections/StringBTreeNode; -> [Ljava/lang/Object; -> Lspec/jbb/infra/Collections/StringBTreeNode; -> [Ljava/lang/Object; -> Lspec/jbb/infra/Collections/StringBTreeNode; -> [Ljava/lang/Object; -> Lspec/jbb/Customer; -> Lspec/jbb/Order;

20 PLDI, June 16-18, 2009 Performance Benchmarks: SPEC JVM98, SPEC JBB 2000, DaCapo Three configurations: Base – unmodified RVM, unmodified benchmarks Infrastructure – modified RVM, unmodified benchmarks WithAssertions – modified RVM, modified benchmarks 16k assertions in db, 15k checked at each GC 31k assertions in jbb, 400 checked at each GC

21 PLDI, June 16-18, 2009 Run-time overhead Geomean: 2.75% slowdown for Infrastructure

22 PLDI, June 16-18, 2009 GC time overhead Geomean: 13.4% slowdown for Infrastructure

23 PLDI, June 16-18, 2009 Run-time overhead Geomean: 1.0% slowdown for WithAssertions

24 PLDI, June 16-18, 2009 GC time overhead Geomean: 19.9% slowdown for WithAssertions

25 PLDI, June 16-18, 2009 Finding bugs SPEC JBB 2000 Uses Factory pattern with destroy() methods Instrument destroy() methods with assert- dead() assertions Also instrument loops where it is clear an object should be unreachable at the end of the loop

26 PLDI, June 16-18, 2009 Finding bugs Found several bugs: “Dead” Order objects reachable from Customer objects; same with Address objects In main program loop, a reference is kept to the Company object from the previous iteration Order objects not properly removed from an orderTable when a DeliveryTransaction is completed Full-path information was very helpful Order bugs could be found more easily with assert-ownedby

27 PLDI, June 16-18, 2009 Conclusion GC is a powerful source of information about program state Can check properties, such as lifetime, that no other subsystem has access to By piggybacking on the existing GC tracing algorithm, we can check interesting properties at low cost Knee in curve of cost/precision tradeoff

28 PLDI, June 16-18, 2009 Thank you! Questions?