RFR: 8200697: Add utility for spin wait with fallback to yield/sleep
David Holmes
david.holmes at oracle.com
Wed Apr 4 23:42:50 UTC 2018
Hi Kim,
If this works you for then by all means use it.
Whether it is useful as a general utility is something I am doubtful of.
Degrading spin-loops are put in for performance reasons and generally
have to interact with surrounding code that captures exactly what is
being waited upon. There is also the issue of thread-state transitions
that need to be carefully managed.
Cheers,
David
On 5/04/2018 4:53 AM, Kim Barrett wrote:
> Please review this addition of SpinYield utility class.
>
> It initially supplies a very simple policy: spin a configured number
> of times, then switch to yielding or (eventually) sleeping. Other
> policies may replace this one or be provided as alternatives in the
> future.
>
> This is joint work with Robbin Ehn.
>
> Robbin and I have immediate uses for this utility in changes we are
> developing. In addition, there are some existing places that might be
> converted to use this utility (or perhaps some extended version of
> it), including SafepointSynchronize::begin, ReadStableMark,
> Thread::SpinAcquire, and ParallelTaskTerminator::offer_termination.
> Those existing potential uses are not being changed here; for now,
> we're just adding the utility in support of our in-development
> changes. We plan to file followup RFEs to consider converting those
> potential uses.
>
> CR:
> https://bugs.openjdk.java.net/browse/JDK-8200697
>
> Webrev:
> http://cr.openjdk.java.net/~kbarrett/8200697/open.00/
>
> Testing:
> Added unit test of basic functionality.
> Build and hs-tier1 (for gtest) on all Oracle platforms.
>
More information about the hotspot-dev
mailing list