Top Banner
Finding Your Cronies: Static Analysis for Dynamic Object Colocation Samuel Z. Guyer Kathryn S. McKinley T H E U N I V E R S I T Y O F T E X A S A T A U S T I N
27

Finding Your Cronies: Static Analysis for Dynamic Object Colocation

Jan 14, 2016

Download

Documents

hayden hayden

T H E U N I V E R S I T Y O F T E X A S. A T A U S T I N. Finding Your Cronies: Static Analysis for Dynamic Object Colocation. Samuel Z. Guyer Kathryn S. McKinley. Motivation. Modern garbage collectors use multiple spaces Generational collectors: - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

Finding Your Cronies: Static Analysis for Dynamic Object Colocation

Samuel Z. Guyer

Kathryn S. McKinley

T H E U N I V E R S I T Y O F

T E X A SA T A U S T I N

Page 2: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 2

Motivation

Modern garbage collectors use multiple spaces

Generational collectors: Allocate new objects in nursery space Many objects die young – collection is cheap Copy survivors into mature space – “promotion”

Problem: longer-lived objects always copied javac: 25% (47 MB out of 185 MB)

nursery mature space

Page 3: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 3

Avoiding promotion

Solution: skip nursery Allocate objects that will survive in mature space

How do we predict nursery survivors? Look at why objects survive...

Most objects survive because they are connected to older objects javac: 10% stack, 90% mature space

nursery mature space

p

Page 4: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 4

Exploiting connectivity

Pointers predict survival Create new object – point to it from mature space

New object will be promoted

Instead: colocate new object... Anticipate the pointer Allocate pointer target in same space as source

nursery mature space

Page 5: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 5

Dynamic Object Colocation

Key: a cooperative approach...

Run-time: new allocation routine coalloc() takes a Object argument – the colocator Allocates new object in same space as colocator

Compile-time: static analysis Determine if a new object will be a pointer target At allocation site: pass pointer source as colocator

Connected objects end up in the same space

Page 6: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 6

Outline

Motivation Dynamic object colocation

Colocators Static analysis for finding colocators Run-time system Results

Related work Conclusions

Page 7: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 7

Simple Example

The new B object will live as long as A* Colocate new B with A Run-time value of p determines behavior:

void Simple(A p){ B newB = new B(); p.f = newB;}

void Simple(A p){ B newB = coalloc B(p); p.f = newB;}

A

newB

nursery mature space

A newBA newB

* Unless p.f is

overwritten

Page 8: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 8

Complex Example

Problem: new C cannot be colocator for new B Solution: use p as colocator for both

Connectivity is transitive – so is survival Simplifies task of finding colocators

void BottomUp(A p){ B newB = new B(); C newC = new C(); newC.f = newB; p.f = newC;}

void BottomUp(A p){ B newB = coalloc B(p); C newC = coalloc C(p); newC.f = newB; p.f = newC;}

A

newB

newC

Page 9: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 9

Finding colocators

Use formal parameters Likely to refer to older objects Order of creation/connection doesn’t matter

Goal: for each allocation site…Will the new object end up connected to a parameter?(Directly or indirectly)

Find colocators using custom pointer analysis Determine connectivity using points-to graph

Page 10: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 10

Analysis algorithm

Points-to graph Node for each parameter, alloc site Edges represent “may point-to”

Visit each instruction in IR Keep track of variable bindings Add edges at putfield and astore

Find colocators using graph Test reachability of allocation nodes from

parameters

One method at a time

newC

newE

newD

newF

void foo(A p, B q) {...}

A B

p q

newGnewE

p

Page 11: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 11

Interprocedural analysis

Common case: local analysis good enoughProblem: allocation, connection in different methods

For example, container classes

Connector methods Record how method connects arguments Apply summary at call sites

Factory methods Treat calls to factory as allocations at call sites

Helpful, but not required...

p = new Element();list.add(p);

Page 12: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 12

