Exploiting the Commutativity Lattice Donald Nguyen, Dimitrios Milind Kulkarni Prountzos, Xin Sui and Keshav Pingali Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X Y Z 2 Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X Y Z atomic { atomic { ... ... S.add(a) S.contains(b) ... ... } } 2 Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X X Y Y Z Z A atomic { atomic { ... ... S.add(a) S.contains(b) ... ... } } 2 Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X X Y Y Z Z A X atomic { atomic { ... ... S.add(a) S.contains(b) ... ... } } 2 Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X X Y Y Z Z A atomic { atomic { ... ... S.add(a) S.contains(b) ... ... } } 2 Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X X Y Y Z Z A atomic { atomic { ... ... S.add(a) S.contains(b) ... ... } } 2 Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X Y Z A atomic { atomic { ... ... S.add(a) S.contains(b) ... ... } } 3 Wednesday, July 20, 2011
Exploiting semantics in transactional execution Set S: X Y Z A Key insight: exploit commutativity properties to ensure transactional behavior atomic { atomic { ... ... S.add(a) S.contains(b) ... ... } } 3 Wednesday, July 20, 2011
Exploiting semantics in transactional execution [Carlstrom et al. [Koskinen et al. PPoPP 07] Set S: X Y Z A POPL 10] [Weihl et al. IEEE Key insight: exploit commutativity properties ToC 88] [Ni et al. PPoPP 07] to ensure transactional behavior atomic { atomic { ... ... [Herlihy & Koskinen [Kulkarni et al. S.add(a) S.contains(b) PPoPP 08] PLDI 07] ... ... } } [Kulkarni et al. ASPLOS 08] 3 Wednesday, July 20, 2011
How do we check commutativity? • Can specify conditions for commutativity: add(a)/r commutes with contains(b)/r if a ≠ b • How should a transactional run-time system check these? • Prior work: ad hoc combinations of logging and locking 4 Wednesday, July 20, 2011
How do we check commutativity? add(a)/r commutes with contains(b)/r if a ≠ b 5 Wednesday, July 20, 2011
How do we check commutativity? add(a)/r commutes with contains(b)/r if a ≠ b or r = false 5 Wednesday, July 20, 2011
How do we check commutativity? • Commutativity can be more complex: add(a)/r commutes with contains(b)/r if a ≠ b or r = false • Prior work often did not fully check commutativity to reduce overhead • How do we know this is correct? 5 Wednesday, July 20, 2011
Contributions • Define a commutativity lattice for reasoning about commutativity specifications • How do we check commutativity? • Provide systematic approaches for implementing commutativity checks • How do we implement low overhead checks? • Show how to use commutativity lattice to correctly construct lower-overhead checkers 6 Wednesday, July 20, 2011
Commutativity σ 1 7 Wednesday, July 20, 2011
Commutativity σ 1 m 1 r 1 7 Wednesday, July 20, 2011
Commutativity σ 1 σ 2 m 1 r 1 7 Wednesday, July 20, 2011
Commutativity σ 1 σ 2 m 1 m 2 r 1 r 2 7 Wednesday, July 20, 2011
Commutativity σ 1 σ 2 σ 3 m 1 m 2 r 1 r 2 7 Wednesday, July 20, 2011
Commutativity σ 1 σ 2 σ 3 m 1 m 2 r 1 r 2 m 1, m 2 commute in σ 1 7 Wednesday, July 20, 2011
Commutativity σ 1 σ ’ 2 σ 3 m 2 m 1 r 2 r 1 m 1, m 2 commute in σ 1 8 Wednesday, July 20, 2011
Using commutativity to guarantee serializability A : m 1 m 2 m 3 m 4 B : m 1 m 2 m 3 m 4 9 Wednesday, July 20, 2011
Using commutativity to guarantee serializability History : m 1 m 1 m 2 m 2 m 3 m 3 m 4 m 4 10 Wednesday, July 20, 2011
Using commutativity to guarantee serializability σ 1 σ 2 σ 3 σ 4 σ 5 σ 6 σ 7 σ 8 σ 9 History : m 1 m 1 m 2 m 2 m 3 m 3 m 4 m 4 10 Wednesday, July 20, 2011
Using commutativity to guarantee serializability σ 1 σ 2 σ 3 σ ’ 4 σ 5 σ 6 σ 7 σ 8 σ 9 History : m 1 m 1 m 2 m 2 m 3 m 3 m 4 m 4 11 Wednesday, July 20, 2011
Using commutativity to guarantee serializability σ 1 σ 2 σ ’ 3 σ ’ 4 σ 5 σ 6 σ 7 σ 8 σ 9 History : m 1 m 2 m 1 m 2 m 3 m 3 m 4 m 4 12 Wednesday, July 20, 2011
Using commutativity to guarantee serializability σ 1 σ 2 σ ’ 3 σ ” 4 σ ’ 5 σ ’ 6 σ ’ 7 σ 8 σ 9 History : m 1 m 2 m 3 m 4 m 1 m 2 m 3 m 4 13 Wednesday, July 20, 2011
Runtime commutativity checks • For each method invocation by transaction B • Runtime checks commutativity with all methods invoked by transaction A • If all checks succeed, execution continues • If any commutativity check fails, one transaction rolled back 14 Wednesday, July 20, 2011
Commutativity conditions φ (m a, m b ) Commutativity condition: 15 Wednesday, July 20, 2011
Commutativity conditions φ (m a, m b ) Commutativity condition: true only if m a and m b commute 15 Wednesday, July 20, 2011
Commutativity conditions φ (m a, m b ) Commutativity condition: * φ (m a, m b ) Precise condition: 15 Wednesday, July 20, 2011
Commutativity conditions φ (m a, m b ) Commutativity condition: * φ (m a, m b ) Precise condition: true if and only if m a and m b commute 15 Wednesday, July 20, 2011
Commutativity conditions φ (m a, m b ) Commutativity condition: * φ (m a, m b ) Precise condition: * φ ( add(a)/r 1 , contains(b)/r 2 ) a ≠ b or r 1 = false 15 Wednesday, July 20, 2011
Commutativity lattice ( add(a)/r 1 , contains(b)/r 2 ) a ≠ b or r 1 = false 16 Wednesday, July 20, 2011
Commutativity lattice ( add(a)/r 1 , contains(b)/r 2 ) a ≠ b or r 1 = false a ≠ b r 1 = false false 16 Wednesday, July 20, 2011
Commutativity lattice ( add(a)/r 1 , contains(b)/r 2 ) Allows most a ≠ b or r 1 = false parallelism a ≠ b r 1 = false Allows no false parallelism 16 Wednesday, July 20, 2011
Implementing Commutativity Wednesday, July 20, 2011
Soundness and completeness • A conflict detection implementation is sound if it claims methods commute only if they actually do according to the conditions • A conflict detection implementation is complete if it claims methods commute if they do according to the conditions 18 Wednesday, July 20, 2011
Running example • Set-like data structure • Supports add and contains ( add(a)/r 1 , contains(b)/r 2 ) a ≠ b or r 1 = false ( add(a)/r 1 , add(b)/r 2 ) a ≠ b or (r 1 = false and r 2 = false ) ( contains(a)/r 1 , contains(b)/r 2 ) true 19 Wednesday, July 20, 2011
Running example • Set-like data structure • Supports add and contains ( add(a)/r 1 , contains(b)/r 2 ) a ≠ b ( add(a)/r 1 , add(b)/r 2 ) a ≠ b ( contains(a)/r 1 , contains(b)/r 2 ) true 20 Wednesday, July 20, 2011
Implementing commutativity • Three schemes • Abstract locking • Forward gatekeeping • General gatekeeping 21 Wednesday, July 20, 2011
Abstract locking • Sound and complete implementation when commutativity condition is simple • Is either true , false , or a set of conjuncts of the form “x ≠ y” ( add(a)/r 1 , contains(b)/r 2 ) a ≠ b or r 1 = false Not simple: a ≠ b Simple: 22 Wednesday, July 20, 2011
Abstract locking • Basic skeleton • Associate an abstract lock with each object that can be passed as an argument to a method • When a method is called, acquire locks on each argument in appropriate mode • Object already locked → commutativity violation • All locks released when transaction ends • Key problem: building compatibility matrix 23 Wednesday, July 20, 2011
Building compatibility matrix • One mode per argument of a method add(a) → add:1 contains(b) → cont:1 24 Wednesday, July 20, 2011
Building compatibility matrix • One mode per argument of a method add(a) → add:1 contains(b) → cont:1 cont:1 add:1 cont:1 add:1 24 Wednesday, July 20, 2011
Building compatibility matrix • Compatibility: If condition includes conjunct “a ≠ b” then modes for a and b incompatible φ ( add(a)/r 1 , contains(b)/r 2 ) : a ≠ b cont:1 add:1 cont:1 add:1 25 Wednesday, July 20, 2011
Building compatibility matrix • Compatibility: If condition includes conjunct “a ≠ b” then modes for a and b incompatible φ ( add(a)/r 1 , contains(b)/r 2 ) : a ≠ b cont:1 add:1 cont:1 add:1 25 Wednesday, July 20, 2011
Building compatibility matrix • Compatibility: modes for a and b incompatible if condition includes conjunct “a ≠ b” φ ( add(a)/r 1 , add(b)/r 2 ) : a ≠ b cont:1 add:1 cont:1 add:1 26 Wednesday, July 20, 2011
Building compatibility matrix • Compatibility: modes for a and b incompatible if condition includes conjunct “a ≠ b” φ ( add(a)/r 1 , add(b)/r 2 ) : a ≠ b cont:1 add:1 cont:1 add:1 26 Wednesday, July 20, 2011
Building the compatibility matrix • Compatibility: modes for a and b incompatible if condition includes conjunct “a ≠ b” φ ( contains(a)/r 1 , contains(b)/r 2 ) : true cont:1 add:1 cont:1 add:1 27 Wednesday, July 20, 2011
Recommend
More recommend