-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simpler and faster lock-free linked list #1565
Conversation
|
|
d381216
to
5f6d127
Compare
Not ready for review yet. There is a potential problem with broken lists structure that should be investigate (still |
5a6a7d9
to
94b644f
Compare
94b644f
to
03b6d1d
Compare
It is ready for review now. Due to the previously merged improvements to |
Lock-free list implementation is considerably simplified, taking into account a limited number of operations that it needs to support. * prev pointers in the list are not marked for removal, since we don't need to support linearizable backwards iteration. * helpDelete method is completely removed. All "delete-helping" is performed only by correctPrev method. * correctPrev method bails out when the node it works on is removed to reduce contention during concurrent removals. * Special open methods "isRemoved" and "nextIfRemoved" are introduced and are overridden in list head class (which is never removed). This ensures that on long list "removeFist" operation (touching head) does not interfere with "addLast" (touch tail). There is still sharing of cache-lines in this case, but no helping between them. All in all, this improvement reduces the size of implementation code and makes it considerably faster. Operations on LinkedListChannel are now much faster (see timings of ChannelSendReceiveStressTest).
03b6d1d
to
0d59d15
Compare
* The problem was introduced by #1565. When doing concurrent add+removeFirst the following can happen: - "add" completes, but has not correct prev pointer in next node yet - "removeFirst" removes freshly added element - "add" performs "finishAdd" that adjust prev pointer of the next node and thus removed element is pointed from the list again * A separate LockFreeLinkedListAddRemoveStressTest is added that reproduces this problem. * The old LockFreeLinkedListAtomicLFStressTest is refactored a bit.
…st (#1845) * The problem was introduced by #1565. When doing concurrent add+removeFirst the following can happen: - "add" completes, but has not correct prev pointer in next node yet - "removeFirst" removes freshly added element - "add" performs "finishAdd" that adjust prev pointer of the next node and thus removed element is pointed from the list again * A separate LockFreeLinkedListAddRemoveStressTest is added that reproduces this problem. * The old LockFreeLinkedListAtomicLFStressTest is refactored a bit.
Lock-free list implementation is considerably simplified, taking into
account a limited number of operations that it needs to support.
don't need to support linearizable backwards iteration.
performed only by correctPrev method.
reduce contention during concurrent removals.
and are overriden in list head class (which is never removed).
This ensures that on long list "removeFist" operation (touching head)
does not interfere with "addLast" (touch tail). There is still
sharing of cache-lines in this case, but no helping between them.
All in all, this improvement reduces the size of implementation code
and makes it considerably faster. Operations on LinkedListChannel are
now much faster (see timings of ChannelSendReceiveStressTest).