380C Lecture 17 Where are we & where we are going –Managed languages Dynamic compilation Inlining Garbage collection –Why you need to care about workloads.

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

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 MC 2 –Copying GC for Memory Constrained Environments Narendran Sachindran J. Eliot.
Steve Blackburn Department of Computer Science Australian National University Perry Cheng TJ Watson Research Center IBM Research Kathryn McKinley Department.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Lecture 21 Dynamic Memory Allocation:- *Allocation of objects in program ’ s heap _e.g. C ’ s malloc/free or Pascal ’ s new/dispose _e.g. C ’ s malloc/free.
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
CSC 213 – Large Scale Programming. Today’s Goals  Consider what new does & how Java works  What are traditional means of managing memory?  Why did.
A Real-Time Garbage Collector Based on the Lifetimes of Objects Lieberman and Hewitt, CACM June 1983, pp Curtis Dunham CS 395T Memory Management,
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.
Beltway: Getting Around Garbage Collection Gridlock Mrinal Deo CS395T Presentation March 2, Content borrowed from Jennifer Sartor & Kathryn McKinley.
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.
380C Where are we & where we are going – Managed languages Dynamic compilation Inlining Garbage collection What else can you do when you examine the heap.
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.
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
CS 1114: Data Structures – memory allocation Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
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.
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
Compilation 2007 Garbage Collection Michael I. Schwartzbach BRICS, University of Aarhus.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
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.
Garbage collection (& Midterm Topics) David Walker COS 320.
1 Reducing Generational Copy Reserve Overhead with Fallback Compaction Phil McGachey and Antony L. Hosking June 2006.
Linked lists and memory allocation Prof. Noah Snavely CS1114
Uniprocessor Garbage Collection Techniques Paul R. Wilson.
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 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.
Taking Off The Gloves With Reference Counting Immix
Ulterior Reference Counting: Fast Garbage Collection without a Long Wait Author: Stephen M Blackburn Kathryn S McKinley Presenter: Jun Tao.
Lecture 10 : Introduction to Java Virtual Machine
A Real-Time Garbage Collector Based on the Lifetimes of Objects Henry Lieberman and Carl Hewitt (CACM, June 1983) Rudy Kaplan Depena CS395T: Memory Management.
Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.
A Mostly Non-Copying Real-Time Collector with Low Overhead and Consistent Utilization David Bacon Perry Cheng (presenting) V.T. Rajan IBM T.J. Watson Research.
Copyright (c) 2004 Borys Bradel Myths and Realities: The Performance Impact of Garbage Collection Paper: Stephen M. Blackburn, Perry Cheng, and Kathryn.
Message Analysis-Guided Allocation and Low-Pause Incremental Garbage Collection in a Concurrent Language Konstantinos Sagonas Jesper Wilhelmsson Uppsala.
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.
Garbage Collection and Memory Management CS 480/680 – Comparative Languages.
UniProcessor Garbage Collection Techniques Paul R. Wilson University of Texas Presented By Naomi Sapir Tel-Aviv University.
1 Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT) Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss (UMass),
David F. Bacon Perry Cheng V.T. Rajan IBM T.J. Watson Research Center ControllingFragmentation and Space Consumption in the Metronome.
A REAL-TIME GARBAGE COLLECTOR WITH LOW OVERHEAD AND CONSISTENT UTILIZATION David F. Bacon, Perry Cheng, and V.T. Rajan IBM T.J. Watson Research Center.
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.
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.
1 The Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT), Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss.
Eliminating External Fragmentation in a Non-Moving Garbage Collector for Java Author: Fridtjof Siebert, CASES 2000 Michael Sallas Object-Oriented Languages.
Introduction to Garbage Collection. GC Fundamentals Algorithmic Components AllocationReclamation 2 Identification Bump Allocation Free List ` Tracing.
Dynamic Compilation Vijay Janapa Reddi
Rifat Shahriyar Stephen M. Blackburn Australian National University
Concepts of programming languages
Ulterior Reference Counting Fast GC Without The Wait
David F. Bacon, Perry Cheng, and V.T. Rajan
Memory Management and Garbage Collection Hal Perkins Autumn 2011
Strategies for automatic memory management
Memory Management Kathryn McKinley.
Beltway: Getting Around Garbage Collection Gridlock
Presentation transcript:

380C Lecture 17 Where are we & where we are going –Managed languages Dynamic compilation Inlining Garbage collection –Why you need to care about workloads & experimental methodology –Alias analysis –Dependence analysis –Loop transformations –EDGE architectures 1

2 Today Garbage Collection –Why use garbage collection? –What is garbage? Reachable vs live, stack maps, etc. –Allocators and their collection mechanisms Semispace Marksweep Performance comparisons –Incremental age based collection Write barriers: Friend or foe? Generational Beltway –More performance

3 Basic VM Structure Executing Program Program/Bytecode Dynamic Compilation Subsystem Class Loader Verifier, etc. Heap Thread Scheduler Garbage Collector

4 True or False? Real programmers use languages with explicit memory management. –I can optimize my memory management much better than any garbage collector

5 True or False? Real programmers use languages with explicit memory management. –I can optimize my memory management much better than any garbage collector –Scope of effort?

6 Why Use Garbage Collection? Software engineering benefits –Less user code compared to explict memory management (MM) –Less user code to get correct –Protects against some classes of memory errors No free(), thus no premature free(), no double free(), or forgetting to free() Not perfect, memory can still leak –Programmers still need to eliminate all pointers to objects the program no longer needs Performance: space time tradeoff –Time proportional to dead objects (explicit mm, reference counting) or live objects (semispace, marksweep) –Throughput versus pause time Less frequent collection, typically reduces total time but increases space requirements and pause times –Hidden locality benefits?

7 What is Garbage? In theory, any object the program will never reference again –But compiler & runtime system cannot figure that out In practice, any object the program cannot reach is garbage –Approximate liveness with reachability Managed languages couple GC with “safe” pointers –Programs may not access arbitrary addresses in memory –The compiler can identify and provide to the garbage collector all the pointers, thus –“Once garbage, always garbage” –Runtime system can move objects by updating pointers –“Unsafe” languages can do non-moving GC by assuming anything that looks like a pointer is one.

8 Reachability stackglobalsregisters heap A B C {.... r0 = obj PC -> p.f = obj.... Compiler produces a stack-map at GC safe-points and Type Information Blocks GC safe points: new(), method entry, method exit, & back- edges (thread switch points) Stack-map: enumerate global variables, stack variables, live registers -- This code is hard to get right! Why? Type Information Blocks: identify reference fields in objects

9 Reachability stackglobalsregisters heap A B C {.... r0 = obj PC -> p.f = obj.... Compiler produces a stack-map at GC safe-points and Type Information Blocks Type Information Blocks: identify reference fields in objects for each type i (class) in the program, a map 302 TIB i

10 Reachability Tracing collector (semispace, marksweep) –Marks the objects reachable from the roots live, and then performs a transitive closure over them stackglobalsregisters heap A B C {.... r0 = obj PC -> p.f = obj.... mark

11 Reachability Tracing collector (semispace, marksweep) –Marks the objects reachable from the roots live, and then performs a transitive closure over them stackglobalsregisters heap A B C {.... r0 = obj PC -> p.f = obj.... mark

12 Reachability Tracing collector (semispace, marksweep) –Marks the objects reachable from the roots live, and then performs a transitive closure over them stackglobalsregisters heap A B C {.... r0 = obj PC -> p.f = obj.... mark

13 Reachability Tracing collector (semispace, marksweep) –Marks the objects reachable from the roots live, and then performs a transitive closure over them All unmarked objects are dead, and can be reclaimed stackglobalsregisters heap A B C {.... r0 = obj PC -> p.f = obj.... mark

14 Reachability Tracing collector (semispace, marksweep) –Marks the objects reachable from the roots live, and then performs a transitive closure over them All unmarked objects are dead, and can be reclaimed stackglobalsregisters heap A B C {.... r0 = obj PC -> p.f = obj.... sweep

15 Today Garbage Collection –Why use garbage collection? –What is garbage? Reachable vs live, stack maps, etc. –Allocators and their collection mechanisms Semispace Marksweep Performance comparisons –Incremental age based collection Write barriers: Friend or foe? Generational Beltway –More performance

16 Semispace Fast bump pointer allocation Requires copying collection Cannot incrementally reclaim memory, must free en masse Reserves 1/2 the heap to copy in to, in case all objects are live heap to spacefrom space

17 Semispace Fast bump pointer allocation Requires copying collection Cannot incrementally reclaim memory, must free en masse Reserves 1/2 the heap to copy in to, in case all objects are live heap to spacefrom space

18 Semispace Fast bump pointer allocation Requires copying collection Cannot incrementally reclaim memory, must free en masse Reserves 1/2 the heap to copy in to, in case all objects are live heap to spacefrom space

19 Semispace Fast bump pointer allocation Requires copying collection Cannot incrementally reclaim memory, must free en masse Reserves 1/2 the heap to copy in to, in case all objects are live heap to spacefrom space

20 Semispace Mark phase: –copies object when collector first encounters it –installs forwarding pointers heap from spaceto space

21 Semispace Mark phase: –copies object when collector first encounters it –installs forwarding pointers –performs transitive closure, updating pointers as it goes heap from spaceto space

22 Semispace Mark phase: –copies object when collector first encounters it –installs forwarding pointers –performs transitive closure, updating pointers as it goes heap from spaceto space

23 Semispace Mark phase: –copies object when collector first encounters it –installs forwarding pointers –performs transitive closure, updating pointers as it goes heap from spaceto space

24 Semispace Mark phase: –copies object when collector first encounters it –installs forwarding pointers –performs transitive closure, updating pointers as it goes –reclaims “from space” en masse heap from spaceto space

25 Semispace Mark phase: –copies object when collector first encounters it –installs forwarding pointers –performs transitive closure, updating pointers as it goes –reclaims “from space” en masse –start allocating again into “to space” heap from spaceto space

26 Semispace Mark phase: –copies object when collector first encounters it –installs forwarding pointers –performs transitive closure, updating pointers as it goes –reclaims “from space” en masse –start allocating again into “to space” heap from spaceto space

27 Semispace Notice: 4fast allocation 4locality of contemporaneously allocated objects 4locality of objects connected by pointers 8wasted space heap from spaceto space

28 Marksweep Free-lists organized by size –blocks of same size, or –individual objects of same size Most objects are small < 128 bytes free lists... heap

29 Marksweep Allocation –Grab a free object off the free list free lists... heap

30 Marksweep Allocation –Grab a free object off the free list free lists... heap

31 Marksweep Allocation –Grab a free object off the free list free lists... heap

32 Marksweep Allocation –Grab a free object off the free list –No more memory of the right size triggers a collection –Mark phase - find the live objects –Sweep phase - put free ones on the free list free lists... heap

33 Marksweep Mark phase –Transitive closure marking all the live objects Sweep phase –sweep the memory for free objects populating free list free lists... heap

34 Marksweep Mark phase –Transitive closure marking all the live objects Sweep phase –sweep the memory for free objects populating free list free lists... heap

35 Marksweep Mark phase –Transitive closure marking all the live objects Sweep phase –sweep the memory for free objects populating free list free lists... heap

36 Marksweep Mark phase –Transitive closure marking all the live objects Sweep phase –sweep the memory for free objects populating free list –can be made incremental by organizing the heap in blocks and sweeping one block at a time on demand free lists... heap

37 Marksweep 4space efficiency 4Incremental object reclamation 8relatively slower allocation time 8poor locality of contemporaneously allocated objects free lists... heap

38 How do these differences play out in practice? Marksweep 4space efficiency 4Incremental object reclamation 8relatively slower allocation time 8poor locality of contemporaneously allocated objects Semispace 4fast allocation 4locality of contemporaneously allocated objects 4locality of objects connected by pointers 8wasted space

39 Methodology [SIGMETRICS 2004] Compare Marksweep (MS) and Semispace (SS) Mutator time, GC time, total time Jikes RVM & MMTk replay compilation measure second iteration without compilation Platforms 1.6GHz G5 (PowerPC 970) 1.9GHz AMD Athlon GHz Intel P4 Linux with perfctr patch & libraries – Separate accounting of GC & Mutator counts SPECjvm98 & pseudojbb

40 Allocation Mechanism Bump pointer – ~70 bytes IA32 instructions, 726MB/s Free list – ~140 bytes IA32 instructions, 654MB/s Bump pointer 11% faster in tight loop – < 1% in practical setting – No significant difference (?)

41 Mutator Time

42 jess

43 jess

44 jess

45 jess

46 javac

47 pseudojbb

48 Geometric Mean Mutator Time

49 Garbage Collection Time

50 Garbage Collection Time Geometric mean pseudojbb jess javac

51 Total Time

52 Total Time pseudojbb Geometric mean jess javac

53 MS/SS Crossover: 1.6GHz PPC

54 MS/SS Crossover: 1.9GHz AMD

55 MS/SS Crossover: 2.6GHz P4

56 MS/SS Crossover: 3.2GHz P4

57 MS/SS Crossover 2.6GHz 1.9GHz 1.6GHz localityspace 3.2GHz

58 Today Garbage Collection –Why use garbage collection? –What is garbage? Reachable vs live, stack maps, etc. –Allocators and their collection mechanisms Semispace Marksweep Performance comparisons –Incremental age based collection Enabling mechanisms –write barrier & remembered sets Heap organizations –Generational –Beltway –Performance comparisons

59 One Big Heap? Pause times –it takes to long to trace the whole heap at once Throughput –the heap contains lots of long lived objects, why collect them over and over again? Incremental collection –divide up the heap into increments and collect one at a time. Increment 1 Increment 2 to spacefrom spaceto spacefrom space

60 Incremental Collection Ideally perfect pointer knowledge of live pointers between increments requires scanning whole heap, defeats the purpose to spacefrom spaceto spacefrom space Increment 1 Increment 2

61 Incremental Collection Ideally perfect pointer knowledge of live pointers between increments requires scanning whole heap, defeats the purpose to spacefrom spaceto spacefrom space Increment 1 Increment 2

62 Incremental Collection to spacefrom spaceto spacefrom space Increment 1 Increment 2 Ideally perfect pointer knowledge of live pointers between increments requires scanning whole heap, defeats the purpose

63 Incremental Collection Ideally perfect pointer knowledge of live pointers between increments requires scanning whole heap, defeats the purpose Mechanism: Write barrier records pointers between increments when the mutator installs them, conservative approximation of reachability to spacefrom spaceto spacefrom space Increment 1 Increment 2

64 Write barrier compiler inserts code that records pointers between increments when the mutator installs them // original program // compiler support for incremental collection p.f = o; if (incr(p) != incr(o) { remembered set (incr(o)) U p.f; } p.f = o; to spacefrom spaceto spacefrom space Increment 1 Increment 2 remset 1 ={w}remset 2 ={f,g} a b c d e f gt u v w x y z

65 Write barrier Install new pointer d -> v // original program // compiler support for incremental collection p.f = o; if (incr(p) != incr(o) { remembered set (incr(o)) U p.f; } p.f = o; to spacefrom spaceto spacefrom space Increment 1 Increment 2 remset 1 ={w}remset 2 ={f,g} a b c d e f gt u v w x y z

66 Write barrier Install new pointer d -> v, then update d-> y // original program // compiler support for incremental collection p.f = o; if (incr(p) != incr(o) { remembered set (incr(o)) = p.f; } p.f = o; to spacefrom spaceto spacefrom space Increment 1 Increment 2 remset 1 ={w}remset 2 ={f,g,d} a b c d e f gt u v w x y z

67 Write barrier Install new pointer d -> v, then update d-> y // original program // compiler support for incremental collection p.f = o; if (incr(p) != incr(o) { remembered set (incr(o)) = p.f; } p.f = o; to spacefrom spaceto spacefrom space Increment 1 Increment 2 remset 1 ={w}remset 2 ={f,g,d,d} a b c d e f gt u v w x y z

68 Write barrier At collection time collector re-examines all entries in the remset for the increment, treating them like roots Collect Increment 2 to spacefrom spaceto spacefrom space Increment 1 Increment 2 remset 1 ={w}remset 2 ={f,g,d,d} a b c d e f gt u v w x y z

69 Write barrier At collection time collector re-examines all entries in the remset for the increment, treating them like roots Collect Increment 2 to spacefrom spaceto spacefrom space Increment 1 Increment 2 remset 1 ={w}remset 2 ={f,g,d,d} a b c d e f gt u v w x y z

70 Summary of the costs of incremental collection write barrier to catch pointer stores crossing boundaries remsets to store crossing pointers processing remembered sets at collection time excess retention to spacefrom spaceto spacefrom space Increment 1 Increment 2 remset 1 ={w}remset 2 ={f,g,d,d} a b c d e f gt u v w x y z

71 Heap Organization What objects should we put where? Generational hypothesis –young objects die more quickly than older ones [Lieberman & Hewitt’83, Ungar’84] –most pointers are from younger to older objects [Appel’89, Zorn’90] ÜOrganize the heap in to young and old, collect young objects preferentially to space from space Young Old

72 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

73 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

74 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

75 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

76 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

77 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

78 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

79 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

80 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

81 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

82 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to space from space Young Old

83 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces –Generalizing to m generations if space n < m fills up, collect n through n-1 to spacefrom spaceto space Young Old

84 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces - ignore remembered sets –Generalizing to m generations if space n < m fills up, collect n through n-1 to spacefrom spaceto space Young Old

85 Generational Heap Organization Divide the heap in to two spaces: young and old Allocate in to the young space When the young space fills up, –collect it, copying into the old space When the old space fills up –collect both spaces - ignore remembered sets –Generalizing to m generations if space n < m fills up, collect 1 through n-1 to spacefrom spaceto space Young Old

86 Generational Write Barrier Unidirectional barrier 4record only older to younger pointers 8no need to record younger to older pointers, since we never collect the old space independently most pointers are from younger to older objects [Appel’89, Zorn’90] track the barrier between young objects and old spaces to space from space Young Old   address barrier

87 Generational Write Barrier to space from space Young Old   unidirectional boundary barrier // original program // compiler support for incremental collection p.f = o; if (p > barrier && o < barrier) { remset nursery U p.f; } p.f = o;

88 Generational Write Barrier Unidirectional 4record only older to younger pointers 8no need to record younger to older pointers, since we never collect the old space independently –most pointers are from younger to older objects [Appel’89, Zorn’90] –most mutations are to young objects [Stefanovic et al.’99] to space from space Young Old  

89 Results

90 Garbage Collection Time

91 Mutator Time

92 Total Time

McKinley, UT Recap Copying improves locality Incrementality improves responsiveness Generational hypothesis –Young objects: Most very short lived Infant mortality: ~90% die young (within 4MB of alloc) –Old objects: most very long lived (bimodal) Mature morality: ~5% die each 4MB of new allocation Help from pointer mutations –In Java, pointers go in both directions, but older to younger pointers across many objects are rare less than 1% –Most mutations among young objects 92 to 98% of pointer mutations

380C Where are we & where we are going –Managed languages Dynamic compilation Inlining Garbage collection –Can we get mutator locality, space efficiency, and collector efficiency all in one collector? –Read: Blackburn and McKinley, Immix: A Mark-Region Garbage Collector with Space Efficiency, Fast Collection, and Mutator Performance, ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pp , Tucson AZ, June –Why you need to care about workloads & methodology –Alias analysis –Dependence analysis –Loop transformations –EDGE architectures 94