RFR (S) : JDK-8245043 : Simplified contention benchmark
eric.caspole at oracle.com
eric.caspole at oracle.com
Tue May 19 14:24:50 UTC 2020
Thanks Sergey and David, I will clean this up - in the case I have been
working on I have been using locksSize=1 without further changes and so
I kind of ignored this part.
Eric
On 5/18/20 7:48 PM, Sergey Kuksenko wrote:
>
> On 5/18/20 4:35 PM, David Holmes wrote:
>> On 19/05/2020 8:38 am, Sergey Kuksenko wrote:
>>> 2. Does "volatile Table[] sharedLocks" need to be volatile?
>>
>> I think the intent is that the array needs to be published safely -
>> though without knowing full details of JMH it is impossible to see how
>> the array creation and filling relates to threads being started (ie
>> does setup() happen-before any threads are started? If so then
>> publication is already safe.) But if the intent is to do safe
>> publication then refreshArray is wrong:
>>
>> 85 void refreshArray() {
>> 86 sharedLocks = new Table[locksSize];
>> 87 for (int i = 0; i < locksSize; i++) {
>> 88 sharedLocks[i] = new Table(i);
>> 89 }
>> 90 }
>>
>> you would need to create a tmp array and fill it, then assign to
>> sharedLocks with the volatile write that publishes the array.
>
> JMH does safe publication between @Setup and @Benchmark methods. And
> yes, I was asking - because of either volatile is not required or tmp
> local array reference is required.
>
>
More information about the hotspot-runtime-dev
mailing list