JDK-8322535 : Change default AArch64 SpinPause instruction
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,os_x
  • CPU: aarch64
  • Submitted: 2023-12-20
  • Updated: 2024-02-14
  • Resolved: 2024-02-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b09Fixed
Related Reports
Relates :  
Description
The Java options OnSpinWaitInst lets you choose which AArch64 instruction should be used in SpinPause(). Valid values are "none", "nop", "isb" and "yield".

Today this option is only available on Linux but JDK-8321371 will bring the same functionality to MacOS.

The default value for OnSpinWaitInst is unfortunately "none".

However hotspot/cpu/aarch64/vm_version_aarch64.cpp contains code that recognizes some CPUs and changes the SpinPause instruction to something better if the user hasn't used the OnSpinWaitInst option. For instance if you run a Neoverse N1, N2, V1 or V2, the default SpinPause instruction will be changed to "isb".

For reasons discussed in JDK-8321371 I think we should change the default value to "yield". I also think we should do measurements on Apple M1, M2 etc. and make sure we change the default to whatever is best for those CPUs (the same way Neoverse changes the default value to "isb").

Comments
Changeset: f356970b Author: Fredrik Bredberg <fbredberg@openjdk.org> Committer: Coleen Phillimore <coleenp@openjdk.org> Date: 2024-02-06 13:25:38 +0000 URL: https://git.openjdk.org/jdk/commit/f356970b8930c6ec122d797d84503a6e86d67526
06-02-2024

Attached a file (spin_pause.c) which can be used to measure the execution time for different instructions that are more or less suitable for use in SpinPause(), e.g. nop, pause, yield, isb.
06-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17430 Date: 2024-01-15 16:25:08 +0000
16-01-2024

Created a test program to measure how long time it takes to issue a large number of instructions from several threads running in parallel. Tested the nop, yield and isb instructions on Apple's M1, M2 and M3 CPUs. Concluded that the yield instruction doesn't take longer to execute than a nop instruction (in fact it takes less time than nop). However isb always takes significantly longer time to run than nop or yield on all of the above mentioned Apple CPUs. Therefore we should default to isb for SpinPause on those Apple CPUs.
15-01-2024