Docstoc

Impact Analysis - of Yury Chebiryak

Document Sample
Impact Analysis - of Yury Chebiryak Powered By Docstoc
					 University of Saarland
Department of Computer Science




  Impact Analysis




        Yury Chebiryak
  urriy@wjpserver.cs.uni-sb.de
Impact Analysis
   is often used to assess the effects of a
    change after change has been made


   is rarely used to predict the effect of
    change before it is instantiated




                                               2/96
Techniques

                  Impact
                  Analysis



     Dependency              Traceability
      Analysis                Analysis




                                            3/96
Dependency-based IA
                  Dependency
                   Analysis




    Program Slicing        Call Graph



   Static    Dynamic



                                        4/96
Whole Program Path-Based
 Dynamic Impact Analysis



         James Law
       Gregg Rothermel
PathImpact
   Dynamic
   Call-based
   Works on binaries
   Relatively low cost
   Relatively low overhead




                              6/96
Call Graph

             A       D


      M          C       E


             B       F


                 G

                             7/96
Call Graph

               A       D


           M       C       E


               B       F


B is changed       G

                               8/96
Call Graph

                      A       D


            M             C       E

   Assumption:
 change in B has a
                      B       F
potential impact on
  nodes reachable
      from B              G

                                      9/96
Execution Traces (ET)
 Run M()
               A        D


           M       C        E


               B        F
 ET: M

                   G

                                10/96
Execution Traces
 Run B()
               A       D


           M       C       E


               B       F
 ET: MB

                   G

                               11/96
Execution Traces
 Return
               A       D


           M       C       E


               B       F
 ET: MBr

                   G

                               12/96
Execution Traces
 Run A()
                A       D


            M       C       E


                B       F
 ET: MBrA

                    G

                                13/96
Execution Traces
 Run C()
               A       D


           M       C       E


               B       F
 ET: MBrAC

                   G

                               14/96
Execution Traces
 Run D()
               A       D


           M       C       E


               B       F
 ET: MBrACD

                   G

                               15/96
Execution Traces
 Return
               A       D


          M        C       E


               B       F
 ET: MBrACDr

                   G

                               16/96
Execution Traces
 Run E()
                A       D


           M        C       E


                B       F
 ET: MBrACDrE

                    G

                                17/96
Execution Traces
 Return
                 A       D


          M          C       E


                 B       F
 ET: MBrACDrEr

                     G

                                 18/96
Execution Traces
 Return
                  A       D


          M           C       E


                  B       F
 ET: MBrACDrErr

                      G

                                  19/96
Execution Traces
 Return
                   A       D


          M            C       E


                   B       F
 ET: MBrACDrErrr

                       G

                                   20/96
Execution Traces
 Return
                     A       D


          M              C       E


                     B       F
 ET: MBrACDrErrrrx

                         G

                                     21/96
Execution Traces II
   Single
                  MBrACDrErrrrx
   Multiple
         MBrACDrErrrrxMBGrrrrxMBCFrrrrx
Programs with loops => very long trace




                                          22/96
SEQUITUR algorithm
Data compression algorithm by Larus:
 Online

 Created grammar reproduces trace exactly

 O(N) running time

 O(N) size in the worst case

 O(log N) size in the best case

 e.g. 2GB trace → 100 MB




                                             23/96
SEQUITUR algorithm
algorithm SEQUITUR( S )
input Execution Trace S
output Grammar G
Grammar G
Rule T
1. for each token in S
2. append token to end of production for T
3. if duplicate digram appears
4.   if other occurrence is a rule g in G
5.     replace new digram with non-terminal of g.
6.   else
7.     form a new rule and replace duplicate
8.     digrams with the new non-terminal.
9. if any rule in G is used only once
10. remove the rule by substituting the production.
11. return G



                                                      24/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx




                                     25/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T → MBrACDrErrrrx




                                     26/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T → MBrACDrE 1 1 x
 1 → rr




                                     27/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T → MBrACDrE11x
 1 → rr




                                     28/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T → MBrACDrE11xM
 1 → rr




                                     29/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T → MBrACDrE11x MB
 1 → rr




                                     30/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T → 2 rACDrE11x 2
 1 → rr
 2 → MB




                                     31/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T → 2rACDrE11x2
 1 → rr
 2 → MB




                                     32/96
