Advancements in Counting Algorithms for Multiprocessing Systems

undefined
 
Max Registers, Counters, and
Monotone Circuits
James Aspnes, Yale University
Hagit Attiya, Technion
Keren Censor, Technion
 
 
PODC 2009
Counting
 
Counting is critical for some programs in
multiprocessing systems
 
 
 
Example: Algorithms for randomized consensus
 
Required: Counters with sub-linear (in the number
of processes 
n
) step complexity per operation
PODC 2009
2
 
0
 
1
 
2
Counter
 
 
Model:
System of 
n
 processes
Asynchronous system: no timing assumptions
Implement using shared Read/Write registers
Crash failures: require wait-free implementations
 
Can be implemented using snapshots in linear time (in 
n
)
PODC 2009
3
Counter
increment
ok
readCounter
v
+1
Related work
 
Lower bound of 
(
n
)
 for time complexity by
Jayanti, Tan, and Toueg [PODC 1996]
and similar lower bounds by 
Ellen, Hendler, and
Shavit [FOCS 2005]
 
Motivated work on approximate counting
[Aspnes and C, SODA 2009]
PODC 2009
4
Exact counting
 
Give up on sub-linear exact counting?
Or inspect lower bound more carefully:
Based on executions with many increments
 
 
But some applications use a small number of increments
 
 
We show an implementation of a 
bounded
 counter
where each operation takes sub-linear time
PODC 2009
5
long operation
A tree-based counter
s
1
s
2
s
3
s
n
s
4
s
1
+s
2
s
3
+s
4
s
1
+...+s
4
∑s
i
s
n-1
+s
n
 
ReadCounter
:
 return value at root
 
Increment
: recursively
increment from leaf to root
+1
p
1 
increments
update
update
update
p
k 
reads
PODC 2009
6
O(log 
n
)
 
steps to increment
 
O(1)
 
steps to read counter
Seems nice, but…
If each node is a multi-writer register, then even for
2 processes and 2 increments this does not work
s
1
s
2
s
1
+s
2
+1
p
1 
increments
PODC 2009
p
2 
increments
+1
+1
+1
update 1
update 2
Counter is
incorrect
7
Max register
 
Replace multi-writer registers with Max
Registers
 
 
 
 
In this case the tree-based counter works
If max registers are linearizable then so is counter
PODC 2009
8
Max Register
WriteMax(
v
)
ok
ReadMax
v
Maximal value
previously
written
 
A tree-based counter
s
1
s
2
s
3
s
n
s
4
 
s
1
+s
2
s
3
+s
4
s
1
+...+s
4
∑s
i
 
 
s
n-1
+s
n
 
ReadCounter
:
return value at root
 
Increment
: recursively
increment from leaf to root
 
PODC 2009
 
9
Max register – recursive construction
 
MaxReg
0
: Max register that supports only the value 0
WriteMax
 is a no-op, and 
ReadMax
 returns 0
MaxReg
1
 supports values in {0,1}
Built from two MaxReg
0
 objects
and one additional multi-writer register “switch”
PODC 2009
MaxReg
0
10
MaxReg
0
MaxReg
0
switch
WriteMax
0
1
=1
ReadMax
 
= ?
 
switch=
0
 : return 
0
 
switch=
1
 : return 
1
Max register – recursive construction
MaxReg
k
 supports values in {0,…,2
k
-1}
Built from two MaxReg
k-1
 objects with values in {0,…,2
k-1
-1}
and one additional multi-writer register “switch”
PODC 2009
MaxReg
k-1
MaxReg
k-1
MaxReg
k
switch
WriteMax
t
t
 
< 2
k-1
 ?
t
t
-2
k-1
ReadMax
=1
 
= ?
t
t
 
switch=
0
 : return 
t
 
switch=
1
 : return 
t
+2
k-1
11
MaxReg
k
 unfolded
PODC 2009
switch
MaxReg
0
switch
switch
switch
MaxReg
0
MaxReg
0
MaxReg
0
MaxReg
0
Complexity does not depend on 
n
:
WriteMax
 
and 
ReadMax
in
 
O(
k
)
 
steps
MaxReg
k
12
A tree-based counter
s
1
s
2
s
3
s
n
s
4
s
1
+s
2
s
3
+s
4
s
1
+...+s
4
∑s
i
s
n-1
+s
n
ReadCounter
:
return value at root
Increment
: recursively 
increment from leaf to root
PODC 2009
13
m
-valued counter:
ReadCounter
:
 O(log 
m
)
 
