Spin Loop Hint support: Draft JEP proposal (original) (raw)
Gil Tene gil at azulsystems.com
Tue Oct 6 04:32:43 UTC 2015
- Previous message: Spin Loop Hint support: Draft JEP proposal
- Next message: Spin Loop Hint support: Draft JEP proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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? ;-)
[4] HotSpot WebRevs for prototype implementation which intrinsifies org.performancehintsSpinHint.spinLoopHint() http://ivankrylov.github.io/spinloophint/webrev/ <http://ivankrylov.github.io/spinloophint/webrev/> * productpd (platform-dependent) flags can be used to conditionalize the support on a platform. This helps to avoid vmversion* tricks.
Thx.
* Does spinloophint imply membar as well? x8664.ad suggests so. librarycall.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.
Thanks, -Aleksey
- Previous message: Spin Loop Hint support: Draft JEP proposal
- Next message: Spin Loop Hint support: Draft JEP proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]