FreeMe: A Static Analysis for Individual Object Reclamation - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

FreeMe: A Static Analysis for Individual Object Reclamation

Description:

Free-Me: A Static Analysis for Individual Object Reclamation. Samuel Z. Guyer. Tufts University ... Reclaim memory quickly, with high overhead. Infrequent GCs: ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 26
Provided by: samuel49
Category:

less

Transcript and Presenter's Notes

Title: FreeMe: A Static Analysis for Individual Object Reclamation


1
Free-Me A Static Analysis for Individual Object
Reclamation
Samuel Z. Guyer Tufts University
Kathryn S. McKinley University of Texas at Austin
Daniel Frampton Australian National University
2
Motivation
  • Automatic memory reclamation (GC)
  • No need for explicit free
  • Garbage collector reclaims memory
  • Eliminates many programming errors
  • Problem when do we get memory back?
  • Frequent GCs
  • Reclaim memory quickly, with high overhead
  • Infrequent GCs
  • Lower overhead, but lots of garbage in memory

3
Example
Read a token (new String)
  • Notice String idName is often garbage
  • Memory

void parse(InputStream stream) while
(not_done) String idName
stream.readToken() Identifier id
symbolTable.lookup(idName) if (id null)
id new Identifier(idName)
symbolTable.add(idName, id)
computeOn(id)
Look up insymbol table
If not there, create new identifier, add to
symbol table
Compute onidentifier
4
Solution
  • Garbage does not accumulate
  • Memory

void parse(InputStream stream) while
(not_done) String idName
stream.readToken() Identifier id
symbolTable.lookup(idName) if (id null)
id new Identifier(idName)
symbolTable.add(idName, id) else
free(idName) computeOn(id)
String idName is garbage, free immediately
5
Our approach
  • Adds free() automatically
  • FreeMe compiler pass inserts calls to free()
  • Preserve software engineering benefits
  • Cant determine lifetimes for all objects
  • Works with the garbage collector
  • Implementation of free() depends on collector
  • Goal
  • Incremental, eager memory reclamation
  • Results reduce GC load, improve performance

6
Outline
  • Motivation
  • Analysis
  • Results
  • Related work
  • Conclusions

7
FreeMe Analysis
  • Goal
  • Determine when an object becomes unreachable
  • Not a whole-program analysis
  • Idea pointer analysis liveness
  • Pointer analysis for reachability
  • Liveness analysis for when

Within a method, for allocation site p new
A where can we place a call to free(p)?
Ill describe the interprocedural parts later
8
Pointer Analysis
  • Connectivity graph
  • Variables
  • Allocation sites
  • Globals (statics)
  • Analysis algorithm
  • Flow-insensitive, field-insensitive

String idName stream.readToken() Identifier id
symbolTable.lookup(idName) if (id null)
id new Identifier(idName) symbolTable.add(idN
ame, id) computeOn(id)
9
Adding liveness
  • Key

An object is reachable only when all incoming
pointers are live
idName
Identifier
(global)
Reachability is union of all these live ranges
readTokenString
10
Liveness Analysis
  • Computed as sets of edges
  • Variables
  • Heappointers

String idName stream.readToken()
idName
Identifier id symbolTable.lookup(idName)
if (id null)
id new Identifier(idName)
(global)
Identifier
symbolTable.add(idName, id)
readTokenString
computeOn(id)
11
Where can we free it?
  • Where object exists
  • -minus-
  • Where reachable

String idName stream.readToken()
readTokenString
Identifier id symbolTable.lookup(idName)
if (id null)
id new Identifier(idName)
symbolTable.add(idName, id)
Compiler inserts call to free(idName)
computeOn(id)
12
Interprocedural component
  • Detection of factory methods
  • Return value is a new object
  • Can be freed by the caller
  • Effects of methods called
  • Describes how parameters are connected
  • Compilation strategy
  • Summaries pre-computed for all methods
  • Free-me only applied to hot methods

String idName stream.readToken()
Hashtable.add (0 ? 1) (0 ? 2)
symbolTable.add(idName, id)
13
Implementation in JikesRVM
  • FreeMe added to OPT compiler
  • Run-time depends on collector
  • Mark/sweep
  • Free-list free() operation
  • Generational mark/sweep
  • Unbump move nursery bump pointer backward
  • Unreserve reduce copy reserve
  • Very low overhead
  • Run longer without collecting

14
Volume freed in MB
105
263
91
98
183
271
180
8195
1544
716
103
515
348
822
523
74
100
50
0
db
ps
mtrt
fop
pmd
jess
jack
antlr
xalan
bloat
javac
jython
raytrace
hsqldb
compress
pseudojbb
15
Volume freed in MB
105
263
91
98
183
271
180
8195
1544
716
103
515
348
822
523
74
100
50
0
db
ps
mtrt
fop
pmd
jess
jack
antlr
xalan
bloat
javac
jython
raytrace
hsqldb
compress
pseudojbb
16
Compare to stack-like behavior
  • Notice Stacks and regions wont work for example
  • idName escapes some of the time
  • Not biased 35 vs 65
  • Comparison restrict placement of free()
  • Object must not escape
  • No conditional free
  • No factory methods
  • Other approaches
  • Optimistic, dynamic stack allocation Azul,
    Corry 06
  • Scalar replacement

17
Volume freed in MB
105
263
91
98
183
271
180
8195
1544
716
103
515
348
822
523
74
100
50
0
db
ps
mtrt
fop
pmd
jess
jack
antlr
xalan
bloat
javac
jython
raytrace
hsqldb
compress
pseudojbb
18
Mark/sweep GC time
All benchmarks
19
Mark/sweep time
All benchmarks
20
GenMS time
All benchmarks
21
GenMS GC time
Why doesnt this help? Note the number of GCs is
greatly reduced
All benchmarks
FreeMe mostly finding short-lived objects
Nursery reclaims dead objects for free (cost
survivors)
22
Bloat GC time
23
Related work
  • Compile-time memory management
  • Functional languages Barth 77, Hughs 92,
    Mazur 01
  • Shape analysis Shaham 03,
    Cherem 06
  • Stack allocation Gay 00, Blanchet
    03, Choi 03
  • Tied to stack frames or other scopes
  • Objects from a site must not escape
  • Region inference Tofte 96, Hallenberg
    02
  • Cheap reclamation no scoping constraints
  • Similar all-or-nothing limitation

24
Conclusions
  • FreeMe analysis
  • Finds many objects to free often 30 - 60
  • Most are short-lived objects
  • GC explicit free()
  • Advantage over stack/region allocation no need
    to make decision at allocation time
  • Generational collectors
  • Nursery works very well
  • Abandon techniques that replace nursery?
  • Mark-sweep collectors
  • 50 to 200 speedup
  • Works better as memory gets tighter

25
Thank You
Write a Comment
User Comments (0)
About PowerShow.com