RFR: 8337657: AArch64: No need for acquire fence in safepoint poll during JNI calls
Dmitry Chuyko
dchuyko at openjdk.org
Thu Aug 1 13:42:02 UTC 2024
This is a tiny change to improve JNI calls performance on AArch64. In SharedRuntime::generate_native_wrapper() and TemplateInterpreterGenerator::generate_native_entry() safepoint_poll is made with acquire=true. It comes from the aarch64 implementation of Thread-local handshakes [0], [1]. Presently, it is no longer required [2].
Turning LDAR into regular load has significant performance effect. For instance, NativeCall benchmarks [3] by @simonis on Graviton 2 show following improvements:
-XX:-UseSystemMemoryBarrier (current default)
NativeCall.callingEmptyNative 8.04%
NativeCall.callingJniCriticalArray 1.01%
NativeCall.callingJniCriticalEmpty 6.73%
NativeCall.callingStaticEmpty 10.47%
NativeCall.methodCallingNativeWithArgs 10.73%
NativeCall.methodCallingNativeWithManyArgs 9.41%
NativeCall.staticMethodCallingStaticNativeIntStub 3.68%
NativeCall.staticMethodCallingStaticNativeNoTiered 9.86%
NativeCall.staticMethodCallingStaticNativeWithManyArgs 4.81%
-XX:+UseSystemMemoryBarrier
NativeCall.callingEmptyNative 33.70%
NativeCall.callingJniCriticalArray 3.64%
NativeCall.callingJniCriticalEmpty 34.15%
NativeCall.callingStaticArray 3.02%
NativeCall.callingStaticEmpty 34.25%
NativeCall.methodCallingNativeWithArgs 35.98%
NativeCall.methodCallingNativeWithManyArgs 34.42%
NativeCall.staticMethodCallingStaticNativeIntStub 15.66%
NativeCall.staticMethodCallingStaticNativeNoTiered 35.27%
NativeCall.staticMethodCallingStaticNativeWithManyArgs 32.99%
Similar improvements are observed on different CPUs.
It is especially interesting that -XX:+UseSystemMemoryBarrier variant began to show improvements in cases where there was parity.
Testing: tier1-3 on linux-aarch64.
[0] https://bugs.openjdk.org/browse/JDK-8189596
[1] https://mail.openjdk.org/pipermail/hotspot-dev/2017-November/029264.html
[2] https://mail.openjdk.org/pipermail/hotspot-compiler-dev/2024-July/078715.html
[3] https://github.com/simonis/Java2Native/tree/main/examples/jmh/java2native
-------------
Commit messages:
- Copyright year
- Safepoint poll with acquire=false in JNI entry/wrapper
Changes: https://git.openjdk.org/jdk/pull/20420/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20420&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8337657
Stats: 20 lines in 2 files changed: 0 ins; 15 del; 5 mod
Patch: https://git.openjdk.org/jdk/pull/20420.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20420/head:pull/20420
PR: https://git.openjdk.org/jdk/pull/20420
More information about the hotspot-dev
mailing list