69
Algorithms for Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components Krishnendu Chatterjee, Amir Kafshdar Goharshady, Rasmus Ibsen-Jensen, Andreas Pavlogiannis POPL 2016

Algorithms for Algebraic Path Properties in Concurrent

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Algorithms for Algebraic Path Properties in Concurrent

Algorithms for Algebraic Path Properties inConcurrent Systems of Constant Treewidth

Components

Krishnendu Chatterjee, Amir Kafshdar Goharshady,Rasmus Ibsen-Jensen, Andreas Pavlogiannis

POPL 2016

Page 2: Algorithms for Algebraic Path Properties in Concurrent

Typical Program Analysis Paradigm

A typical paradigm in program analysis is to reduce the problem to astandard graph problem P:Input: Program

1 Extract control flow graph G

2 Annotate G

3 Run best general graph algorithm for P on G

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 2

Page 3: Algorithms for Algebraic Path Properties in Concurrent

Typical Program Analysis Paradigm

A typical paradigm in program analysis is to reduce the problem to astandard graph problem P:Input: Program

1 Extract control flow graph G

2 Annotate G3 Run best general graph algorithm for P on G

by exploiting special structure of CFGs

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 2

Page 4: Algorithms for Algebraic Path Properties in Concurrent

Static Analysis of Concurrent Programs

Static dataflow/quantitative analysis of concurrent systems

System consists of CFGs of local threads + sync vars

A node of the concurrent system specifies the local state of eachthread (+ sync)

System transitions wrt interleaving semantics

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 3

Page 5: Algorithms for Algebraic Path Properties in Concurrent

Algebraic Paths in Static Analysis

Concurrent system annotated with a (complete, closed) semiring.

Variety of properties expressible

(Generalized) reachabilityDistributive dataflow analysis problemsQuantitative problems (quality measures / quantitative verification)Algebraic relaxations for interprocedural analysis

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 4

Page 6: Algorithms for Algebraic Path Properties in Concurrent

Algebraic Paths in Static Analysis

Concurrent system annotated with a (complete, closed) semiring.

Variety of properties expressible

(Generalized) reachabilityDistributive dataflow analysis problemsQuantitative problems (quality measures / quantitative verification)Algebraic relaxations for interprocedural analysis

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 4

Page 7: Algorithms for Algebraic Path Properties in Concurrent

Formal Setting

Complete, closed semiring S = (Σ,⊕,⊗, 0, 1)

k local graphs Gi = (Vi ,Ei ), |Vi | ≤ n

Compose a concurrent system G = (V ,E ,wt)

Nodes of the form v = 〈v1, . . . , vk〉E ⊆ product(E1, . . . ,Ek)

i.e. (〈u1, . . . , uk 〉, 〈v1, . . . , vk 〉) ∈ E

Global weight function wt : E → Σ

Weight of a path P : x1, x2, . . . , xm:

⊗(P) = wt(x1, x2)⊗ wt(x2, x3) · · · ⊗ wt(xk−1, xm)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 5

Page 8: Algorithms for Algebraic Path Properties in Concurrent

Formal Setting

Complete, closed semiring S = (Σ,⊕,⊗, 0, 1)

k local graphs Gi = (Vi ,Ei ), |Vi | ≤ n

Compose a concurrent system G = (V ,E ,wt)

Nodes of the form v = 〈v1, . . . , vk〉E ⊆ product(E1, . . . ,Ek)

i.e. (〈u1, . . . , uk 〉, 〈v1, . . . , vk 〉) ∈ E

Global weight function wt : E → Σ

Weight of a path P : x1, x2, . . . , xm:

⊗(P) = wt(x1, x2)⊗ wt(x2, x3) · · · ⊗ wt(xk−1, xm)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 5

Page 9: Algorithms for Algebraic Path Properties in Concurrent

Formal Setting

Complete, closed semiring S = (Σ,⊕,⊗, 0, 1)

k local graphs Gi = (Vi ,Ei ), |Vi | ≤ n

Compose a concurrent system G = (V ,E ,wt)

Nodes of the form v = 〈v1, . . . , vk〉E ⊆ product(E1, . . . ,Ek)

i.e. (〈u1, . . . , uk 〉, 〈v1, . . . , vk 〉) ∈ E

Global weight function wt : E → Σ

Weight of a path P : x1, x2, . . . , xm:

⊗(P) = wt(x1, x2)⊗ wt(x2, x3) · · · ⊗ wt(xk−1, xm)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 5

