Hello core-libs-dev,
I've found under some circumstances that the
java.util.concurrent.LinkedBlockingQueue class can suffer from false
sharing on the "head" and "last" fields. By using the @Contended annotation on
those fields, this can be reduced when
the rate of queuing is high.
When doing so, the improvement that we see with the
o.o.b.j.util.concurrent.ProducerConsumer microbenchmark is on the
order of 40% to 13%. On one platform the result is reduced from 360ns/op down
to 206ns/op, and at worst another platform
sees a result of 238ns/op reduced to 207ns/op.
However, there is a size penalty, running with compressed references the change
in size of LinkedBlockignQueue objects
is from 40 to 424 bytes and for uncompressed 64-bit references the change is
from 72 to 456 bytes. However, our
expectation is that LinkedBlockingQueue instances would be few in number.
The circumstances where this is likely to occur is when a LinkedBlockingQueue
is highly contended, with the producer and
consumer rapidly queuing and dequeuing small pieces of work.
In my research I've not noticed any discussion of @Contended in this particular
circumstance. I'd like to know if it has
been discussed elsewhere, and under what circumstances would such a change be
accepted? While an improvement on
contended fields can be easily demonstrated, the overall effect on heap size
and cache pollution is more difficult to
demonstrate.
Many thanks,
Stuart
IMPORTANT NOTICE: The contents of this email and any attachments are
confidential and may also be privileged. If you are not the intended recipient,
please notify the sender immediately and do not disclose the contents to any
other person, use it for any purpose, or store or copy the information in any
medium. Thank you.