U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Garbage Collection Without...
-
date post
21-Dec-2015 -
Category
Documents
-
view
216 -
download
0
Transcript of U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Garbage Collection Without...
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Garbage CollectionWithout Paging
Matthew Hertz, Yi Feng,Emery Berger
University of Massachusetts Amherst
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Garbage Collection Performance
Garbage collection now performs reasonably well High throughput Low pause times Given large heap and sufficient
memory
But: what happens when there’s not enough RAM?
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
RAM
Hard Disk
Heap: most pages in RAM, one on diskGC begins
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
Collector touches an evicted page...
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
... bringing the page into memory ...
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
RAM
Hard Disk
... but triggers another page eviction.
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
RAM
Hard Disk
... but triggers another page eviction.
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
Collector touches newly-evicted page...
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
RAM
Hard Disk
Collector touches newly-evicted page...
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
... leading to the eviction of yet another page…
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
GC Performance While Paging
… which eventually triggers more paging.
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Program Throughput
Paging causes a 40 to 62-fold increase in runtime
Execution Time of pseudoJBB w/ 77MB Heap
0
100
200
300
400
500
600
212 163 153 143 133 123 113 103 93Available Memory
Exec
uti
on T
ime
(in s
)
GenCopy
GenMS
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Outline
Motivation GC without paging
Cooperative garbage collection Bookmarking
Results
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
The problem
Garbage collector: VM-oblivious Examines all reachable objects Lacks knowledge of page residency
Treats evicted and resident pages identically
Virtual memory: GC-oblivious GC & application have different access
patterns Likely to evict pages needed by GC
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Cooperative Garbage Collection
Bookmarkingcollector
Extended virtual memory manager
Select victim(s)Update
residency
page eviction
notificationvictim
page(s)
Page replacement
In response to notifications, BC:Adjusts heap size to fit in main memoryPrevents eviction of important pagesAvoids touching non-resident pages
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Avoiding Page Evictions
When notified, avoid a pending eviction…
0 000
RAM
Hard Disk
0
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Avoiding Page Evictions
…find a page BC knows to be empty…
0 000
RAM
Hard Disk
0
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Avoiding Page Evictions
… and discard it…
0 000
RAM
Hard Disk
0
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Avoiding Page Evictions
… eliminating the need to evict a page.
0 000
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Limit of Heap Sizing
Could collect, compact, compress, etc.
Eventually: Will run out of pages to discard Going to have to evict non-empty
pages Result: Paging
Can we avoid this?
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Bookmarks
We introduce bookmarks: Summaries of connectivity info on
evicted pages References from objects on the page
These summaries enable GC w/o paging
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0 000
Bookmarking
RAM
Hard Disk
Process page before eviction…
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0 000
Bookmarking
B
B
... by following pointers & bookmark-ing targets...
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0 000
Bookmarking
B
B
... increment the referring page count...
RAM
Hard Disk
1
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
1 000
Bookmarking
B B
B B
B
B
B
... conservatively bookmark objects on the page...
RAM
Hard Disk
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0 00
Bookmarking
... then tell extended VM to evict the page.
RAM
Hard Disk
0B B
B B
B
B
B
1
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Bookmarking Details
Cheap summary of connectivity One bit per object: free One word per page: referring page
count Bookmarks cleared when count = zero
Use bookmarks as secondary roots during garbage collection
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Collection with Bookmarks
Process objects as usual, but...
B
B
roots
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Collection with Bookmarks
... ignore any references to evicted pages.
B
B
roots
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Collection with Bookmarks
Use bookmarks to recreate evicted references...
B
B
roots
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Collection with Bookmarks
... and continue collection.
roots
B
B
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Collection with Bookmarks
B
B
roots
Result: Garbage collection without paging!
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Collection with Bookmarks
B
B
roots
Note: can waste space on evicted pages.
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Bookmarking Incompleteness
Space waste not just on evicted pages
Collection with bookmarks is necessarily incomplete Not guaranteed to reclaim all memory
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Bookmarking Incompleteness
B
B
When a reference to an evicted object changes…
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Bookmarking Incompleteness
B
B
When a reference to an evicted object changes…
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
1 0
0
0
RAM
Hard Disk
Bookmarking Incompleteness
B B
B B
B
B
B
…it can make evicted objects unreachable.
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Bookmarking Incompleteness
B
B
But bookmarks cannot be removed…
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Bookmarking Incompleteness
B
B
…retaining unreachable heap objects.
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Bookmarking Completeness
Worst-case: completeness requires duplicating evicted pages See paper for more info
How can we preserve completeness?
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0B B
B B
B
1 00
RAM
Hard Disk
Bookmarking Completeness
B
B
If the heap becomes full…
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0
0 00
RAM
Hard Disk
Bookmarking Completeness
…BC removes all bookmarks…
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0
0 00
???
???
Bookmarking Completeness
…and performs a VM-oblivious collection...
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0
0 00
???
???
Bookmarking Completeness
…reclaiming all unreachable objects.
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
0 0
0
0
???
???
Bookmarking Completeness
…reclaiming all unreachable objects.
BC’s worst case is other collectors’ common case
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
BC Performance Optimizations
Uses generational design similar to GenMS Yields good performance when not
paging
Compacts heap to reduce pressure Prevents single object from tying
down a page
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Outline
Motivation GC without paging
Cooperative garbage collection Bookmarking
Results
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Experimental Methodology
Extended Linux kernel 2.4.20 Eviction notification vm_relinquish() Added only 600 LOC
Jikes RVM 2.3.2 & MMTk Compare BC to MarkSweep,
SemiSpace, CopyMS, GenCopy, GenMS
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Throughput w/o Memory Pressure
BC runtime comparable to GenMS
Geo. Mean for Execution Time Relative to BC
0.95
1.00
1.05
1.10
1.15
1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00Relative Heap Size
Rel
ativ
e Ex
ecuti
on T
ime
BCGenCopyGenMS
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Throughput while Paging
BC throughput closely follows ideal curve
Execution Time for pseudoJBB w/ 77MB Heap
0
100
200
300
400
500
600
212 163 153 143 133 123 113 103 93
Available Memory
Exec
utio
n Ti
me
(in s
)
IdealBCGenCopyGenMS
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
BMU Curve w/ Memory Pressure
Bookmarking crucial for good performance
0.0%1566 ms
71.9%12231 ms
0.0%81591 ms
39.1%467944 ms
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Summary of Results
When not paging: BC as fast as GenMS
When paging: vs. GenMS (fastest when not paging)
41x faster, avg pause up to 218x smaller vs. CopyMS (next fastest when
paging) 5x faster, avg pause up to 45x smaller
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Conclusion
Bookmarking collector available at: http://www.cs.umass.edu/~hertz
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Thank you
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Other Pointer Summarizations
Pointer Compression Save space by compressing pointers Tracing pointers becomes expensive
Remembered Sets Add evicted pointers to buffers Requires space upon pages eviction
Per Object Referring Page Counts Increases BC overheads
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Related Work
VM-Sensitive Garbage Collection Linearizing LISP lists [Bobrow/Murphy]
Does not know or use which heap pages are memory resident
Independent heap regions [Bishop] Cannot avoid page faults when region
contains evicted pages Ephemeral garbage collection [Moon]
Must access evicted pages when they contain pointers into generations being collected
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Related Work
VM-Cooperative Garbage Collection Discarding empty pages [Cooper, et al.]
No mechanism for evicting non-empty pages Shrinking heap size [Alonso/Appel]
Responds to memory pressure changes only after a collection
Automatic heap sizing [Yang, et al.] Orthogonal approach that determines proper
heap size
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Throughput w/ Memory Pressure
BC outperforms fixed nursery collectors
212 163 153 143 133 123 113 103 930
50000
100000
150000
200000
250000
300000
350000
400000
450000
500000Execution Time for pseudoJBB w/ 77MB
HeapBCBC w/ Fixed NurseryBC w/ Fixed Nursery and Resizing OnlyGenCopy w/ Fixed NurseryGenMS w/ Fixed Nursery
Available Memory
Exe
cutio
n T
ime (
ms)
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Multiprogramming Performance
491 292 282 272 262 252 242 232 222 212 202 192 182 172 1620
100000
200000
300000
400000
500000
Elapsed Time for 2 runs of pseudoJBB, 77MB HeapBC
GenCopyGenMSCopyMSSemiSpace
Available Memory (MB)
Tota
l Wall
Clo
ck T
ime (
ms)
BC performs well in many environments
UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS A AMHERST • MHERST • Department of Computer Science Department of Computer Science
Experimental Methodology
Benchmarks:SPECjvm98, ipsixql, jython, and pseudoJBB
“Opt-and-reset” methodology First iteration optimizes all code Record results from second run