1 / 20

Counting

Max Registers, Counters, and Monotone Circuits James Aspnes , Yale University Hagit Attiya , Technion Keren Censor, Technion. Counting. Counting is critical for some programs in multiprocessing systems Example: Algorithms for randomized consensus

step
Download Presentation

Counting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Max Registers, Counters, and Monotone CircuitsJames Aspnes, Yale UniversityHagitAttiya, TechnionKeren Censor, Technion

  2. 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 0 2 1

  3. 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) Counter +1 increment ok readCounter v

  4. 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]

  5. 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 long operation

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

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

  8. 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 Max Register WriteMax(v) Maximal value previously written ok ReadMax v

  9. A tree-based counter 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 …

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

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

  12. MaxRegk unfolded MaxRegk switch • Complexity does not depend on n: • WriteMaxand ReadMaxinO(k)steps … … switch switch switch MaxReg0 MaxReg0 MaxReg0 MaxReg0 MaxReg0 …

  13. A tree-based counter 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 …

  14. 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 • BothWriteMax and ReadMax of value v take O(min(log v, n)) steps

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

  16. Lower bound of min(log m, n-1) • No process takes steps after pn so pn does not write • 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 R pn reads pn reads

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

  18. 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

  19. 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

  20. Thank you

More Related