SEQUITUR: example
ET: MBrACDrErrrrxMBGrrrrxMBCFrrrrx
 T   →   2rACDrE113G43CF4rx
 1   →   rr
 2   →   MB
 3   →   x2
 4   →   1r

           grammar => whole path DAG



                                       33/96
Whole path DAG

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2       4  1 r




M      A      B     C       D   E    F    G      r      x




                                                        34/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B              3 x 2       4  1 r


                                UP()




M      A      B     C       D          E    F    G      r      x




                                                               35/96
PathImpact
              BACKWARD()                    FORWARD()           X




       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r        2  M B              3 x 2             4  1 r
                                 UP()




M      A      B       C      D          E      F        G      r      x



                                                                      36/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B     C       D   E        F      G      r      x


PathImpact(E): I {E}               Returns=0        I = {}



                                                              37/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B      C      D   E        F      G      r       x


PathImpact(E): up(T, E)             Returns=0        I = {E}



                                                               38/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B      C      D   E        F      G      r       x


PathImpact(E): forward(1)           Returns=0        I = {E}



                                                               39/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B      C      D   E        F      G      r       x


PathImpact(E): forward(r)           Returns=0        I = {E}



                                                               40/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B      C      D   E        F      G      r       x


PathImpact(E): Returns++            Returns=0        I = {E}



                                                               41/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B      C      D   E        F      G      r       x


PathImpact(E): forward(r)           Returns=1        I = {E}



                                                               42/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B      C      D   E        F      G      r       x


PathImpact(E): Returns++            Returns=1        I = {E}



                                                               43/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B         3 x 2             4  1 r




M      A      B      C      D     E        F      G      r       x


PathImpact(E): after forward(1)       Returns=4        I = {E}



                                                                 44/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B        3 x 2             4  1 r




M      A      B      C      D    E        F      G      r       x


PathImpact(E): forward(3) -> x       Returns=4        I = {E}



                                                                45/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B        3 x 2             4  1 r




M      A      B      C       D   E        F      G      r       x


PathImpact(E): backward(r)           Returns=4        I = {E}
                                     Skip=0

                                                                46/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B       3 x 2             4  1 r




M      A      B         C   D   E        F      G      r       x


PathImpact(E): Skip++               Returns=4        I = {E}
                                    Skip=0

                                                               47/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B            3 x 2             4  1 r




M      A      B      C      D        E        F      G      r       x


PathImpact(E): backward(D)->Skip--       Returns=4        I = {E}
                                         Skip=1

                                                                    48/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B          3 x 2             4  1 r




M      A      B      C         D   E        F      G      r       x


PathImpact(E): backward(C)->           Returns=4        I = {E}
               I := I U {C},           Skip=0
               Returns--
                                                                  49/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B          3 x 2             4  1 r




M      A      B      C         D   E        F      G      r      x


PathImpact(E): backward(A)->           Returns=3        I = {E, C}
               I := I U {A},           Skip=0
               Returns--
                                                                     50/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B            3 x 2             4  1 r




M      A      B      C      D        E        F      G      r      x


PathImpact(E): backward(r)->Skip++       Returns=2        I = {E, C, A}
                                         Skip=0

                                                                    51/96
PathImpact

       T  2 r A C D r E 1 1 3 G 4 3 C F 4 r x




    1  r r       2  M B          3 x 2             4  1 r




M      A      B      C      D      E        F      G      r      x


PathImpact(E): after backward(2)       Returns=1        I = {E, C, A, M}
                                       Skip=0

                                                                  52/96
   Chianti: A Tool for Change
Impact Analysis of Java Programs

          Ophelia Chesley
            Xiaoxia Ren
          Barbara G. Ryder
             Fenil Shah
             Frank Tip
Chianti: high-level concept
Inputs:
1) test suite T
2) original version of code
3) edited version of code




                              54/96
Chianti: high-level concept
1)   set of interdependent atomic changes A




                                              55/96
Chianti: high-level concept
1)   set of interdependent atomic changes A
2)   call graph for each test in T




                                              56/96
Chianti: high-level concept
1)   set of interdependent atomic changes A
2)   call graph for each test in T
3)   T´ T – potentially affected by cA




                                              57/96
