averroes: letting go of the library!karim ali averroes: letting go of the library! partial-program...

Post on 10-Apr-2020

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Averroes: Letting go of the library!

Karim Ali

Workshop on WALA - PLDI ‘15 June 13th, 2015

Karim Ali Averroes: Letting go of the library! 2

public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!");}

}

Karim Ali Averroes: Letting go of the library!

• ~ 8 seconds

• ~ 600 MB of memory

• > 900 reachable methods

• > 1,700 call edges3

public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!");}

}

Karim Ali Averroes: Letting go of the library!

Hello, World!

4

Karim Ali Averroes: Letting go of the library!

Partial-Program Analysis

5

Karim Ali Averroes: Letting go of the library!

Partial-Program Analysis

6

I'd like to ignore library code

what about callbacks?

this would be unsound but better than nothing

ignore non-application program elements (e.g., system libraries)?

whole-program analysis always pulls in the world for completeness.

The problem is that the world is fairly large

I am NOT interested in those

Karim Ali Averroes: Letting go of the library!

Partial-Program Analysis

7

?

Karim Ali Averroes: Letting go of the library! 8

Ideal Call Graph

Karim Ali Averroes: Letting go of the library! 9

Ideal Call Graph

Whole-Program Call Graph

Karim Ali Averroes: Letting go of the library! 10

Ideal Call Graph

Whole-Program Call Graph

Incomplete Call Graph (unsound)

Karim Ali Averroes: Letting go of the library! 11

Ideal Call Graph

Whole-Program Call Graph

Incomplete Call Graph (unsound)

Conservative Call Graph

(highly imprecise)

Karim Ali Averroes: Letting go of the library! 12

Analyzed Code

?m(){ ...

}

c.center = new Point(0,0);

call method

create objectmodify field

Conservative Assumptions

Karim Ali Averroes: Letting go of the library!

Ideal Call Graph

Whole-Program Call Graph

Incomplete Call Graph (unsound)

Conservative Call Graph

(highly imprecise)

Partial-Program Call Graph

13

Karim Ali Averroes: Letting go of the library!

The Separate Compilation Assumption

14

Karim Ali Averroes: Letting go of the library!

The Separate Compilation Assumption

All of the library classes can be compiled in the absence of the application classes.

15

Karim Ali Averroes: Letting go of the library!

Constraints

1. Class Hierarchy

2. Class Instantiation

3. Local Variables

4. Method Calls

16

5. Field Access

6. Array Access

7. Static Initialization

8. Exception Handling

Karim Ali Averroes: Letting go of the library!

Constraints

1. Class Hierarchy

2. Class Instantiation

3. Local Variables

4. Method Calls

17

5. Field Access

6. Array Access

7. Static Initialization

8. Exception Handling

Karim Ali Averroes: Letting go of the library!

Library Points-to Set (LPT)

18

Application Library

pt(v1) = o1 o3

pt(v2) = o2 o3

pt(v3) = o1 o4

LPT =o1

o2 o3 o5

[Tip & Palsberg OOPSLA’00]

Karim Ali Averroes: Letting go of the library!

Library Callbacks

19

Application Library

class C { m(); }

class B extends L { m(); }

class A extends L { m(); } calls

class L { m(); }

1

LPT = A C

2

Karim Ali Averroes: Letting go of the library! 20

[K. Ali and O. Lhoták, ECOOP ’13]

Karim Ali Averroes: Letting go of the library!

JAR

Placeholder Library

SCA

JAR

21

Karim Ali Averroes: Letting go of the library! 22

REF

REF

Placeholder Library

SCA

REF

averroes.Library

Application

Karim Ali Averroes: Letting go of the library! 23

averroes.Library

Karim Ali Averroes: Letting go of the library! 24

