-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8319876: Reduce memory consumption of VM_ThreadDump::doit #16598
Conversation
👋 Welcome back yanglong1010! A progress list of the required criteria for merging this PR into |
@yanglong1010 The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
Please describe the fix a bit better. My reading: Please run |
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.
Yes please explain the problem and the fix better. It is far from clear that every ResourceArea allocation that is made from this code can be safely discarded when this method returns. Which objects are the ones consuming so much space, and which can be erased? Maybe we should be avoiding these allocations rather than cleaning them up more promptly. ??
hi Aleksey, |
hi David, The situation we encountered is that in a Java process with a large number of threads, executing The reason is that I saw that in |
Are we sure adding an RM at that place is okay? BTW, should be obvious but if you run tests, pls make sure to test debug builds to get Arena zapping on chopped arena chunks. |
From what I can see these two are CHeap-allocated:
The MEMFLAGS indicate that they are CHeap-allocated. |
Wait, how does this work on expansion?
Calls What am I missing? Update, never mind, I see the big switch in GrowableArray::allocate now. |
/label add serviceability |
@dcubed-ojdk |
Hi |
Okay I'm running this through our CI testing as well. I can't see any easy way to check for escaping resource objects other than testing. |
Our testing passed tiers 1-5. Thanks |
|
@yanglong1010 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 82 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dholmes-ora, @stefank) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@dholmes-ora David Thanks. |
Could I get another review ? |
/integrate |
/sponsor |
@yanglong1010 |
Going to push as commit 8ec6b8d.
Your commit was automatically rebased without conflicts. |
@D-D-H @yanglong1010 Pushed as commit 8ec6b8d. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Thank you all ~ |
I would like to fix this.
Create 4096 threads, and the stack depth of each thread is 256.
After running jmx.dumpAllThreads(true, true), the RSS reaches 5.3GiB.
After optimization, the RSS is 250MiB.
I would appreciate it if anyone could review this.
update
If the number of
threads
andstack depth
are relatively large, we need to apply for more space inResourceArea
during the execution ofjmx.dumpAllThreads(true, true)
.The reason is that
VM_ThreadDump::doit
createsvframe
for eachframe
of eachthread
.jdk/src/hotspot/share/services/threadService.cpp
Line 704 in fe0ccdf
sizeof
vframe
is 4808 (bytes), and sizeofcompiledVFrame
is 4824 (bytes), mainly because thexmm registers
inRegisterMap
are relatively large. Assuming there are 4096threads
and eachthread
has 256frames
, the memory required is 4096 * 256 * 4824 = 4.7GiB。These memories of all threads are released once by the the initial
ResourceMark
ofVM_ThreadDump::doit
.jdk/src/hotspot/share/runtime/vmOperations.cpp
Line 269 in fe0ccdf
My solution is to add a
ResourceMark
for each thread.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16598/head:pull/16598
$ git checkout pull/16598
Update a local copy of the PR:
$ git checkout pull/16598
$ git pull https://git.openjdk.org/jdk.git pull/16598/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16598
View PR using the GUI difftool:
$ git pr show -t 16598
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16598.diff
Webrev
Link to Webrev Comment