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

8319876: Reduce memory consumption of VM_ThreadDump::doit #307

Closed
wants to merge 1 commit into from

Conversation

yanglong1010
Copy link

@yanglong1010 yanglong1010 commented Mar 1, 2024

Hi, all

Could I have a review of this backport.

This pull request contains a backport of commit 8ec6b8de3bb3d7aeebdcb45d761b18cce3bab75e from the openjdk/jdk repository.
This backport can significantly reduce the RSS during the execution of ThreadMXBean.dumpAllThreads(boolean, boolean).

On jdk21u-dev, if creates 4096 threads, and the stack depth of each thread is 256.
On the version that does not contain this backport, during the execution of ThreadMXBean.dumpAllThreads(true, true), the RSS reaches about 5GiB.
On the version that contains this backport, the max RSS is about 300MiB.

There is a difference between jdk21u-dev and openjdk/jdk.
On openjdk/jdk, ThreadStackTrace::dump_stack_at_safepoint will only be executed in VMThread.
But on jdk21u-dev, ThreadStackTrace::dump_stack_at_safepoint will be executed in VMThread or RuntimeWorker, so when creating ResourceMark, can not directedly specify VMThread like what openjdk/jdk does, but needs to read current thread.

Testing:
I ran tier1, tier2, tier3, tier4 on my host machine with the jdk21u-dev including this backport.
tier1, tier2, and tier3 all passed.
Because my host does not have a display device, I added export JTREG_KEYWORDS="!headful" before running tier4.
Finally, some tests in tier4 that depend on the printing device failed, and the rest were successful.

The GHA failed in [linux-cross-compile, build(riscv64), Create sysroot].
I've also seen others fail at this step as well (e.g. link), it looks like there's an issue with the GHA's process.

I would appreciate it if anyone could review this.

Thanks!


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8319876 needs maintainer approval

Issue

  • JDK-8319876: Reduce memory consumption of VM_ThreadDump::doit (Enhancement - P4 - Approved)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk21u-dev.git pull/307/head:pull/307
$ git checkout pull/307

Update a local copy of the PR:
$ git checkout pull/307
$ git pull https://git.openjdk.org/jdk21u-dev.git pull/307/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 307

View PR using the GUI difftool:
$ git pr show -t 307

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk21u-dev/pull/307.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 1, 2024

👋 Welcome back yanglong1010! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot changed the title Backport 8ec6b8de3bb3d7aeebdcb45d761b18cce3bab75e 8319876: Reduce memory consumption of VM_ThreadDump::doit Mar 1, 2024
@openjdk
Copy link

openjdk bot commented Mar 1, 2024

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport rfr Pull request is ready for review labels Mar 1, 2024
@mlbridge
Copy link

mlbridge bot commented Mar 1, 2024

Webrevs

@openjdk
Copy link

openjdk bot commented Mar 7, 2024

⚠️ @yanglong1010 This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@yanglong1010
Copy link
Author

/approval 8319876 request I would like to backport this fix to jdk21u. This backport can significantly reduce the RSS during the execution of ThreadMXBean.dumpAllThreads(boolean, boolean).
Low risk: Through code analysis, we can confirm that the added ResouceMark can be safely destructed.
Testing: All GHA tests are passed (except linux-cross-compile, build(riscv64), Create sysroot. It looks like there's an issue with the GHA's process). I ran tier1, tier2, tier3, tier4 on my host machine with the jdk21u-dev including this backport. tier1, tier2, and tier3 all passed. Because my host does not have a display device, I added export JTREG_KEYWORDS="!headful" before running tier4. Finally, some tests in tier4 that depend on the printing device failed, and the rest were successful.
Not Clean: On openjdk/jdk, ThreadStackTrace::dump_stack_at_safepoint will only be executed in VMThread.
But on jdk21u-dev, ThreadStackTrace::dump_stack_at_safepoint will be executed in VMThread or RuntimeWorker, so when creating ResourceMark, can not directly specify VMThread like what openjdk/jdk does, but needs to read current thread.

@openjdk
Copy link

openjdk bot commented Mar 8, 2024

@yanglong1010
8319876: The approval request has been created successfully.

@openjdk openjdk bot added the approval label Mar 8, 2024
@openjdk
Copy link

openjdk bot commented Mar 13, 2024

@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:

8319876: Reduce memory consumption of VM_ThreadDump::doit

Reviewed-by: phh

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 124 new commits pushed to the master branch:

  • 4c7b1d9: 8313710: jcmd: typo in the documentation of JFR.start and JFR.dump
  • 0bbb803: 8318727: Enable parallelism in vmTestbase/vm/gc/concurrent tests
  • f5dfd8b: 8311823: JFR: Uninitialized EventEmitter::_thread_id field
  • d17aa5e: 8319437: NMT should show library names in call stacks
  • 2800d8b: 8326643: JDK server does not send a dummy change_cipher_spec record after HelloRetryRequest message
  • 245de59: 8309752: com/sun/jdi/SetLocalWhileThreadInNative.java fails with virtual test thread factory due to OpaqueFrameException
  • 6791646: 8328812: Update and move siphash license
  • c263bc5: 8327998: Enable java/lang/ProcessBuilder/JspawnhelperProtocol.java on Mac
  • 0bfb53c: 8323994: gtest runner repeats test name for every single gtest assertion
  • 7751996: 8326661: sun/java2d/cmm/ColorConvertOp/ColConvTest.java assumes profiles were generated by LCMS
  • ... and 114 more: https://git.openjdk.org/jdk21u-dev/compare/2d791b8b856f6c3794f5f36a68548b15e93474f4...master

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 (@phohensee) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed approval labels Mar 14, 2024
@yanglong1010
Copy link
Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Apr 3, 2024
@openjdk
Copy link

openjdk bot commented Apr 3, 2024

@yanglong1010
Your change (at version c163843) is now ready to be sponsored by a Committer.

@DamonFool
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Apr 3, 2024

Going to push as commit 342ae64.
Since your change was applied there have been 124 commits pushed to the master branch:

  • 4c7b1d9: 8313710: jcmd: typo in the documentation of JFR.start and JFR.dump
  • 0bbb803: 8318727: Enable parallelism in vmTestbase/vm/gc/concurrent tests
  • f5dfd8b: 8311823: JFR: Uninitialized EventEmitter::_thread_id field
  • d17aa5e: 8319437: NMT should show library names in call stacks
  • 2800d8b: 8326643: JDK server does not send a dummy change_cipher_spec record after HelloRetryRequest message
  • 245de59: 8309752: com/sun/jdi/SetLocalWhileThreadInNative.java fails with virtual test thread factory due to OpaqueFrameException
  • 6791646: 8328812: Update and move siphash license
  • c263bc5: 8327998: Enable java/lang/ProcessBuilder/JspawnhelperProtocol.java on Mac
  • 0bfb53c: 8323994: gtest runner repeats test name for every single gtest assertion
  • 7751996: 8326661: sun/java2d/cmm/ColorConvertOp/ColConvTest.java assumes profiles were generated by LCMS
  • ... and 114 more: https://git.openjdk.org/jdk21u-dev/compare/2d791b8b856f6c3794f5f36a68548b15e93474f4...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 3, 2024
@openjdk openjdk bot closed this Apr 3, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Apr 3, 2024
@openjdk
Copy link

openjdk bot commented Apr 3, 2024

@DamonFool @yanglong1010 Pushed as commit 342ae64.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@yanglong1010
Copy link
Author

Thank you all !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants