[concurrency-interest] ConcurrentLinkedQueue padding

Nathan and Ila Reynolds nathanila at gmail.com
Wed Nov 22 11:46:20 EST 2017

Also, each thread most likely has its own Thread Local Allocation Buffer 
(TLAB).  With multiple threads enqueuing, each thread will create a node 
from its own TLAB.  Thus, the nodes from different threads will not be 
able to share the same cache line.  I could see this as being a bad 
thing.  Ideally, we would want all of the nodes to be packed as close as 
possible to each other to improve cache locality and hence performance.  
If a thread is simply reading through the nodes, then this will 
definitely help performance.  If a thread is CASing, then only 1 thread 
should be accessing the cache line anyway.


On 11/22/2017 9:06 AM, Martin Buchholz via Concurrency-interest wrote:
> None of the linked list based node classes use @Contended.  Node 
> classes tend to be small and @Contended adds a lot of memory 
> overhead.  When multiple threads are enqueueing, you're likely instead 
> to get "true sharing" contention as they all try to CAS the very same 
> next link.
> On Tue, Nov 21, 2017 at 1:33 PM, Carl Mastrangelo via 
> Concurrency-interest <concurrency-interest at cs.oswego.edu 
> <mailto:concurrency-interest at cs.oswego.edu>> wrote:
>     Hi concurrency interest,
>     I was looking through ConcurrentLinkedQueue and noticed that
>     unlike several of the other concurrent classes, the volatile Node
>     pointers as well as the Nodes themselves don't have any padding. 
>     This makes me wonder, could there be false sharing when using
>     multiple producers to add to the queue?  I was under the
>     impression that the GC tends to group fields of a class near each
>     other, which would imply that there is going to likely be
>     contention when quickly updating (and reading) from it.
>     Carl
>     _______________________________________________
>     Concurrency-interest mailing list
>     Concurrency-interest at cs.oswego.edu
>     <mailto:Concurrency-interest at cs.oswego.edu>
>     http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>     <http://cs.oswego.edu/mailman/listinfo/concurrency-interest>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20171122/47e8c54c/attachment-0001.html>

More information about the Concurrency-interest mailing list