RFR: 8157023: Integrate NMT with JFR [v3]
Thomas Stuefe
stuefe at openjdk.org
Tue Dec 6 15:10:21 UTC 2022
On Tue, 6 Dec 2022 11:54:37 GMT, Stefan Johansson <sjohanss at openjdk.org> wrote:
>> Please review this enhancement to include NMT information in JFR recordings.
>>
>> **Summary**
>> Native Memory Tracking summary information can be obtained from a running VM using `jcmd` if started with `-XX:NativeMemoryTracking=summary/detail`. Using `jcmd` requires you to run a separate process and to parse the output to get the needed information. This change adds JFR events for NMT information to enable additional ways to consume the NMT data.
>>
>> There are two new events added:
>> * _NativeMemoryUsage_ - The total native memory usage.
>> * _NativeMemoryUsagePart_ - The native memory usage for each component.
>>
>> These events are sent periodically and by default the interval is 1s. This can of course be discussed, but that is the staring point. When NMT is not enabled on events will be sent.
>>
>> **Testing**
>> * Added a simple test to verify that the events are sent as expected depending on if NMT is enabled or not.
>> * Mach5 sanity testing
>
> Stefan Johansson has updated the pull request incrementally with one additional commit since the last revision:
>
> Special snapshot for NMT events in JFR
src/hotspot/share/services/memSnapshot.cpp line 66:
> 64: MallocMemory* mm = ms->by_type(flag);
> 65: _malloc_snapshot[i] = mm->malloc_size() + mm->arena_size();
> 66: total_arena_size += mm->arena_size();
Another issue I just noticed is that you now account for memory in owned arena chunks twice, once as mtChunk, and once as arena memory for the owning arena. This is a similar issue as I described in https://github.com/openjdk/jdk/pull/11497#discussion_r1041093340 .
The correct way would be to do a real snapshot with a copy, which calls `MallocMemorySnapshot::make_adjustment()`. But that is expensive. The way you do it, by directly looking at the counters, is faster. Therefore - and because I plan to improve this anyway - my recommendation would be to just omit mtChunk for the moment.
-------------
PR: https://git.openjdk.org/jdk/pull/11449
More information about the hotspot-dev
mailing list