Skip to content

Conversation

earthling-amzn
Copy link
Contributor

@earthling-amzn earthling-amzn commented Sep 23, 2025

There are several issues addressed in this PR:

  • Shenandoah always ran a full GC after any degenerated cycle
  • The number of consecutive degenerated GCs with bad progress was reset for every degenerated cycle
  • Good progress was reported in generational mode even when no progress is made

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-8368152: Shenandoah: Incorrect behavior at end of degenerated cycle (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27456

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 23, 2025

👋 Welcome back wkemper! 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 Sep 23, 2025

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

8368152: Shenandoah: Incorrect behavior at end of degenerated cycle

Reviewed-by: kdnilsen, ysr

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

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Sep 23, 2025
@openjdk
Copy link

openjdk bot commented Sep 23, 2025

@earthling-amzn The following labels will be automatically applied to this pull request:

  • hotspot-gc
  • shenandoah

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.

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

mlbridge bot commented Sep 23, 2025

Webrevs

Copy link
Contributor

@kdnilsen kdnilsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A common scenario that I have seen in various GC logs is the following:

  1. Concurrent GC experiences allocation failure and degenerates
  2. Degenerated GC fails to make progress because lots of garbage was allocated after the start of concurrent marking (ie. all garbage is floating)
  3. We escalate to Full GC, resulting in a very long STW delay (The Full GC delay plus the delay for degen that preceded Full GC)
  4. It is often the case that better throughput and better latency is realized if we run a concurrent GC which may once again degenerate, rather than escalating from the first degen to Full GC. All of the floating garbage that was locked up during the previous GC should be reclaimed by the second concurrent (possibly degenerated) GC, so the second cycle should have "good progress" even if the first did not.
  5. I believe the solution you've implemented here will first try a second concurrent/degenerated cycle before escalating to Full GC. Will you confirm that?

Should we have some comments in this code to explain why CONSECUTIVE_BAD_DEGEN_PROGRESS_THRESHOLD is 2 and not 1?

@earthling-amzn
Copy link
Contributor Author

There is a comment in shDegeneratedGC explaining this scenario. I'll move it to shCollectorPolicy. I didn't quite understand why single-gen mode would not benefit equally from this reasoning, but I tried to preserve the original intended behavior.

Copy link
Member

@ysramakrishna ysramakrishna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; left some documentation nits, but approved even if the documentation suggestions aren't taken.

🚢

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 23, 2025
@ysramakrishna
Copy link
Member

Also, independently, I think the notion of progress should be clarified based on current implementation in ShenandoahMetricsSnapshot::is_good_progress() (which declaration should itself have a brief comment):

   Compare before and after snapshots to determine if GC
   made sufficient progress. The notion of progress is based on space free after,
   change in space freed, or changes in internal and/or external fragmentation.

I found it slightly confusing that even though a Generation argument is passed into the method, it's really not used directly as far as I could tell in the notion of progress. The metrics all appear to be heap-wide, rather than generation-wide. There is a comment about the collection set being proportional to the generation in question which of course makes sense, but I'd much rather we didn't pass in an argument that isn't used there, but rather address it directly in the documentation.

May be I am missing something?

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 23, 2025
@earthling-amzn
Copy link
Contributor Author

You're right that the generation argument to is_good_progress is unused. I think it makes sense to instead pass this to the shMetrics constructor and have it evaluate used from the generation. I will experiment with this, but I think it's outside the scope of this PR.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 23, 2025
@earthling-amzn
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 24, 2025

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 24, 2025
@openjdk openjdk bot closed this Sep 24, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 24, 2025
@openjdk
Copy link

openjdk bot commented Sep 24, 2025

@earthling-amzn Pushed as commit f36c33c.

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

@earthling-amzn earthling-amzn deleted the fix-genshen-brownout branch September 24, 2025 22:45
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 integrated Pull request has been integrated shenandoah shenandoah-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants