RFR: JDK-8296764 NMT: reduce loads in os::malloc
Ioi Lam
iklam at openjdk.org
Thu Nov 10 23:35:07 UTC 2022
On Thu, 10 Nov 2022 06:11:28 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> We read the NMT level at every ps::malloc/realloc/free etc, even if NMT is off. That is unavoidable. But we also read a second variable that shadows the NMT level `_nmt_was_initialized`. That state is synonymous with NMT level "unknown," so there is no need for this second load.
>
> Furthermore, NMT level is volatile. That had been necessary in older times since we used to shut down NMT on resource exhaustion. But since [JDK-8256844](https://bugs.openjdk.org/browse/JDK-8256844), NMT level is fixed at initialization, so we can remove the volatile specifier.
>
> Patch
> - removes `_nmt_was_initialized` and redirects it to `MemTracker::is_initialized()`, which gets inlined to a load of NMT level.
> - makes NMT level non-volatile
> - removes _is_nmt_env_valid, which had been dead code
src/hotspot/share/services/nmtPreInit.cpp line 182:
> 180: // in post-init, no modifications to the lookup table are possible.
> 181: void NMTPreInit::pre_to_post() {
> 182: assert(MemTracker::is_initialized() == false, "just once");
Maybe this should be `!MemTracker::is_initialized()` to be consistent with the rest of the code?
test/hotspot/gtest/nmt/test_nmtpreinit.cpp line 116:
> 114: }
> 115: void test_post() {
> 116: assert(!MemTracker::is_initialized() == false,
Hmm, I am confused by the double negation :-)
-------------
PR: https://git.openjdk.org/jdk/pull/11080
More information about the hotspot-runtime-dev
mailing list