an space bound for obstruction-free leader election

30
An Space Bound for Obstruction-Free Leader Election George Giakkoupis, Maryam Helmi, Lisa Higham and Philipp Woelfel DISC 2013

Upload: syshe

Post on 22-Feb-2016

36 views

Category:

Documents


0 download

DESCRIPTION

An Space Bound for Obstruction-Free Leader Election. George Giakkoupis , Maryam Helmi , Lisa Higham and Philipp Woelfel DISC 2013. Leader Election. Shared memory with n processors. Atomic multi writer snapshot object. Each process has to decide on one value, win or lose. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: An   Space Bound for Obstruction-Free Leader Election

An Space Bound for Obstruction-Free Leader Election

George Giakkoupis, Maryam Helmi, Lisa Higham and Philipp Woelfel

DISC 2013

Page 2: An   Space Bound for Obstruction-Free Leader Election

Leader Election

• Shared memory with n processors.• Atomic multi writer snapshot object. • Each process has to decide on one value, win or

lose.• Exactly one process (the leader) wins:– At least one process wins– At most one process wins

• Wait free leader election cannot be solved using only read write registers

Page 3: An   Space Bound for Obstruction-Free Leader Election

Obstruction-Freedom

• A deterministic algorithm is obstruction-free, if it guarantees that any process will finish if it performs enough steps alone.

• Obstruction free step complexity- the maximum number of steps until a process taking steps alone finishes.

Page 4: An   Space Bound for Obstruction-Free Leader Election

Obstruction Free Leader Election

• Shared array of registers. • The algorithms proceeds in phases, in each

phase a process writes to • Each registers in contains a pair of process id

and phase number, initialized to zero.

(0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)𝑅Process id Phase #

Page 5: An   Space Bound for Obstruction-Free Leader Election

Obstruction Free Leader Election

(0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)

𝜙=1𝜙=2

(p,1) (p,1)(p,2) (p,2) (p,2)

Phase # Double collect until

equal

Code for process

1While m do r[0..m] = R.scan() if

