140
John Field Janus: exploiting parallelism via hindsight Omer Tripp Roman Manevich Mooly Sagiv

Janus : exploiting parallelism via hindsight

  • Upload
    jayme

  • View
    37

  • Download
    0

Embed Size (px)

DESCRIPTION

Janus : exploiting parallelism via hindsight. Roman Manevich. Omer Tripp. John Field. Mooly Sagiv. the PMD code analyzer. the PMD code analyzer. popular open-source code analyzer (~2,000 weekly downloads). the PMD code analyzer. popular open-source code analyzer (~2,000 weekly downloads). - PowerPoint PPT Presentation

Citation preview

Page 1: Janus : exploiting parallelism via hindsight

John Field

Janus: exploiting parallelism via hindsight

Omer Tripp Roman Manevich

Mooly Sagiv

Page 2: Janus : exploiting parallelism via hindsight

the PMD code analyzer

Page 3: Janus : exploiting parallelism via hindsight

the PMD code analyzerpopular open-source code analyzer (~2,000 weekly

downloads)

Page 4: Janus : exploiting parallelism via hindsight

the PMD code analyzerpopular open-source code analyzer (~2,000 weekly

downloads)

scans source files modularly =>

parallelization opportunity

Page 5: Janus : exploiting parallelism via hindsight

the main loop of PMD (simplified)

Page 6: Janus : exploiting parallelism via hindsight

the main loop of PMD

analyze files in parallel

Page 7: Janus : exploiting parallelism via hindsight

the main loop of PMD

but.. (shared as local)

Page 8: Janus : exploiting parallelism via hindsight

the main loop of PMD

hmm.. can’t we “localize” ctx?

Page 9: Janus : exploiting parallelism via hindsight

the main loop of PMDnot so fast.. (happens sometimes, deep down the stack)

Page 10: Janus : exploiting parallelism via hindsight

the main loop of PMD

no cloning =>

Page 11: Janus : exploiting parallelism via hindsight

the main loop of PMD

reuse => @atomic ≈ @sequential

Page 12: Janus : exploiting parallelism via hindsight

the main loop of PMDto summarize..

Page 13: Janus : exploiting parallelism via hindsight

the main loop of PMDto summarize..available

parallelism

Page 14: Janus : exploiting parallelism via hindsight

the main loop of PMDto summarize..available

parallelismmissed by write-set approach

Page 15: Janus : exploiting parallelism via hindsight

Janus: sequence-based detection/* offlin

e */

Page 16: Janus : exploiting parallelism via hindsight

T1

ctx.sourceCodeFilename = …;…String fname=ctx.sourceCodeFilename;…

T2

ctx.sourceCodeFilename = …;…String fname=ctx.sourceCodeFilename;…

Janus: sequence-based detection/* offlin

e */

Page 17: Janus : exploiting parallelism via hindsight

T1

ctx.sourceCodeFilename = …;…String fname=ctx.sourceCodeFilename;…

T2

ctx.sourceCodeFilename = …;…String fname=ctx.sourceCodeFilename;…

Janus: sequence-based detection/* offlin

e */

Page 18: Janus : exploiting parallelism via hindsight

Janus: sequence-based detectionT1

ctx.sourceCodeFilename = …;…ctx.setAttribute(s, …);…

T2

ctx.sourceCodeFilename = …;…… = ctx.getAttribute(s);…

/* offline */

Page 19: Janus : exploiting parallelism via hindsight

Janus: sequence-based detectionT1

ctx.sourceCodeFilename = …;…ctx.setAttribute(s, …);…

T2

ctx.sourceCodeFilename = …;…… = ctx.getAttribute(s);…

/* offline */

Page 20: Janus : exploiting parallelism via hindsight

Janus: sequence-based detectionT1

ctx.sourceCodeFilename = …;…ctx.setAttribute(s, …);…

T2

ctx.sourceCodeFilename = …;…… = ctx.getAttribute(s);…

