On Formal Analysis of OO Languages using Rewriting Logic: Designing - - PowerPoint PPT Presentation

on formal analysis of oo languages using rewriting logic
SMART_READER_LITE
LIVE PREVIEW

On Formal Analysis of OO Languages using Rewriting Logic: Designing - - PowerPoint PPT Presentation

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion On Formal Analysis of OO Languages using Rewriting Logic: Designing for Performance Mark Hills and Grigore Ro su { mhills,


slide-1
SLIDE 1

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

On Formal Analysis of OO Languages using Rewriting Logic: Designing for Performance

Mark Hills and Grigore Ro¸ su {mhills, grosu}@cs.uiuc.edu

Department of Computer Science University of Illinois at Urbana-Champaign

6 June 2007

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-2
SLIDE 2

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

1

Rewriting Logic Semantics and KOOL

2

Analysis in KOOL with Rewriting Logic

3

Improving Performance

4

Conclusion

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-3
SLIDE 3

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Outline

1

Rewriting Logic Semantics and KOOL

2

Analysis in KOOL with Rewriting Logic

3

Improving Performance

4

Conclusion

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-4
SLIDE 4

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

The KOOL Language

KOOL is

  • bject-oriented: classes, methods, dynamic dispatch,

exceptions; all values objects dynamic: dynamically typed, adding extensions for modifying code at runtime concurrent: multiple threads of execution, shared memory, locks acquired on objects extensible, with various features “plugged in”: synchronized methods, semaphores, reflective capabilities

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-5
SLIDE 5

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Design Motivations for KOOL

Experiment with optional and pluggable type systems Investigate interaction of language features with verification and analysis Create a language suitable for languages courses, without some “confusing” features from other languages

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-6
SLIDE 6

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

A Sample KOOL Program

1 class Factorial is 2

method Fact(n) is

3

if n = 0 then

4

return 1;

5

else

6

return n * self.Fact(n-1);

7

fi

8

end

9 end 10 11 console << (new Factorial).Fact(200) Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-7
SLIDE 7

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Rewriting Logic Semantics of Programming Languages

Rewriting logic is an extension of equational logic with support for concurrency Language semantics provides formal definitions of language features Rewriting logic semantics: formal language definitions using rewriting logic Definitions are executable with rewriting logic engines, like Maude

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-8
SLIDE 8

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

The Rewriting Logic Semantics Project

KOOL is part of ongoing work on rewriting logic semantics Other work includes many languages and supporting tools, researchers at multiple universities Java, Beta, Scheme, Prolog, Haskell, PLAN, BC, CCS, MSR, ABEL, SILF, FUN, π-calculus, variants of λ-calculus, others

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-9
SLIDE 9

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

KOOL Program States

States in KOOL represented as multisets of state components Multisets formed by putting components next to one another

  • p

: KState KState -> KState [assoc comm id: empty]

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-10
SLIDE 10

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

KOOL Program States

State StringList Control Environment StringList Store ClassSet MethodStack ExceptionStack LoopStack Continuation Object Name cset mem

  • utput

input k mstack estack lstack Nat nextloc Thread env control cobj cclass t LockSet LockTupleSet busy holds Name Nat lbl tid Nat nextTid

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-11
SLIDE 11

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

KOOL Program States: A Simple Term

1

stmt(if E then S else S’ fi)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-12
SLIDE 12

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

KOOL Program States: A More Complex Term

1

t(control(k(llookup(L) -> K) CS) TS) mem(Mem)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-13
SLIDE 13

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Sample KOOL Semantics

Equations represent non-competing transitions, and have the general form eq l = r (unconditional) or ceq l = r if c (conditional):

1

eq stmt(if E then S else S’ fi) = exp(E) -> if(S,S’) .

2

eq val(primBool(true)) -> if(S,S’) = stmt(S) .

3

eq val(primBool(false)) -> if(S,S’) = stmt(S’) .

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-14
SLIDE 14

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Sample KOOL Semantics

Equations represent non-competing transitions, and have the general form eq l = r (unconditional) or ceq l = r if c (conditional):

1

eq stmt(if E then S else S’ fi) = exp(E) -> if(S,S’) .

2

eq val(primBool(true)) -> if(S,S’) = stmt(S) .

3

eq val(primBool(false)) -> if(S,S’) = stmt(S’) .

Rules represent transitions which may compete, and have the general form rl l => r (unconditional) or crl l => r if c (conditional):

1

crl t(control(k(llookup(L) -> K) CS) TS) mem(Mem) =>

2

t(control(k(val(V) -> K) CS) TS) mem(Mem)

3

if V := Mem[L] /\ V =/= undefined .

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-15
SLIDE 15

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Running KOOL Programs

Programs parsed, converted to Maude, and executed, with results displayed to user KOOL programs execute directly in the language semantics, defined using rewriting logic Stats: 335 equations in semantics, 15 rules, 1406 lines No type checker; violations (message not understood, wrong number of arguments, etc) handled at runtime with exceptions

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-16
SLIDE 16

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Outline

1

Rewriting Logic Semantics and KOOL

2

Analysis in KOOL with Rewriting Logic

3

Improving Performance

4

Conclusion

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-17
SLIDE 17

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Analysis Overview

KOOL uses analysis capabilities of Maude to provide program analysis: Search allows a breadth-first search over the program state space Model Checking allows verification of finite-state systems using LTL formulae Rewriting logic rules determine size of state space/transitions between states

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-18
SLIDE 18

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Breadth-First Search

KOOL provides breadth-first search over output values “out-of-the-box” Can either find all output values or search for a specific value

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-19
SLIDE 19

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Search Example: Output Interleavings

1

class Main is

2

var p1, p2;

3 4

method Test(id) is

5

console << "ID is " << id;

6

end

7 8

method Run is

9

spawn(self.Test(1));

10

spawn(self.Test(2));

11

console << "Done";

12

end

13

end

14 15

(new Main).Run

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-20
SLIDE 20

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Output Interleavings Results

1

> runkool -s Spawn5.kool

2 3

Solution 1 (state 16)

4

states: 38 rewrites: 8325 in 464ms cpu (471ms real) (17940

5

rewrites/second)

6

SL:[StringList] --> "Done"

7 8

...

9 10

Solution 13 (state 455)

11

states: 456 rewrites: 70193 in 4944ms cpu (4994ms real) (14196

12

rewrites/second)

13

SL:[StringList] --> "ID is ","2","ID is ","1","Done"

14 15

No more solutions.

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-21
SLIDE 21

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Search Example: The Thread Game

KOOL version of a problem formulated by J. Moore

1

class ThreadGame is

2

var x;

3 4

method ThreadGame is

5

x <- 1;

6

end

7 8

method Add is

9

while true do x <- x + x; od

10

end

11 12

method Run is

13

spawn(self.Add); spawn(self.Add);

14

console << x;

15

end

16

end

17

(new ThreadGame).Run

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-22
SLIDE 22

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Thread Game Results

1

> runkool -t 5 ThreadGame.kool

2 3

Solution 1 (state 769)

4

SL:[StringList] --> "5"

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-23
SLIDE 23

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Model Checking

KOOL uses Maude to provide basic model checking capabilities Extended with labeled statements; labels can be used in LTL formulae Runtime allows custom Maude modules with new LTL properties to be loaded and used during verification

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-24
SLIDE 24

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Dining Philosophers

1

class Philosopher is

2

method Run(id,left,right) is

3

while true do

4

// thinking here...

5

hungry:

6

acquire left;

7

acquire right;

8

eating:

9

release left;

10

release right;

11

  • d

12

end

13

end

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-25
SLIDE 25

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Model Checking the Dining Philosophers

1

> runkool DP.kool -m ... model checking arguments ...

Model checking arguments generally include formula to check When formula doesn’t hold, a counterexample is generated When formula holds, true is returned

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-26
SLIDE 26

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

A Problem Arises

Analysis is slow, we quickly hit maximum problem size. Ph’s No Optimizations Counterex DeadFree 2 0.830 1.530 3 0.912 34.924 4 1.466 1226.323 5 6.465 NA 6 66.683 NA 7 805.278 NA 8 NA NA

Figure: Dining Philosophers Model Checking Performance

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-27
SLIDE 27

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

A Problem Arises

But why? In KOOL, all operations are message sends, even addition

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-28
SLIDE 28

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

A Problem Arises

But why? In KOOL, all operations are message sends, even addition All operations will require memory lookups, since even numbers are objects

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-29
SLIDE 29

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

A Problem Arises

But why? In KOOL, all operations are message sends, even addition All operations will require memory lookups, since even numbers are objects All memory lookups are rules

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-30
SLIDE 30

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

A Problem Arises

But why? In KOOL, all operations are message sends, even addition All operations will require memory lookups, since even numbers are objects All memory lookups are rules Rules increase the size of the state space

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-31
SLIDE 31

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

A Problem Arises

But why? In KOOL, all operations are message sends, even addition All operations will require memory lookups, since even numbers are objects All memory lookups are rules Rules increase the size of the state space In addition, heap constantly changes, making many more programs infinite state (impossible to model check)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-32
SLIDE 32

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

A Problem Arises

But why? In KOOL, all operations are message sends, even addition All operations will require memory lookups, since even numbers are objects All memory lookups are rules Rules increase the size of the state space In addition, heap constantly changes, making many more programs infinite state (impossible to model check) Shows that a reasonable definition for execution may not work well for analysis

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-33
SLIDE 33

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion Search Model Checking A Problem...

Our Goal

Reduce the number of rule applications by changing the semantics

  • f KOOL while still maintaining observable program behavior

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-34
SLIDE 34

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Outline

1

Rewriting Logic Semantics and KOOL

2

Analysis in KOOL with Rewriting Logic

3

Improving Performance

4

Conclusion

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-35
SLIDE 35

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Optimizing KOOL

Two approaches to optimizing KOOL programs for analysis: Change semantics to reduce usage of rules, focusing on changes that also speed up normal execution (e.g. reduce number of message sends)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-36
SLIDE 36

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Optimizing KOOL

Two approaches to optimizing KOOL programs for analysis: Change semantics to reduce usage of rules, focusing on changes that also speed up normal execution (e.g. reduce number of message sends) Change semantics to reduce usage of rules, even at the expense of slower program execution

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-37
SLIDE 37

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Auto-Boxing in KOOL

1

(1 + 2) * 3 // desugars as (1.+(2)).*(3)

In KOOL, this involves creation of 5 objects, 2 method calls, multiple primitive manipulation operations Heavy use of memory causes execution and analysis performance problems Familiar problem in OO languages (Smalltalk and SELF, for instance) Goal: use scalar values instead, automatically converting to

  • bjects (auto-boxing, as in C#) when needed

With auto-boxing, 2 operations, neither requiring memory lookup

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-38
SLIDE 38

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Adding Auto-Boxing

Step 1: Allow scalar values, versus just objects (3 equations)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-39
SLIDE 39

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Adding Auto-Boxing

Step 1: Allow scalar values, versus just objects (3 equations) Step 2: Modify method call semantics to handle scalar

  • perations without performing a method call (42 equations)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-40
SLIDE 40

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Adding Auto-Boxing

Step 1: Allow scalar values, versus just objects (3 equations) Step 2: Modify method call semantics to handle scalar

  • perations without performing a method call (42 equations)

Step 3: Return scalars from some operations that currently return objects (e.g. primitive integer addition) (50 equations)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-41
SLIDE 41

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Adding Auto-Boxing

Step 1: Allow scalar values, versus just objects (3 equations) Step 2: Modify method call semantics to handle scalar

  • perations without performing a method call (42 equations)

Step 3: Return scalars from some operations that currently return objects (e.g. primitive integer addition) (50 equations) Step 4: Box scalars when needed (4 equations)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-42
SLIDE 42

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Adding Auto-Boxing

Step 1: Allow scalar values, versus just objects (3 equations) Step 2: Modify method call semantics to handle scalar

  • perations without performing a method call (42 equations)

Step 3: Return scalars from some operations that currently return objects (e.g. primitive integer addition) (50 equations) Step 4: Box scalars when needed (4 equations) 8 more additional changes – most changes for auto-boxing mechanical

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-43
SLIDE 43

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Auto-Boxing Results

Ph’s No Optimizations Auto-boxing Counterex DeadFree Counterex DeadFree 2 0.830 1.530 0.799 0.878 3 0.912 34.924 0.899 2.901 4 1.466 1226.323 1.346 23.451 5 6.465 NA 5.226 237.714 6 66.683 NA 45.747 2501.498 7 805.278 NA 476.916 NA 8 NA NA NA NA

Figure: Dining Philosophers Model Checking Performance

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-44
SLIDE 44

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

The KOOL Memory Model

KOOL memory represented as finite map, Location → Value Object references are Locations, objects are Values Memory at toplevel, since all threads share same memory space Memory accesses use rules, since accesses in different threads can compete

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-45
SLIDE 45

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Memory Pools

Idea: Can we split memory into shared and unshared pools,

  • nly use rules for accessed to shared pool?

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-46
SLIDE 46

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Memory Pools

Idea: Can we split memory into shared and unshared pools,

  • nly use rules for accessed to shared pool?

Answer: Yes, if we’re careful...

Local variable accesses should never compete Object-level variable accesses may compete If a variable may be shared, anything reachable through it may be shared as well Conservative assumption: if it can be shared, make it shared, else leave it unshared; once shared, never goes back (simple rule, room for improvement)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-47
SLIDE 47

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Implementing Memory Pools

Add second memory pool (smem), with equations and rules to access it (4 equations, 2 rules)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-48
SLIDE 48

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Implementing Memory Pools

Add second memory pool (smem), with equations and rules to access it (4 equations, 2 rules) Add equations to move items from unshared to shared memory, taking account of transitivity (3 equations)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-49
SLIDE 49

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Implementing Memory Pools

Add second memory pool (smem), with equations and rules to access it (4 equations, 2 rules) Add equations to move items from unshared to shared memory, taking account of transitivity (3 equations) On spawn of a new method, all locations reachable through message target and actual arguments shared (1 rule)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-50
SLIDE 50

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Implementing Memory Pools

Add second memory pool (smem), with equations and rules to access it (4 equations, 2 rules) Add equations to move items from unshared to shared memory, taking account of transitivity (3 equations) On spawn of a new method, all locations reachable through message target and actual arguments shared (1 rule) On spawn of arbitrary expression, contents of current environment (all names in scope) shared (1 rule)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-51
SLIDE 51

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Implementing Memory Pools

Add second memory pool (smem), with equations and rules to access it (4 equations, 2 rules) Add equations to move items from unshared to shared memory, taking account of transitivity (3 equations) On spawn of a new method, all locations reachable through message target and actual arguments shared (1 rule) On spawn of arbitrary expression, contents of current environment (all names in scope) shared (1 rule) On assignment to shared location, share new reachable locations (included in above)

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-52
SLIDE 52

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Implementing Memory Pools

Add second memory pool (smem), with equations and rules to access it (4 equations, 2 rules) Add equations to move items from unshared to shared memory, taking account of transitivity (3 equations) On spawn of a new method, all locations reachable through message target and actual arguments shared (1 rule) On spawn of arbitrary expression, contents of current environment (all names in scope) shared (1 rule) On assignment to shared location, share new reachable locations (included in above) Overall, fewer changes compared to auto-boxing, but more complex

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-53
SLIDE 53

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Shared Memory and Auto-Boxing Combined

Ph’s No Optimizations Auto-boxing + Memory Pools Counterex DeadFree Counterex DeadFree 2 0.830 1.530 0.758 0.782 3 0.912 34.924 0.812 1.270 4 1.466 1226.323 1.070 4.192 5 6.465 NA 2.264 22.467 6 66.683 NA 9.236 124.818 7 805.278 NA 50.527 797.308 8 NA NA 299.630 4744.427

Figure: Dining Philosophers Model Checking Performance

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-54
SLIDE 54

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion In General Auto-Boxing Shared and Unshared Memory Overall Results

Shared Memory and Auto-Boxing Combined

Ph’s Auto-boxing Auto-boxing + Memory Pools Counterex DeadFree Counterex DeadFree 2 0.799 0.878 0.758 0.782 3 0.899 2.901 0.812 1.270 4 1.346 23.451 1.070 4.192 5 5.226 237.714 2.264 22.467 6 45.747 2501.498 9.236 124.818 7 476.916 NA 50.527 797.308 8 NA NA 299.630 4744.427

Figure: Dining Philosophers Model Checking Performance

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-55
SLIDE 55

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Outline

1

Rewriting Logic Semantics and KOOL

2

Analysis in KOOL with Rewriting Logic

3

Improving Performance

4

Conclusion

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-56
SLIDE 56

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Conclusions

Methods to define languages using rewriting logic semantics fairly well understood Good definitions for execution can have poor analysis performance Optimizations from analysis and programming languages can be applied to improve analysis performance Two straight-forward implementations of optimizations shown here; both improve performance dramatically

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-57
SLIDE 57

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Future Work

Provide GC for KOOL, which should help improve memory performance Investigate ways to optimize definitions automatically, and/or prove changes preserve behavior Look for other optimizations that could further improve performance Investigate modularity of optimizations – can optimized memory model be applied to memory model for other languages, for instance?

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance

slide-58
SLIDE 58

Outline Rewriting Logic Semantics and KOOL Analysis in KOOL with Rewriting Logic Improving Performance Conclusion

Related Work

Rewriting Logic Semantics: The Rewriting Logic Semantics Project, Jos´ e Meseguer and Grigore Ro¸ su, TCS, Volume 373(3), pp 217–237, 2007. Rewriting Logic Definition Performance: On Modelling Sensor Networks in Maude, Dilia E. Rodr´ ıguez, WRLA’06. Analysis Performance in Maude: State Space Reduction of Rewrite Theories Using Invisible Transitions, Azadeh Farzan and Jos´ e Meseguer, AMAST 2006; Partial Order Reduction for Rewriting Semantics of Programming Languages, Azadeh Farzan and Jos´ e Meseguer, WRLA 2006.

Mark Hills and Grigore Ro¸ su OO Languages and Rewriting Logic: Designing for Performance