steps
Increment
: 
O(log 
n
 log 
m)
 
steps
Analysis
 
Inductive linearizability proof
No contradiction with lower bound of JTT
because of bounded size of max register and
counter
Extension to 
unbounded
 max registers (and
counters) with complexity according to value
written or read
Both
 WriteMax
 and 
ReadMax
 of value 
v
 take
O(min(log 
v, n
)) 
steps
PODC 2009
14
Lower bound of 
min(log 
m
, 
n-1
)
 
S
m
 = {executions with 
WriteMax
 operations up to
value 
m
 by p
1
…,p
n-1
, followed by one 
ReadMax
operation by p
n
}
 
 
T(m,n) 
= worst case cost of 
ReadMax
 in 
S
m
PODC 2009
15
p
n
 reads
Lower bound of 
min(log 
m
, 
n-1
)
 
No process takes steps after p
n
 so p
n
 does not write
 
 
 
Reads a fixed register 
R
. Did anyone write to 
R
?
k
 = minimal such that there is a write to 
R
 in 
S
k
No one in 
S
k-1
 writes to 
R
 so 
T(m,n)≥T(k-1,n)+1
PODC 2009
16
 
p
n
 reads
 
p
n
 reads
R
Lower bound of 
min(log 
m
, 
n-1
)
In addition, consider a run in 
S
k
 that writes to 
R
PODC 2009
17
 
write to 
R 
by p
i
Finish writes
except by p
i
Non-concurrent
writes in {k,…,m}
 
write to 
R 
by p
i
 
T(m,n)
T(m-k+1,n-1)+1
 
p
n
 returns maximal value from {k,…,m}
 
p
n
 reads
 
Solve recurrence:
T(m,n) 
≥ 1+ min
k
 {max(
T(k-1,n),  T(m-k+1,n-1))
}
 
, we had 
T(m,n)≥T(k-1,n)+1
R
R
 
p
n
 reads
Summary
 
Implementation of max registers with
O(min(log 
v
, 
n
)) 
steps per operation writing
or reading the value 
v
Sub-linear implementation of counters
Extension of counters to any monotone circuit
with 
monotone consistency
 instead of
linearizability
PODC 2009
18
Summary
 
Lower bounds
An alternative proof for JTT
Tight lower bound for max registers
Same lower bound proof for counters
Further research: close gap between upper and
lower bounds on counters
Randomized lower bound
Further research: randomized algorithm?
 
Take-home message:
Lower bounds do not always have the final say
PODC 2009
19
 
 
 
Thank you
 
PODC 2009
 
20
Unbalanced tree
PODC 2009
MaxReg
0
switch
switch
switch
switch
MaxReg
0
MaxReg
0
21
Bentley and Yao [1976]
switch
switch
switch
MaxReg
0
MaxReg
0
MaxReg
0
MaxReg
0
Leaf 
i
 is at
depth 
O(log 
i
)
Unbounded max register
PODC 2009
MaxReg
0
switch
switch
Snapshot-based
counter
switch
switch
MaxReg
0
MaxReg
0
22
Slide Note
Embed
Share

Presentation of key concepts and advancements in counting algorithms for multiprocessing systems, focusing on topics like max registers, counters, and monotone circuits. Discusses the importance of efficient counting in achieving consensus, crash failure requirements, and lower bounds for time complexity. Explores different approaches such as tree-based counters and the use of Max Registers as solutions to counter implementation challenges.

  • Counting Algorithms
  • Multiprocessing Systems
  • Max Registers
  • Consensus Algorithms

