An Adaptive, Region-based Allocator for Java Feng Qian & Laurie Hendren 2002.

Slides:



Advertisements
Similar presentations
Virtual Memory 3 Fred Kuhns
Advertisements

Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Register Allocation Zach Ma.
Introduction to Memory Management. 2 General Structure of Run-Time Memory.
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
1 Overview Assignment 5: hints  Garbage collection Assignment 4: solution.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Garbage Collection What is garbage and how can we deal with it?
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.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
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.
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
Virtual Memory Primitives for User Programs Andrew W. Appel and Kai Li Presented by: Khanh Nguyen.
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
Generational Stack Collection And Profile driven Pretenuring Perry Cheng Robert Harper Peter Lee Presented By Moti Alperovitch
Run-Time Storage Organization
U NIVERSITY OF M ASSACHUSETTS Department of Computer Science Automatic Heap Sizing Ting Yang, Matthew Hertz Emery Berger, Eliot Moss University of Massachusetts.
Run time vs. Compile time
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Run-time Environment and Program Organization
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.
Uniprocessor Garbage Collection Techniques Paul R. Wilson.
1.1 CAS CS 460/660 Introduction to Database Systems File Organization Slides from UC Berkeley.
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.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static.
1 Overview Assignment 6: hints  Living with a garbage collector Assignment 5: solution  Garbage collection.
Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.
Chapter 7: Runtime Environment –Run time memory organization. We need to use memory to store: –code –static data (global variables) –dynamic data objects.
CS3012: Formal Languages and Compilers The Runtime Environment After the analysis phases are complete, the compiler must generate executable code. The.
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
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
Runtime Environments Compiler Construction Chapter 7.
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
Free-Me: A Static Analysis for Automatic Individual Object Reclamation Samuel Z. Guyer, Kathryn McKinley, Daniel Frampton Presented by: Dimitris Prountzos.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 Automatic Heap Sizing: Taking Real Memory into Account Ting Yang, Emery Berger,
Chapter 4 Memory Management Virtual Memory.
September 11, 2003 Beltway: Getting Around GC Gridlock Steve Blackburn, Kathryn McKinley Richard Jones, Eliot Moss Modified by: Weiming Zhao Oct
Run-Time Storage Organization Compiler Design Lecture (03/23/98) Computer Science Rensselaer Polytechnic.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
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.
1 Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT) Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss (UMass),
CS383 Programming Languages Quiz About runtime stack, which one is incorrect? a.The stack grows and shrinks as a process runs. b.The stack is used.
® 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.
1 The Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT), Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss.
Storage Allocation Mechanisms
Garbage Collection What is garbage and how can we deal with it?
Non Contiguous Memory Allocation
Dynamic Memory Allocation
Concepts of programming languages
David F. Bacon, Perry Cheng, and V.T. Rajan
Strategies for automatic memory management
Closure Representations in Higher-Order Programming Languages
Binding Times Binding is an association between two things Examples:
Chapter 12 Memory Management
Garbage Collection Advantage: Improving Program Locality
Run-time environments
Garbage Collection What is garbage and how can we deal with it?
Presentation transcript:

An Adaptive, Region-based Allocator for Java Feng Qian & Laurie Hendren 2002

Roadmap n Stack allocation n A better algorithm n Implementation issues n Experiments results n Future enhancements

Stack Allocation - Advantages n Non Escaping objects can be allocated on the stack n Objects on the stack can be freed without GC intervention

Stack Allocation - Disadvantages n Static escape analysis requires whole program analysis –Can’t work with Dynamic Class Loading n Large arrays n Objects created in a loop with overlapping lifetimes

The Solution n Treat local regions as stack frames extensions n Stackable objects can be created in local regions n Regions which contain only non- escaping objects are freed when the stack frame is popped

Adaptive Escape Analysis n Dynamically categorize allocation sites as local or non-local n Detect escaping objects by write barriers –Mark region as dirty and give to GC –Mark allocation site as non-local n As execution proceeds, local regions are more likely to stay clean

Topics - Implementation n Regions n Escaping Objects n Allocation Sites n The Allocator

Regions n Region points to a list of pages in the heap n Token represents regions n Global and Free regions n Local regions

Global Region n Objects created in non-local allocation sites n Pages containing objects that have escaped local regions n Work with GC

Free Region n List of free pages n The Global and Local Regions takes pages from this region

Local Regions n Used as a stack extension n Assigned to activation’s stack frame n A method activation obtains a region by –getting a new region from the allocator –inheriting its caller’s region n New regions are freed before exiting

Escaping Objects n Escaping Object - pointed by an object in another region n Write barriers before bytecode instructions: –putstatic –putfield: lhs.f=rhs –aastore

Escaping Objects n What about methods returning objects ? –Inserting write barriers before bytecode areturn –Requiring all such methods to inherit caller’s region

Allocation Sites n Allocation sites are uniquely indexed n Allocation sites are all initialized to local n Each object stores its allocation site in its header n An allocation site becomes non-local when an object allocated at the site escapes n A bit vector is used to record states of allocation sites

The Allocator n Different GCs have different heap organizations –Mark & Sweep use a single space heap –Copying Collectors use two spaces heap –Generational Collectors use many spaces for aging areas n The heap we discuss is where new objects are allocated

Memory Organization

NewRegion n Free region tokens are managed by a stack n NewRegion pops a region and returns it n If no region is left then the Global region is returned

FreeRegion n If the Dirty field is clean, add the pages to the Free region n Else, add the pages to the Global region n Push region token to the tokens’ stack

Alloc n Only local sites allocate from local regions n First try to allocate memory from the first page n Add a new page if necessary n Look for a bunch of continuous pages for large object

Lazy Region Allocation n Many activation records have empty regions –methods that do not allocate objects –non-local allocations n Call NewRegion only when a new region is needed

Adaptive VM n Assign unique indexes to allocation sites at compilation n Store allocation site index in object header n Store region ID in the stack frame n Methods prologue and epilogue have more instructions n Write barriers before specific bytecodes

Prototype Implementation n Jikes RVM - baseline compiler n Semi-space copying collector n Fixed page size n Objects taking multiple pages

Experimental Results n Allocation sites n Effects of regions and page sizes on collections and fragmentation n Allocation behavior n Behavior of write barriers n Effect of adaptation

Allocation Sites

Effect of regions and page sizes on collections and fragmentation

Allocation Behavior

Behavior of write barriers

Region reclaimed space

Region allocated at runtime

Effect of adaptation

n Current scheme predicts future objects will escape after one object from that site escapes n Without adaptation predicts future objects non-escaping 9% 2 1%11jess 589%9629%15javac froth#collectionsfroth#collections without adaptationwith adaptation

Summary n Page size is important - overhead in froth and expensive searches is low n For many benchmarks a high percent of memory can be put in local regions n The average write barrier operations are low cost n Adaptation finds local sites

Runtime Improvements n The overhead of current implementation is still too high ! n Functions used by region management are written in Java n Ongoing work on a more optimized version

Possible Enhancements n Use more than one bit to find non-local allocation sites n Use a dirty bit per page and not per region n Periodically reset allocation sites to local

The End