2 How to implement a concurrent system using reads and writes Traditional lock-based solutions are inefficient (deadlocks) Traditional lock-free solutions are expensive (strong synchronization primitives, failure detectors) Exploiting the absence of step contention Obstruction-free Solo-fast
4 Lock-free distributed computing Given a distributed shared memory system with certain base objects, which objects can be implemented lock-free ? [Lamport, 1978]
5 Implementing an object Devise a distributed algorithm that, using base (hardware) objects, provides an illusion of the object implemented in a hardware p1 p2 p3 enq(1) ok deq()01 enq(0)
6 Safety Linearizability: every operation appears instantaneously between its invocation and response events p1 p2 p3 enq(1) ok deq()01 enq(0)
7 Liveness Ideally, wait-freedom : any process completes any operation, regardless of the behavior of other processes ? Not wait-free
8 Register base objects (usually available) p1 p2 p3 W W R W R R
9 Any object from registers? Wait-free consensus from reads and writes is impossible [Fischer et al., 1985], [Dolev et al., 1987] [Loui and Abu-Amara, 1987], [Herlihy, 1991] Why consensus? 1. Universal 2. Indispensable Why impossible? Steps of concurrent processes interleave
10 How to achieve wait-freedom Registers Failure detectors Powerful base objects Wait-freedom & Linearizability 1. Complex 2. Expensive Progress for everyone?
11 Progress for lucky ones Guarantee progress only when you run alone, i.e., encounter no contention (the most common case in practice) [Herlihy et al., ICDCS 2003, DISC 2003]
13 Step contention The step contention of an execution fragment is the number of processes that take steps in the fragment’s interval The interval contention counts the number of operations p1 p2 p3 ir i’r’ SC(i,r)=2 IC(i,r)=3 SC(i’,r’)=1 IC(i’,r’)=2
14 Solo termination [Fich et al., 1998] Every operation that eventually encounters no step contention must return p1 p2 p3 ir
15 Using interval contention? [Luchangco et al., 2003] When there is no interval contention: terminate using only reads and writes When there is interval contention terminate using hardware C&S Constant in time and space! But not much different from lock-based
16 When there is step contention 1. Keep trying (obstruction-free) 2. Use “expensive” primitives (solo-fast)
18 Obstruction-free interface Obstruction-free object invocation response wait fail wait = might have taken effect fail = did not take effect
19 Returning control in case of contention Wait and try again later p1 p2 p3 ir wait
20 Returning control in case of contention Abort the operation p1 p2 p3 i waitfail
21 Only fail? Obstruction-free object invocation response fail (no effect) Transaction-like operations?
22 Only fail? One “only-fail” consensus object C and one registers R can be used to implement 2- process wait-free consensus Code for p1: propose(v1) x1 := C.propose(v1) if x1=fail then x1:=R return x1 Code for p2: propose(v2) R := v2 repeat x2=C.propose(v2) until x2 <> fail return x2
23 Obstruction-free objects do exist! Time complexity There is a step contention-free operation that takes Ω(n) steps Space complexity Ω(n) of registers are used And this is optimal! (reduction to [Jayanti et al., 2000]) Registers OF & linearizable implecmentation of any object
24 Gracefull degradation? Ω + registers WF consensus Registers only OF consensus Gracefully degrading consensus? WF if Ω «behaves well» OF otherwise Not possible (reduction to [LA87, DDS87, Her91])
26 Solo-fast implementations Solo-fast implementation of any object: linear in time and space (seems to be optimal) if no step contention detected then use registers to terminate else use “expensive” primitives to terminate
27 Bottom line Lock-based solutions Wait-free solutions Inefficient Expensive Obstruction-free & solo-fast implementations: - For any object - Linear in time and space Inherently expensive?
28 Perspectives Complexity of obstruction-free consensus (at least non- constant) Complexity of solo-fast implementations (using slightly more powerful primitives on a fast path) Optimal contention management