260 likes | 364 Views
Free me. Written By: Samuel Z. Guyer, Kathryn S. Mckinley and Daniel Frampton Presented by: Uri Inon. Today's Topics. Motivation Technique Performance Related Work Conclusion. Reminder – GC Definition. Garbage Collector is responsible for removing unused object for the heap.
E N D
Free me Written By: Samuel Z. Guyer, Kathryn S. Mckinley and Daniel Frampton Presented by: Uri Inon
Today's Topics • Motivation • Technique • Performance • Related Work • Conclusion
Reminder – GC Definition • Garbage Collector is responsible for removing unused object for the heap. • Saves the programmer managing the heap. • On the other-hand, GC takes resources of the run-time.
Motivation • We wish to “help” the GC, so it will be activated less often. • This is done by finding objects (in compilation time) that are dead, and add commands (in the code) to free them.
Motivation - Example public void parse(InputStream stream){ while (...){ String idName=stream.readToken(); Identifier id=symbolTable.lookup(idName) if (id== null){ id= new Identifier(idName); symbolTable.add(idName,id); { computeOn(id); { { Allocated If id!=null idName isn’t used
Technique • Build Internal Representation • Pointer Connectivity • Procedure Summaries • Object Reachability and Liveness • Free Placement • Possible improvements
IR-Graph While … exit idName = stream.readToken() Id0 = symbolTable.lookup(idName) If (id0 = null) Id1 = new Identifier(idName) symbolTable.add(idName,id1) Id2 = (id0,id1) computeOn(id2)
Pointer Connectivity • Flow insensitive • Field insensitive • Interprocedural • Build a graph of the pointers, Allocation sites and one node for all globals
Pointer Connectivity - Example While … exit idName readToken idName = stream.readToken() id1 New Identifier Id0 = symbolTable.lookup(idName) id2 id0 If (id0 = null) global symbolTable Id1 = new Identifier(idName) symbolTable.add(idName,id1) Id2 = (id0,id1) computeOn(id2)
Procedure Summaries • Checks if the procedure is a factory. • If at all paths of the procedure a new object is returned – it’s a factory. • Checks which parameters are connected. idName readToken id1 symbolTable.add(idName,id1) New Identifier (P0,P1),(P0,P2) global symbolTable
Object Reachability and Liveness • Identifies when objects become dead. • Searches for a path that an object becomes un-reachable. • The reachability of an object is the union of then objects that might be pointing it idName New Identifier global readToken
Object Reachability and Liveness - Example While … exit idName = stream.readToken() global Id0 = symbolTable.lookup(idName) If (id0 = null) We Can Add Free Id1 = new Identifier(idName) New Identifier readToken symbolTable.add(idName,id1) Id2 = (id0,id1) idName computeOn(id2)
Free Placement • If we can free an object in several places – where should we do it? • In all of them! • Add temporary variable to avoid errors: • v = new Object(); • v = x.f; • free(v); //error!
Free Placement – Example idName = stream.readToken() idName = stream.readToken() t0 = idName Id0 = symbolTable.lookup(idName) Id0 = symbolTable.lookup(idName) If (id0 = null) If (id0 = null) Id1 = new Identifier(idName) Id1 = new Identifier(idName) symbolTable.add(idName,id1) symbolTable.add(idName,id1) else free(to) t0 = null
Possible improvements • Interprocedural analysis • Flow and field sensitive • TBD
Implementation of Free() • Pass the pointer and size • Lazy Free-List • Links the object to the appropriate free-list. • Unbump • Frees the object. If it was the last move the pointer backwards. • Unreserved • Reduce the reserved size in the GC
Methodology • Jikes RVM - The vm they use in the experiment • MMTK – Memory management component. Has several GCs. • Compilation time • Almost double • Can improve • Selecting less hot methods • Some optimizations of the analysis
Effectiveness • 32% On average • 80% was the best • Javac-inl – add support for inline
Mark-Sweep Collector – Total Time • 50% improvement on small heaps • 10% improvement on moderate heaps • 5% improvement on large heaps
Mark-Sweep Collector – Times cont’ GC Time Run Time
Generation Collector – Times cont’ GC Time Run Time
Related Work • Compile-Time free and Reuse • Identifying the last use of all objects and freeing them (without GC at all) • Reusing a dead object for another object at the same size • Stack Allocation • Detects objects whose lifetime correspond to method scope, and allocates them on the stack. • Region Allocation • Manage ALL objects based on allocation site lifetime or adding regions
Conclusion • Free-me can’t replace GC. • It improves Mark and Sweep GC significantly, and helps it to have closer performances to Generation GC.