DirectBufferAllocTest fails after replacement of Thread.sleep() with Thread.onSpinWait()
Alan Bateman
Alan.Bateman at oracle.com
Tue Jun 21 07:00:51 UTC 2022
On 20/06/2022 22:58, David Holmes wrote:
>
> Thread.onSpinWait _is_ busy-waiting, but it may (depending on
> architecture) actually execute a more (power) efficient form of
> busy-wait.
>
> The takeaway from this exercise is that loops with sleeps can't always
> be replaced by loops that busy-wait. Functionally the logic is the
> same, but you can't just ignore the concurrency aspects.
Right, and in this case I don't think a busy wait would be very
efficient as it would require a very high max spin count. To date
Peter's exponential back-off has worked well and it's rare to hear about
OOME cases caused by code that that is allocating direct buffers for
single use. In time, I assume we will see more code using the new FFM
API which can support deterministic memory release.
-Alan
More information about the core-libs-dev
mailing list