Page 10: Algorithms for Algebraic Path Properties in Concurrent

Graph Problem: Semiring Distances

Weight of a path P : x1, x2, . . . , xm:

⊗(P) = wt(x1, x2)⊗ wt(x2, x3) · · · ⊗ wt(xk−1, xm)

Semiring distance from u to v :

d(u, v) =⊕

P:u v

⊗(P)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 6

Page 11: Algorithms for Algebraic Path Properties in Concurrent

Method 1: Thread 11 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

Method 2: Thread 21 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

1

2 3

4

5

6 7

8

9

1

2 3

4

5

6 7

8

9

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 7

Page 12: Algorithms for Algebraic Path Properties in Concurrent

Nodes V : 〈2, 7〉

Method 1: Thread 11 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

Method 2: Thread 21 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

1

2 3

4

5

6 7

8

9

1

2 3

4

5

6 7

8

9

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 7

Page 13: Algorithms for Algebraic Path Properties in Concurrent

Nodes V : 〈2, 7〉

Edges E : (〈2, 7〉, 〈6, 8〉)

Method 1: Thread 11 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

Method 2: Thread 21 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

1

2 3

4

5

6 7

8

9

1

2 3

4

5

6 7

8

9

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 7

Page 14: Algorithms for Algebraic Path Properties in Concurrent

Nodes V : 〈2, 7〉

Edges E : (〈2, 7〉, 〈6, 8〉)

Weights wt : E → Σ : wt(〈2, 7〉, 〈6, 8〉) = α

Method 1: Thread 11 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

Method 2: Thread 21 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

1

2 3

4

5

6 7

8

9

1

2 3

4

5

6 7

8

9

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 7

Page 15: Algorithms for Algebraic Path Properties in Concurrent

Nodes V : 〈2, 7〉

Edges E : (〈2, 7〉, 〈6, 8〉)

Weights wt : E → Σ : wt(〈2, 7〉, 〈6, 8〉) = α

Pair query: d(〈1, 1〉, 〈7, 7〉)

Method 1: Thread 11 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

Method 2: Thread 21 while 1 do2 if turn = −1 then3 lock(`)4 turn← my id5 unlock(`)

6 if turn = my id then7 /* do stuff */8 turn← −1

9 end

1

2 3

4

5

6 7

8

9

1

2 3

4

5

6 7

8

9

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 7

Page 16: Algorithms for Algebraic Path Properties in Concurrent

Existing Algorithmic Approach

Construct the product graph G from the local components G1,G2

Compute transitive closure (all-pairs) on G

Warshall-Floyd-Kleene algorithm, cubic complexity

O((

n2)3)

= O(n6)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 8

Page 17: Algorithms for Algebraic Path Properties in Concurrent

Existing Algorithmic Approach

Construct the product graph G from the local components G1,G2

Compute transitive closure (all-pairs) on G

Warshall-Floyd-Kleene algorithm, cubic complexity

O((

n2)3)

= O(n6)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 8

Page 18: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

Component graphs have special structure, i.e., low-treewidth graphs

Measures similarity of a graph to a treeWell-known property of control-flow graphs

A faster algorithm for the transitive closure O(n6)→ O

(n4+ε

)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 9

Page 19: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

Component graphs have special structure, i.e., low-treewidth graphs

Measures similarity of a graph to a treeWell-known property of control-flow graphs

A faster algorithm for the transitive closure O(n6)→ O

(n4+ε

)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 9

Page 20: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

On demand analysis: preprocess vs query

Preprocessing spectrum

Transitive ClosureNo Preprocessing

Answering a few queries does not require the transitive closure

On demand analysis: preprocess more only if expecting many queries

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 10

Page 21: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

On demand analysis: preprocess vs query

Preprocessing spectrum

Transitive ClosureNo Preprocessing

Answering a few queries does not require the transitive closure

On demand analysis: preprocess more only if expecting many queries

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 10

Page 22: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

2 components: product size n × n, transitive closure has n4 entries

Existing O(n6) time for transitive closure

Preprocessing spectrum

Transitive ClosureNo Preprocessing

(1): Transitive closure almost optimal

(3): Conditionally optimal

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 11

Page 23: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

2 components: product size n × n, transitive closure has n4 entries

Existing O(n6) time for transitive closure

Preprocessing spectrum

Transitive ClosureNo Preprocessing

