Lecture 37: Consensus III & Final Thoughts
COSC 273: Parallel and Distributed Computing
Spring 2023
Annoucements
- Final Submissions: Tuesday, 05/09 by 5:00pm
- documentation = 40% of grade
- code style = 10% of grade
- remove all debugging messages!
- test on cluster (timeout/compile errors)
- Assignment/Quiz grading this week
Leaderboard 3
Primes Task (baseline 58810ms):
- The AMA (2024ms)
- Test Group Name Please Ignore (2217ms)
- IsaM (2222ms)
- Team 2 (2295ms)
Sorting Task (baseline 8034ms):
- Deadlock Dodgers (1309ms)
- MRC (1356ms)
- Daily Mammoth (1451ms)
- Benchmark (1509ms)
Binary Consensus
Setup: $n$ processes with binary inputs
-
Agreement: all processes output the same value
-
Validity: if all systems have the same input, they all output that valuex
-
Termination: all (non-faulty) processes decide on an output and terminate after a finite number of steps
Theorem (FLP, 1985). There is no algorithm that achieves consensus in the presence of even a single faulty process.
Bivalent & Critical Executions
An execution $E$ is…
- …bivalent if the final output is not yet determined
- …critical if the execution is bivalent, but no extension
Lemma 2. Every consensus protocol has a bivalent initial state.
Lemma 3. Every consensus protocol has a citical execution $E$.
Outline of Proof of FLP
Assume only 2 processes, $P_0$ and $P_1$
- Start from a critical execution $E$
- $E$ is bivalent, but any extension is univalent
- Consider all possibilities for next step:
- both threads
read
for next step
- one thread
read
s, the other write
s
- both threads
write
- Show that in any case, we contradict either criticality of
E
or correctness of protocol
Assumptions
Without loss of generality:
- There are two processes $P_0$ and $P_1$
- $E$ is a critical state
- if $P_0$ has next step, resulting execution is $0$-valent
- if $P_1$ has next step, resulting execution is $1$-valent
Case 1: read
/read
Assumption: next operations for both $P_0$ and $P_1$ are read
- Start from critical state $E$
- if $P_0$ steps next, output is
0
- if $P_1$ steps next, output is
1
read
/read
read
/read
Next Step
read
/read
Problem
Case 2: read
/write
Assumption:
read
/write
Setup
read
/write
Next Step
read
/write
Indistinguishable
read
/write
$P_0$ Crashes
Case 3: write
/write
Assumption: next operation for both $P_0$ and $P_1$ is write
Subcases:
- Sub-case a: write to different registers
- Sub-case b: write to same register
write
/write
Different Registers
write
/write
Next Step
write
/write
Indistinguishable
write
/write
Same Register
write
/write
Next Step
write
/write
Indistinguishable
Conclusion
In general:
- Indistinguishable executions produce same output
Assuming a wait-free consensus protocol using only read/write registers:
- Showed there is a bivalent initial state
- Showed there is a critical execution
- Given a critical execution
- found indistinguishable states that must give different outputs
- this is a contradiction!
Remark. 1 and 2 hold for all protocols; 3 assumes only read/write registers
Consensus is Impossible?
Well not quite!
- We just proved impossibility in our computational model!
- atomic read/write registers
- wait-free (or faults)
- nasty scheduler!
Does the Model Reflect Reality?
- single CPUs have stronger primitives!
- we might have better schedulers
- computation could be distributed
- how to implement
compareAndSet
for a communication network?
- faults could be worse
Implications
- Atomic read/write registers are insufficient to solve fundamental tasks in parallel computing
- this drives the development of hardware primitives (e.g. CAS)
- We can quantify the computational power of primitive operations
- read/write registers have consensus number 1
- FIFO queues have consensus number 2
- given wait-free queues, 2 threads can solve consensus (How?)
- $\implies$ cannot implement concurrent queues with read/write registers
- Can use
compareAndSet
to achieve consensus (How?)
1. Parallelism is Powerful
2. Communication is Costly
3. Synchronization is Subtle
- locks
- atomic operations
- concurrent data structures
- progress and correctness
- consensus
4. Definitions & Proofs are Critical
- computing technology affects every aspect of modern life
- systems are built upon computational primitives (e.g., consensus)
- to reason about effects of a system, we must clarify
- desired outcomes (definitions)
- component capabilities (assumptions)
Ethical question. How much uncertainty is acceptable?