-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8368527: JMX: Add an MXBeans method to query GC CPU time #27537
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back JonasNorlinder! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@JonasNorlinder The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
/label add hotspot-gc |
@JonasNorlinder |
/label remove core-libs |
@AlanBateman |
This proposal will probably require discussion as to whether this is a property of a standard MXBean or a JDK-specific MXBean. It might be that GarbageCollectorMXBean is a better place for this. |
Thanks @AlanBateman. I did first consider To clarify what I mean with "exposing a sub-component at a time"; consider the following
Its output will be
So no
Additionally it includes a method to request a GC, which made me think that this could be a good fit for this method. That being said if my above observations are incorrect or there is a more appropriate place to put this method I'm happy to update the PR. |
I don't think this is appropriately placed in MemoryMXBean. I will discuss in the CSR request |
JMM_GC_COUNT = 10, /* Total number of collections */ | ||
JMM_JVM_UPTIME_MS = 11, /* The JVM uptime in milliseconds */ | ||
JMM_GC_CPU_TIME = 11, /* Total accumulated GC CPU time */ | ||
JMM_JVM_UPTIME_MS = 12, /* The JVM uptime in milliseconds */ |
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.
It looks a bit odd to me to change the existing define of UPTIME here.
OK it is not a public interface used between different versions, and people should not be mixing up jmm.h and management implementations... But usually we would just add the new definition? (items below are not strictly grouped by name) Maybe this is just a nit, and only makes cross-version comparisons easier.
Looks good overall.
Hi all,
This PR augments the CPU time sampling measurement capabilities that a user can perform from Java code with the addition of
MemoryMXBean.getGcCpuTime()
. With this patch it will be possible for a user to measure process and GC CPU time during critical section or iterations in benchmarks to name a few. This new method complements the existingOperatingSystemMXBean.getProcessCpuTime()
for a refined understanding.CollectedHeap::gc_threads_do
may operate on terminated GC threads during shutdown, but thanks to JDK-8366865 by @walulyai we can piggyback on the newUniverse::is_shutting_down
. I have implemented a stress-testtest/jdk/java/lang/management/MemoryMXBean/GetGcCpuTime.java
that may identify reading CPU time of terminated threads. Synchronizing onUniverse::is_shutting_down
andHeap_lock
resolves this problem.FWIW; To my understanding we don't want to add a
Universe::is_shutting_down
check in gc_threads_do as this may introduce a performance penalty that is unacceptable, therefore we must be careful about the few places where external users call upon gc_threads_do and may race with a terminating VM.Tested: test/jdk/java/lang/management/MemoryMXBean/GetGcCpuTime.java, jdk/javax/management/mxbean hotspot/jtreg/vmTestbase/nsk/monitoring on Linux x64, Linux aarch64, Windows x64, macOS x64 and macOS aarch64 with release and fastdebug.
Progress
Issues
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27537/head:pull/27537
$ git checkout pull/27537
Update a local copy of the PR:
$ git checkout pull/27537
$ git pull https://git.openjdk.org/jdk.git pull/27537/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27537
View PR using the GUI difftool:
$ git pr show -t 27537
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27537.diff
Using Webrev
Link to Webrev Comment