Spin Loop Hint support: Draft JEP proposal
gil at azulsystems.com
Tue Oct 6 04:32:43 UTC 2015
> On Oct 5, 2015, at 1:56 AM, Aleksey Shipilev <aleksey.shipilev at oracle.com> wrote:
> Hi Gil,
> Glad to see this being addressed!
> On 10/04/2015 07:22 PM, Gil Tene wrote:
>> We propose to add a method to the JDK which would be hint that a spin
>> loop is being performed. E.g.
>> jdk.util.PerformanceHints.spinLoopHint(), which will hopefully evolve
>> to a Java SE API, e.g. java.util.PerformanceHints.spinLoopHint(). The
>> specific name space location, class name, and method name will be
>> determined as part of development of this JEP.
> Yes, that would be a tough part. JDK is usually oblivious of these
> low-level platform-specific hints, they go to sun.misc.* (e.g. Unsafe,
> @Contended and others...). I'll let Project Leads to make that call :)
I don't think of this as platform specific. And it's not much lower level than e.g. some java.util.concurrent stuff (but probably doesn't belong in that package because it's not really about concurrency). I'm looking for a proper Java SE spec'ed way to do this. So sun.misc.* won't work. I'm sure we don't want another Unsafe for people to abuse...
But naming the class and method is the smaller, easier detail. Right? ;-)
>>  HotSpot WebRevs for prototype implementation which intrinsifies
> * product_pd (platform-dependent) flags can be used to conditionalize
> the support on a platform. This helps to avoid vm_version_* tricks.
> * Does spinloophint imply membar as well? x86_64.ad suggests so.
> library_call.cpp suggests so. It seems weird to conflate the two, even
> though it's understandable you want to piggyback on existing machinery.
Semantically. spinLoopHint() has zero semantic requirements, and therefore no
implied behavior of any kind (no membar).
We implemented the pause intrinsic as a variant representation of a membar
because that was one relatively simple way of having it stay within the loop (or
with whatever control flow it is under). The "membar" variant implementation
doesn't prohibit reordering of loads or stores.
> * I think spinLoopHint() misses a @HotspotIntrinsicCandidate annotation.
Will add that in future prototypes.
More information about the core-libs-dev