RFR: 8301341: LinkedTransferQueue does not respect timeout for poll() [v8]

Doug Lea dl at openjdk.org
Fri Jul 21 11:19:43 UTC 2023


On Fri, 21 Jul 2023 10:55:19 GMT, Doug Lea <dl at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java line 446:
>> 
>>> 444:                         Thread.onSpinWait();
>>> 445:                     else
>>> 446:                         LockSupport.parkNanos(ns);
>> 
>> @DougLea If `ns` is sufficiently large, would it not make sense to use managed blocking in case the current thread is a FJWT as below? 🤔
>
> It's a good point, but we don't normally do this. Added (L336):
>      * returns just barely too soon. As is the case in most j.u.c
>      * blocking support, untimed waits use ManagedBlockers when
>      * callers are ForkJoin threads, but timed waits use plain
>      * parkNanos, under the rationale that known-to-be transient
>      * blocking doesn't require compensation. (This decision should be
>      * revisited here and elsewhere to deal with very long timeouts.)

I should have mentioned that the tradeoffs include that using ManagedBlocking for timed waits here adds overhead: -- constructing of another object just to track the time, and duplicate checks of other parts of await(. Which requires choosing a threshold where it would be worthwhile. Which is  a hard-to-win decision.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14317#discussion_r1270561315


More information about the core-libs-dev mailing list