-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
JDK-8286198: [linux] Fix process-memory information #8553
JDK-8286198: [linux] Fix process-memory information #8553
Conversation
👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into |
GHA test error on Windows irrelevant for this patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand your "free retained" terminology, but otherwise the changes seem fine and do what you describe.
Thanks,
David
@tstuefe This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 71 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Thank you, David. Free Retained memory is memory you free()'d but which is retained by the glibc, not handed back to the Operating System. |
Hi Thomas, when looking at the manpage https://man7.org/linux/man-pages/man3/mallinfo.3.html |
No, it's wrong. Hence this patch (see patch description - the number does not account for large areas allocated by the glibc with mmap). Not sure what the state of that manpage is. But I tested this very thoroughly. Observe: 1a) Old VM allocates 100mio 16 byte blocks:thomas@starfish:~$ jjjcmd de.stuefe.repros.AllocCHeap VM.info | grep C-Heap OK. 1b) Old VM allocates 16 100mio byte blocks:thomas@starfish:~$ jjjcmd de.stuefe.repros.AllocCHeap VM.info | grep C-Heap Not OK. It says 5,7M, but we just allocated (payloadsize) ~1.6G. 2a) Patched VM allocates 100mio 16 byte blocks:thomas@starfish:~$ jjjcmd de.stuefe.repros.AllocCHeap VM.info | grep C-Heap Still OK. 2b) Patched VM allocates 16 100mio byte blocks:thomas@starfish:~$ jjjcmd de.stuefe.repros.AllocCHeap VM.info | grep C-Heap Now it looks legit too, compared to (1b). The lower size (1.6G vs 3.1G) stems from the massively lower glibc overhead when allocating large areas instead of tiny blocks. |
Thanks @dholmes-ora and @MBaesken ! /integrate |
Going to push as commit 9e320d9.
Your commit was automatically rebased without conflicts. |
We use mallinfo/mallinfo2 to obtain information about the glibc used memory, but there is an error which causes it to be correct only for fine granular malloc allocations. glibc puts larger allocations in mmap-allocated areas, which were missing from the old calculation.
This patch fixes that; it also adds information about memory retained in the glibc after free. Note that the latter unfortunately does not follow glibc trims because trimming is done AFAIK with madvice(MADV_DONTNEED) which does not seem to affect glibc internal bookkeeping. Still its a very valuable thing to know in order to estimate glibc overhead especially in fine granular mass allocation scenarios.
Tests: Lots of manual tests with various malloc loads and granularities, in addition to automated tests.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8553/head:pull/8553
$ git checkout pull/8553
Update a local copy of the PR:
$ git checkout pull/8553
$ git pull https://git.openjdk.java.net/jdk pull/8553/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8553
View PR using the GUI difftool:
$ git pr show -t 8553
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8553.diff