/* offline */

Page 21: Janus : exploiting parallelism via hindsight

the main loop of PMD

in paper:• more real-world examples• more coding patterns encouraging refined conflict detection

Page 22: Janus : exploiting parallelism via hindsight
Page 23: Janus : exploiting parallelism via hindsight

running example

Reverse-Delete MST

G’ = G(e1 … en) = SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

Page 24: Janus : exploiting parallelism via hindsight

running example

Reverse-Delete MST

G’ = G(e1 … en) = SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

ordered

Page 25: Janus : exploiting parallelism via hindsight

running example

Reverse-Delete MST

G’ = G(e1 … en) = SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

heavy

Page 26: Janus : exploiting parallelism via hindsight

running example

Reverse-Delete MST

G’ = G(e1 … en) = SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

identity if edge restored (available parallelism)

Page 27: Janus : exploiting parallelism via hindsight

take I: blind parallelism

Reverse-Delete MST

G’ = G(e1 … en) = SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

parallel for // broken but fast

Page 28: Janus : exploiting parallelism via hindsight

take II: write-set speculation

Reverse-Delete MST

G’ = G(e1 … en)= SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

/* with boosting *

/

@atomic // exploit graph semantics: node ≈ location

Page 29: Janus : exploiting parallelism via hindsight

take II: write-set speculation/* with b

oosting */

can we exploit the available

parallelism with this

approach?

Page 30: Janus : exploiting parallelism via hindsight

the write-set approach in action

T1 T2

v1 v2uG:

Page 31: Janus : exploiting parallelism via hindsight

the write-set approach in action

RemoveEdge(u,v1) RemoveEdge(u,v2)T1 T2

v1 v2uG:

Page 32: Janus : exploiting parallelism via hindsight

the write-set approach in action

RemoveEdge(u,v1) RemoveEdge(u,v2)T1 T2

v1 v2uG:

Page 33: Janus : exploiting parallelism via hindsight

the write-set approach in action

RemoveEdge(u,v1)b = HasPath(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)

T1 T2

v1 v2uG:

Page 34: Janus : exploiting parallelism via hindsight

the write-set approach in action

RemoveEdge(u,v1)b = HasPath(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)

T1 T2

v1 v2uG:

Page 35: Janus : exploiting parallelism via hindsight

the write-set approach in action

RemoveEdge(u,v1)b = HasPath(u,v1)test b

RemoveEdge(u,v2)b = HasPath(u,v2)test b

T1 T2

v1 v2uG:

Page 36: Janus : exploiting parallelism via hindsight

the write-set approach in action

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

Page 37: Janus : exploiting parallelism via hindsight

the write-set approach in action

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

Page 38: Janus : exploiting parallelism via hindsight

take III: online commutativity checking

/* with boosting *

/

Reverse-Delete MST

G’ = G(e1 … en)= SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

@atomic // full commutativity checking

Page 39: Janus : exploiting parallelism via hindsight

precise checking in action

v1 v2uG:

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

Page 40: Janus : exploiting parallelism via hindsight

precise checking in action

v1 v2uG:

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

Page 41: Janus : exploiting parallelism via hindsight

precise checking in action

v1 v2uG:

RemoveEdge(u,v1); HasPath(u,v1); AddEdge(u,v1)

RemoveEdge(u,v2); HasPath(u,v2); AddEdge(u,v2)

RemoveEdge(u,v2); HasPath(u,v2); AddEdge(u,v2)

RemoveEdge(u,v1); HasPath(u,v1); AddEdge(u,v1)

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

Page 42: Janus : exploiting parallelism via hindsight

precise checking in action

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

RemoveEdge(u,v1); HasPath(u,v1); AddEdge(u,v1)

RemoveEdge(u,v2); HasPath(u,v2); AddEdge(u,v2)

RemoveEdge(u,v2); HasPath(u,v2); AddEdge(u,v2)

RemoveEdge(u,v1); HasPath(u,v1); AddEdge(u,v1)

∙≡

Page 43: Janus : exploiting parallelism via hindsight

but.. can we really afford this?

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

Page 44: Janus : exploiting parallelism via hindsight

but.. can we really afford this?

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

expensive instrumentation

Page 45: Janus : exploiting parallelism via hindsight

but.. can we really afford this?

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

expensive instrumentation

+

Page 46: Janus : exploiting parallelism via hindsight

but.. can we really afford this?

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

expensive instrumentation

expensive conflict detection+

Page 47: Janus : exploiting parallelism via hindsight

but.. can we really afford this?

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

expensive instrumentation

expensive conflict detection+

Page 48: Janus : exploiting parallelism via hindsight

but.. can we really afford this?

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

expensive instrumentation

expensive conflict detection+poor performance

Page 49: Janus : exploiting parallelism via hindsight

take III: Janus/* with b

oosting */