n3+ε

(1) n4+ε + i

(1): Transitive closure almost optimal

(3): Conditionally optimal

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 11

Page 24: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

2 components: product size n × n, transitive closure has n4 entries

Existing O(n6) time for transitive closure

Preprocessing spectrum

Transitive ClosureNo Preprocessing

n3+εn1+ε

(1) n4+ε + i(2) n3+ε + i · n

(1): Transitive closure almost optimal

(3): Conditionally optimal

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 11

Page 25: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

2 components: product size n × n, transitive closure has n4 entries

Existing O(n6) time for transitive closure

Preprocessing spectrum

Transitive ClosureNo Preprocessing

n3+εn1+ε

(1) n4+ε + i(2) n3+ε + i · n(3) n3 + i · n2

(1): Transitive closure almost optimal

(3): Conditionally optimal

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 11

Page 26: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

2 components: product size n × n, transitive closure has n4 entries

Existing O(n6) time for transitive closure

Preprocessing spectrum

Transitive ClosureNo Preprocessing

n3+εn1+ε

(1) n4+ε + i(2) n3+ε + i · n(3) n3 + i · n2

(1): Transitive closure almost optimal

(3): Conditionally optimal

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 11

Page 27: Algorithms for Algebraic Path Properties in Concurrent

Our Improvements for Semiring Distances

2 components: product size n × n, transitive closure has n4 entries

Existing O(n6) time for transitive closure

Preprocessing spectrum

Transitive ClosureNo Preprocessing

n3+εn1+ε

(1) n4+ε + i(2) n3+ε + i · n(3) n3 + i · n2

(1): Transitive closure almost optimal

(3): Conditionally optimal

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 11

Page 28: Algorithms for Algebraic Path Properties in Concurrent

Outline

Tree decompositions

Treewidth of the concurrent system

On demand analysis on the concurrent tree-decomposition

Experimental results

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 12

Page 29: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V

Tree(G )G

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 13

Page 30: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V

Tree(G )G

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 13

Page 31: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V

Tree(G )G

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 13

Page 32: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V

Tree(G )G

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 13

Page 33: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V

Tree(G )

B1

B2

B3

∃ x1 ∈ B1 ∩ B2

∃ x2 ∈ B2 ∩ B3

d(10,6)=d(10, x1)⊗ d(x1, x2)⊗ d(x2, 6)

8, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 13

Page 34: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V

Tree(G )

B1

B2

B3

∃ x1 ∈ B1 ∩ B2

∃ x2 ∈ B2 ∩ B3

d(10,6)=d(10, x1)⊗ d(x1, x2)⊗ d(x2, 6)

Semiring distances reduce to:

1. Tree decomposition

2. Local Distances

8, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 13

Page 35: Algorithms for Algebraic Path Properties in Concurrent

Treewidth

CFGs of typical imperative programs have tree-decompositions of smallsized bags

Theoretically, for goto-free programs

Pascal ≤ 4C ≤ 7

In practice small in imperative programs (e.g. Java ≤ 8)

G Tree(G )

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 14

Page 36: Algorithms for Algebraic Path Properties in Concurrent

Treewidth

CFGs of typical imperative programs have tree-decompositions of smallsized bags

Theoretically, for goto-free programs

Pascal ≤ 4C ≤ 7

In practice small in imperative programs (e.g. Java ≤ 8)

Theorem (Tree decomposition)

For constant treewidth graphs,Tree(G ) can be constructed in O(n) time.

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 14

Page 37: Algorithms for Algebraic Path Properties in Concurrent

Treewidth of the Concurrent System

tw = 1

×tw = 1

tw = n − 1

Components of small treewidth can yield a concurrent system G ofvery large treewidth!

Computing an optimal tree decomposition of G is intractable (NP-C)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 15

Page 38: Algorithms for Algebraic Path Properties in Concurrent

Strongly Balanced Tree Decompositions

Convert the local tree decompositions to

Binary: every bag has two children

Strongly balanced: most bags have two subtrees of approximatelyequal size

Tree(G1)

Strongly Balanced Tree(G1)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 16

Page 39: Algorithms for Algebraic Path Properties in Concurrent

Strongly Balanced Tree Decompositions

Convert the local tree decompositions to

Binary: every bag has two children

Strongly balanced: most bags have two subtrees of approximatelyequal size

Tree(G1)

Strongly Balanced Tree(G1)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 16