lose else if (#entries with ( and #entries )

lose else if r[0…] = [(p,),…,(p,)]

else Let be the smallest : r[i](p,)R[i](p,)

EndWin

Page 6: An   Space Bound for Obstruction-Free Leader Election

Not Wait Free

(0,0)

If 2 processes alternate in executing the while loop they never finish the 1st phase

(0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)(1,1)(2,1)(1,1)(2,1)

1While m do r[0..m] = R.scan() if

lose else if (#entries with ( and #entries )

lose else if r[0…] = [(p,),…,(p,)]

else Let be the smallest : r[i](p,)R[i](p,)

EndWin

Page 7: An   Space Bound for Obstruction-Free Leader Election

Obstruction Free Leader Election

Obstruction Free Step Complexity: For each phase at most scan operations, each

scan with step complexity .

1While m do r[0..m] = R.scan() if

lose else if (#entries with ( and #entries )

lose else if r[0…] = [(p,),…,(p,)]

else Let be the smallest : r[i](p,)R[i](p,)

EndWin

Page 8: An   Space Bound for Obstruction-Free Leader Election

Not All Processes Lose• Lemma 1: Not all processes lose.• If all processes lose, let be the last phase.

Last scan of phase , by

lost thus, the orange or purple condition must hold after the

scan

Contradiction to .

The last scan of that caused to

lose

lost thus, the purple condition must hold

after the scan

#entries of Contradiction to

the scan of

(q,) (---,---) (q,) (p,) (---,---) (---,---)

Page 9: An   Space Bound for Obstruction-Free Leader Election

Obstruction Free Leader Election 1While m do r[0..m] = R.scan() if

lose else if (#entries with ( and #entries )

lose else if r[0…] = [(p,),…,(p,)]

else Let be the smallest : r[i](p,)R[i](p,)

EndWin

Observation 1: Only processes in phase write to

Observation 2: If two processes got to phase ( got to phase first), than entries of where written by different processes before the next scan of

Page 10: An   Space Bound for Obstruction-Free Leader Election

Only one wins𝑁 0

𝑁 √𝑛 𝑛√𝑛≅ √𝑛

𝑁 2√𝑛

• the set of processes that participate in phase

Page 11: An   Space Bound for Obstruction-Free Leader Election

Only one wins𝑁 0

𝑁 √𝑛

𝑁 2√𝑛

Lemma 3:

Lemma 2:

Page 12: An   Space Bound for Obstruction-Free Leader Election

Lemma 2:

All entries equal

Each process write to at most once before the scan of , at most processes can write to

At least 2 entries remain equal to , and any process

that scan must lose

() () () () ()() (---,---)()

𝑅 [𝜙 ,…,𝜙+𝑛𝜙 ]

Let be the first process that got to phase

Page 13: An   Space Bound for Obstruction-Free Leader Election

Lemma 3:

• Easy warm up case: • Suppose: 𝑛0−𝑛𝑘=(𝑛0−𝑛1 )+(𝑛1−𝑛2 )…(𝑛𝑘− 1−𝑛𝑘)

𝑘∈𝑂 (√𝑛)

Page 14: An   Space Bound for Obstruction-Free Leader Election

𝑡𝑖 𝑡𝑖′

Lemma 3:

processes entered phase The first extra

process entered phase

The th extra process entered phase

The th extra process entered phase

The last processes entered phase

Page 15: An   Space Bound for Obstruction-Free Leader Election

Lemma 3:

The th extra process entered phase

The th extra process entered phase

equal

At most one entry with before the scan by

() () () () ()() (0,0)()

𝑅 [0 ,…, 𝑖]

Only processes in phase

processes from smaller phases write to

These processes will lose after the write

Page 16: An   Space Bound for Obstruction-Free Leader Election

𝑡𝑖 𝑡𝑖′

Lemma 3:

processes entered phase The first extra

process entered phase

The th extra process entered phase

The th extra process entered phase

The last processes entered phase

-1 processes at phase<lost

-2 processes at phase<lost…

At least processes will lose in the time interval

Page 17: An   Space Bound for Obstruction-Free Leader Election

Time intervals of different phases do not overlapThe total number of processes that will lose is at least

At least processes will lose in the time interval

Lemma 3:

Page 18: An   Space Bound for Obstruction-Free Leader Election

𝑛≥ ∑0≤𝑖 ≤𝜅

𝑑𝑖 (𝑑𝑖−1)2

Lemma 3:

Page 19: An   Space Bound for Obstruction-Free Leader Election

𝑛= ∑0≤𝑖<𝜅

(𝑛𝑖−𝑛𝑖+ 1)+𝑛𝜅≥ ∑0≤𝑖<𝜅

(𝑛𝑖−𝑛𝑖+1)

≥ ∑0≤ 𝑖<𝜅

(𝑖−𝑑𝑖 )= ∑0≤𝑖<𝜅

𝑖− ∑0≤𝑖 ≤𝜅

𝑑𝑖=𝜅(𝜅−1)

2− ∑0≤𝑖 ≤𝜅

𝑑𝑖

Lemma 3:

Page 20: An   Space Bound for Obstruction-Free Leader Election

Lemma 3:

𝑛≥ ∑0≤𝑖 ≤𝜅

𝑑𝑖 (𝑑𝑖−1)2

𝜅∈𝑂 (√𝑛)

.

.

.

Page 21: An   Space Bound for Obstruction-Free Leader Election

Lemma 3:

Wrap Up: Only one wins𝑁 0

𝑁 √𝑛 𝑛√𝑛≅ √𝑛

𝑁 2√𝑛

Lemma 2:

Page 22: An   Space Bound for Obstruction-Free Leader Election

Optimization: Early Termination

• exits the while loop if:– The green condition is satisfied– did not see any other process during phases and .

• Applying this condition, a process finishes after solo steps.

Page 23: An   Space Bound for Obstruction-Free Leader Election

Deterministic to Randomized

Deterministic obstruction-free

algorithm

Randomized wait-free algorithm

• Preserve space complexity

Page 24: An   Space Bound for Obstruction-Free Leader Election

Randomized Model

• Processes can use local coin-flips to make random decisions.

• The scheduling and process crashes are controlled by an oblivious adversary, which determines the entire (infinite) schedule ahead of time.

Page 25: An   Space Bound for Obstruction-Free Leader Election

Randomized Wait-free

• A deterministic algorithm is wait-free if every process finishes in an finite number of its own steps.

• A randomized algorithm is randomized wait-free if every process finishes in an expected finite number of steps.

Page 26: An   Space Bound for Obstruction-Free Leader Election

Deterministic to Randomized

Deterministic obstruction-free

algorithm

Randomized wait-free algorithm

(oblivious adversary)

• Preserve space complexity

Any process finishes after

executing at most b steps without interference

Any process finishes w.h.p.

after O(b(n+b)logn)

steps

Page 27: An   Space Bound for Obstruction-Free Leader Election

Transformation Technique

• Flip a coin in the beginning and after every b steps.

• Each coin flip returns heads with probability , independently.

Execute thenext b steps of the given deterministic algorithm

Execute b dummy steps

Page 28: An   Space Bound for Obstruction-Free Leader Election

Rough Transformation Analysis• Fix the schedule • Order the processes by the order in which

they take their real step. • Look at process , and define disjoint blocks:

real steps of , steps of other process, number of coin flips in the block

Heads

Page 29: An   Space Bound for Obstruction-Free Leader Election

Rough Transformation Analysis

• number of coin flips in the block • At most coin flip outside the block effect the block• Unobstructed block contains real steps only by • The probability of a block to be unobstructed is

≈ (1− 1𝑛 )𝑚𝑏 +(𝑛−1 )

Page 30: An   Space Bound for Obstruction-Free Leader Election

To Sum Up

• We saw a deterministic obstruction-free implementation of leader election using registers.

• We saw a technique to transform any deterministic obstruction free algorithm into a randomized wait free algorithm for the oblivious adversary.