© 2005 P. Kouznetsov Computing with Reads and Writes in the Absence of Step Contention Hagit Attiya...

29
© 2005 P. Kouznetsov Computing with Reads and Writes in the Absence of Step Contention Hagit Attiya Rachid Guerraoui Petr Kouznetsov School of Computer and Communication Sciences EPFL Department of Computer Science Technion

Transcript of © 2005 P. Kouznetsov Computing with Reads and Writes in the Absence of Step Contention Hagit Attiya...

© 2005 P. Kouznetsov

Computing with Reads and Writes in the Absence of Step

Contention

Hagit Attiya Rachid Guerraoui Petr Kouznetsov

School of Computer and Communication Sciences

EPFL

Department of Computer Science

Technion

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 contentionObstruction-freeSolo-fast

3

Outline

BackgroundLock-free computing

ContributionStep contentionObstruction-free implementations Solo-fast implementations

Perspectives

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 deq()

enq(0)

6

Safety

Linearizability: every operation appears instantaneously between its invocation and response events

p1

p2

p3

enq(1) ok

deq() 01 deq()

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

p3W

W

RW

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. Universal2. Indispensable

Why impossible?Steps of concurrent

processes interleave

10

How to achieve wait-freedom

Registers

Failure detectors

Powerful base objects

Wait-freedom& Linearizability

1. Complex2. Expensiv

e

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]

12

Outline

BackgroundLock-free computing using reads and writes

ContributionStep contentionObstruction-free implementations Solo-fast implementations

Perspectives

13

Step contentionThe 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

i r

i’ r’

SC(i,r)=2IC(i,r)=3 SC(i’,r’)=

1IC(i’,r’)=

2

14

Solo termination [Fich et al., 1998]

Every operation that eventually encounters no step contention must return

p1

p2

p3

i r

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)

17

Outline

BackgroundLock-free computing

ContributionStep contentionObstruction-free implementationsSolo-fast implementations

Concluding remarks

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

i rwait wait

20

Returning control in case of contention

Abort the operation

p1

p2

p3

i wait fail

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:=Rreturn x1

Code for p2:propose(v2)

R := v2repeat

x2=C.propose(v2) until x2 <> failreturn x2

23

Obstruction-free objects do exist!

Time complexityThere 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])

RegistersOF & linearizableimplecmentation

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])

25

Outline

BackgroundLock-free computing

ContributionStep contentionObstruction-free algorithmsSolo-fast implementations

Perspectives

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 terminateelse 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

29

Thank you!