Concurrent stack does not existSome weeks ago I read this thought-provoking article by Nir Shavit "Data Structures in the Multicore Age"(PDF). The topic is about efficiency of concurrent data structures. There have been many thinkings going on after the reading, but the most interesting point to me is that the author started trying to use a "concurrent stack", but ended up happily using a pool.
Now there can be several interesting questions to ask. Can we give up some property of a data structure if it is crucial to the correctness of the program? If we can give up the LIFO ordering, then why did we think we need a stack? But the most interesting question is probably:
I think the answer is No --- a "concurrent stack" hasn't ever existed. Here is why:
From the above, we can see that there is a fundamental conflict between the two notions, "concurrency" and a "stack".
If we have realized that the essence of a stack is a continuation, and a continuation (by itself) is sequential, then it is no surprise we arrive at this conclusion. Since a LIFO order is essential to a stack, we can't call the data structure a "stack" if we can't maintain a LIFO order.
Even if we continue to think that we are using a stack, the threads are in effect just distributing messages, with the operations "push = send" and "pop = receive". So in essence this data structure is a pool. This exactly justifies the author's relaxation to a pool, although no actual relaxation happens --- the data structure has been a pool from the beginning. It was just disguised as a stack and less efficient. So we see that the concept of a "concurrent stack" does not really exist. We also see that some data structures we have in the sequential world may not have concurrent counterparts. |