Skip to content

8381566: G1: Concurrent refinement pre-sweep time logged as incorrect negative value#30551

Open
tabata-d wants to merge 2 commits intoopenjdk:masterfrom
tabata-d:pre-sweep
Open

8381566: G1: Concurrent refinement pre-sweep time logged as incorrect negative value#30551
tabata-d wants to merge 2 commits intoopenjdk:masterfrom
tabata-d:pre-sweep

Conversation

@tabata-d
Copy link
Copy Markdown
Member

@tabata-d tabata-d commented Apr 2, 2026

In certain application workloads, a Young GC may occur during G1 concurrent refinement. When this happens, the pre-sweep processing time is incorrectly logged as a negative value. This is a logging-only issue at the debug level.

Cause

The pre-sweep duration is calculated using the following logic:

get_duration(State::Idle, State::SweepRT).seconds() * 1000.0

This calculation expects the current concurrent refinement cycle to have already reached the State::SweepRT state by the time the log is generated. However, if a Young GC interrupts the process before reaching SweepRT, the last recorded timestamp for State::SweepRT belongs to the previous refinement cycle.
Consequently, the code calculates the difference between the Idle state of the current cycle and the SweepRT state of the previous cycle, resulting in an incorrect negative duration.

Proposed Fix

If the process has not yet reached State::SweepRT, I propose logging the duration from Idle to the current state. While this value will be identical to the "Refinement took" time and may offer limited additional insight, it is preferable to outputting misleading negative values. Furthermore, it remains consistent with the actual time spent in the pre-sweep phase up to that point.

Alternative Considered

I considered outputting a specific message indicating that the pre-sweep did not complete (e.g., "pre-sweep not complete"). However, I decided against this to avoid duplicating large blocks of logging code, which would decrease maintainability.

Testing

  • Tested on Linux x64.
  • All tests in the :hotspot_gc group passed.

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

Issue

  • JDK-8381566: G1: Concurrent refinement pre-sweep time logged as incorrect negative value (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30551/head:pull/30551
$ git checkout pull/30551

Update a local copy of the PR:
$ git checkout pull/30551
$ git pull https://git.openjdk.org/jdk.git pull/30551/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30551

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30551.diff

Using Webrev

Link to Webrev Comment

tabatad and others added 2 commits April 2, 2026 09:13
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 2, 2026

👋 Welcome back dtabata! 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
Copy Markdown

openjdk bot commented Apr 2, 2026

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

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Apr 2, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 2, 2026

@tabata-d The following label will be automatically applied to this pull request:

  • hotspot-gc

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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 2, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Apr 2, 2026

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant