coarse grained transactions
play

Coarse-Grained Transactions Eric Koskinen University of Cambridge - PowerPoint PPT Presentation

Coarse-Grained Transactions Eric Koskinen University of Cambridge 20 January 2010 Joint work with Matthew Parkinson, Maurice Herlihy Wednesday, 20 January 2010 Abstract Data Types global SkipList set; atomic { atomic { set.Add(3); if


  1. Coarse-Grained Transactions Eric Koskinen University of Cambridge 20 January 2010 Joint work with Matthew Parkinson, Maurice Herlihy Wednesday, 20 January 2010

  2. Abstract Data Types global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } Wednesday, 20 January 2010

  3. Abstract Data Types ADT Operations global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } Wednesday, 20 January 2010

  4. Abstract Data Types ADT Operations global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } T1 (Add3) (Rm5) T2 (Has6) (Rm7) Wednesday, 20 January 2010

  5. Abstract Data Types ADT Operations global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) Wednesday, 20 January 2010

  6. Abstract Data Types ADT Operations global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } Abort! T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) Wednesday, 20 January 2010

  7. Abstract Data Types ADT Operations global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } Abort! T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  8. Abstract Data Types ADT Operations global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } Abort! T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Abort! Wednesday, 20 January 2010

  9. Abstract Data Types • Low-level synchronization (r/w conflicts) impairs performance • So how can operations be synchronized? Wednesday, 20 January 2010

  10. what if skiplist is linearizable? Wednesday, 20 January 2010

  11. Abstract Data Types global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  12. Abstract Data Types global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  13. Abstract Data Types global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  14. Abstract Data Types global SkipList set; atomic { atomic { set.Add(3); if set.Has(6) then set.Rm(5) set.Rm(7) } } T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Equiv. Serial History T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  15. Abstract Data Types • Abstract data types ... Wednesday, 20 January 2010

  16. Abstract Data Types • Abstract data types ... • ... require abstract synchronization: Wednesday, 20 January 2010

  17. Abstract Data Types • Abstract data types ... • ... require abstract synchronization: • ... based on method “movement” Wednesday, 20 January 2010

  18. Abstract Data Types • Abstract data types ... • ... require abstract synchronization: • ... based on method “movement” • Left Movers, Right Movers, Both Movers Wednesday, 20 January 2010

  19. Abstract Data Types set.Rm(5) set.Rm(7) set.Rm(5) set.Has(6) T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  20. Abstract Data Types set.Rm(5) set.Rm(7) ⊳ set.Rm(5) set.Has(6) T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  21. Abstract Data Types set.Rm(5) set.Rm(7) ⊲ set.Rm(5) set.Has(6) T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  22. Abstract Data Types set.Rm(5) set.Rm(7) ⊲ ⊳ set.Rm(5) set.Has(6) T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  23. Abstract Data Types set.Rm(5) set.Rm(7) ⊲ ⊳ set.Rm(5) set.Has(6) ⊲ ⊳ T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  24. Abstract Data Types set.Rm(5) set.Rm(7) ⊲ ⊳ set.Rm(5) set.Has(6) ⊲ ⊳ set.*(x) set.*(y) ⊲ ⊳ T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  25. Abstract Data Types set.Rm(5) set.Rm(7) ⊲ ⊳ set.Rm(5) set.Has(6) ⊲ ⊳ if x ≠ y set.*(x) set.*(y) ⊲ ⊳ T1 (Add3) (Rm5) (cmt) T2 (Has6) (Rm7) (cmt) Wednesday, 20 January 2010

  26. Left-movers o.m ⊳ p.n iff Wednesday, 20 January 2010

  27. Left-movers o.m ⊳ p.n iff { σ ′′ | ∃ σ ′ .σ → σ ′ ∧ σ ′ p.n o.m − − − − → σ ′′ } ⊆ ∀ σ { σ ′′′ | ∃ σ ′ .σ → σ ′ ∧ σ ′ p.n o.m − − − − → σ ′′′ } Wednesday, 20 January 2010

  28. Left-movers o.m ⊳ p.n iff { σ ′′ | ∃ σ ′ .σ → σ ′ ∧ σ ′ p.n o.m − − − − → σ ′′ } ⊆ ∀ σ { σ ′′′ | ∃ σ ′ .σ → σ ′ ∧ σ ′ p.n o.m − − − − → σ ′′′ } Similar for Right-movers Wednesday, 20 January 2010

  29. Left-movers dec() inc() dec() 1 0 1 0 time Wednesday, 20 January 2010

  30. Left-movers inc() dec() dec() 1 0 1 11 0 2 1 0 time What Theory? Sept 2009 10 Wednesday, 20 January 2010

  31. Left-movers Valid sequence of calls (same return values) inc() dec() dec() 1 0 1 11 0 2 1 0 time What Theory? Sept 2009 11 Wednesday, 20 January 2010

  32. Left-movers inc() dec() dec() 1 0 1 11 0 2 1 0 time Same final state What Theory? Sept 2009 12 Wednesday, 20 January 2010

  33. Left-movers inc() dec() dec() 1 0 1 11 0 2 1 0 time Same final state inc() dec() What Theory? Sept 2009 12 Wednesday, 20 January 2010

  34. Left-movers inc() dec() dec() 1 0 1 11 0 2 1 0 time Same final state inc() dec() ⊳ What Theory? Sept 2009 12 Wednesday, 20 January 2010

  35. Left-movers dec() inc() dec() 1 0 1 0 time What Theory? Sept 2009 13 Wednesday, 20 January 2010

  36. Left-movers dec() inc() dec() -1 1 0 1 0 time What Theory? Sept 2009 14 Wednesday, 20 January 2010

  37. Left-movers dec() inc() dec() -1 1 0 1 0 time dec() is NOT a left mover w.r.t inc() What Theory? Sept 2009 14 Wednesday, 20 January 2010

  38. Right-movers time If and are adjacent, Ok to move later Wednesday, 20 January 2010

  39. Right-movers Both-movers time time If and are adjacent, If and are adjacent, Ok to move later Ok to swap Wednesday, 20 January 2010

  40. Syntax ::= c ; s | beg t ; s | skip s ::= c ; t | x := o.m ( a ); t | end t Wednesday, 20 January 2010

  41. Atomic Semantics C a = T, σ where T : list s Wednesday, 20 January 2010

  42. Atomic Semantics C a = T, σ where T : list s → A s ′ , σ ′ s, σ − → A T 1 :: s ′ :: T 2 , σ ′ T 1 :: s :: T 2 , σ − Wednesday, 20 January 2010

  43. Atomic Semantics C a = T, σ where T : list s → A s ′ , σ ′ s, σ − → A T 1 :: s ′ :: T 2 , σ ′ T 1 :: s :: T 2 , σ − Statements σ ′ ∈ � c � σ → A s, σ ′ c ; s, σ − t, σ ⇓ A σ ′ → A s, σ ′ beg t ; s, σ − Wednesday, 20 January 2010

  44. Atomic Semantics C a = T, σ where T : list s → A s ′ , σ ′ s, σ − → A T 1 :: s ′ :: T 2 , σ ′ T 1 :: s :: T 2 , σ − Statements Transactions σ ′′ ∈ � o.m ( a ) � σ t, σ ′′ ⇓ A σ ′ σ ′ ∈ � c � σ → A s, σ ′ o.m ( a ); t, σ ⇓ A σ ′ c ; s, σ − t, σ ⇓ A σ ′ end , σ ⇓ A σ → A s, σ ′ beg t ; s, σ − Wednesday, 20 January 2010

  45. Theorem. The atomic semantics Atomic Semantics produce serial histories. C a = T, σ where T : list s → A s ′ , σ ′ s, σ − → A T 1 :: s ′ :: T 2 , σ ′ T 1 :: s :: T 2 , σ − Statements Transactions σ ′′ ∈ � o.m ( a ) � σ t, σ ′′ ⇓ A σ ′ σ ′ ∈ � c � σ → A s, σ ′ o.m ( a ); t, σ ⇓ A σ ′ c ; s, σ − t, σ ⇓ A σ ′ end , σ ⇓ A σ → A s, σ ′ beg t ; s, σ − Wednesday, 20 January 2010

  46. Implementation Strategies Wednesday, 20 January 2010

  47. Implementation Strategies Pessimistic Optimistic undos undos undos T 1 T 2 T 3 T 1 T 2 T 3 add(2) rm(4) add(4) redos redos redos merge merge Boosting, Open Nested Txns, Lock Inf. RW STM, Intel, TL2, Burkhardt Wednesday, 20 January 2010

  48. Implementation Strategies Pessimistic Optimistic undos undos undos T 1 T 2 T 3 T 1 T 2 T 3 add(2) rm(4) add(4) Abort! redos redos redos merge merge Boosting, Open Nested Txns, Lock Inf. RW STM, Intel, TL2, Burkhardt Wednesday, 20 January 2010

  49. Implementation Strategies Pessimistic Optimistic C opt = T, σ sh , ℓ sh C p = T, σ T i : N ⊥ × s × list M T i : N ⊥ × s × σ × σ × ℓ τ Wednesday, 20 January 2010

  50. Implementation Strategies Pessimistic Optimistic C opt = T, σ sh , ℓ sh C p = T, σ T i : N ⊥ × s × list M T i : N ⊥ × s × σ × σ × ℓ τ transaction identifier code oustanding ops Wednesday, 20 January 2010

  51. Implementation Strategies Pessimistic Optimistic C opt = T, σ sh , ℓ sh C p = T, σ T i : N ⊥ × s × list M T i : N ⊥ × s × σ × σ × ℓ τ transaction identifier thread-local state previous state code replay log oustanding ops Wednesday, 20 January 2010

Recommend


More recommend