Skip to content

Commit

Permalink
Simpler and faster lock-free linked list
Browse files Browse the repository at this point in the history
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 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).

A known (at still open) problem is that in ConflatedChannel a receiver
can starve in scenarios with multiple senders, constantly trying to help
them. Fixing this starvation is out of the scope of this improvement.
  • Loading branch information
elizarov committed Oct 2, 2019
1 parent af09e01 commit 4b62d3b
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 196 deletions.
Loading

0 comments on commit 4b62d3b

Please sign in to comment.