Page 40: Algorithms for Algebraic Path Properties in Concurrent

Strongly Balanced Tree Decompositions

Convert the local tree decompositions to

Binary: every bag has two children

Strongly balanced: most bags have two subtrees of approximatelyequal size

Tree(G1)

Strongly Balanced Tree(G1)

n

n2

n2

n4

n4

n4

n4

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 16

Page 41: Algorithms for Algebraic Path Properties in Concurrent

Strongly Balanced Tree Decompositions

Convert the local tree decompositions to

Binary: every bag has two children

Strongly balanced: most bags have two subtrees of approximatelyequal size

Tree(G1)

Strongly Balanced Tree(G1)

n

n2

n2

n4

n4

n4

n4

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 16

Page 42: Algorithms for Algebraic Path Properties in Concurrent

Tree Decomposition of the Concurrent System

Tree(G1)

t n

t n2 t n

2

t n4 t n

4 t n4 t n

4

t = O(1)

Tree(G2)

t n

t n2 t n

2

t n4 t n

4 t n4 t n

4

cn

c n2 c n

2 c n2 c n

2

. . . . . . . . . . . .c n4

Tree(G )

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 17

Page 43: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n

n2

n2

n4

n4

n4

n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 44: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n

n2

n2

n4

∗ n4

n4

n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 45: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n

n2

n2

n4

∗ n4

∗ n4

n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 46: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n

n2

n2

n4

∗ n4

∗ n4

∗ n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 47: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n

n2

n2

n4

∗ n4

∗ n4

∗ n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 48: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n

n2

∗ n2

n4

∗ n4

∗ n4

∗ n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 49: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n

n2

∗ n2

n4

∗ n4

∗ n4

∗ n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 50: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n∗

n2

∗ n2

n4

∗ n4

∗ n4

∗ n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 51: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n∗

n2

∗∗ n2

n4

∗ n4

∗ n4

∗ n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 52: Algorithms for Algebraic Path Properties in Concurrent

On Demand Analysis: Local Distances

For every two nodes u, v appearing in a bag, compute d(u, v)

Tree(G )

. . .

n∗

n2

∗ n2

n4

∗ n4

∗ n4

∗ n4

Transitive closure on the bags instead of the whole system

Cost decreases geometrically on the levels

Transitive closure on the root dominatesO(n6)→ O(n3)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 18

Page 53: Algorithms for Algebraic Path Properties in Concurrent

Tradeoffs

Preprocessing spectrum

Transitive ClosureNo Preprocessing

n3+εn1+ε

(1) n4+ε + i(2) n3+ε + i · n(3) n3 + i · n2

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 19

Page 54: Algorithms for Algebraic Path Properties in Concurrent

Experiments

Control-flow graphs (CFGs) of methods from java libraries andbenchmarks

Focus on algorithmic comparison with standard transitive closurealgorithms

Used the tropical min-plus semiring on R ∪ ∞

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 20

Page 55: Algorithms for Algebraic Path Properties in Concurrent

Experiments 1

CFGs from the DaCapo suit

n nodes each CFG

2-self product: size n × n

Random weights in [−103, 103]

Compute the transitive closure

Baseline: Bellman-Ford

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 21

Page 56: Algorithms for Algebraic Path Properties in Concurrent

Experiments 1

CFGs from the DaCapo suit

n nodes each CFG

2-self product: size n × n

Random weights in [−103, 103]

Compute the transitive closure

Baseline: Bellman-Ford

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 21

Page 57: Algorithms for Algebraic Path Properties in Concurrent

Experiments 1

CFGs from the DaCapo suit

n nodes each CFG

2-self product: size n × n

Random weights in [−103, 103]

Compute the transitive closure

Baseline: Bellman-Ford

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 21

Page 58: Algorithms for Algebraic Path Properties in Concurrent

Experiments 2

CFGs from container methods injava.util.concurrent

Bloated with values of locks

2-self product: size n × n

Random weights in [−103, 103]

Transitive closure

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 22

Page 59: Algorithms for Algebraic Path Properties in Concurrent

Experiments 2

CFGs from container methods injava.util.concurrent

Bloated with values of locks

2-self product: size n × n

Random weights in [−103, 103]

Transitive closure

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 22

Page 60: Algorithms for Algebraic Path Properties in Concurrent

Experiments 2

CFGs from container methods injava.util.concurrent

Bloated with values of locks

2-self product: size n × n

