A Pattern-based Transformation Approach to Parallelise Software Systems using a System Dependency Graph
Johanna E. Krause 27 January 2016
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 1 / 37
A Pattern-based Transformation Approach to Parallelise Software - - PowerPoint PPT Presentation
A Pattern-based Transformation Approach to Parallelise Software Systems using a System Dependency Graph Johanna E. Krause 27 January 2016 Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 1 / 37 Outline 1.
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 1 / 37
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 2 / 37
Motivation
◮ Parallel programs are mostly more performant
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 3 / 37
Motivation
◮ Parallel programs are mostly more performant ◮ Many legacy systems would benefit from parallelisation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 3 / 37
Motivation
◮ Parallel programs are mostly more performant ◮ Many legacy systems would benefit from parallelisation ◮ Manual adjustments are time and cost consuming
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 3 / 37
Goals
Christian Wulf ― 18.02.2015
Legend: S1: SDG Construction S2: Gathering S3: SDG Enrichment S4: Ranking S5: Pattern Detection S6: Transformation S7: Code Generation System dependency graph (SDG) Parallelism plan
S4 S6 S5
Semi-automatic transformation
Runtime information Static information
Parallelization pattern Candidate pattern Sequential program Parallel program
S7 S3
Pattern-based detection and utilization of potential parallelism in software systems [Wulf14] Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 4 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns ◮ Goal 2: Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns ◮ Goal 2: Formalising Candidate Patterns
◮ G2.1: Formalising as System Dependency Graph (SDG) Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns ◮ Goal 2: Formalising Candidate Patterns
◮ G2.1: Formalising as System Dependency Graph (SDG) ◮ G2.2: Formalising as Cypher Match Query (CMQ) Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns ◮ Goal 2: Formalising Candidate Patterns
◮ G2.1: Formalising as System Dependency Graph (SDG) ◮ G2.2: Formalising as Cypher Match Query (CMQ)
◮ Goal 3: Transforming Candidate Patterns to Parallelisation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns ◮ Goal 2: Formalising Candidate Patterns
◮ G2.1: Formalising as System Dependency Graph (SDG) ◮ G2.2: Formalising as Cypher Match Query (CMQ)
◮ Goal 3: Transforming Candidate Patterns to Parallelisation
◮ G3.1: Formalising as SDG Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns ◮ Goal 2: Formalising Candidate Patterns
◮ G2.1: Formalising as System Dependency Graph (SDG) ◮ G2.2: Formalising as Cypher Match Query (CMQ)
◮ Goal 3: Transforming Candidate Patterns to Parallelisation
◮ G3.1: Formalising as SDG ◮ G3.2: Formalising as Cypher Update Query (CUQ) Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Goals
◮ Goal 1: Mining of Candidate and Parallelisation Patterns ◮ Goal 2: Formalising Candidate Patterns
◮ G2.1: Formalising as System Dependency Graph (SDG) ◮ G2.2: Formalising as Cypher Match Query (CMQ)
◮ Goal 3: Transforming Candidate Patterns to Parallelisation
◮ G3.1: Formalising as SDG ◮ G3.2: Formalising as Cypher Update Query (CUQ)
◮ Goal 4: Evaluating the Speed-Up of the Transformed
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 5 / 37
Approach
Database
JAVA JAVA
MATCH (node1)
(node2) WHERE ... RETURN node1, node2
Cypher Match Query
MATCH node... WHERE ... CREATE/DELETE ... RETURN node...
Cypher Update Query
Candidate Pattern Parallelisation Pattern
Pattern Mining
choose prototype formalise pattern formalise transformation create SDG generate execute Sequential Program Parallelised Program Resulting candidates: 1) 2) ... parallelise execute 1. 2. 3. 0. Evaluation 4.
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 6 / 37
Approach ⊲ Mining of Candidate and Parallelisation Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 7 / 37
Approach ⊲ Mining of Candidate and Parallelisation Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 7 / 37
Approach ⊲ Mining of Candidate and Parallelisation Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 7 / 37
Approach ⊲ Mining of Candidate and Parallelisation Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 7 / 37
Approach ⊲ Formalising Candidate Patterns
?? MethodCall ?? MethodCall/ Assignment
avDur > 200ms avDur > 200ms
... ... ... ?? Method ?? Method
calls calls
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 8 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 9 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 10 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 10 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 11 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 11 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 12 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 12 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 13 / 37
Approach ⊲ Formalising Candidate Patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 13 / 37
Approach ⊲ Formalising Candidate Patterns MATCH ( d1 : Method ) <−[:CALLS]− (m1: MethodCall ) −[cfs :CONTROL_FLOW*1..5] − > (m2: MethodCall ) −[:CALLS]−> ( d2 : Method ) WHERE m1. avgDurationInMs > 200 AND m2. avgDurationInMs > 200 WITH m1, m2, d1 , d2 , cfs MATCH path = (m1) −[:CONTROL_FLOW*1..5] − > (m2) WITH m1, m2, d1 , d2 , cfs , f i l t e r ( intermediateNode IN nodes( path ) WHERE intermediateNode <> m1 AND intermediateNode <> m2) AS intermediateNodes WHERE NOT (m1) −[:DATA_FLOW*1..5] − > (m2) AND none ( cf IN cfs WHERE exis ts ( cf . case ) ) AND NOT (m1) −[:DATA_FLOW]−> ( : Field ) <−[:DATA_FLOW]− (m2) AND d1 . i s P a r a l l e l i s a b l e =true AND d2 . i s P a r a l l e l i s a b l e =true
AND a l l (node IN intermediateNodes WHERE NOT (m1) −[:DATA_FLOW]−> (node) AND (NOT node: MethodCall OR a l l ( pathcall IN ( ( node) −[:CALLS]−> ( ) ) WHERE a l l ( call IN rels ( pathcall ) WHERE endNode( call ) . isParallelisable=true OR endNode( call ) : Constructor ) ) ) )
RETURN c o l l e c t ( DISTINCT id (m1) ) Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 14 / 37
Approach ⊲ Formalising Candidate Patterns
◮ less restrictive: allow modification of fields except concurrently
◮ Attention: handle overridden methods separately!
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 15 / 37
Approach ⊲ Transformation
◮ Usage of nested Callables and Futures
◮ Enables return value ◮ Enables exception handling
◮ Organisation with Java’s ExecutorsService (thread pool)
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 16 / 37
Approach ⊲ Transformation Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 17 / 37
Approach ⊲ Transformation
◮ Add new nodes according to Soot representation ◮ Add new control flows and hierarchy ◮ Remove unused control flows ◮ New variable/class names (variable scope) ◮ Exception handling
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 18 / 37
Approach ⊲ Transformation
◮ Add new nodes according to Soot representation ◮ Add new control flows and hierarchy ◮ Remove unused control flows ◮ New variable/class names (variable scope) ◮ Exception handling
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 18 / 37
Approach ⊲ Transformation
◮ Implementation in Java ◮ Cypher queries (from String) ◮ Neo4J Java API
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 19 / 37
Approach ⊲ Transformation
◮ Implementation in Java ◮ Cypher queries (from String) ◮ Neo4J Java API
◮ Reusability of the queries ◮ Dynamic build of queries ◮ Temporary storing of nodes
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 19 / 37
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 20 / 37
Evaluation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 21 / 37
Evaluation
◮ Generation of Java source code from the Neo4J SDG is very
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 21 / 37
Evaluation
◮ Generation of Java source code from the Neo4J SDG is very
◮ Try-catch blocks ◮ Throw exceptions ◮ Loop Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 21 / 37
Evaluation
◮ Generation of Java source code from the Neo4J SDG is very
◮ Try-catch blocks ◮ Throw exceptions ◮ Loop
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 21 / 37
Evaluation
◮ Feasibility of the approach ◮ Quantitative occurrence of the candidate patterns ◮ Extendibility of the approach
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 22 / 37
Evaluation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 23 / 37
Evaluation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 24 / 37
Evaluation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 25 / 37
Evaluation
◮ without runtime information constraints ◮ branches excluded ◮ no allowance of ’isParallelisable=true’ for more flexibility
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 25 / 37
Evaluation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 26 / 37
Evaluation
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 27 / 37
Evaluation
◮ Modular because of Java ◮ Reusability of queries ◮ Semi-automatism easily extendible ◮ Configurable, e.g. runtime constraints ◮ New candidate and parallelisation patterns can be designed with
◮ When SDG changes, CMQs and transformation have to be
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 28 / 37
Conclusion and Future Work
◮ Successful implementation of 3 patterns ◮ Powerful, but complex approach
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 29 / 37
Conclusion and Future Work
◮ Successful implementation of 3 patterns ◮ Powerful, but complex approach
◮ Generate Java code from SDG for performance evaluation ◮ Add runtime information ◮ Implement additional candidate and parallelisation patterns
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 29 / 37
Conclusion and Future Work
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 30 / 37
Conclusion and Future Work
Database
JAVA JAVA
MATCH (node1)
(node2) WHERE ... RETURN node1, node2
Cypher Match Query
MATCH node... WHERE ... CREATE/DELETE ... RETURN node...
Cypher Update Query
Candidate Pattern Parallelisation Pattern
Pattern Mining
choose prototype formalise pattern formalise transformation create SDG generate execute Sequential Program Parallelised Program Resulting candidates: 1) 2) ... parallelise execute 1. 2. 3. 0. Evaluation 4.
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 31 / 37
Conclusion and Future Work
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 32 / 37
Conclusion and Future Work
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 33 / 37
Conclusion and Future Work
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 34 / 37
Conclusion and Future Work
Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 35 / 37
Conclusion and Future Work ✳✳✳ ✐♥t ♥Pr♦❝❡ss♦rs ❂ P❛r❛❧❧❡❧✐s❛t✐♦♥❯t✐❧ ✳ ◆❯▼❇❊❘❴❖❋❴P❘❖❈❊❙❙❖❘❙ ❀ ❥❛✈❛✳✉t✐❧✳❝♦♥❝✉rr❡♥t✳ ❊①❡❝✉t♦r❙❡r✈✐❝❡ ♣♦♦❧ ❂ ❥❛✈❛✳✉t✐❧✳ ❝♦♥❝✉rr❡♥t✳❊①❡❝✉t♦rs ✳ ♥❡✇❋✐①❡❞❚❤r❡❛❞P♦♦❧ ✭♥Pr♦❝❡ss♦rs ✮❀ ❉❛t❛❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ❝❛❧❧❛❜❧❡✶ ❂ ♥❡✇ ❈♦♥♥❡❝t✐♦♥❙❡t✉♣ ✳ ❉❛t❛❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ✭❞❛t❛❙❈ ✮❀ ❥❛✈❛✳✉t✐❧✳❝♦♥❝✉rr❡♥t✳❋✉t✉r❡ ❁❄❃ ❢✉t✉r❡✶ ❂ ♣♦♦❧✳s✉❜♠✐t✭❝❛❧❧❛❜❧❡✶ ✮❀ ❊✈❡♥t❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ❝❛❧❧❛❜❧❡✷ ❂ ♥❡✇ ❈♦♥♥❡❝t✐♦♥❙❡t✉♣ ✳ ❊✈❡♥t❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ✭❡✈❡♥t❙❈ ✮❀ ❥❛✈❛✳✉t✐❧✳❝♦♥❝✉rr❡♥t✳❋✉t✉r❡ ❁❄❃ ❢✉t✉r❡✷ ❂ ♣♦♦❧✳s✉❜♠✐t✭❝❛❧❧❛❜❧❡✷ ✮❀ tr② ④ ❢✉t✉r❡✶✳❣❡t ✭✮❀ ❢✉t✉r❡✷✳❣❡t ✭✮❀ ⑥ ❝❛t❝❤ ✭ ■♥t❡rr✉♣t❡❞❊①❝❡♣t✐♦♥ ❡✮ ④ ⑥ ❝❛t❝❤ ✭❥❛✈❛✳✉t✐❧✳❝♦♥❝✉rr❡♥t✳ ❊①❡❝✉t✐♦♥❊①❝❡♣t✐♦♥ ❡✮ ④ ❚❤r♦✇❛❜❧❡ ❝❛✉s❡ ❂ ❡✳❣❡t❈❛✉s❡ ✭✮❀ ✐❢ ✭❝❛✉s❡ ✐♥st❛♥❝❡♦❢ ❊rr♦r✮ ④ t❤r♦✇ ✭❊rr♦r✮ ❝❛✉s❡❀ ⑥ ✐❢ ✭❝❛✉s❡ ✐♥st❛♥❝❡♦❢ ❘✉♥t✐♠❡❊①❝❡♣t✐♦♥ ✮ ④ t❤r♦✇ ✭ ❘✉♥t✐♠❡❊①❝❡♣t✐♦♥ ✮ ❝❛✉s❡❀ ⑥ ⑥ ♣♦♦❧✳s❤✉t❞♦✇♥ ✭✮❀ ✳✳✳ Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 36 / 37
Conclusion and Future Work ♣r✐✈❛t❡ st❛t✐❝ ❝❧❛ss ❉❛t❛❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ✐♠♣❧❡♠❡♥ts ❈❛❧❧❛❜❧❡ ❁❱♦✐❞ ❃ ④ ♣r✐✈❛t❡ ■❉❛t❛❙❡r✈❡r❈♦♥♥❡❝t✐♦♥ ❞❛t❛❙❈❀ ♣✉❜❧✐❝ ❉❛t❛❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ✭ ■❉❛t❛❙❡r✈❡r❈♦♥♥❡❝t✐♦♥ ❞❛t❛❙❈✮ ④ s✉♣❡r ✭✮❀ t❤✐s✳❞❛t❛❙❈ ❂ ❞❛t❛❙❈❀ ⑥ ❅❖✈❡rr✐❞❡ ♣✉❜❧✐❝ ❱♦✐❞ ❝❛❧❧ ✭✮ t❤r♦✇s ❊①❝❡♣t✐♦♥ ④ ❞❛t❛❙❈✳❝♦♥♥❡❝t ✭✮❀ r❡t✉r♥ ♥✉❧❧❀ ⑥ ⑥ ♣r✐✈❛t❡ st❛t✐❝ ❝❧❛ss ❊✈❡♥t❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ✐♠♣❧❡♠❡♥ts ❈❛❧❧❛❜❧❡ ❁❱♦✐❞ ❃ ④ ♣r✐✈❛t❡ ■❊✈❡♥t❙❡r✈❡r❈♦♥♥❡❝t✐♦♥ ❡✈❡♥t❙❈❀ ♣✉❜❧✐❝ ❊✈❡♥t❙❈❈♦♥♥❡❝t❈❛❧❧❛❜❧❡ ✭ ■❊✈❡♥t❙❡r✈❡r❈♦♥♥❡❝t✐♦♥ ❡✈❡♥t❙❈✮ ④ s✉♣❡r ✭✮❀ t❤✐s✳❡✈❡♥t❙❈ ❂ ❡✈❡♥t❙❈❀ ⑥ ❅❖✈❡rr✐❞❡ ♣✉❜❧✐❝ ❱♦✐❞ ❝❛❧❧ ✭✮ ④ ❡✈❡♥t❙❈✳❝♦♥♥❡❝t ✭✮❀ r❡t✉r♥ ♥✉❧❧❀ ⑥ ⑥ Johanna E. Krause Parallelise Software Systems using an SDG 27 January 2016 37 / 37