Reverse-Delete MST

G’ = G(e1 … en)= SortEdgesByDecreasingWeight() for i=1 … n

G’.RemoveEdge(ei)if (!G’.HasPath(ei.u, ei.v))

G’.AddEdge(ei)return G’

@atomic // accurate checking utilizing offline data!

Page 50: Janus : exploiting parallelism via hindsight

the Janus approach

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

Page 51: Janus : exploiting parallelism via hindsight

the Janus approach

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

sequence-based detection

Page 52: Janus : exploiting parallelism via hindsight

the Janus approach

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

sequence-based detection => accurate

Page 53: Janus : exploiting parallelism via hindsight

the Janus approach

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

sequence-based detection

candidate sequences learned ahead of production runs, in profiling

=> accurate

Page 54: Janus : exploiting parallelism via hindsight

the Janus approach

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

sequence-based detection

candidate sequences learned ahead of production runs, in profiling

commutativity testing done offline

=> accurate

Page 55: Janus : exploiting parallelism via hindsight

the Janus approach

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

sequence-based detection

candidate sequences gleaned ahead of production runs, in profiling

commutativity testing done offline

=> accurate=> cheap

Page 56: Janus : exploiting parallelism via hindsight
Page 57: Janus : exploiting parallelism via hindsight

the Janus flow

offline

Page 58: Janus : exploiting parallelism via hindsight

the Janus flowfind candidate sequences via

profiling*ST runs*single

locations

offline

Page 59: Janus : exploiting parallelism via hindsight

the Janus flowfind candidate sequences via

profiling*ST runs*single

locations

offlinelow instrumentation

overhead

Page 60: Janus : exploiting parallelism via hindsight

the Janus flowfind candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

offline

Page 61: Janus : exploiting parallelism via hindsight

the Janus flowfind candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

Page 62: Janus : exploiting parallelism via hindsight

the Janus flowfind candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

cheap conflict detection

Page 63: Janus : exploiting parallelism via hindsight

the Janus flowfind candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

Page 64: Janus : exploiting parallelism via hindsight

the Janus flowfind candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

Page 65: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

Page 66: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

miss perform write-set detection

Page 67: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

miss perform write-set detection

online

soundness

Page 68: Janus : exploiting parallelism via hindsight
Page 69: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

miss perform write-set detection

user input

Page 70: Janus : exploiting parallelism via hindsight

the Janus spec: data

n1:v1

n2:v2 n3:v2

n4:v1

Page 71: Janus : exploiting parallelism via hindsight

the Janus spec: data

n1:v1

node data

n1 v1

… …

neighbor node

n2 n1

n1 n2

n3 n1

… …

n2:v2 n3:v2

n4:v1

Page 72: Janus : exploiting parallelism via hindsight

the Janus spec: operationsnode data

n1 V1

n2 v2

n1:v1

n2:v2

Page 73: Janus : exploiting parallelism via hindsight