Random weights in [−103, 103]

Transitive closure

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 22

Page 61: Algorithms for Algebraic Path Properties in Concurrent

Thank you!Questions?

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 23

Page 62: Algorithms for Algebraic Path Properties in Concurrent

Experiments 2

CFGs from container methods injava.util.concurrent

Bloated with values of locks

2-self product: size n × n

Random weights in [−103, 103]

Transitive closure times:

To(s) : our algorithmTb(s): baseline (Bellman-Ford)

Java method n To(s) Tb(s)

ArrayBlockingQueue: poll 19 19 60

ArrayBlockingQueue: peek 20 20 81

LinkedBlockingDeque: advance 25 29 195

PriorityBlockingQueue: removeEQ 25 32 176

ArrayBlockingQueue: init 26 47 249

LinkedBlockingDeque: remove 26 49 290

ArrayBlockingQueue: offer 26 56 304

ArrayBlockingQueue: clear 28 33 389

ArrayBlockingQueue: contains 32 205 881

DelayQueue: remove 42 267 3792

ConcurrentHashMap: scanAndLockForPut 46 375 2176

ArrayBlockingQueue: next 46 407 3915

ConcurrentHashMap: put 72 1895 > 8 h

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 1

Page 63: Algorithms for Algebraic Path Properties in Concurrent

Results

2 components

Preprocess Query time

Time Space Single-source Pair Partial pair

Existing O(n6) O(n4) O(n2) O(1) O(1)

Our result (ε > 0) O(n3) O(n2+ε) O(n2+ε) O(n2) O(n2)

Our result (ε > 0) O(n3+ε) O(n3) O(n2+ε) O(n) O(1)

Our result (ε > 0) O(n4+ε) O(n4) O(n2) O(1) O(1)

k ≥ 3 components

Preprocess Query time

Time Space Single-source Pair Partial pair

Existing O(n3k ) O(n2k ) O(nk ) O(1) O(1)

Our result O(n3k−3) O(n2k−1) O(n2(k−1)) O(nk−1) O(1)

Our result O(n3k−2) O(n2k) O(nk) O(1) O(1)

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 2

Page 64: Algorithms for Algebraic Path Properties in Concurrent

Results (2 Components)

2 components: product size n × n, transitive closure has n4 entries

Existing O(n6) time for transitive closure

n1+ε n3+ε n4

n1+ε

n3

n3 + (i + j) · n2

(3)

n3+ε + i · n + j

(2)n4+ε + i + j

(1)

i pair queries

jp

arti

alp

air

qu

erie

s

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 3

Page 65: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V such that:

1 Every node of G is contained in a bag

2 Every edge of G is contained in a bag

3 Every node of G appears in a contiguous subtree of Tree(G ).

G Tree(G )

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 4

Page 66: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V such that:

1 Every node of G is contained in a bag

2 Every edge of G is contained in a bag

3 Every node of G appears in a contiguous subtree of Tree(G ).

G Tree(G )

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 4

Page 67: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V such that:

1 Every node of G is contained in a bag

2 Every edge of G is contained in a bag

3 Every node of G appears in a contiguous subtree of Tree(G ).

G Tree(G )

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 4

Page 68: Algorithms for Algebraic Path Properties in Concurrent

Tree Decompositions

Definition (Tree decomposition)

Given a graph G = (V ,E ), a tree-decomposition Tree(G ) = (VT ,ET )is a tree of bags Bi ⊆ V such that:

1 Every node of G is contained in a bag

2 Every edge of G is contained in a bag

3 Every node of G appears in a contiguous subtree of Tree(G ).

G Tree(G )

1

8

9

2

10

3

6

4

7

58, 9, 10

1, 8, 9

2, 8, 10

2, 3, 10

7, 8, 9

6, 7, 9

4, 6, 9 5, 6, 7

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 4

Page 69: Algorithms for Algebraic Path Properties in Concurrent

Conditional Optimality

1 Any graph G can be constructed as the product of twoconstant-treewidth graphs G1, G2

2 =⇒ Semiring distance on the product of G1, G2 as hard as on G

3 Widely conjectured Ω(n3) lower-bound

x1

x2 x3

x1 x2 x3y1 y2 y3

x1

x2

x3

y1

y2

y3

Chatterjee, Kafshdar Goharshady, Ibsen-Jensen, Pavlogiannis Algebraic Path Properties in Concurrent Systems of Constant Treewidth Components 5