Skip to content

8384221: GenShen: WhiteBox full GC promotion is not reliable#31302

Open
pf0n wants to merge 2 commits into
openjdk:masterfrom
pf0n:8384221
Open

8384221: GenShen: WhiteBox full GC promotion is not reliable#31302
pf0n wants to merge 2 commits into
openjdk:masterfrom
pf0n:8384221

Conversation

@pf0n
Copy link
Copy Markdown
Contributor

@pf0n pf0n commented May 27, 2026

There are tests that issue a WhiteBox full GC and check whether the object was promoted. If it wasn't, the test either retries until promotion succeeds or fails automatically. GenShen fails these tests because it never promotes on the first cycle and isn't guaranteed to promote on later ones.

Fix

Introduce an always tenure mode only used for WhiteBox full GCs to promote objects regardless if its age does not meet the tenuring threshold.

Testing with linux-x86_64-server-fastdebug

These tests were previously failing or timing out. With this change they pass with 100 iterations each:

gc/TestReferenceClearDuringMarking.java
gc/TestNativeReferenceGet.java
gc/TestReferenceRefersTo.java
gc/TestReferenceRefersToDuringConcMark.java
gc/TestJNIWeak/TestJNIWeak.java

Additional testing: hotspot_gc_shenandoah

Notes

Having a tenuring threshold of 0 won't work because certain assertions will fire and calculations would break.

ShenandoahGenerationalHeuristics::adjust_evacuation_budgets can set the promotion reserve smaller than a min-size PLAB, in which case no thread can allocate a PLAB. To avoid this, we keep at least one min-size PLAB per worker in the promotion reserve.

There's a possibility of abbreviated cycles occurring. In an abbreviated cycle, no evacuation occurs, so if no regions are eligible for promote-in-place, no objects will be promoted. We can try to force the cset to be non-empty which prevents abbreviated cycles. We reconfigure specific thresholds in ShenandoahGlobalHeuristics::choose_global_collection_set to make this work.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8384221: GenShen: WhiteBox full GC promotion is not reliable (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31302

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented May 27, 2026

👋 Welcome back pf0n! 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 May 27, 2026

@pf0n 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:

8384221: GenShen: WhiteBox full GC promotion is not reliable

Reviewed-by: wkemper, 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 35 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@earthling-amzn, @ysramakrishna) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk Bot added hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels May 27, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 27, 2026

@pf0n 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
Copy link
Copy Markdown

openjdk Bot commented May 27, 2026

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-gc. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label May 27, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented May 27, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@earthling-amzn earthling-amzn 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. Requested a minor change.

Comment thread src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp Outdated
if (gen_heap->age_census()->is_always_tenure()) {
// Cap excess_old at one min-PLAB per worker so this much stays in old's promotion reserve
// instead of being transferred to young.
const size_t min_plab_total = gen_heap->plab_min_size() * HeapWordSize * heap->workers()->max_workers();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In other words, we are trying to keep old from giving any capacity to young so that old can hold all of the promotions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's correct.

Copy link
Copy Markdown
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 to me, modulo one minor comment in passing re "_allows_promotion" field default value change.

_promotion_failure_count(0),
_promotion_failure_words(0),
_allows_promotion(false),
_allows_promotion(true),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is interesting, and to me somewhat unexpected.

Did this require any changes elsewhere? I'd have expected this to be the default setting, but I see calls to enable/disable promotions on plab's at various places. I wonder if this is used only for sanity checking and should just be a debug-only field used in assertion checks, or if it's used for control-flow in places.

Probably worth a closer look.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label May 29, 2026
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 ready Pull request is ready to be integrated rfr Pull request is ready for review shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants