Download presentation
Presentation is loading. Please wait.
Published byAugust Jennings Modified over 9 years ago
1
Michael Bond Kathryn McKinley The University of Texas at Austin
2
http://www.codeproject.com/KB/showcase/IfOnlyWedUsedANTSProfiler.aspx Driverless truck 10,000 lines of C# Leak: past obstacles remained reachable No immediate symptoms “This problem was pernicious because it only showed up after 40 minutes to an hour of driving around and collecting obstacles.” Quick “fix”: restart after 40 minutes Environment sensitive More obstacles in deployed setting Unresponsive after 28 minutes
3
Driverless truck 10,000 lines of C# Leak: past obstacles remained reachable No immediate symptoms “This problem was pernicious because it only showed up after 40 minutes to an hour of driving around and collecting obstacles.” Quick “fix”: restart after 40 minutes Environment sensitive More obstacles in deployed setting Unresponsive after 28 minutes Different environments & inputs different behavior Uncertainty in deployed systems Hard to fix before deployment
4
Deployed systems have leaks Critical systems need immediate help Leak pruning tolerates bad effects Reclaims memory automatically High precision & low overhead Bounds resources Preserves semantics
5
Why tolerate leaks Why leaks are so bad How leak pruning works How leak pruning predicts leaked objects Evaluation
6
Memory leaks are a real problem Managed languages do not eliminate them
7
Memory leaks are a real problem Managed languages do not eliminate them Reachable Unreachable
8
Memory leaks are a real problem Managed languages do not eliminate them Live ReachableDead
9
Memory leaks are a real problem Managed languages do not eliminate them Live Reachable Dead
10
Memory leaks are a real problem Managed languages do not eliminate them Live Reachable Dead
11
Memory leaks are a real problem Managed languages do not eliminate them Slow & crash real programs Live Dead
12
Memory leaks are a real problem Managed languages do not eliminate them Slow & crash real programs Unacceptable for some applications Fixing leaks is hard Leaks take time to materialize Failure far from cause
13
Is it a memory leak or a case of stale memory ? Is it correct to always consider stale memory as equivalent to unreachable memory ?
14
Why tolerate leaks Why leaks are so bad How leak pruning works How leak pruning predicts leaked objects Evaluation
15
Garbage collection based on liveness Live Reachable Dead
16
Garbage collection based on liveness Take action when memory exhausted Live Reachable Dead
17
Garbage collection based on liveness Take action when memory exhausted Live Reachable Dead
18
Garbage collection based on liveness Take action when memory exhausted Live Dead Throw OOM error Out of memory!
19
Garbage collection based on liveness Take action when memory exhausted Live Dead Out of memory! Throw OOM error Reclaim some objects
20
Garbage collection based on liveness Reclaim predicted dead objects Reclaimed Live
21
Garbage collection based on liveness Reclaim predicted dead objects Reclaimed Live A A B B
22
Garbage collection based on liveness Reclaim predicted dead objects Live A A ?
23
Garbage collection based on liveness Reclaim predicted dead objects Poison references to reclaimed objects Live A A X
24
Garbage collection based on liveness Reclaim predicted dead objects Poison references to reclaimed objects Live A A X Throw InternalError with OOMError attached
25
Garbage collection based on liveness Reclaim predicted dead objects Poison references to reclaimed objects Live A A X Throw InternalError with OOMError attached Worst case: defers fatal errors Best case: keeps leaky programs running much longer or indefinitely
26
Instead of returning the error can we return some other object, to keep program going ? Eg DieHard What about semantics in that case ?
27
INACTI VE OBSER VE SELECTPRUNE Heap not full <50% Heap filled >50% Heap not full Heap full
28
Why tolerate leaks Why leaks are so bad How leak pruning works How leak pruning predicts leaked objects Evaluation
29
Predicting the future Leaked objects not used again Highly stale objects likely leaked Alternative: offload to disk [Melt, Bond & McKinley ’08] [LeakSurvivor, Tang et al. ’08] [Panacea, Goldstein et al. ’07, Breitgand et al. ’07] Tolerates mispredictions Eventually exhausts disk (if disk at all)
30
Predicting the future Leaked objects not used again Highly stale objects likely leaked Alternative: offload to disk [Melt, Bond & McKinley ’08] [LeakSurvivor, Tang et al. ’08] [Panacea, Goldstein et al. ’07, Breitgand et al. ’07] Tolerates mispredictions Eventually exhausts disk (if disk at all) Need high precision One misprediction: program terminates Need high precision One misprediction: program terminates
31
Identify references to prune Roots of leaked data structures Categorize by reference type ParserInfo PreparedStatement
32
Identify references to prune Roots of leaked data structures Categorize by reference type Criteria Highly stale references ▪ More stale than most stale instance accessed previously ParserInfo PreparedStatement MaxS&U 2-4 GCs
33
Identify references to prune Roots of leaked data structures Categorize by reference type Criteria Highly stale references ▪ More stale than most stale instance accessed previously Reference type keeping most bytes reachable ParserInfo PreparedStatement MaxS&U 2-4 GCs Size 132MB
34
Identify references to prune Roots of leaked data structures Categorize by reference type Criteria Highly stale references ▪ More stale than most stale instance accessed previously Reference type keeping most bytes reachable Piggyback on GC: two-phase transitive closure ParserInfo PreparedStatement MaxS&U 2-4 GCs Size 132MB
35
Based on colleague’s JDBC application Leak: SQL statements remain in set
36
HashSet Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[]
37
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[]
38
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[]
39
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32
40
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32
41
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32
42
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] enqueued HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32
43
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] enqueued HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 enqueued
44
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] enqueued HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 0 0 0 enqueued
45
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] enqueued HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes enqueued 20 0 0
46
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] enqueued HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 60 enqueued 0 0
47
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] enqueued HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 572 enqueued 0 0
48
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 572 enqueued 0 0
49
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 572 enqueued 244 0
50
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 420M 180M 0
51
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 420M 180M 0
52
HashSet … …… Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] Parser Info Parser Info Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] byte[][] byte[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 420M 180M 0
53
HashSet … …… Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 420M 180M 0
54
HashSet … …… Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 0 0 0
55
HashSet … …… Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 0 0 0 enqueued
56
HashSet … …… Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 50M 220M 0
57
HashSet … …… Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 50M 220M 0
58
HashSet … …… Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] Result Set Result Set Hash Entry Hash Entry Prepared Statement Prepared Statement Field[] HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 50M 220M 0
59
HashSet … … Hash Entry Hash Entry Prepared Statement Prepared Statement Hash Entry Hash Entry Prepared Statement Prepared Statement Hash Entry Hash Entry Prepared Statement Prepared Statement HashEntry PreparedStatement ParserInfo PreparedStatement ResultSet MaxS&U 0-1 16-32 Bytes 50M 220M 0
60
HashSet … … Hash Entry Hash Entry Prepared Statement Prepared Statement Hash Entry Hash Entry Prepared Statement Prepared Statement Hash Entry Hash Entry Prepared Statement Prepared Statement Algorithm efficiently selects references to consistently unused data structures based on type
61
Why tolerate leaks Why leaks are so bad How leak pruning works How leak pruning predicts leaked objects Evaluation
62
Leak pruning added to Jikes RVM 2.9.2 http://www.jikesrvm.org/Research+Archive Performance stress test Non-leaking programs: DaCapo & SPEC benchmarks Low overhead ▪ 3% (Core 2) or 5% (Pentium 4) ▪ Primarily read barriers
67
Low footprint & often helps a lot all-the-time deployed use Low footprint & often helps a lot all-the-time deployed use
68
INACTI VE OBSER VE SELECTPRUNE Heap not full <50% Heap filled >50% Heap not full Heap full
69
What about bursty leaks ? Can we have dynamically adjustable limit for switching on Leak Pruning ? Can we dynamically switch off Leak Pruning ?
70
What if stale objects interleaved with active objects ? Is it useful to find source of these leaks ? If yes then how ?
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.