Chianti: high-level concept
1)   set of interdependent atomic changes A
2)   call graph for each test in T
3)   T´ T – potentially affected by cA
4)   for tiT´ determine A´A that may have
     affected ti




                                              58/96
Chianti: high-level concept
1)     set of interdependent atomic changes A
2)     call graph for each test in T
3)     T´ T – potentially affected by cA
4)     for tiT´ determine A´A that may have
       affected ti

     determine subset of      isolate subset of
     methods affected by     changes that affect
       a set of changes          a given test

                                                   59/96
Chianti: architecture
                   Set of Unit Tests

       Original      Call Graph         Changed
      program P       Builder          program P’



                   Atomic Change
      Call Graph      Decoder          Call Graph
       of Tests                         of Tests
         in P         Atomic             in P’
                     Changes &
                    Dependencies


       Affected      CI analyzer       Affecting
        Tests                          Changes
                      CHIANTI

                                                    60/96
Chianti: architecture
                   Set of Unit Tests

      Original                         Changed
      program        Call Graph        program
         P            Builder             P’

                   Atomic Change
      Call Graph      Decoder          Call Graph
       of Tests                         of Tests
         in P         Atomic             in P’
                     Changes &
                    Dependencies


       Affected      CI analyzer       Affecting
        Tests                          Changes
                      CHIANTI

                                                    61/96
Chianti: architecture
                   Set of Unit Tests

       Original      Call Graph         Changed
      program P       Builder          program P’



                   Atomic Change
      Call Graph      Decoder          Call Graph
       of Tests                         of Tests
         in P         Atomic              in P’
                     Changes &
                    Dependencies


      Affected      CI analyzer        Affecting
       Tests          CHIANTI          Changes

                                                    62/96
Example: original version
class A{
  public A() {}
  public void foo (){}
}
class B extends A{
  public B(){}
  public void foo(){}
}
class C extends A{
  public C(){}
}


                            63/96
Example: changed version
class A{
  void foo (){}
  int x;
}
class B extends A{
  void foo(){ B.bar(); }
  static void bar(){ y=17; }
  static int y;
}
class C extends A{
  void foo(){ x=18; }
  int z;
}

                               64/96
Example: tests
class Tests {
  public static void test1(){
     A a = new A();
     a.foo();
  }
  public static void test2(){
     A a = new B();
     a.foo();
  }
  public static void test3(){
     A a = new C();
     a.foo();
  }
}
                                65/96
Review: Atomic Changes
Change   Description
AC       Add an empty class
DC       Delete an empty class
AM       Add an empty method
DM       Delete an empty method
CM       Change body of a method
LC       Change virtual method lookup
AF       Add a field
DF       Delete a field
                                        66/96
Review: Atomic Changes II
Change   Description
CFI      Change definition of an instance field initializer
CSFI     Change definition of a static field initializer
AI       Add an empty instance initializer
DI       Delete an empty instance initializer
CI       Change definition of an instance initializer
ASI      Add an empty static initializer
DSI      Delete an empty static initializer
CSI      Change definition of a static initializer

                                                           67/96
Example: Step 1
class A{
  void foo (){}
  int x;
}
class B extends A{
  void foo(){ B.bar(); }
  static void bar(){ y=17; }
  static int y;
}
class C extends A{
  void foo(){ x=18; }
  int z;
}
                               68/96
Example: Step 1
class A{                AM
  void foo (){}        B.bar()
  int x;
}
class B extends A{
  void foo(){ B.bar(); }          CM
  static void bar(){ y=17; }     B.foo()
  static int y;
}
class C extends A{
  void foo(){ x=18; }    AF       CM
  int z;                 B.y     B.bar()
}
                                       69/96
Example: Step 1
class A{                 AF         CM
  void foo (){}          A.x       C.foo()
  int x;
}
class B extends A{
  void foo(){ B.bar(); }
  static void bar(){ y=17; }
  static int y;
}
class C extends A{
  void foo(){ x=18; }   AM          LC
  int z;               C.foo()   C, A.foo()
}
                                         70/96
Example: Step 1
class A{
  void foo (){}
  int x;
}
class B extends A{
  void foo(){ B.bar(); }       AF
  static void bar(){ y=17; }   C.z
  static int y;
}
class C extends A{
  void foo(){ x=18; }
  int z;
}
                                     71/96