Uploaded on Oct 02, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Max Registers, Counters, and Monotone Circuits James Aspnes, Yale University Hagit Attiya, Technion Keren Censor, Technion PODC 2009

  2. Counting 2 Counting is critical for some programs in multiprocessing systems 0 1 2 Example: Algorithms for randomized consensus Required: Counters with sub-linear (in the number of processes n) step complexity per operation PODC 2009

  3. Counter 3 increment ok +1 Counter Model: readCounter v System of n processes Asynchronous system: no timing assumptions Implement using shared Read/Write registers Crash failures: require wait-free implementations Can be implemented using snapshots in linear time (in n) PODC 2009

  4. Related work 4 Lower bound of (n) for time complexity by Jayanti, Tan, and Toueg [PODC 1996] and similar lower bounds by Ellen, Hendler, and Shavit [FOCS 2005] Motivated work on approximate counting [Aspnes and C, SODA 2009] PODC 2009

  5. Exact counting 5 Give up on sub-linear exact counting? Or inspect lower bound more carefully: Based on executions with many increments long operation But some applications use a small number of increments We show an implementation of a bounded counter where each operation takes sub-linear time PODC 2009

  6. A tree-based counter 6 Increment: recursively increment from leaf to root p1 increments ReadCounter: return value at root pk reads si +1 update s1+...+s4 O(log n) steps to increment O(1) steps to read counter update s1+s2 s3+s4 sn-1+sn update s1 s2 s3 s4 sn PODC 2009

  7. Seems nice, but 7 If each node is a multi-writer register, then even for 2 processes and 2 increments this does not work p1 increments p2 increments +1 +1 Counter is incorrect +1 +1 s1+s2 update 1 update 2 s1 s2 PODC 2009

  8. Max register 8 Replace multi-writer registers with Max Registers WriteMax(v) Maximal value previously written ok Max Register ReadMax v In this case the tree-based counter works If max registers are linearizable then so is counter PODC 2009

  9. A tree-based counter 9 Increment: recursively increment from leaf to root ReadCounter: return value at root si s1+...+s4 s1+s2 s3+s4 sn-1+sn s1 s2 s3 s4 sn PODC 2009

  10. Max register recursive construction 10 MaxReg0: Max register that supports only the value 0 WriteMax is a no-op, and ReadMax returns 0 MaxReg0 MaxReg1 supports values in {0,1} Built from two MaxReg0 objects and one additional multi-writer register switch =1 0 1 WriteMax = ? switch ReadMax switch=0 : return 0 MaxReg0 MaxReg0 switch=1 : return 1 PODC 2009

  11. Max register recursive construction 11 MaxRegksupports values in {0, ,2k-1} Built from two MaxRegk-1objects with values in {0, ,2k-1-1} and one additional multi-writer register switch =1 t t WriteMax < 2k-1 ? = ? switch t-2k-1 t ReadMax t t switch=0 : return t MaxRegk-1 MaxRegk-1 switch=1 : return t+2k-1 MaxRegk PODC 2009

  12. MaxRegk unfolded 12 MaxRegk switch Complexity does not depend on n: WriteMax and ReadMax in O(k) steps switch switch switch MaxReg0 MaxReg0 MaxReg0 MaxReg0 MaxReg0 PODC 2009

  13. A tree-based counter 13 Increment: recursively increment from leaf to root ReadCounter: return value at root si m-valued counter: ReadCounter: O(log m) steps Increment: O(log n log m)steps s1+...+s4 s1+s2 s3+s4 sn-1+sn s1 s2 s3 s4 sn PODC 2009

  14. Analysis 14 Inductive linearizability proof No contradiction with lower bound of JTT because of bounded size of max register and counter Extension to unbounded max registers (and counters) with complexity according to value written or read Both WriteMax and ReadMax of value v take O(min(log v, n)) steps PODC 2009

  15. Lower bound of min(log m, n-1) 15 Sm = {executions with WriteMax operations up to value m by p1 ,pn-1, followed by one ReadMax operation by pn} pn reads T(m,n) = worst case cost of ReadMax in Sm PODC 2009

  16. Lower bound of min(log m, n-1) 16 No process takes steps after pn so pn does not write pn reads pn reads R Reads a fixed register R. Did anyone write to R? k = minimal such that there is a write to R in Sk No one in Sk-1 writes to R so T(m,n) T(k-1,n)+1 PODC 2009

  17. Lower bound of min(log m, n-1) 17 In addition, consider a run in Sk that writes to R write to R by pi pn reads R write to R by pi Finish writes except by pi Non-concurrent writes in {k, ,m} R pn reads pnreturns maximal value from {k, ,m} T(m,n) T(m-k+1,n-1)+1 Solve recurrence: T(m,n) 1+ mink {max(T(k-1,n), T(m-k+1,n-1))} , we had T(m,n) T(k-1,n)+1 PODC 2009

  18. Summary 18 Implementation of max registers with O(min(log v, n)) steps per operation writing or reading the value v Sub-linear implementation of counters Extension of counters to any monotone circuit with monotone consistency instead of linearizability PODC 2009

  19. Summary 19 Lower bounds An alternative proof for JTT Tight lower bound for max registers Same lower bound proof for counters Further research: close gap between upper and lower bounds on counters Randomized lower bound Further research: randomized algorithm? Take-home message: Lower bounds do not always have the final say PODC 2009

  20. 20 Thank you PODC 2009

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#