Dynamic Fitness Functions for Genetic Improvement in Compilers and - - PowerPoint PPT Presentation

dynamic fitness functions for genetic improvement in
SMART_READER_LITE
LIVE PREVIEW

Dynamic Fitness Functions for Genetic Improvement in Compilers and - - PowerPoint PPT Presentation

Oliver Krauss MSc Dynamic Fitness Functions for Genetic Improvement in Compilers and Interpreters Kyoto 16.7.2018 Advisors: Prof. Dr. Dr. h.c. Hanspeter Mssenbck, Prof. (FH) Priv.-Doz. Dipl.-Ing. Dr. Michael Affenzeller Abstract Genetic


slide-1
SLIDE 1

Oliver Krauss MSc

Dynamic Fitness Functions for Genetic Improvement in Compilers and Interpreters

Kyoto 16.7.2018

Advisors: Prof. Dr. Dr. h.c. Hanspeter Mössenböck,

  • Prof. (FH) Priv.-Doz. Dipl.-Ing. Dr. Michael Affenzeller
slide-2
SLIDE 2

Abstract

Genetic Improvement on Interpreter / Compiler Abstract Syntax Tree (AST)

– Improve non-functional software features (performance) – Deal with large fitness landscapes – Dynamic fitness functions ... – split test suites by the complexity of the cases – Sequential or Parallel – ... don't perform well – ... show promise

Page 1 | 26

slide-3
SLIDE 3

Outline

Motivation Background Methodology - Analyze Testdata Methodology - Dynamic Evaluation Results Discussion & Outlook

Page 2 | 26

slide-4
SLIDE 4

Outline

Motivation Background Methodology - Analyze Testdata Methodology - Dynamic Evaluation Results Discussion & Outlook

Page 3 | 26

slide-5
SLIDE 5

Search Space Size

∗ ∗ ∗ ∗ ∗ ∗ ∗ depth width – n node types (MiniC -> 158) – depth 5, width 5

Page 4 | 26

slide-6
SLIDE 6

Search Space Size

∗ ∗ ∗ ∗ ∗ ∗ ∗ depth width – n node types (MiniC -> 158) – depth 5, width 5 – All Options -> n3901 – MiniC -> 466.638

Page 4 | 26

slide-7
SLIDE 7

Search Space Size

∗ ∗ ∗ ∗ ∗ ∗ ∗ depth width – n node types (MiniC -> 158) – depth 5, width 5 – All Options -> n3901 – MiniC -> 466.638 – depth 10, width 10

Page 4 | 26

slide-8
SLIDE 8

Search Space Size

∗ ∗ ∗ ∗ ∗ ∗ ∗ depth width – n node types (MiniC -> 158) – depth 5, width 5 – All Options -> n3901 – MiniC -> 466.638 – depth 10, width 10 – All Options -> n11.111.111.101 – MiniC -> 80.814.253.363

Page 4 | 26

slide-9
SLIDE 9

Outline

Motivation Background Methodology - Analyze Testdata Methodology - Dynamic Evaluation Results Discussion & Outlook

Page 5 | 26

slide-10
SLIDE 10

JIT Compilation with GI I

Code

void main () { int i, n, now , prev , next; prev = 0; now = 1; i = 0; n = 30; while (i < n){ if (i == 0 ) print (0); else if (i == 1) print (1); else { next = now + prev; prev = now; now = next; print(next); } i = i + 1; } }

GI

Truffle Graal Coco/R Optimize Compile

Figure: Code Interpretation and Compilation with GI (Truffle and Graal images from [1])

Page 6 | 26

slide-11
SLIDE 11

JIT Compilation with GI II

MiniC

– Subset of C11 [2] – Coco/R -> Creates Scanner & Parser in Java – 342 node classes (103 operators, 55 operands)

Page 7 | 26

slide-12
SLIDE 12

JIT Compilation with GI III

Truffle [3, 1]

– Interpreter based on AST – Generalized and Spezialized AST - Nodes – Self optimizing by AST-Rewriting – Can run any Guest Language on the JVM – Python, Ruby, JavaScript, ...

Page 8 | 26

slide-13
SLIDE 13

JIT Compilation with GI IV

Graal [4, 5, 6]

– Just-in-time (JIT) compiler – Agressive optimizations – Part of OpenJDK

Page 9 | 26

slide-14
SLIDE 14

JIT Compilation with GI V

AST from Coco/R Select subtree for Optimization Run in Truffle Collect Testdata

IN OUT 1 1 2 1 3 2 4 3 5 5

Create Stub GI Population Evaluate Population with Truffle Hand best solution to Truffle clone & build Profile

Get Testdata

clone AST

evaluate

cross & mutate after x Generations

Figure: GP Optimization in depth

Page 10 | 26

slide-15
SLIDE 15

Architectural Overview

Figure: The architecture of the optimization framework in combination with Truffle and Graal

Page 11 | 26

slide-16
SLIDE 16

Outline

Motivation Background Methodology - Analyze Testdata Methodology - Dynamic Evaluation Results Discussion & Outlook

Page 12 | 26

slide-17
SLIDE 17

