RFR: 8319447: Improve performance of delayed task handling
Doug Lea
dl at openjdk.org
Tue Feb 25 22:44:00 UTC 2025
On Tue, 25 Feb 2025 19:42:01 GMT, Sunmisc Unsafe <duke at openjdk.org> wrote:
>> Is it possible to use getAndSet instead of cas-loop on #pend?
>>
>> final Task t = tail.getAndSet(task);
>> t.next = task;
>>
>> but that would require a new head field to bypass, probably not worth the gamble if the footprint increases a lot
>
>> @sunmisc You are right that it would be nice if there were a way to efficiently use getAndSet here because a failed reference CAS hits slow paths that vary across GCs. But all of the ways I know to do this are much worse.
>
> After a few days of benchmarks, I realized that you would be absolutely right. Although I thought if we separate the head (for deleting) and the tail (for inserting) there would be less contention.
> Even the fact that we can change the head (delete) only in one thread does not help us from volatile, moreover, it became worse.
> Perhaps I have made a mistake somewhere in the implementation
@sunmisc Thanks for independently trying alternatives. We both had reasons to suspect that other mechanics might work out as well or better, but none seem to.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23702#issuecomment-2683456519
More information about the core-libs-dev
mailing list