public class averroes.Library {

public static Object libraryPointsTo;public static void doItAll() {// Class instantiation

// Library callbacks

// Field writes

// Array element writes

// Exception Handling}

}

Karim Ali Averroes: Letting go of the library!

Evaluated for SOOT and DOOP

✓ 300x smaller library!

✓ Up to 15x faster analysis

✓ Up to 8x less memory

✓ Precise

✓ Sound

25

Karim Ali Averroes: Letting go of the library!

Implementation Tweaks

26

Karim Ali Averroes: Letting go of the library!

Class Loaders in WALA

27

ClassLoaderReference.Extension

ClassLoaderReference.Primordial

ClassLoaderReference.Application

Karim Ali Averroes: Letting go of the library!

Problem 1: App.methods()

28

ClassLoaderReference.Extension

ClassLoaderReference.Primordial

ClassLoaderReference.Application

public class Library {

public static void doItAll() {// Class instantiationA a = new A();

// Library callbacksa.foo();

}}

Karim Ali Averroes: Letting go of the library!

Problem 1: App.methods()

29

ClassLoaderReference.Extension

ClassLoaderReference.Primordial

ClassLoaderReference.Application

public class Library {

public static void doItAll() {// Class instantiationA a = new A();

// Library callbacksa.foo();

}}

Karim Ali Averroes: Letting go of the library!

Solution 1: App.methods()

30

ClassLoaderReference.Extension

ClassLoaderReference.Primordial

ClassLoaderReference.Application

public class Library {

public static void doItAll() {// Class instantiationA a = new A();

// Library callbacksa.foo();

}}

Karim Ali Averroes: Letting go of the library!

Problem 2: doItAll()

31

ClassLoaderReference.Extension

ClassLoaderReference.Primordial

ClassLoaderReference.Application

public class Library {

public static void doItAll() {...

}}

public class PrintStream {

public void println(String s) {...

Library.doItAll();...

}}

Karim Ali Averroes: Letting go of the library!

Solution

32

Karim Ali Averroes: Letting go of the library! 33

public class AbstractLibrary {public static AbstractLibrary instance;public abstract void doItAll();

}

public class Library extends AbstractLibrary {static {

AbstractLibrary.instance = new Library();}

public void doItAll() {...A a = new A();

}}

public class PrintStream {public void println(String s) {

... AbstractLibrary.instance.doItAll();

...}

}

ClassLoaderReference.Primordial

ClassLoaderReference.Primordial

ClassLoaderReference.Application

Karim Ali Averroes: Letting go of the library! 34

public class AbstractLibrary {public static AbstractLibrary instance;public abstract void doItAll();

}

public class Library extends AbstractLibrary {static {

AbstractLibrary.instance = new Library();}

public void doItAll() {...A a = new A();

}}

public class PrintStream {public void println(String s) {

... AbstractLibrary.instance.doItAll();

...}

}

ClassLoaderReference.Primordial

ClassLoaderReference.Primordial

ClassLoaderReference.Application

Karim Ali Averroes: Letting go of the library!

public class AbstractLibrary {public static AbstractLibrary instance;public abstract void doItAll();

}

public class Library extends AbstractLibrary {static {

AbstractLibrary.instance = new Library();}

public void doItAll() {...A a = new A();

}}

public class PrintStream {public void println(String s) {

... AbstractLibrary.instance.doItAll();

...}

}

ClassLoaderReference.Primordial

ClassLoaderReference.Primordial

ClassLoaderReference.Application

35

Karim Ali Averroes: Letting go of the library!

Evaluation

36

Karim Ali Averroes: Letting go of the library!

Evaluation

• What are the performance gains of using the placeholder library?

• How precise is Averroes?

• Does using the placeholder library affect the soundness of WALA?

37

Karim Ali Averroes: Letting go of the library!

Library Size

38

SCA

Original Library ~ 25 MB

Placeholder Library ~ 80 KB

300xSMALLER

ON AVG

Karim Ali Averroes: Letting go of the library! 39

Execution Time

WALAOverhead WALAAVEAnalysis WALAAVE

OverheadWALAAnalysis AVERROES

Exec

utio

n Ti

me

(s)

0

5

10

15

20

25

30

antlr bloat chart hsqldb luindex lusearch pmd xalan compress db jack javac jess raytrace

2xFASTER

ON AVG

Karim Ali Averroes: Letting go of the library! 40

WALA WALAAVE

Memory UsageM

emor

y Us

age

(GB)

0.00.10.20.30.40.50.60.70.80.91.01.1

antlr bloat chart hsqldb luindex lusearch pmd xalan compress db jack javac jess raytrace

2xLESS

ON AVG

Karim Ali Averroes: Letting go of the library!

Precision of Averroes

41

Karim Ali Averroes: Letting go of the library!

|WALAAVE \ WALA| |WALA|

ANTLR 2.06%BLOAT 19.66%CHART 22.76%HSQLDB 32.56%LUINDEX 4.35%LUSEARCH 10.45%

PMD 7.78%XALAN 33,100.00%

COMPRESS 0.00%DB 7.04%JACK 3.63%JAVAC 1.21%JESS 8.70%

RAYTRACE 0.00%42

Precision of Averroes

8%ON AVG

Karim Ali Averroes: Letting go of the library! 43

Imprecise Library Callbacks

Application Library

JDBC Implementation

JDBC Interface

Client Code

WALAAVE \ WALA

HSQLDB org.hsqldb.jdbc.* 577 (70%)

Karim Ali Averroes: Letting go of the library!

Sound(i?)ness

44

Karim Ali Averroes: Letting go of the library! 45

Unsoundness w.r.t. Dynamic Call Graphs|DYNAMIC \ WALA|

|DYNAMIC||DYNAMIC \ WALAAVE|

|DYNAMIC|ANTLR - -BLOAT - -CHART 6% 6%HSQLDB 4% 4%LUINDEX 1% -LUSEARCH 1% -

PMD 3% -XALAN 99% -

COMPRESS - -DB - -

JACK - -JAVAC - -JESS - -

RAYTRACE - -

Karim Ali Averroes: Letting go of the library!

Reasons for Unsoundness

46

public void notifyListeners(Event event) { Object[] ls = this.listenerList.getListenerList(); for (int i = ls.length - 2; i >= 0; i -= 2) { if (ls[i] == Listener.class) { ((Listener)ls[(i + 1)]).changed(event); } } }

Karim Ali Averroes: Letting go of the library!

Correctness ProofBased on Featherweight Java

47

Karim Ali Averroes: Letting go of the library! 48

FJ…

m

m’

Karim Ali Averroes: Letting go of the library! 49

FJ FJAVE…

m

m’

m

m’

Karim Ali Averroes: Letting go of the library!

Evaluation Summary

✓ 300x smaller library!

✓ 2x faster

✓ 2x less memory

✓ Precise

✓ Sound

50

Karim Ali Averroes: Letting go of the library!

What’s Next?

51

Karim Ali Averroes: Letting go of the library!

Automatic Library Detection

What’s Next?Analyzing Large Frameworks

SCALACGSCA

DOOPSCA

Application Library

The Past The Future

Incremental JAR Generation

Better Reflection Support

Integration with WALA

52

Karim Ali Averroes: Letting go of the library!

Analyzing Large Frameworks

SCALACG

DOOP

The Future

53

• library is much larger than application • event-based systems => many callbacks • modeling application lifecycle is not trivial

Karim Ali Averroes: Letting go of the library!

Better Reflection Support

SCALACG

DOOP

The Future

54

better support for reflection

automatic library detection

incremental JAR generation

Karim Ali Averroes: Letting go of the library!

WALA Averroes Analysis Scope

WALA Analysis Scope

Integration with WALA

SCALACG

DOOP

The Future

55

Averroes: Letting go of the library! Karim Ali

Technische Universität Darmstadt karimali.ca

https://github.com/karimhamdanali/averroes

top related