[jdk21u-dev] RFR: 8319876: Reduce memory consumption of VM_ThreadDump::doit

Long Yang duke at openjdk.org
Fri Mar 1 08:21:17 UTC 2024


Hi, all

Could I have a review of this backport.

This pull request contains a backport of commit [8ec6b8de3bb3d7aeebdcb45d761b18cce3bab75e](https://github.com/openjdk/jdk/commit/8ec6b8de3bb3d7aeebdcb45d761b18cce3bab75e) from the [openjdk/jdk](https://github.com/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](https://github.com/yanglong1010/jdk21u-dev/actions/runs/8093195914/job/22116320956) failed in [linux-cross-compile, build(riscv64), Create sysroot].
I've also seen others fail at this step as well (e.g. [link](https://github.com/openjdk-bots/jdk21u-dev/actions/runs/8077954001/job/22081472372)), it looks like there's an issue with the GHA's process.

I would appreciate it if anyone could review this.

Thanks!

-------------

Commit messages:
 - 8319876: Reduce memory consumption of VM_ThreadDump::doit

Changes: https://git.openjdk.org/jdk21u-dev/pull/307/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk21u-dev&pr=307&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8319876
  Stats: 3 lines in 2 files changed: 0 ins; 2 del; 1 mod
  Patch: https://git.openjdk.org/jdk21u-dev/pull/307.diff
  Fetch: git fetch https://git.openjdk.org/jdk21u-dev.git pull/307/head:pull/307

PR: https://git.openjdk.org/jdk21u-dev/pull/307


More information about the jdk-updates-dev mailing list