[concurrency-interest] spinLoopHint() JEP draft discussion

Gil Tene gil at azulsystems.com
Tue Oct 6 14:56:46 EDT 2015

A variant of synchronic for j.u.c would certainly be cool to have. Especially if it supports a hint that makes it actually spin forever rather than block (this may be what expect_urgent means, or maybe a dedicated spin level is needed). An implementation could use spinLoopHint() under the hood, or other things where appropriate (e.g. if MWAIT was usefully available in user mode in some future, and had a way to limit the wait time).

However, an abstraction like synchronic is a bit higher level than spinLoopHint(). One of the main drivers for spinLoopHint() is direct-use cases by programs and libraries outside of the core JDK. E.g. spinning indefinitely (or for limited periods) on dedicated vcores is a common practice in high performance messaging and communications stacks, as is not unreasonable on today's many-core systems. E.g. seeing 4-8 threads "pinned" with spinning loops is common place in trading applications, in kernel bypass network stacks, and in low latency messaging. And the conditions for spins are often more complicated than those expressible by synchronic (e.g. watching multiple addresses in a mux'ed spin). I'm sure a higher level abstraction for a spin wait can be enriched enough to come close, but there are many current use cases that aren't covered by any currently proposed abstraction.

So, I like the idea of an abstraction that would allow uncomplicated spin-wait use, but I also think that direct access to spinLoopHint() is very much needed. They don't contradict each other.

— Gil.

> On Oct 6, 2015, at 9:49 AM, Hans Boehm <boehm at acm.org> wrote:
> If you haven't seen it, you may also be interested in
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0126r0.pdf <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0126r0.pdf>
> which seems to be a very different perspective on roughly the same space.
> On Tue, Oct 6, 2015 at 8:11 AM, Gil Tene <gil at azulsystems.com <mailto:gil at azulsystems.com>> wrote:
> I posted a draft JEP about adding spinLoopHint() for discussion on core-libs-dev and hotspot-dev. May be of interest to this group. The main focus is supporting outside-of-the-JDK spinning needs (for which there are multiple eager users), but it could/may be useful under the hood in j.u.c.
> http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-October/035613.html <http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-October/035613.html>
> See draft JEP, tests, and links to prototype JDKs to play with here:
> https://github.com/giltene/GilExamples/tree/master/SpinHintTest <https://github.com/giltene/GilExamples/tree/master/SpinHintTest>
> — Gil.
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu <mailto:Concurrency-interest at cs.oswego.edu>
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest <http://cs.oswego.edu/mailman/listinfo/concurrency-interest>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20151006/4ca37481/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20151006/4ca37481/attachment.bin>

More information about the Concurrency-interest mailing list