Analysis features

Observation: Allocation doesn’t affect correctness Colocation analysis can be unsound

Simplify algorithm One pass – no fixed-point computation No conservative assumptions (parameter aliasing)

No closed-world assumptionWorks with class loading, reflection, native methods

Ignore some connectionsHeuristics to identify volatile pointers

* Unless p.f is

overwritten

*

Page 13: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 13

Volatility heuristics

Some connections should not cause colocation Mistakes can fill the mature space with garbage

Prune them out of the graph...

void bar(Container c) { for (...) { c.add(new String(...)); } c.clear();}

New string is conditionally stored

Heuristic: store must post-dominate allocation

Container object is immediately cleared

Heuristic: skip connections that have null assignments

void foo(Container c, Value v) { String value_name = new String(v); if ( ! c.contains(value_name)) c.add(value_name);}

Page 14: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 14

Run-time

Coalloc routine – generational collector

Factory methods At call site save the colocator At start of method retrieve the colocator Colocation depends on calling context

VM_Address coalloc(int bytes, VM_Address colocator) { if (! colocator.isZero() && colocator.LT(NURSERY_START)) return matureAlloc(bytes); else return nursery.alloc(bytes);}

If the colocator is non-null and resides in the

mature space…… allocate the new object directly in the

mature space.… otherwise, allocate the object in the

nursery.

Page 15: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 15

Methodology

JikesRVM using MMTk3.2 GHz Pentium 4, 1 GB memory, Linux 2.6.0

Generational collectors – 4 MB bounded nursery GenCopy – copying older space GenMS – mark/sweep older space

Benchmarks: SPECJVM98 + pseudojbb Compile all methods ahead of time (+ 5-10%)

Goals: Reduce nursery promotion – GC time Avoid filling up the mature space with garbage

Page 16: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 16

Nursery survival

2.1 3.2 7.747.7 6.4 6.759.8100%

50%

150%

jessraytracedbjavac mtrt jackpseudojbb

Base

2.0

0.9

4.1 3.3 3.623.1

Co

loc

Byt

es i

n m

atu

re s

pac

e(n

orm

aliz

ed)

MB promoted MB mature space alloc

2.7

3.4 7.848.7 6.57.8

86.7

Base

Co

loc

Base

Co

loc

Base

Co

loc

Base

Co

loc

Base

Co

loc

Base

Co

loc

13.8

Page 17: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 17

GC Time: javac

62%

57%

Page 18: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 18

GC Time: jbb

-24%

40%35%

55%

Page 19: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 19

GC Time: average % speedup

Page 20: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 20

Runtime: javac

4%

8%

Page 21: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 21

Runtime: average % speedup

Page 22: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 22

Runtime: db % speedup

Page 23: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 23

Related Work

Co-allocation for locality [Chilimbi 99]

Manually add coalloc() calls

Pretenuring [Blackburn 01]

Static decision – needs alloc-site homogeneity

Connectivity-based GC [Hirzel 03]

Statically partitions objects Requires sound pointer analysis

Our approach combines static and dynamic

Page 24: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 24

Conclusions

Dynamic object colocation overcomes limitations of static approaches

Static analysis for garbage collection Complex property (object lifetime) predicted by simple

information (local connectivity) Use aggressive, unconventional points-to analysis

Cooperative approach Exploit different strengths of compiler and run-time

Page 25: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 25

Thank You

http://www.cs.utexas.edu/users/sammy

Page 26: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 26

GC Time: jbb % speedup

Page 27: Finding Your Cronies:  Static Analysis for  Dynamic Object Colocation

OOPSLA, Oct 27, 2004 Guyer, McKinley 27

Conclusions

Compiler can assist garbage collector Compiler can discover useful information Complex property (lifetime) predicted by simple

information (connectivity)

Cooperative approach Static analysis to identify opportunities Run-time system handles dynamic behavior Low cost and effective

Generalizes to other multi-space collectors