Integrated: 8337657: AArch64: No need for acquire fence in safepoint poll during JNI calls

Dmitry Chuyko dchuyko at openjdk.org
Fri Aug 9 17:59:37 UTC 2024


On Thu, 1 Aug 2024 13:36:26 GMT, Dmitry Chuyko <dchuyko at openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: 358d77da
Author:    Dmitry Chuyko <dchuyko at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/358d77dafbe0e35d5b20340fccddc0fb8f3db82a
Stats:     19 lines in 2 files changed: 0 ins; 15 del; 4 mod

8337657: AArch64: No need for acquire fence in safepoint poll during JNI calls

Reviewed-by: phh

-------------

PR: https://git.openjdk.org/jdk/pull/20420


More information about the hotspot-dev mailing list