michael bond kathryn mckinley the university of texas at austin

70
Michael Bond Kathryn McKinley The University of Texas at Austin

Upload: august-jennings

Post on 24-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Michael Bond Kathryn McKinley The University of Texas at Austin

Michael Bond Kathryn McKinley

The University of Texas at Austin

Page 2: Michael Bond Kathryn McKinley The University of Texas at Austin

http://www.codeproject.com/KB/showcase/IfOnlyWedUsedANTSProfiler.aspx

Driverless truck 10,000 lines of C#

Leak: past obstacles remained reachableNo 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 minutesEnvironment sensitive

More obstacles in deployed setting Unresponsive after 28 minutes

Page 3: Michael Bond Kathryn McKinley The University of Texas at Austin

Driverless truck 10,000 lines of C#

Leak: past obstacles remained reachableNo 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 minutesEnvironment sensitive

More obstacles in deployed setting Unresponsive after 28 minutes

Different environments & inputs different behavior

Uncertainty in deployed systems

Hard to fix before

deployment

Page 4: Michael Bond Kathryn McKinley The University of Texas at Austin

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

Page 5: Michael Bond Kathryn McKinley The University of Texas at Austin

Why tolerate leaks

Why leaks are so bad

How leak pruning works

How leak pruning predicts leaked objects

Evaluation

Page 6: Michael Bond Kathryn McKinley The University of Texas at Austin

Memory leaks are a real problem Managed languages do not eliminate

them

Page 7: Michael Bond Kathryn McKinley The University of Texas at Austin

Memory leaks are a real problem Managed languages do not eliminate

them

Reachable

Unrea

chab

le

Page 8: Michael Bond Kathryn McKinley The University of Texas at Austin

Memory leaks are a real problem Managed languages do not eliminate

them

LiveLive

ReachableDead

Page 9: Michael Bond Kathryn McKinley The University of Texas at Austin

Memory leaks are a real problem Managed languages do not eliminate

them

LiveLive

Reachable

Dead

Page 10: Michael Bond Kathryn McKinley The University of Texas at Austin

Memory leaks are a real problem Managed languages do not eliminate

them

LiveLive

Reach

able

Dead

Page 11: Michael Bond Kathryn McKinley The University of Texas at Austin

Memory leaks are a real problem Managed languages do not eliminate

them Slow & crash real programs

LiveLiveDead

Page 12: Michael Bond Kathryn McKinley The University of Texas at Austin

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

Page 13: Michael Bond Kathryn McKinley The University of Texas at Austin

Is it a memory leak or a case of stale memory ?

Is it correct to always consider stale memory as equivalent to unreachable memory ?

Page 14: Michael Bond Kathryn McKinley The University of Texas at Austin

Why tolerate leaks

Why leaks are so bad

How leak pruning works

How leak pruning predicts leaked objects

Evaluation

Page 15: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness

LiveLive

Reachable

Dead

Page 16: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Take action when memory exhausted

LiveLive

Reachable

Dead

Page 17: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Take action when memory exhausted

LiveLive

ReachableDead

Page 18: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Take action when memory exhausted

LiveLive

DeadThrow OOM

errorThrow OOM

error

Out of memor

y!

Out of memor

y!

Page 19: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Take action when memory exhausted

LiveLive

Dead

Out of memor

y!

Out of memor

y!

Throw OOM error

Throw OOM error

Reclaim some

objects

Reclaim some

objects

Page 20: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Reclaim predicted dead objects

Reclaim

ed

LiveLive

Page 21: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Reclaim predicted dead objects

Reclaim

ed

LiveLive

AB

Page 22: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Reclaim predicted dead objects

LiveLive

A?

Page 23: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Reclaim predicted dead objects Poison references to reclaimed objects

LiveLive

AX

Page 24: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Reclaim predicted dead objects Poison references to reclaimed objects

LiveLive

AXThrow InternalError with OOMError attached

Page 25: Michael Bond Kathryn McKinley The University of Texas at Austin

Garbage collection based on liveness Reclaim predicted dead objects Poison references to reclaimed objects

LiveLive

AXThrow InternalError with OOMError attached

Worst case: defers fatal

errors

Worst case: defers fatal

errors

Best case: keeps leaky programs running much

longer or indefinitely

Best case: keeps leaky programs running much

longer or indefinitely

Page 26: Michael Bond Kathryn McKinley The University of Texas at Austin

Instead of returning the error can we return some other object, to keep program going ?

Eg DieHardWhat about semantics in that case ?

Page 27: Michael Bond Kathryn McKinley The University of Texas at Austin

INACTIVE

OBSERVE

SELECT

PRUNE

Heap not full

<50% Heap filled

>50%

Heap not full

Heap full

Page 28: Michael Bond Kathryn McKinley The University of Texas at Austin

Why tolerate leaks

Why leaks are so bad

How leak pruning works

How leak pruning predicts leaked objects

Evaluation

Page 29: Michael Bond Kathryn McKinley The University of Texas at Austin

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)

Page 30: Michael Bond Kathryn McKinley The University of Texas at Austin

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 precisionOne misprediction: program terminates

Page 31: Michael Bond Kathryn McKinley The University of Texas at Austin

Identify references to prune Roots of leaked data structures Categorize by reference type

ParserInfoPreparedStatement

Page 32: Michael Bond Kathryn McKinley The University of Texas at Austin

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

ParserInfoPreparedStatement

MaxS&U

2-4 GCs

Page 33: Michael Bond Kathryn McKinley The University of Texas at Austin

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

ParserInfoPreparedStatement

MaxS&U

2-4 GCs

Size

132MB

Page 34: Michael Bond Kathryn McKinley The University of Texas at Austin

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 reachablePiggyback on GC: two-phase transitive closure

ParserInfoPreparedStatement

MaxS&U

2-4 GCs

Size

132MB

Page 35: Michael Bond Kathryn McKinley The University of Texas at Austin

Based on colleague’s JDBC application

Leak: SQL statements remain in set

Page 36: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSetParser

Info

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

Page 37: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

Page 38: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

Page 39: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32

Page 40: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32

Page 41: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32

Page 42: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

enqueued

enqueued

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32

Page 43: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

enqueued

enqueued

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32

enqueued

enqueued

enqueued

enqueued

Page 44: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

enqueued

enqueued

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

0

0

0

enqueued

enqueued

enqueued

enqueued

Page 45: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

enqueued

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

enqueued

enqueued

enqueued

enqueued

20

0

0

Page 46: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

enqueued

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

60

enqueued

enqueued

enqueued

enqueued

0

0

Page 47: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

enqueued

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

572

enqueued

enqueued

enqueued

enqueued

0

0

Page 48: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

572

enqueued

enqueued

enqueued

enqueued

0

0

Page 49: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

572

enqueued

enqueued

enqueued

enqueued

244

0

Page 50: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

420M

180M

0

Page 51: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

420M

180M

0

Page 52: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

ParserInfo

ResultSet

HashEntry

PreparedStatement

Field[]

byte[][] byte[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

420M

180M

0

Page 53: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

420M

180M

0

Page 54: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

0

0

0

Page 55: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

0

0

0

enqueued

enqueued

enqueued

Page 56: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

50M

220M

0

Page 57: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

50M

220M

0

Page 58: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

……

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

ResultSet

HashEntry

PreparedStatement

Field[]

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

50M

220M

0

Page 59: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

HashEntry

PreparedStatement

HashEntry

PreparedStatement

HashEntry

PreparedStatement

HashEntry PreparedStatement

PreparedStatement ParserInfo

PreparedStatement ResultSet

MaxS&U

0-1

0-1

16-32Bytes

50M

220M

0

Page 60: Michael Bond Kathryn McKinley The University of Texas at Austin

HashSet

HashEntry

PreparedStatement

HashEntry

PreparedStatement

HashEntry

PreparedStatement

Algorithm efficiently selects

references to consistently unused data structures based on type

Page 61: Michael Bond Kathryn McKinley The University of Texas at Austin

Why tolerate leaks

Why leaks are so bad

How leak pruning works

How leak pruning predicts leaked objects

Evaluation

Page 62: Michael Bond Kathryn McKinley The University of Texas at Austin

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

Page 63: Michael Bond Kathryn McKinley The University of Texas at Austin
Page 64: Michael Bond Kathryn McKinley The University of Texas at Austin
Page 65: Michael Bond Kathryn McKinley The University of Texas at Austin
Page 66: Michael Bond Kathryn McKinley The University of Texas at Austin
Page 67: Michael Bond Kathryn McKinley The University of Texas at Austin

Low footprint &often helps a

lot all-the-time

deployed use

Page 68: Michael Bond Kathryn McKinley The University of Texas at Austin

INACTIVE

OBSERVE

SELECT

PRUNE

Heap not full

<50% Heap filled

>50%

Heap not full

Heap full

Page 69: Michael Bond Kathryn McKinley The University of Texas at Austin

What about bursty leaks ?Can we have dynamically adjustable

limit for switching on Leak Pruning ?Can we dynamically switch off Leak

Pruning ?

Page 70: Michael Bond Kathryn McKinley The University of Texas at Austin

What if stale objects interleaved with active objects ?

Is it useful to find source of these leaks ? If yes then how ?