RFR: JDK-8318636: Add jcmd to print annotated process memory map [v4]
Gerard Ziemski
gziemski at openjdk.org
Fri Oct 27 17:32:33 UTC 2023
On Fri, 27 Oct 2023 12:28:51 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Analysts and supporters often use /proc/xx/maps to make sense of the memory footprint of a process.
>>
>> Interpreting the memory map correctly can help when used as a complement to other tools (e.g. NMT). There even exist tools out there that attempt to annotate the process memory map with JVM information.
>>
>> That, however, can be more accurately done from within the JVM, at least for mappings originating from hotspot. After all, we can correlate the mapping information in NMT with the VMA map.
>>
>> Example output (from a spring petstore run):
>>
>> [example_system_map.txt](https://github.com/openjdk/jdk/files/13179054/example_system_map.txt)
>>
>> This patch adds the VM annotations for VMAs that are *mmaped*. I also have an experimental patch that works with malloc'ed memory, but it is not ready yet for consumption and I leave that part of for now.
>
> Thomas Stuefe has updated the pull request incrementally with three additional commits since the last revision:
>
> - Fix spelling
> - timeout fuse
> - Feedback Johan
I really like this feature, hope the other platforms can be done as well. (I am also really looking forward to seeing how you did the "malloc" version)
I think we should set the user expectations correctly and say somewhere that these mappings are only for mmaped memory, ex change:
`Memory mappings:`
to
`Memory mappings (mmaped):`
or something like that.
These lines look akward next to each other:
0x000000070a400000 - 0x0000000800000000 4123000832 ---p 00000000 JAVAHEAP
0x00007f4e747dd000 - 0x00007f4e747e1000 16384 ---p 00000000 STACK(72821 "AWT-EventQueue-0")
0x0000563e6decb000 - 0x0000563e6decc000 4096 r--p 00000000 /home/gerard/Desktop/Work/8318636/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java
0x00007f4e26000000 - 0x00007f4e26d3b000 13873152 rw-p 00001000 CDS /home/gerard/Desktop/Work/8318636/jdk/build/linux-x86_64-server-fastdebug/images/jdk/lib/server/classes.jsa
in my opinion. The majority of entries either have the component or path in the **info** field (except CDS). Could we print it simply as:
0x000000070a400000 - 0x0000000800000000 4123000832 ---p 00000000 JAVAHEAP
0x00007f4e747dd000 - 0x00007f4e747e1000 16384 ---p 00000000 STACK(72821 "AWT-EventQueue-0")
0x0000563e6decb000 - 0x0000563e6decc000 4096 r--p 00000000 /home/gerard/Desktop/Work/8318636/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java
0x00007f4e26000000 - 0x00007f4e26d3b000 13873152 rw-p 00001000 CDS=/home/gerard/Desktop/Work/8318636/jdk/build/linux-x86_64-server-fastdebug/images/jdk/lib/server/classes.jsa
I find the compact way more aesthetically pleasing and easier to read.
Next I'm going to start looking into the implementation...
-------------
Changes requested by gziemski (Committer).
PR Review: https://git.openjdk.org/jdk/pull/16301#pullrequestreview-1702252387
More information about the hotspot-runtime-dev
mailing list