Node Visitation

fib

{}

read

n

if

ret ret

||

==

n 1

==

n

n + fib

n 1

fib

n 2 Visited Previously Visited Spezialisation

Goal: visit all nodes – n = 0 [v=14,s=0]

Page 13 | 26

slide-18
SLIDE 18

Node Visitation

fib

{}

read

n

if

ret ret

||

==

n 1

==

n

n + fib

n 1

fib

n 2 Visited Previously Visited Spezialisation

Goal: visit all nodes – n = 0 [v=14,s=0] – n = 1 [v=11,s=0]

Page 13 | 26

slide-19
SLIDE 19

Node Visitation

fib

{}

read

n

if

ret ret

||

==

n 1

==

n

n + fib

n 1

fib

n 2 Visited Previously Visited Spezialisation

Goal: visit all nodes – n = 0 [v=14,s=0] – n = 1 [v=11,s=0] – n = 2 [v=23,s=6]

Page 13 | 26

slide-20
SLIDE 20

Test Metrics I

Correctness - Percentage of successful tests

correctness(AST,tests) = tests

n=1 succeeded(AST,test)

tests (1)

Complexity - Percentage of nodes visited by a test

complexity(AST,test) = nodes

n=1

visited(AST,test) nodes(AST) (2)

Page 14 | 26

slide-21
SLIDE 21

Test Metrics II

Overlap - Percentage of nodes visited by two tests

  • verlap(A,B) =

nodes

n=1

visited(A) ∩ visited(B) max(nodes

n=1

visited(A), nodes

n=1

visited(B)) (3)

Confidence - Percentage of nodes visited by test suite

confidence(testsuite,AST) = nodes

n=1

visited(testsuite) nodes(AST) (4)

Page 15 | 26

slide-22
SLIDE 22

Outline

Motivation Background Methodology - Analyze Testdata Methodology - Dynamic Evaluation Results Discussion & Outlook

Page 16 | 26

slide-23
SLIDE 23

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-24
SLIDE 24

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-25
SLIDE 25

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-26
SLIDE 26

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-27
SLIDE 27

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-28
SLIDE 28

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-29
SLIDE 29

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-30
SLIDE 30

Sequential Fitness Function

Figure: Sequential algorithm, iteratively increasing the amount of tests used by the genetic algorithm (GA) to verify ASTs

Page 17 | 26

slide-31
SLIDE 31

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-32
SLIDE 32

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-33
SLIDE 33

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-34
SLIDE 34

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-35
SLIDE 35

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-36
SLIDE 36

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-37
SLIDE 37

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-38
SLIDE 38

Parallel Fitness Function

Figure: Parallel algorithm, splitting a test suite into parts, and iteratively recombining them into bigger suites until the original suite is reached

Page 18 | 26

slide-39
SLIDE 39

Outline

Motivation Background Methodology - Analyze Testdata Methodology - Dynamic Evaluation Results Discussion & Outlook

Page 19 | 26

slide-40
SLIDE 40

Test SetUp

GA vs. Sequential FFN vs. Parallel FFN

– Same configuration for all – No grafting – Comparison of solved test cases Table: Use Case statistics Use Case

  • No. Nodes

Tests Nodes visited x*2 8 5 5, 5, 5, 5, 5 Sqrt 60 5 14, 42, 42, 42, 53 Fibonacci 32 5 11, 15, 30, 30, 30 Constructed 31 5 11, 15, 20, 20, 21

Page 20 | 26

slide-41
SLIDE 41

Results

UseCases

x*2 always solved, except Parallel FFN

Fitness Functions

Page 21 | 26

slide-42
SLIDE 42

Results

UseCases

x*2 always solved, except Parallel FFN Sqrt return 2

Fitness Functions

Page 21 | 26

slide-43
SLIDE 43

Results

UseCases

x*2 always solved, except Parallel FFN Sqrt return 2 Fibonacci only first 2 (Sequential FFN)

Fitness Functions

Page 21 | 26

slide-44
SLIDE 44

Results

UseCases

x*2 always solved, except Parallel FFN Sqrt return 2 Fibonacci only first 2 (Sequential FFN) Constructed 3 of 5 tests solved

Fitness Functions

Page 21 | 26

slide-45
SLIDE 45

Results

UseCases

x*2 always solved, except Parallel FFN Sqrt return 2 Fibonacci only first 2 (Sequential FFN) Constructed 3 of 5 tests solved

Fitness Functions

GA Baseline

Page 21 | 26

slide-46
SLIDE 46

Results

UseCases

x*2 always solved, except Parallel FFN Sqrt return 2 Fibonacci only first 2 (Sequential FFN) Constructed 3 of 5 tests solved

Fitness Functions

GA Baseline Sequential FFN Solved more tests

Page 21 | 26

slide-47
SLIDE 47

Results

UseCases

x*2 always solved, except Parallel FFN Sqrt return 2 Fibonacci only first 2 (Sequential FFN) Constructed 3 of 5 tests solved

Fitness Functions

GA Baseline Sequential FFN Solved more tests Parallel FFN Total failure

