Skip to content

Conversation

@jyma22
Copy link

@jyma22 jyma22 commented Dec 17, 2025

CPUTimeCounters unconditionally creates CPUTimeGroups::CPUTimeType::gc_total. Since only Parallel and G1 are supported by this framework/class, this leads to publishing a counter that always resolves to 0. This may be contradictory for an end-user especially so as we now support logging GC CPU time for any GC inside Hotspot. For an example using -XX:+UseZGC -Xlog:cpu we get

[7.907s][info][cpu] === CPU time Statistics =============================================================
[7.907s][info][cpu]                                                                             CPUs
[7.907s][info][cpu]                                                                s       %  utilized
[7.907s][info][cpu]    Process
[7.907s][info][cpu]      Total                                              186.9562  100.00      23.6
[7.907s][info][cpu]      Garbage Collection                                   0.6700    0.36       0.1
[7.907s][info][cpu]        GC Threads                                         0.6692    0.36       0.1
[7.907s][info][cpu]        VM Thread                                          0.0008    0.00       0.0
[7.907s][info][cpu] =====================================================================================

But jcmd $(pgrep -n java) PerfCounter.print | grep -E "sun.threads.total_gc_cpu_time" prints: sun.threads.total_gc_cpu_time=0.

Testing: passed tier1-4


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8373625 needs maintainer approval

Issue

  • JDK-8373625: CPUTimeCounters creates a total counter for unsupported GCs (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 104

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 17, 2025

👋 Welcome back jyma22! 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
Copy link

openjdk bot commented Dec 17, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title Backport 30be94086aad42b99a15a05fe5115f552e8efb8b 8373625: CPUTimeCounters creates a total counter for unsupported GCs Dec 17, 2025
@openjdk
Copy link

openjdk bot commented Dec 17, 2025

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

@openjdk openjdk bot added backport Port of a pull request already in a different code base clean Identical backport; no merge resolution required labels Dec 17, 2025
@jyma22 jyma22 marked this pull request as ready for review December 17, 2025 18:51
@openjdk
Copy link

openjdk bot commented Dec 17, 2025

⚠️ @jyma22 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 17, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 17, 2025

Webrevs

@jyma22
Copy link
Author

jyma22 commented Dec 17, 2025

/approval request Backporting this patch fixes the misleading GC CPU time counter issue where sun.threads.total_gc_cpu_time always reports 0 for non-G1/Parallel collectors. The change conditionally creates the gc_total counter only when UseG1GC or UseParallelGC is enabled, preventing contradictory metrics when using other collectors like ZGC that report GC CPU time through logging but not through this counter framework.

Patch applies cleanly to 25u.

Included test passes. Ran tier1-4 with no regressions observed.

@openjdk
Copy link

openjdk bot commented Dec 17, 2025

@jyma22
8373625: The approval request has been created successfully.

@openjdk openjdk bot added the approval Requires approval; will be removed when approval is received label Dec 17, 2025
@GoeLin
Copy link
Member

GoeLin commented Dec 19, 2025

HI @jyma22
please backport to 26 first. Maybe refer to next release of 25 as this is brand new.
Removing the label for now.

@openjdk openjdk bot removed the approval Requires approval; will be removed when approval is received label Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Port of a pull request already in a different code base clean Identical backport; no merge resolution required rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants