Skip to content

8381549: GenShen: Global collections skip coalesce and fill when the collection set is empty#30543

Closed
earthling-amzn wants to merge 2 commits intoopenjdk:masterfrom
earthling-amzn:fix-missing-global-coalesce
Closed

8381549: GenShen: Global collections skip coalesce and fill when the collection set is empty#30543
earthling-amzn wants to merge 2 commits intoopenjdk:masterfrom
earthling-amzn:fix-missing-global-coalesce

Conversation

@earthling-amzn
Copy link
Copy Markdown
Contributor

@earthling-amzn earthling-amzn commented Apr 1, 2026

When objects become unreachable in old regions they will no longer have their references updated. If a heap walk tries to follow one of these references, it may encounter garbage and crash. This step was inadvertently skipped by an erroneous code change in a recent refactoring.


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-8381549: GenShen: Global collections skip coalesce and fill when the collection set is empty (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30543

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 1, 2026

👋 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
Copy Markdown

openjdk bot commented Apr 1, 2026

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

8381549: GenShen: Global collections skip coalesce and fill when the collection set is empty

Reviewed-by: kdnilsen, xpeng, 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 20 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 Apr 1, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 1, 2026

@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 Apr 1, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Apr 1, 2026

Webrevs

@ysramakrishna
Copy link
Copy Markdown
Member

If a heap walk tries to follow one of these references, it may encounter garbage and crash.

What was the heap walk that tried to follow one of these references? Are we talking about a dead (unmarked) object? Would that not be skipped because of using the valid (complete) marking bit map during such a walk? (Was it dirty card / remset scanning of old gen?) Something else?

Change looks good, but wanted to make sure I understood the need for the coalesce and fill necessary for a linear walk over the region.

@earthling-amzn
Copy link
Copy Markdown
Contributor Author

In this case, the heap walk was indeed a remembered set scan. The remembered set scan cannot use the mark bitmap for old during old marking. The scan relies on old, no longer reachable objects, being filled in before old marking resets the bitmap.

Copy link
Copy Markdown
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.

I have some questions about the intent here?

// eligible for coalescing. As implemented now, this has the side effect of possibly initiating mixed-evacuations
// after a global cycle for old regions that were not included in this collection set.
heap->old_generation()->prepare_for_mixed_collections_after_global_gc();
heap->old_generation()->update_old_regions_after_global_cycle();
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.

I'm not sure we want to make this change. IIUC, as currently implemented, we may end a Global GC with many candidates for mixed evacuation. While this means "completion" of the Global GC is somewhat delayed, it also means the Global GC has a much smaller impact on the normal cadence of young collections.

What is the impact of this change?

  1. Does it force us to do all mixed evacuation in a single cycle?
  2. Does it reduce the amount of mixed evacuation that we are able to perform following an "old mark"?

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.

Sorry for the panic. This is just a name change?

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 this context, "update" does not mean update-refs. It means:

"update" the internal list of mixed-evacuation candidates?
"update" the gc log?

I guess I was a bit confused by the name of this function. Help me understand what we are trying to communicate with this name?

Copy link
Copy Markdown
Contributor Author

@earthling-amzn earthling-amzn Apr 2, 2026

Choose a reason for hiding this comment

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

I am open to better names. In retrospect, I made the change to skip this function call when the collection set is empty because of the old name: prepare_for_mixed_collections_after_global_gc. The function does much more than prepare for mixed collections. Critically, if there are no collection candidates at all, it must still transition the old generation to the FILLING state so that dead objects are replaced with array primitives. Maybe transition_old_generation_after_global_gc?

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.

Thanks. I like that name better.

Copy link
Copy Markdown
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.

Thanks.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 3, 2026
Copy link
Copy Markdown

@pengxiaolong pengxiaolong left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me!

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.

🚢

(but left a small remark re documentation comment; not essential and doesn't need a re-review.)


bool entry_coalesce_and_fill();
void prepare_for_mixed_collections_after_global_gc();
void transition_old_generation_after_global_gc();
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.

Thanks for the nice explanation in the PR discussion/convo w/Kelvin.

Might be a good idea to add a one-sentence documentation comment for the method here while you are here may be? I realize the method itself is fairly small, but ... :-)

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.

I shall add one in a subsequent PR. Thank you!

@earthling-amzn
Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 3, 2026

Going to push as commit f21e47d.
Since your change was applied there have been 21 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 Apr 3, 2026
@openjdk openjdk bot closed this Apr 3, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 3, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 3, 2026

@earthling-amzn Pushed as commit f21e47d.

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

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.

4 participants