Presentation is loading. Please wait.

Presentation is loading. Please wait.

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 MC 2 –Copying GC for Memory Constrained Environments Narendran Sachindran J. Eliot.

Similar presentations


Presentation on theme: "U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 MC 2 –Copying GC for Memory Constrained Environments Narendran Sachindran J. Eliot."— Presentation transcript:

1 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 MC 2 –Copying GC for Memory Constrained Environments Narendran Sachindran J. Eliot B. Moss Emery Berger

2 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 2 Motivation Handheld Devices: PDAs, cell phones Constrained memory, limited power Run applications with diverse requirements Multimedia, scaled down desktop apps. Java becoming popular on handhelds Safety, portability Garbage collection Require good throughput & low pauses, in constrained memory

3 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 3 Mark-Sweep Collection Free list allocation First-fit, best-fit, segregated free lists… Does not copy data  Space overhead not very high  Fragmentation: lowers space utilization  Locality effects  Different sizes are segregated  New objects may be interspersed with old

4 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 4 Mark-(Sweep)-Compact Collection Low space overhead Bump pointer allocation Good throughput in constrained memory Preserves object allocation order Good locality Long pause times

5 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 5 (Generational) Copying Collection  Bump pointer allocation  Copies data, avoids fragmentation  Reorders objects: can improve locality  Min. space required = 2X live data size

6 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 6 Mark-Copy Collection: Goal Manages space in old generation Overcome 2X space overhead Better space utilization Generational copying Mark-Copy

7 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 7 Mark-Copy Space Usage Divides space into equal size windows Reserves one window for copying Collects in two phases: Mark and Copy Generational copying Mark-Copy

8 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 8 Mark-Copy In Action Nursery Old Generation Unmapped Nursery Old Generation A B C D E F R1R2 Unmapped Nursery Old Generation Unmapped A B C D E F R1R2 G R3 Nursery Old Generation Unmapped A B C D E F R1R2 G H R3 Nursery Old Generation Unmapped A B C D E F R1R2 G H R3 Nursery Old Generation Unmapped A B C D E F R1R2 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 Nursery Old Generation Unmapped A B C D E F R1 G H R3 B Nursery Old Generation Unmapped A B C D E F R1 G H R3 B Nursery Old Generation Unmapped A B C D E F R1 G H R3 B Nursery Old Generation Unmapped A B C D E F R1 G H R3 B Nursery Old Generation Unmapped A B C D E F R1 G H R3 B Nursery Old Generation Unmapped C D E F R1 G H R3 B Unmapped Nursery Old Generation Unmapped C D E F R1 G H R3 B Unmapped Nursery Old Generation Unmapped C D E F R1 G H R3 B Unmapped Nursery Old Generation Unmapped C D E F R1 G H R3 B C D G Unmapped Nursery Old Generation Unmapped R1 R3 B C D G Unmapped Nursery Old Generation Unmapped R1 R3 B C D G Unmapped Nursery Old Generation Unmapped R1 R3 B C D G Unmapped

9 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 9 Experimental Results Implemented in Jikes RVM (2.2.2)/JMTk Macintosh PPC (533 MHz), 640MB memory, Linux 2.4.10 Collectors evaluated Mark-Copy vs. Gen. copy (Appel style) Mark-Copy vs. Mark-Sweep Mark-Copy vs. Gen. Mark-Sweep

10 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 10 Mark-Copy vs. Gen. Copy

11 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 11 _213_javac Mark/Cons

12 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 12 _ 213_javac GC Time

13 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 13 _213_javac Execution Time

14 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 14 Mark-Copy vs. Gen. Mark-Sweep

15 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 15 _213_javac GC Time

16 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 16 _213_javac Execution Time

17 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 17 Mark-Copy Summary Mark-Copy vs. Gen. copy Runs in less space Outperforms in small and moderate heaps Mark-Copy vs. Mark-Sweep Outperforms non-generational collector in small and moderate size heaps Improves exec. time for some programs when compared with gen. collector

18 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 18 Mark-Copy Limitations Requires virtual memory support Always copies all live data Potentially large remembered sets Could grow as large as heap Long pauses Non-incremental marking and copying

19 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 19 MC 2 –Memory Constrained Copying Overcomes mark-copy limitations Removes virtual memory requirement Incremental mark and copy phases Bounded space for remembering

20 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 20 Removing Use of Memory Mapping Use ‘logical’ instead of object address Every window has a logical address Logical address implies collection order Remset insert requires logical address lookup High occupancy windows moved logically

21 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 21 Handling Large Remembered Sets Set a limit on the total remset size We use 5% of total heap space Check size regularly, on allocation ‘slow path’ Coarsen large remsets when space close to limit Replace large remsets with card table

22 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 22 Making Collection Incremental Interleave marking & copying with program (mutator) activity Problem: Mutator could modify object graph between collection increments Could cause reclamation of live objects Solution: Track mutations using write barrier Record mutated slots in remsets at GC time

23 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 23 Making Collection Incremental Popular objects Popular = Highly referenced Cause long pauses when copied MC 2 identifies popular objects while coarsening remset Isolates these objects at high end of heap May cause long pause once, but does not recur

24 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 24 Incremental Copying Example

25 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 25 Incremental Copying Example

26 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 26 Incremental Copying Example

27 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 27 Incremental Copying Example

28 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 28 Incremental Copying Example

29 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 29 Experimental Results Implemented in Jikes RVM (2.2.3)/JMTk Pentium 4 1.7 GHz, 512MB memory, RedHat Linux 2.4.7-10 Collectors evaluated Generational Mark-Sweep (MS) Generational Mark-Compact (MSC) MC 2

30 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 30 Non-incremental Collector Improvements

31 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 31 JMTk Heap Layout Boot Image Imm. Object Space Large Object Space Old GenerationNursery

32 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 32 JMTk Generational Collection Write barrier records pointers into the nursery from objects outside the nursery Fast–only two comparisons Nursery collections efficient Full collections scan entire boot image to locate live objects on heap Inefficient for small heaps Scan ~2 million pointers, only 0.4% relevant

33 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 33 Old write barrier Boot Image Imm. Object Space Large Object Space Old GenerationNursery

34 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 34 New Write Barrier Records pointers into nursery Also records mutated boot image objects Full collections avoid boot image scan Scan only mutated boot image objects Reduces full GC time (4x for small programs) Efficient for small heaps (reduction in GC time > cost of new write barrier)

35 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 35 New Write Barrier Boot Image Imm. Object Space Large Object Space Old GenerationNursery

36 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 36 JMTk Heap Data and code allocated in same region Poor code locality  high ITLB miss rate Maintaining separate data and code regions improves locality for copying collectors

37 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 37 _213_javac (MSC GC Time)

38 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 38 _213_javac (MSC Execution Time)

39 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 39 MC 2 vs. MS and MSC

40 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 40 jess Execution Time

41 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 41 javac Execution Time

42 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 42 Bounded Mutator Utilization (jess)

43 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 43 Bounded Mutator Utilization (javac)

44 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 44 MC 2 Summary Runs with low space overhead Throughput comparable to MS and MSC Average pause times factor of 4 lower than MS, factor of 7 lower than MSC Suitable for handheld devices with soft real time requirements: Low space overhead Good throughput Short pause times

45 U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 45 The Papers Mark-Copy: OOPSLA 2003 MC 2 : OOPSLA 2004 Naren Sachindran PhD forthcoming


Download ppt "U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 1 MC 2 –Copying GC for Memory Constrained Environments Narendran Sachindran J. Eliot."

Similar presentations


Ads by Google