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

Viktor Klang duke at openjdk.org
Fri Jul 21 14:20:47 UTC 2023


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

>> 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.

@DougLea I suspect that a good "governing principle" here is: is the timed park expected to be prematurely unparked, and is the delay sufficiently large to warrant compensation—use ManagedBlocker. Ideally (perhaps) the call to ManagedBlocker takes an "expected conservative estimate of blocking"-nanos, and then that behavior could be completely enclosed within the ManagedBlocker-construct itself (and thus be uniformly applied). It could also use heuristics about expected lifetime of compensating threads to see if it is justified to add one... Just thoughts off of the top of my head. 🤔

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

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


More information about the core-libs-dev mailing list