the Janus spec: operationsnode data

n1 V1

n2 v2

n1:v1

n2:v2

public void addnode(n) { nodes.add(n); }

Page 74: Janus : exploiting parallelism via hindsight

the Janus spec: operations

public void addnode(n) { nodes.add(n); }

node data

n1 V1

n2 v2

insert <n.d,n> into “nodes”

n1:v1

n2:v2

Page 75: Janus : exploiting parallelism via hindsight

the Janus spec: operationsnode data

n1 V1

n2 v2

n1:v1

n2:v2

n1:v1

n2:v2

n.d:n

public void addnode(n) { nodes.add(n); }

insert <n.d,n> into “nodes”

Page 76: Janus : exploiting parallelism via hindsight

the Janus spec: operationsnode data

n1 V1

n2 v2

n1:v1

n2:v2

node data

n1 v1

n2 v2

n n.d

n1:v1

n2:v2

n.d:n

public void addnode(n) { nodes.add(n); }

insert <n.d,n> into “nodes”

Page 77: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

miss perform write-set detection

Page 78: Janus : exploiting parallelism via hindsight

sequence mining

v1 v2uG:

Page 79: Janus : exploiting parallelism via hindsight

sequence mining

v1 v2uG:

G’ = G

Page 80: Janus : exploiting parallelism via hindsight

sequence mining

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

Page 81: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)T1

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

Page 82: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)

T1

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

Page 83: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)

T1

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1

Page 84: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test b

T1

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1

Page 85: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

T1

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1

Page 86: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

T1

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1; AddEdge/T1

Page 87: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)T1 T2

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1; AddEdge/T1

Page 88: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)T1 T2

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1; AddEdge/T1

RemoveEdge/T2

Page 89: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)

T1 T2

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1; AddEdge/T1

RemoveEdge/T2

Page 90: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test b

T1 T2

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1; AddEdge/T1

RemoveEdge/T2; HasPath/T2

Page 91: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1; AddEdge/T1

RemoveEdge/T2; HasPath/T2

Page 92: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

RemoveEdge/T1; HasPath/T1; AddEdge/T1

RemoveEdge/T2; HasPath/T2; AddEdge/T2

Page 93: Janus : exploiting parallelism via hindsight

sequence mining

RemoveEdge(u,v1)b = HasPath(u,v1)test bAddEdge(u,v1)

RemoveEdge(u,v2)b = HasPath(u,v2)test bAddEdge(u,v2)

T1 T2

v1 v2uG:

G’ = G(e1 … en) = SortEdgesByDecreasingWeight()

return G’

RemoveEdge/T1; HasPath/T1; AddEdge/T1

RemoveEdge/T2; HasPath/T2; AddEdge/T2

Page 94: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

miss perform write-set detection

Page 95: Janus : exploiting parallelism via hindsight

commutativity checking

RemoveEdge(u,v1

); HasPath(u,v1); AddEdge(u,v1)

RemoveEdge(u,v2

); HasPath(u,v2); AddEdge(u,v2)

RemoveEdge(u,v2

); HasPath(u,v2); AddEdge(u,v2)

RemoveEdge(u,v1

); HasPath(u,v1); AddEdge(u,v1)

Page 96: Janus : exploiting parallelism via hindsight

commutativity checking

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

Page 97: Janus : exploiting parallelism via hindsight

commutativity checking

ɸ0 = encode(G)ɸ1 = ɸ0 ˄ {x,y} ϵ “edges”…ɸk = ɸk-1 ˄ {x,y} ϵ “edges”…ɸk+1 = ɸk ˄ {x,y} ϵ “edges”…ɸm = ɸm-1 ˄ {x,y} ϵ “edges”

ψ0 = encode(G)ψ1 = ψ0 ˄ {x,z} ϵ “edges”…ψk = ψk-1 ˄ {x,z} ϵ “edges”…ψk+1 = ψk ˄ {x,y} ϵ “edges”…ψm = ψm-1 ˄ {x,y} ϵ “edges”

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

