Presentation is loading. Please wait.

Presentation is loading. Please wait.

Optimizing The Optimizer: Improving Data Flow Analysis in Soot Michael Batchelder 4 / 6 / 2005 A COMP-621 Class Project.

Similar presentations


Presentation on theme: "Optimizing The Optimizer: Improving Data Flow Analysis in Soot Michael Batchelder 4 / 6 / 2005 A COMP-621 Class Project."— Presentation transcript:

1 Optimizing The Optimizer: Improving Data Flow Analysis in Soot Michael Batchelder 4 / 6 / 2005 A COMP-621 Class Project

2 Presentation Outline ● Introduction and Motivation ● Previous Work ● Overview of Algorithms ● Results ● Future Extensions ● Summary and Conclusion

3 Introduction and Motivation ● Soot is a framework for analyzing and optimizing Java, But it's slow and memory intensive! – Relies on many analyses that iterate to a fixed-point. – Iterating over large Control Flow Graphs takes time and memory. – Code is readable and maintainable, but slow. ● Can we reduce these costs?

4 Introduction and Motivation ● How can we reduce time / memory costs? – Many Control Flow Graph nodes do not effect in/out flow sets of an analysis. ● Store less – can we simply point to the flowset of the node's parent? YES ● Iterate less – can we skip nodes completely? YES ● Be Smarter - can we iterate more smartly, like using a worklist? YES

5 Introduction and Motivation ● How can we reduce time / memory costs? – Better coding – or perhaps “more optimized” coding. ● Example: don't remove(i) out of Lists ● Try not to perform method calls in loops – Make smarter choices about data structures ● HashSet can make for a better list if: – Order does not matter – You're calling contains a lot – O(1) not O(n)! – You're removing a lot – O(1) not O(n) – Basically, Know Your API and Language!

6 Previous Work ● “Automatic Construction of Sparse Data Flow Evaluation Graphs” - 1998 – Jong-Deook Choi, Ron Cytron, and Jeanne Ferrante – Presents an algorithm to compute “Sparse Data Flow Graph” – Combines information as early as possible – Forwards information directly to where it's needed – Uesless information is not represented

7 Previous Work ● “A Simple, Fast Dominance Algorithm” – Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy – Presents algorithms for: – Dominators ● in practice faster than Lengauer-Tarjan's – Dominance Frontiers ● in practice, faster than Cytron, et al's. – Algorithms with “discouraging asymoptotic complexities” can be faster in practice than better engineered approaches.

8 Previous Work ● Dominator: – A node n dominates node b if all paths from start to b pass through n. ● Dominator Frontier: – For a node n, the set of all nodes y such that n dominates a predecessor but does not strictly dominate y.

9 Presentation Outline ● Introduction and Motivation ● Previous Work ● Overview of Algorithms – Sparse Data Flow Graphs – Fast Dominators / Dominance Frontiers ● Results ● Future Extensions ● Summary and Conclusion

10 Overview of Algorithms ● Sparse Flow Graph: – Need to know information about the flow analysis to construct itself: ● getFlowThroughConstant(Unit u) – returns constant transference flowset or null ● isFlowThroughIdentity(Unit u) – returns true if the unit u has identity transference

11 Overview of Algorithms Sparse Graph for Must Reaching Definitions

12 Overview of Algorithms ● Construction of Sparse Graph: – N sg = {root} U {Y | f y != i} ● Add root node and all nodes that do not have identity transference to N sg – N df = U DF(x) ∀ x ∈ N sg ● For all nodes in N sg collect a list of nodes N df in their dominance frontiers! – Search(root)

13 Overview of Algorithms ● Construction of Sparse Graph (cont): – Search(n) recurses down the dominator tree ● Link node n to the current top of the stack ● If node n is in SG, make it top of the stack ● Create mapping for FG successor nodes not in SG ● Link FG successor nodes that are in N df ● Call Search on all children in dominator tree

14 Overview of Algorithms – Link(x) ● If f x = K x then NO EDGE ● else – If f TOS = K TOS then ● In(x) = In(x) ∧ K TOS – Else ● E sg = E sg U (TOS,x)

15 Overview of Algorithms ● A Simple, Fast Dominators Algorithm: – Initialize all immediate dominators: idom=null – While changing: ● For each node n except start – For each predecessor p of n ● idom = intersect (idom, p.idom) – Intersect(n1, n2) ● returns closest matching node in path to dominator tree root. (two finger method)

16 Overview of Algorithms ● “A Simple, Fast Dominance Frontier Algorithm”

17 Presentation Outline ● Introduction and Motivation ● Previous Work ● Overview of Algorithms ● Results ● Future Extensions ● Conclusion

18 Results: Size of Full vs. Sparse

19 Results: Cytron vs. Cooper

20 Results: Converting to Shimple

21 Results: Flow Analysis

22 Results: Hand Optimizations

23 Results ● Cooper's approach is much faster than Cytron's in almost all cases. ● Sparse Graphs work for forward or backward flow analysis. ● Sparse Graphs suffer in Soot! – Inability to handle constant transference – Dominators / Dominance Tree / Frontiers must be computed, despite Soot's main IR Jimple.

24 Future Extensions ● Reusable Sparse Graphs? ● Java Source Annotations in Jimple for Constant Transference? ● Sparse Backwards and Bidirectional analysis through Extended SSA (eSSA) – An early beta of eSSA has been implemented by Navin and committed to Soot.

25 Conclusions ● We've managed to increase the speed of Dominators / Tree / Dominance Frontier! ● Sparse Graphs are (mostly) useless without constant transference ● There are certain limitations that just cannot be avoided. (e.g. Building the dominators / frontiers)

26 The End


Download ppt "Optimizing The Optimizer: Improving Data Flow Analysis in Soot Michael Batchelder 4 / 6 / 2005 A COMP-621 Class Project."

Similar presentations


Ads by Google