RFR: 8334234: NMT: Re-evaluate MallocMemory and VirtualMemory counter classes

Robert Toyonaga duke at openjdk.org
Mon Aug 12 16:57:43 UTC 2024


### Summary
This PR splits up NMT memory counter classes into "live" and "flat" versions. Currently, the same classes are used and reused in both live (recording) and snapshotted (reporting) contexts.  However, after counters have been shapshotted, they no longer need to be atomic or require things like peak updating. "Live" classes are now atomic and have methods needed for recording allocation/dealocation and updating peaks. "Flat" classes basically just hold data to later be reported, are not atomic, and only have methods for retrieving data. 

I've also made all counters  in `LiveVirtualMemory` update atomically, when previously only the peaks in `VirtualMemory` were updated atomically.  

**Testing**
- tier1
- jdk/test/hotspot/jtreg/gtest/NMTGtests.java
- jdk/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java

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

Commit messages:
 - split up atomic and flat counters. Make VirtualMemory fully atomic

Changes: https://git.openjdk.org/jdk/pull/20550/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20550&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8334234
  Stats: 305 lines in 14 files changed: 161 ins; 4 del; 140 mod
  Patch: https://git.openjdk.org/jdk/pull/20550.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20550/head:pull/20550

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


More information about the serviceability-dev mailing list