RFR: 8317453: NMT: Performance benchmarks are needed to measure speed and memory [v9]

Gerard Ziemski gziemski at openjdk.org
Tue Apr 29 19:10:23 UTC 2025


> Please review this addition of an internal benchmark, mostly of interest to those working with NMT.
> 
> This benchmark allows us to record a pattern of memory allocation operations (i.e. `malloc`, `realloc` and `free`) as well as the virtual memory allocations (i.e. `VirtualMemoryTracker::add_reserved_region`, etc.) and record those into files.
> 
> Later we can use that recording to _play back_ the pattern with different code or settings to compare the performance (i.e. memory usage as well as time).
> 
> The goal of this benchmark is for anyone working on NMT to be able to measure and prove whether their improvement helps or regresses the performance.
> 
> ### To use it:
> 
> To record pattern of allocations of memory calls:
> 
> `NMTRecordMemoryAllocations=0x7FFFFFFF ./build/macosx-aarch64-server-release/xcode/build/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -jar build/macosx-aarch64-server-release/images/jdk/demo/jfc/J2Ddemo/J2Ddemo.jar`
> 
> OR to record pattern of allocations of virtual memory calls:
> 
> `NMTRecordVirtualMemoryAllocations=0x7FFFFFFF ./build/macosx-aarch64-server-release/xcode/build/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -jar build/macosx-aarch64-server-release/images/jdk/demo/jfc/J2Ddemo/J2Ddemo.jar`
> 
> This will result in the file:
> -  hs_nmt_pid22770_allocs_record.log (is the chronological record of the the desired operations)
> OR
> - hs_nmt_pid22770_virtual_allocs_record.log (is the chronological record of the desired operations)
> 
> And 2 additional files:
> - hs_nmt_pid22770_info_record.log (is the record of default NMT memory overhead and the NMT state)
> - hs_nmt_pid22770_threads_record.log (is the record of thread names that can be retrieved later when processing)
> 
> 
> then to actually run the benchmark:
> 
> NMTBenchmarkRecordedPID=22770 ./build/macosx-aarch64-server-release/xcode/build/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary
> 
> ### Usage:
> 
> See the issue for more details and the design document.

Gerard Ziemski has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 20 commits:

 - Merge remote-tracking branch 'upstream/master' into JDK-8317453
 - simplify ifdefs
 - expose NMTRecorder_Locker on Windows
 - expose NMTRecorder_Locker on Windows
 - use existing hotspot mutex mechanism
 - simplify
 - NULL -> nullptr
 - can't use new operator
 - init the mutex
 - fixes after merge
 - ... and 10 more: https://git.openjdk.org/jdk/compare/ead67574...1bf32149

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

Changes: https://git.openjdk.org/jdk/pull/23786/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23786&range=08
  Stats: 1104 lines in 14 files changed: 1095 ins; 0 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/23786.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23786/head:pull/23786

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


More information about the hotspot-dev mailing list