Page 21 | 26

slide-48
SLIDE 48

Outline

Motivation Background Methodology - Analyze Testdata Methodology - Dynamic Evaluation Results Discussion & Outlook

Page 22 | 26

slide-49
SLIDE 49

Discussion I

Concepts show promise

– Sequential FFN outperformed GA – Known why all solutions failed – Can be improved

Stuck in local optima

– Sequential - solutions dominate from previous – Additive mutator – Parallel - one previous repeat dominates – Merge crossover

Page 23 | 26

slide-50
SLIDE 50

Discussion II

Correctness measurement is binary 0|1

– Increase amount of tests – Switch correctness measure from 0|1 to 0..1

Search Space Size may be too big

– Use indicators from original AST – Operators / Operands – Types – Restrict size with loop/branch counting

Page 24 | 26

slide-51
SLIDE 51

Outlook

– Sequential FFN -> Age Layered Population Structure (ALPS) – Parallel FFN -> Island GA – Implement Mutator & Crossover Operators – Update FFN to also include hot path – Your Suggestion Here

Page 25 | 26

slide-52
SLIDE 52

Contact

Oliver Krauss

  • liver.krauss@fh-

hagenberg.at +43 (0)50804-27195

Page 26 | 26

slide-53
SLIDE 53

Bibliography I

[1]

  • T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer,
  • G. Richards, D. Simon, and M. Wolczko, “One vm to rule them all”, in

Proceedings of the 2013 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software, ser. Onward! 2013, Indianapolis, Indiana, USA: ACM, 2013, pp. 187–204. [Online]. Available: http://doi.acm.org/10.1145/2509578.2509581. [2] ISO, ISO/IEC 9899:2011 Information technology — Programming languages — C. Geneva, Switzerland: International Organization for Standardization,

  • Dec. 2011, 683 (est.) [Online]. Available: http://www.iso.org/iso/iso_

catalogue/catalogue_tc/catalogue_detail.htm?csnumber=57853.

Page 1 | 7

slide-54
SLIDE 54

Bibliography II

[3]

  • C. Wimmer and T. Würthinger, “Truffle: A self-optimizing runtime system”,

in Proceedings of the 3rd Annual Conference on Systems, Programming, and Applications: Software for Humanity, ser. SPLASH ’12, Tucson, Arizona, USA: ACM, 2012, pp. 13–14. [Online]. Available: http://doi.acm.org/10.1145/2384716.2384723. [4]

  • OpenJDK. (2018), Graal project, Last Accessed - 2018-04-23, [Online].

Available: http://openjdk.java.net/projects/graal/. [5]

  • D. Simon, C. Wimmer, B. Urban, G. Duboscq, L. Stadler, and T. Würthinger,

“Snippets: Taking the high road to a low level”, ACM Trans. Archit. Code Optim., vol. 12, no. 2, 20:20:1–20:20:25, Jun. 2015. [Online]. Available: http://doi.acm.org/10.1145/2764907.

Page 2 | 7

slide-55
SLIDE 55

Bibliography III

[6]

  • L. Stadler, G. Duboscq, H. Mössenböck, and T. Würthinger, “Compilation

queuing and graph caching for dynamic compilers”, in Proceedings of the Sixth ACM Workshop on Virtual Machines and Intermediate Languages,

  • ser. VMIL ’12, Tucson, Arizona, USA: ACM, 2012, pp. 49–58. [Online].

Available: http://doi.acm.org/10.1145/2414740.2414750. [7]

  • R. Olsen and B. Ostman, Using fitness landscapes to visualize evolution in

action, https://www.youtube.com/watch?v=4pdiAneMMhU, [Last Accessed 14.07.2018], 2014.

Page 3 | 7

slide-56
SLIDE 56

Appendix A - Run Configuration

Crossover A single point crossover was selected Mutator A single point mutator was selected. The point to be mutated is selected randomly by the mutator. Mutation Probability was set to 57% Selector crossover and mutator use a tournament selection PopulationSize was set to 200 individuals Generations each run was 20 generations. GA, and the sequential FFN took 80 generations over 4 restarts. Parallel FFN took 60 generations initially and 20 generations after restart = 80 generations. Elitism per generation the 3 best individuals were preserved Restart-Elitism 10 best individuals. Parallel FFN had 30 individuals carried over (10 from each group). Operators and Operands all AST nodes of the MiniC language were selected as operators and operands for each test case.

Page 4 | 7

slide-57
SLIDE 57

Appendix B - Constructed Use Case

Listing 1: Constructed Use Case

int constructed(int n) { if (n == 0) { return 1; } if (n == 1) { return 2; } if (n == 2) { return n + 1; } return n * n; }

Page 5 | 7

slide-58
SLIDE 58

Appendix C - Threats to Validity

Performance Measurements - Graal Specific

– Runs in same JVM influence each following run – 200.000 runs for measurement due to warm up phase

Page 6 | 7

slide-59
SLIDE 59

Appendix D - Fitness Landscape Vi- sualization

Figure: Regular Static Fitness Landscape [7] Figure: Test-based Fitness Landscape

Page 7 | 7