On Sun, 12 May 2024 13:05:48 GMT, Doug Lea <d...@openjdk.org> wrote:

>> The goal is to reduce the worst form of contention: when queue arrays are 
>> laid out adjacently in memory. Increasing sizes has some impact but with 
>> diminishing returns. Thanks for the comment as a reminder that I haven't 
>> rechecked this lately in light of other layout changes. Will do.
>
> After recheckiing, the best policy is to leave internal queues the same, but 
> initialize external queues larger.

Probably a misplaced post again, but why can't you allocate an array of arrays
where the outer array is 30
and the inner array will be doubled, 
then the segment can be calculated by log(index)
with: resize O(1), read/write O(1).

This approach can also be used in ConcurrentHashMap
sample implementation 
https://github.com/sunmisc/wormhole/blob/main/main/src/main/java/sunmisc/utils/concurrent/memory/ReferenceSegmentMemory.java

I don't know if this method exists anywhere else, I invented it, maybe it was 
invented before me.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19131#discussion_r1610669070

Reply via email to