Example: atomic changes
        AM                  AF          CM
       B.bar()              A.x        C.foo()




                  CM
 AF              B.foo()
 C.z




        AF        CM        AM          LC
        B.y      B.bar()   C.foo()   C, A.foo()



                                                  72/96
Recall: high-level concept
1)   set of interdependent atomic changes A
2)   call graph for each test in T
3)   T´ T – potentially affected by cA
4)   for tiT´ determine A´A that may have
     affected ti




                                              73/96
Example: affected tests
A test is affected if its call graph contains:
1)  node that corresponds to CM or DM, or
2)  edge that corresponds to LC




                                                 74/96
Example: affected tests




                          75/96
Example: test1
                             <A, A.foo()>
          Tests.test1()



  A.A()                   A.foo()


                    void test1(){
                     A a = new A();
                     a.foo();}

                                            76/96
Example: test2
                             <B, A.foo()>
          Tests.test2()



                                             CM
  B.B()                   B.foo()           B.foo()



                    void test2(){
  A.A()              A a = new B();
                     a.foo();}

                                                      77/96
Example: test3
                             <C, A.foo()>      LC
          Tests.test3()                     C, A.foo()




  C.C()                   A.foo()


                    void test3(){
  A.A()              A a = new C();
                     a.foo();}

                                                     78/96
Recall: high-level concept
1)   set of interdependent atomic changes A
2)   call graph for each test in T
3)   T´ T – potentially affected by cA
4)   for tiT´ determine A´A that may have
     affected ti




                                              79/96
Example: affecting changes
The set of atomic changes that affect a given
   affected test includes:
1) all atomic changes for nodes with AM and CM,
2) atomic changes in LC category, and
3) their transitively prerequisite atomic changes




                                            80/96
Example: affecting changes




                             81/96
Example: AffectingChanges(test2)
                             <B, A.foo()>
          Tests.test2()



  B.B()                   B.foo()
                                             CM
                                            B.foo()

  A.A()                   B.bar()            CM
                                            B.bar()


                                                      82/96
Example: AffectingChanges(test2)
           AM
          B.bar()




                     CM
                    B.foo()




           AF        CM
           B.y      B.bar()



                               83/96
Example
Remember the atomic change:

                    AF
                    C.z



This atomic change does not affect any of the tests
=> additional tests are needed.


                                              84/96
Snapshot




           85/96
Chianti: Evaluation




  Number of atomic changes between each pair of Daikon versions.
                                                                   86/96
Chianti: Evaluation




        Categorization of the atomic changes.
                                                87/96
Chianti: Evaluation




   Percentage of affected tests for each of the Daikon versions.
                                                                   88/96
Chianti: Evaluation




   Average percentage of affecting changes, per affected test.
                                                                 89/96
Summary
PathImpact
  dynamic – uses dynamic traces
  online
  works on binaries
Chianti
  uses dynamic call graphs
  applicable for OOP (e.g. Java)
  determines affecting changes for every test

                                                 90/96
References
[1]   Chesley, O., Dolby, J., Ren, X., Ryder, B., Shah, F., and Tip, F. Chianti:
      A prototype change impact analysis tool for Java. Tech. Rep. DCS-TR-
      533, Rutgers University Department of Computer Science, September
      2003.

[2]   Chesley, O., Ren, X., Ryder, B., Shah, F., and Tip, F. Chianti: a tool for
      change impact analysis of java programs. In Proceedings of the 19th
      annual ACM SIGPLAN Conference on Object-oriented programming,
      systems, languages, and applications, pp. 432448.

[3]   Law, J., Rothermel, G. Whole program Path-Based dynamic impact
      analysis. In Proc. of the 25th International Conference on Software
      Engineering, May 03-10, 2003, Portland, Oregon.

[4]   Ryder, B., Tip, F. Change impact analysis for object-oriented programs.
      In Proceedings of the 2001 ACM SIGPLAN-SIGSOFT workshop on
      Program analysis for software tools and engineering, pp. 4653, June
      2001, Snowbird, Utah, United States.

                                                                             91/96
Thanks for listening.

    Questions?



                        92/96

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:11
posted:12/6/2012
language:Unknown
pages:92