Visit Azul.com Support

Spin Loop Hint

Need help?
Schedule a consultation with an Azul performance expert.
Contact Us

The Intel x86 processors with the SSE2 instruction set contain a new instruction Pause that indicates that the CPU, which is currently running the thread, is effectively in a spin loop. Encountering such an indicator can help the CPU give more compute resources to other running threads by optimizing thread scheduling and thread switches. The new SpinHint java API helps the Azul Zing Builds of OpenJDK (Zing) to emit the x86 Pause instruction where the spinLoopHint method is being called. It does not change the semantics of the java code in any way.

Note
Use the spin loop hint with caution. For additional guidance and information on this advanced tuning instruction, contact Azul Technical Support.

To use spin loop hint with Zing do the following:

  1. Import the package org.performancehints.

  2. Add a call SpinHint.spinLoopHint() where you want to hint to the CPU that this location is a spin loop.

The example below illustrates how to use SpinHint.

SpinHintLoopGilExample