wise automated test generation for worst case complexity
play

WISE: Automated Test Generation for Worst-Case Complexity Jacob - PowerPoint PPT Presentation

WISE: Automated Test Generation for Worst-Case Complexity Jacob Burnim Sudeep Juvekar Koushik Sen Performance-Directed Testing Automated tested has focused on correctness bugs. Goal: Apply to software performance. Find performance


  1. WISE: Automated Test Generation for Worst-Case Complexity Jacob Burnim Sudeep Juvekar Koushik Sen

  2. Performance-Directed Testing  Automated tested has focused on correctness bugs.  Goal: Apply to software performance.  Find performance bottlenecks.  Security: Algorithmic denial-of-service.  Today: Computational complexity testing.  How slow is an operation in the worst case?  Does a function meet its algorithmic complexity spec?

  3. Performance-Directed Testing  Example: Performance bug in Jar  Reported by Sun on May 15, 2009  update method O(N 2 ) instead of O(N)  O(N) look-up on every file, rather than O(1)  wasted 75% of run-time building rt.jar

  4. Goal of WISE  W orst-case I nputs from S ymbolic E xecution Input Size: N // insertion sort InsertionSort() for(i = 0 .. N-1) for(j = i .. 1) if (A[j] < A[j-1]) Input Size: N swap(A[j], A[j-1]) else break

  5. Goal of WISE  W orst-case I nputs from S ymbolic E xecution Input Output Size: N 1: 1 // insertion sort InsertionSort() 2: 2 1 for(i = 0 .. N-1) WISE for(j = i .. 1) 3: 3 2 1 if (A[j] < A[j-1]) Input Size: N … swap(A[j], A[j-1]) N: N … else 2 1 break

  6. Worst-Cast Empirical Complexity 300 # Basic Blocks 5 4 3 2 1 200 100 0 0 3 Input Size 6 9 12 15

  7. Worst-Cast Empirical Complexity 300 10 9 … 2 1 # Basic Blocks 200 100 0 0 3 Input Size 6 9 12 15

  8. Worst-Cast Empirical Complexity 300 15 14 … 2 1 # Basic Blocks 200 100 0 0 3 Input Size 6 9 12 15

  9. Worst-Cast Empirical Complexity 300 # Basic Blocks N 2 + N - 1 200 basic blocks. 100 0 0 3 Input Size 6 9 12 15

  10. Overview of WISE  Uses symbolic test generation to explore possible program executions.  Widely used in automated software testing. (DART, CUTE, SAGE, EXE, KLEE, JPF, …)  Key Idea: Learn from executions on small inputs.  In Quicksort, pivot should be smaller than all elements to which it’s compared.

  11. Outline  Motivation + Goal of WISE  Background: Symbolic Test Generation  Naïve Algorithm for Finding Complexity  WISE Algorithm  Evaluation  Conclusions + Future Work

  12. Symbolic Test Generation  Goal: A test input for every program path. 2*y == x f(int x, int y) F T { z = 2*x; x > y + 8 if (z == x) F T if (x > y + 8) print(“Hi”) Computation Tree }

  13. Symbolic Test Generation  Depth-first search of computation tree. 2*y == x f(int x, int y) F T { z = 2*x; x > y + 8 if (z == x) F T if (x > y + 8) print(“Hi”) Computation Tree }

  14. Symbolic Test Generation  Depth-first search of computation tree. 2*y == x 2*y == x f(int x, int y) F T { z = 2*x; x > y + 8 x > y + 8 if (z == x) F T if (x > y + 8) print(“Hi”) Φ ( path ): 2y ≠ x } Input: x = 0, y = 1

  15. Symbolic Test Generation  Depth-first search of computation tree. 2*y == x 2*y == x f(int x, int y) F T { z = 2*x; x > y + 8 x > y + 8 if (z == x) F T if (x > y + 8) print(“Hi”) Φ ( path ): 2y = x ∧ x ≤ y+8 } Input: x = 1, y = 2

  16. Symbolic Test Generation  Depth-first search of computation tree. 2*y == x 2*y == x f(int x, int y) F T { z = 2*x; x > y + 8 x > y + 8 if (z == x) F T if (x > y + 8) print(“Hi”) Φ ( path ): 2y = x ∧ x > y+8 } Input: x = -10, y = -20

  17. Symbolic Test Generation  Depth-first search of computation tree. 2*y == x 2*y == x f(int x, int y) F T { z = 2*x; x > y + 8 x > y + 8 if (z == x) F T if (x > y + 8) print(“Hi”) Φ ( path ): 2y = x ∧ x > y+8 } Input: x = -10, y = -20

  18. Outline  Motivation + Goal of WISE  Background: Symbolic Test Generation  Naïve Algorithm for Finding Complexity  WISE Algorithm  Evaluation  Conclusions + Future Work

  19. Symbolic Execution for Complexity  Naïve Algorithm:  Generate every execution on N inputs.  Return input for longest execution.

  20. Symbolic Execution for Complexity  Naïve Algorithm: F N=2: F T F

  21. Symbolic Execution for Complexity  Naïve Algorithm: F N=2: F T F Longest Execution (4 basic blocks)

  22. Symbolic Execution for Complexity  Naïve Algorithm: F N=2: F T F Worst-case Input: 2 1

  23. Symbolic Execution for Complexity  Naïve Algorithm: F N=3: F T T F F T F T F F T F F

  24. Symbolic Execution for Complexity  Naïve Algorithm: F N=3: F T T F F T F T F F T F Longest Execution F (7 basic blocks)

  25. Symbolic Execution for Complexity  Naïve Algorithm: F N=3: F T T F F T F T F F T F Worst-Case Input: F 3 2 1

  26. Symbolic Execution for Complexity  Naïve Algorithm: F N=3: F T T F F T F T F F T F Worst-Case Input: F 3 2 1

  27. Path Space Explosion  Naïve algorithm does not scale. N=15:  1.6 × 10 25 paths  Longest has only 121 basic blocks

  28. Path Space Explosion  Naïve algorithm does not scale. N=15:  1.6 × 10 25 paths  Longest has only 121 basic blocks

  29. Outline  Motivation + Goal of WISE  Background: Symbolic Test Generation  Naïve Algorithm for Finding Complexity  WISE Algorithm  Evaluation  Conclusions + Future Work

  30. Overview of WISE  Step 1 : From executions on small inputs, learn oracle for longest paths.

  31. Overview of WISE  Step 1 : From executions on small inputs, learn oracle for longest paths. F F F T F N=1 N=2 N=3

  32. Overview of WISE  Step 1 : From executions on small inputs, learn oracle for longest paths. F F F T F N=1 N=2 N=3

  33. Overview of WISE  Step 1 : From executions on small inputs, learn oracle for longest paths. F F F T F N=1 N=2 N=3  Step 2 : For large inputs, only examine paths generated by oracle.

  34. Overview of WISE  Step 1 : From executions on small inputs, learn oracle for longest paths. F F F T F N=1 N=2 N=3  Step 2 : For large inputs, only examine paths generated by oracle. N=15

  35. Overview of WISE  Step 1 : From executions on small inputs, learn oracle for longest paths. F F F T F N=1 N=2 N=3  Step 2 : For large inputs, only examine paths generated by oracle. N=15

  36. Overview of WISE  Step 1 : From executions on small inputs, learn oracle for longest paths. F F F T F N=1 N=2 N=3  Step 2 : For large inputs, only examine paths generated by oracle. N=15

  37. Oracles for Longest Paths  Goal : Prune search of computation tree. F T F F F T T F T F T F F F

  38. Oracles for Longest Paths  Goal : Prune search of computation tree. F T F F F T T F T F T F F F

  39. Branch Policy Oracles  Classify each conditional in P:  Free: Must explore true or false branch.  Biased: When feasible, only explore true (resp. false) branch.

  40. Branch Policy Oracles  Each conditional in P classified as: Free: Biased: F T F

  41. Branch Policy Oracles  Each conditional in P classified as: Free: Biased: F T F

  42. Branch Policy Oracles  Each conditional in P classified as: Free: Biased (true): F T F T F F

  43. Branch Policy Oracles  Each conditional in P classified as: Free: Biased (true): F T F T F F

  44. Example: Searching w/ Branch Policy  N insertions into empty sorted list: // list with sentinel INT_MAX insert(list* p, int x) { while (x > p->data) { p = p->next; } p->next = new list(p->data, 
 p->next); p->data = x; }

  45. Example: Searching w/ Branch Policy  N insertions into empty sorted list: // list with sentinel INT_MAX insert(list* p, int x) { while (x > p->data) { Biased to p = p->next; true branch. } p->next = new list(p->data, 
 p->next); p->data = x; }

  46. Example: Searching w/ Branch Policy sorted list: F ∞  T F F insert(list, x 1 ); insert(list, x 2 ); T T F F insert(list, x 3 ); T T F F F F

  47. x 1 > ∞ Example: Searching w/ Branch Policy sorted list: F ∞  T F F p:  x: x 1 T T F F T T F F while (x > p->data) { p = p->next; F F }

  48. Example: Searching w/ Branch Policy x 2 > x 1 sorted list: F x 1  ∞  T F F p:  x: x 2 T T F F T T F F while (x > p->data) { p = p->next; F F }

  49. Example: Searching w/ Branch Policy sorted list: F x 2 > ∞ x 1  ∞  T F F p:  x: x 2 T T F F T T F F while (x > p->data) { p = p->next; F F }

  50. Example: Searching w/ Branch Policy sorted list: F x 1  x 2  ∞  T F x 3 > x 1 F p:  x: x 3 T T F F T T F F while (x > p->data) { p = p->next; F F }

  51. Example: Searching w/ Branch Policy sorted list: F x 1  x 2  ∞  T F F p:  x: x 3 T T F F x 3 > x 2 T T F F while (x > p->data) { p = p->next; F F }

  52. Example: Searching w/ Branch Policy sorted list: F x 1  x 2  ∞  T F F p:  x: x 3 T T F F T T F F while (x > p->data) { p = p->next; x 3 > ∞ F F }

  53. Example: Searching w/ Branch Policy F T F F T T F F T T F F F F

  54. Example: Searching w/ Branch Policy F T F F T T F F T T F F F F

Recommend


More recommend