[concurrency-interest] Spin Loop Hint support: Draft JEP

Martin Thompson mjpt777 at gmail.com
Tue Dec 1 09:13:44 EST 2015


On 1 December 2015 at 13:46, Vitaly Davidovich <vitalyd at gmail.com> wrote:

> Relax was a suggested name that fits with the current Linux kernel
>> convention. However it was felt this suggested implementation rather than
>> notifying state.
>
>
> Yes, 'relax' is a well known term for this, and sticking to known
> conventions/terms is desirable.  I don't see how it suggests implementation
> though, nor even if it did suggest anything, why that's a bad thing.  If we
> want to avoid any suggestions, let's call it "foobar" :).
>

Thread.relax() was my initial suggestion. I'll leave it to the others for
why they did not think this was suitable.


> The "on" prefix was suggested as the caller is notifying the runtime that
>> it is in a spin-wait loop. This allows the runtime the option of reacting
>> to the event, or not, and allows flexibility in how it chooses to react to
>> this information. The method is not waiting; the method is notifying that
>> the caller is waiting.
>
>
> Yes, but we don't have Runtime.onGC() or Runtime.onRunFinalization(), and
> both of those are documented as "suggesting" the VM perform those actions.
>  spinLoopHint() sounded much better than what's proposed here, and carries
> the suggestion/hint/optionality that's desired.  IMHO, onSpinWait() is the
> least appealing options proposed thus far.
>

System.gc() and Runtime.runFinalizersOnExit(boolean) are clear instructions
to the system/runtime to do something in an imperative fashion. The
onSpinWait() is a declarative statement about the state of the current
thread. I can understand a dislike to a name. We all have personal taste on
this but I don't think you are comparing similar semantics.

Consider the runtime as an object. You send it a message via a method. What
exactly is spinLoopHint() telling the Runtime what to do? It is applying an
event but not expressing it via any convention. "spinLoopHint()" works for
me on a Thread to an extent. We should express intent or declare status for
this. Hints don't fit comfortably in a programming model.

The actual naming does not matter so much as this will only be used by
minority of programmers. I'll prepare to be flamed on that :-) However it
is desperately needed and anything that makes it slip the date to make Java
9 would be such a let down.

Martin...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20151201/0e13328b/attachment.html>


More information about the Concurrency-interest mailing list