Page 98: Janus : exploiting parallelism via hindsight

commutativity checking

ɸ0 = encode(G)ɸ1 = ɸ0 ˄ {x,y} ϵ “edges”…ɸk = ɸk-1 ˄ {x,y} ϵ “edges”…ɸk+1 = ɸk ˄ {x,y} ϵ “edges”…ɸm = ɸm-1 ˄ {x,y} ϵ “edges”

ψ0 = encode(G)ψ1 = ψ0 ˄ {x,z} ϵ “edges”…ψk = ψk-1 ˄ {x,z} ϵ “edges”…ψk+1 = ψk ˄ {x,y} ϵ “edges”…ψm = ψm-1 ˄ {x,y} ϵ “edges”

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

test: ¬(ѱ ≡ ɸ)

Page 99: Janus : exploiting parallelism via hindsight

commutativity checking

ɸ0 = encode(G)ɸ1 = ɸ0 ˄ {x,y} ϵ “edges”…ɸk = ɸk-1 ˄ {x,y} ϵ “edges”…ɸk+1 = ɸk ˄ {x,y} ϵ “edges”…ɸm = ɸm-1 ˄ {x,y} ϵ “edges”

ψ0 = encode(G)ψ1 = ψ0 ˄ {x,z} ϵ “edges”…ψk = ψk-1 ˄ {x,z} ϵ “edges”…ψk+1 = ψk ˄ {x,y} ϵ “edges”…ψm = ψm-1 ˄ {x,y} ϵ “edges”

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,z); HasPath(x,z); AddEdge(x,z)

RemoveEdge(x,y); HasPath(x,y); AddEdge(x,y)

test: ¬(ѱ ≡ ɸ)

in paper:• encoding rules• “projection” : sound commutativity checking for sequences induced by individual memory locations

Page 100: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

miss perform write-set detection

Page 101: Janus : exploiting parallelism via hindsight

generalization RemoveEdge(x,y); HasPath(x,y);

AddEdge(x,y)S1= RemoveEdge(x,z); HasPath(x,z);

AddEdge(x,z)S2=

Page 102: Janus : exploiting parallelism via hindsight

generalization RemoveEdge(x,y); HasPath(x,y);

AddEdge(x,y)S1= RemoveEdge(x,z); HasPath(x,z);

AddEdge(x,z)S2=

[S1 S2]G // “concrete” seq.s commute

Page 103: Janus : exploiting parallelism via hindsight

generalization RemoveEdge(x,y); HasPath(x,y);

AddEdge(x,y)S1= RemoveEdge(x,z); HasPath(x,z);

AddEdge(x,z)S2=

[S1 S2]G // “concrete” seq.s commute

S1(G) = S1∙S1(G) // idempotentS2(G) = S2∙S2(G) // idempotent

Page 104: Janus : exploiting parallelism via hindsight

generalization RemoveEdge(x,y); HasPath(x,y);

AddEdge(x,y)S1= RemoveEdge(x,z); HasPath(x,z);

AddEdge(x,z)S2=

[S1 S2]G // “concrete” seq.s commute

S1(G) = S1∙S1(G) // idempotentS2(G) = S2∙S2(G) // idempotent

Page 105: Janus : exploiting parallelism via hindsight

generalization RemoveEdge(x,y); HasPath(x,y);

AddEdge(x,y)S1= RemoveEdge(x,z); HasPath(x,z);

AddEdge(x,z)S2=

[S1 S2]G // “concrete” seq.s commute

S1(G) = S1∙S1(G) // idempotentS2(G) = S2∙S2(G) // idempotent

[S1+ S2

+]G // Kleene-cross generalization

Page 106: Janus : exploiting parallelism via hindsight

generalization RemoveEdge(x,y); HasPath(x,y);

