Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-53596] Dump a native memory tracking (NMT) report on signal #8814

Open
roberttoyonaga opened this issue Apr 22, 2024 · 4 comments
Open

Comments

@roberttoyonaga
Copy link
Collaborator

Feature request

Please include the following information:

Is your feature request related to a problem? Please describe.
Not related to a problem/bug.

Describe the solution you'd like.
It would be great to be able to dump an NMT report upon receiving a signal (similar to heap dumps).

In regular Java mode, NMT reports can be requested via jcmd. However, since Native Image doesn't have jcmd, a report is only written upon program completion. The usefulness of this is limited because the report will only show a snapshot of the memory usage at the time shutdown hooks are run (the data is kept as an instantaneous snapshot).

When NMT is enabled alongside JFR, JFR events will continuously expose NMT data. This solves the aforementioned problem of only getting a snapshot upon shutdown. However, there is no guarantee that JFR is included in the image along with NMT. JFR also has higher overhead than NMT so users may not want to include it.

SIGUS1 and SIGUSR2 are already taken by heap dumps and compilation dumps respectively. One possibility is to dump an NMT report whenever a heap dump is created. This makes sense because the NMT report fills in memory information not covered by heap dumps. Another possibility is to use SIGUSR1 or SIGUSR2 depending on whether they are already used by other features. This approach is a little messy and only works if all 3 features aren't being used.

Describe who do you think will benefit the most.
GraalVM users and developers can benefit from this.

Describe alternatives you've considered.
Another approach might be to create a SubstrateVM specific MXBean for NMT. This MXBean would be capable of initiating an NMT report dump through remote JMX. Users would need to include the remote JMX feature in their image. Then they could remotely request NMT reports from JDK Mission Control, VisualVM, or some other method of JMX connection.

I don't think this is the best solution since it requires including another feature in the image.

Express whether you'd like to help contributing this feature
I can help work on this, if others think it is a useful addition.

@fernando-valdez
Copy link
Member

Thanks for requesting this new feature.
We will keep track in this internal ticket: GR-53596

@fernando-valdez fernando-valdez changed the title Dump a native memory tracking (NMT) report on signal [GR-53596] Dump a native memory tracking (NMT) report on signal Apr 23, 2024
@roberttoyonaga
Copy link
Collaborator Author

@christianhaeubl how do you feel about the proposed ideas?

@christianhaeubl
Copy link
Member

Dumping NMT data on SIGUSR1 sounds reasonable. In the long run, I think that we should try to move away from the signal-based approach (there is no good way to specify which data should be dumped).

@roberttoyonaga
Copy link
Collaborator Author

Yes, there wouldn't be a way of choosing whether to dump the heap or NMT, if both are enabled. For now, I'll work on always dumping both.

I also think it would be a good idea to write the report to a file location specified at runtime (similar to a .jfr file), instead of only as console output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants