david f. bacon t.j. watson research center
DESCRIPTION
Parallel and Concurrent Real-time Garbage Collection Part I: Overview and Memory Allocation Subsystem. David F. Bacon T.J. Watson Research Center. What It Does. (Demo). http://www.youtube.com/user/ibmrealtime. What it Is. A production garbage collector that is - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/1.jpg)
1
Parallel and ConcurrentReal-time Garbage Collection
Part I: Overview and Memory Allocation Subsystem
David F. Bacon
T.J. Watson Research Center
QuickTime™ and a decompressor
are needed to see this picture.
![Page 2: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/2.jpg)
2
What It Does
(Demo)
http://www.youtube.com/user/ibmrealtime
![Page 3: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/3.jpg)
3
What it Is
• A production garbage collector that is
– Real-time (450us worst-case latencies)
– Multiprocesing (uses multiple CPUs)
– Concurrent (can run in background)
– Robust (within and across JVMs)
![Page 4: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/4.jpg)
4
Why It’s Important
DDG-1000 Destroyer
Telco SIP Switch
Air Java(w/ Berkeley CE)
JAviator(w/ Salzburg)
Java-basedSynthesizer
Playstation/Xbox etc
Automotive Electronics
33%
7%
22%
Trade Execution
![Page 5: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/5.jpg)
5
Who and When
Metronome(2001-2004)
Recycler(1999-2001)
WebSphere Realtime(2004-2007)
QuickTime™ and a decompressorare needed to see this picture.QuickTime™ and a decompressorare needed to see this picture.
Dick Attanasio David BaconV.T. RajanSteve Smith
Han Lee
David BaconPerry ChengV.T. Rajan
Martin Vechev
Josh AuerbachDavid BaconPerry ChengDave Grove
5 Developers10 Testers
5 Salespeople…
![Page 6: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/6.jpg)
6
Digression: Keys to Success
• Intelligence
• Collaboration
• Problem Selection
![Page 7: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/7.jpg)
7
Perspectives
• Concurrent garbage collection is
– A key language runtime component
– A challenging verification problem
– A multi-faceted concurrent algorithm
![Page 8: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/8.jpg)
8
Goals• Learn how to bridge:
– from abstract design…– …to concrete implementation
• Learn how to combine different– algorithms…– …and implementations…– …into a complete system
• Gain deep understanding– highly complex, real-world system– apply lessons to your problems
![Page 9: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/9.jpg)
9
Where it Fits InJVMJVM
JITInterpreter GC
Class LibrariesRTSJ
Arraylets, Barriers
Class LibrariesRTSJ
Arraylets, Barriers
AoTCompiler
RTSJScopes,Threads
Class(Un)Loader(realtime)
JVMPI Debug RAS
SystemManagement
Weird RefsWeak, Soft,Phantom, JNI
Heap FormatDump & Parse
DocumentationDocumentation
Test
24x7 (at least)
Test
24x7 (at least)
![Page 10: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/10.jpg)
10
Fundamental Issues
• Functional correctness (duh)
• Liveness– Timeliness (real-time bounds)
• Fairness– Priorities
• Initiation and Termination
• Contention
• Non-determinism
![Page 11: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/11.jpg)
11
Why is Concurrency Hard?
• Performance– Contention
– Load Balancing
– Overhead -> Granularity
• “Inherent” Simultaneity
• Timing and Determinism
![Page 12: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/12.jpg)
12
Stack
GC: A Simple Problem (?)
• Transitive Graph Closure
rr
pp TTa
b
XXa
b UUa
b
ZZa
b
WWa
b
YYa
b Class Foo { Foo a; Foo b;}
![Page 13: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/13.jpg)
13
Basic Approaches: Mark/Sweep
Stack
rr
pp TTa
b
XXa
b UUa
b
ZZa
b
WWa
b
YYa
b
WWa
b
ZZa
b
YYa
b
XXa
b
freefree
• O(live) mark phase but O(heapsize) sweep
• Usually requires no copying
• Mark stack is O(maxdepth)
![Page 14: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/14.jpg)
14
Basics II: Semi-space Copying
• O(live)
• If single-threaded, no mark stack needed
• Wastes 50% of memory
Stack
rr
pp
TTa
b XXa
b
UUa
b ZZa
b
WWa
b
YYa
b
WWa
b
ZZa
b
YYa
b
XXa
b
![Page 15: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/15.jpg)
15
Kinds of “Concurrent” Collection
• “Stop the World”
• Parallel
• Concurrent
• Incremental
APP GC APP
APP APP
APP APP
APP GC APP
APP APP
APP APP
GC
GC
APP
APP
APP APPGC
APP GC
APP
APP
APP
APP
APP
GC APP
APP
APP
GC APP
APP
APP
![Page 16: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/16.jpg)
16
Our Subject: Metronome-2 System
• Parallel, Incremental, and Concurrent
• No increment exceeds 450us
• Real-time Scheduling
• Smooth adaptation from under- to over-load
• Implementation in production JVM
GC
APP GC
APP GC APP GC APP
APP
APP GC APP
APP APP APP
![Page 17: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/17.jpg)
17
What Does “Real-time” Mean?
• Minimal, predictable interruption of application
• Collection finishes before heap is exhausted
• “Real space” - bounded, predictable memory
• Honor thread priorities
• Micro- or macro-level determinism (cf. CK)
![Page 18: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/18.jpg)
18
The Cycle of Life
AllocateAllocate
FreeFree
MutateMutate
• Not really a “garbage collector”…
• … but a memory management subsystem
![Page 19: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/19.jpg)
19
Metronome Memory Organization
• Page-based• Segregated free lists• Ratio bounds internal & page-internal fragmentation
![Page 20: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/20.jpg)
20
Large Objects: Arraylets
• (Almost) eliminates external fragmentation• (Almost) eliminates need for compaction• Very large arrays still need contiguous pages• Extra indirection for array access
![Page 21: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/21.jpg)
21
Page Data Structures
1616 6464 256256 freefree
![Page 22: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/22.jpg)
22
Page Data Synchronization, Take 1
1616 6464 256256 freefree
![Page 23: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/23.jpg)
23
Page Data, Take 2
1616 6464 256256 freefree
1616 6464 256256
Thread 1
1616 6464 256256
Thread 2
![Page 24: David F. Bacon T.J. Watson Research Center](https://reader034.vdocument.in/reader034/viewer/2022051623/56815b01550346895dc8b262/html5/thumbnails/24.jpg)
24
http://www.research.ibm.com/metronome
https://sourceforge.net/projects/tuningforkvp