AddEdge(x,y)S1= RemoveEdge(x,z); HasPath(x,z);

AddEdge(x,z)S2=

[S1 S2]G // “concrete” seq.s commute

S1(G) = S1∙S1(G) // idempotentS2(G) = S2∙S2(G) // idempotent

[S1+ S2

+]G // Kleene-cross generalization

++

Page 107: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

specialized spec

miss perform write-set detection

Page 108: Janus : exploiting parallelism via hindsight

specialized commutativity specstate operation operation

Page 109: Janus : exploiting parallelism via hindsight

specialized commutativity specstate operation operation

any AddEdge(x,z)/ff AddEdge(x,y)/tt

Page 110: Janus : exploiting parallelism via hindsight

specialized commutativity specstate operation operation

any AddEdge(x,z)/ff AddEdge(x,y)/tt

any HasPath(z,w)/tt AddEdge(x,y)/ff

Page 111: Janus : exploiting parallelism via hindsight

specialized commutativity specstate operation operation

any AddEdge(x,z)/ff AddEdge(x,y)/tt

any HasPath(z,w)/tt AddEdge(x,y)/ff

Page 112: Janus : exploiting parallelism via hindsight

specialized commutativity specstate operation operation

any AddEdge(x,z)/ff AddEdge(x,y)/tt

any HasPath(z,w)/tt AddEdge(x,y)/ff

any[ RemoveEdge(x,z)/tt;

HasPath(x,z)/ff; AddEdge(x,z)/tt ]+

[ RemoveEdge(x,y)/tt; HasPath(x,y)/ff;

AddEdge(x,y)/tt ]+

Page 113: Janus : exploiting parallelism via hindsight

specialized commutativity specstate operation operation

any AddEdge(x,z)/ff AddEdge(x,y)/tt

any HasPath(z,w)/tt AddEdge(x,y)/ff

any[ RemoveEdge(x,z)/tt;

HasPath(x,z)/ff; AddEdge(x,z)/tt ]+

[ RemoveEdge(x,y)/tt; HasPath(x,y)/ff;

AddEdge(x,y)/tt ]+

tailored for given application

Page 114: Janus : exploiting parallelism via hindsight

the Janus flow

consult sequence cache

when attempting to

commit a transaction

find candidate sequences via

profiling*ST runs*single

locations

test sequences for

commutativity

cache (generalized version) of

commutative sequences

offline

online

miss perform write-set detection

Page 115: Janus : exploiting parallelism via hindsight

parallelization protocol

shared state [k]

shared state [k+1]

shared state [k+2]

privatized state [k]

privatized state [k’]

a1

a2

.

.

.

.

.an

b1

b2

.

.

.

.

.bm

(a1 … an) (b∙ 1 … bm) Sk ≡ (b1 … bm) (a∙ 1 … an) Sk

Page 116: Janus : exploiting parallelism via hindsight

parallelization protocol

shared state [k]

shared state [k+1]

shared state [k+2]

privatized state [k]

privatized state [k’]

a1

a2

.

.

.

.

.an

b1

b2

.

.

.

.

.bm

(a1 … an) (b∙ 1 … bm) Sk ≡ (b1 … bm) (a∙ 1 … an) Sk

Page 117: Janus : exploiting parallelism via hindsight

parallelization protocol

shared state [k]

shared state [k+1]

shared state [k+2]

privatized state [k]

privatized state [k’]

shared state [k+3]

replay on shared

state

bi

Page 118: Janus : exploiting parallelism via hindsight

parallelization protocol

shared state [k]

shared state [k+1]

shared state [k+2]

privatized state [k]

privatized state [k’]

a1

a2

.

.

.

.

.an

b1

b2

.

.

.

.

.bm

(a1 … an) (b∙ 1 … bm) Sk ≡ (b1 … bm) (a∙ 1 … an) Sk

Page 119: Janus : exploiting parallelism via hindsight

