RFR: 8322535: Change default AArch64 SpinPause instruction
Andrew Haley
aph at openjdk.org
Tue Jan 16 16:54:20 UTC 2024
On Tue, 16 Jan 2024 15:50:56 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:
> > Your customers are running cloud apps on Apple M1/M2?
>
> In theory they could. M1, M2 and M2 Pro instances are available in cloud. However I am not aware any such cases.
Right.
> > Yeah, I know. What I don't know is how much of a cargo cult this is. Apple M1 etc. have very large reorder buffers, and serializing all instructions may not be the best plan.
>
> I hope hardware engineers will notice this improper uses of ISB and will either implement YIELD or something equivalent to it. YIELD could be an alias of a new instruction.
I think the problem is that the right amount of time to spin for is application dependent. It also depends on things like the way the memory coherence system works, which is architecturally very different on Apple designs.
We could do something less violent than ISB for SpinPause. We could execute a bunch of UDIV instructions with a loop-carried dependency, or cycle an xor-shift generator. That could be made to delay for any number of clock cycles, so we can delay without the side effects of an ISB. We could try to measure how many cycles ISB takes in the "good" cases and design a delay that takes as long as an ISB without disrupting everything else.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17430#issuecomment-1894131403
More information about the hotspot-dev
mailing list