I have a bunch of threads with a bunch of counters. Threads decrement the counters, and interesting things happen if a counter hits zero. This is trivial to implement with atomic ops.
However, it gets harder if we require two properties to hold regardless of the number of threads or counters:
- Scalability: Decrementing a counter is O(polylog).
- Compactness: The memory per counter is O(1).
I know how to do either one of these in isolation: the trivial implementation is compact and hierarchical counting networks [4] are scalable). Is it possible to do both?
Note: Since O(n) threads can't make O(n) different changes O(1) memory in time less than O(n), solving this requires sharing data structure between the different counters.
[4]: J. Aspnes, M. Herlily, and N. Shavit. Counting networks. Journal of the ACM, 41(5):1020-1048, Sept 1994.
Update: Jed Brown pointed out the obvious fact that O(1) time is impossible. Changed to polylog.