parallelization protocol

shared state [k]

shared state [k+1]

shared state [k+2]

privatized state [k+2]

retr

y

Page 120: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

Page 121: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

Page 122: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

Page 123: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

Page 124: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)

Page 125: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)

Page 126: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

Page 127: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

Page 128: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

RemoveEdge(u,v3

)HasPath(u,v3)AddEdge(u,v3)

Page 129: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

RemoveEdge(u,v3

)HasPath(u,v3)AddEdge(u,v3)

?

Page 130: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

RemoveEdge(u,v3

)HasPath(u,v3)AddEdge(u,v3) x.f =

y;||z = x.f;

Page 131: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

RemoveEdge(u,v3

)HasPath(u,v3)AddEdge(u,v3)

dope!

Page 132: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

RemoveEdge(u,v3

)HasPath(u,v3)AddEdge(u,v3)

state operation operation

any[ RemoveEdge(x,z)/tt;

HasPath(x,z)/ff; AddEdge(x,z)/tt ]+

[ RemoveEdge(x,y)/tt; HasPath(x,y)/ff;

AddEdge(x,y)/tt ]+

b

Page 133: Janus : exploiting parallelism via hindsight

parallel reverse-delete MST

RemoveEdge(u,v1

)HasPath(u,v1)AddEdge(u,v1)RemoveEdge(u,v2

)HasPath(u,v2)AddEdge(u,v2)

RemoveEdge(u,v3

)HasPath(u,v3)AddEdge(u,v3)that’

s better..

Page 134: Janus : exploiting parallelism via hindsight
Page 135: Janus : exploiting parallelism via hindsight

benchmarksdescription name

utility for synchronizing pairs of directories JFileSync

greedy graph-coloring algorithm JGraphT-1 (coloring)

saturation-degree node-ordering algorithm for heuristic graph coloring

JGraphT-2 (ordering)

Java source code analyzer PMD

machine-learning library for data-mining tasks Weka

Page 136: Janus : exploiting parallelism via hindsight

Seq 1 2 3 4 5 6 7 80

0.5

1

1.5

2

2.5

Fine-grained conflict detection

Coarse-grained conflict detection

Sequential

Seq 1 2 3 4 5 6 7 80

0.5

1

1.5

2

2.5

Seq 1 2 3 4 5 6 7 80

0.5

1

1.5

2

2.5

Seq 1 2 3 4 5 6 7 80

0.5

1

1.5

2

2.5

Seq 1 2 3 4 5 6 7 80

0.5

1

1.5

2

2.5

Weka

PMD

JGraphT-2

JFileSync

JGraphT-1 speedup

Page 137: Janus : exploiting parallelism via hindsight

Fine-grained conflict detection

Coarse-grained conflict detection

1 2 3 4 5 6 7 80

0.51

1.52

2.53

3.54

4.5

Weka

1 2 3 4 5 6 7 80

0.51

1.52

2.53

3.54

4.5

JFileSync

1 2 3 4 5 6 7 80

0.51

1.52

2.53

3.54

4.5

PMD

1 2 3 4 5 6 7 80

0.51

1.52

2.53

3.54

4.5

JGraphT-2

1 2 3 4 5 6 7 80

0.51

1.52

2.53

3.54

4.5

JGraphT-1 retries

Page 138: Janus : exploiting parallelism via hindsight

0%

10%

20%

30%

40%

50%

60%

70%

80%

90%

WekaPMDJGraphT-2 JFileSyncJGraphT-1

misses

W/ seq. abstraction W/O seq. abstraction

Page 139: Janus : exploiting parallelism via hindsight

conclusions

profiling is useful for speculation• prevalent behaviors (dependencies) => effective

specialization• speculation = safety net

Janus enables practical accuracy boosting

• lifts commutativity checking to sequences of operations• runtime overhead comparable to write-set approach

Page 140: Janus : exploiting parallelism via hindsight