Skip to content

8381643: Shenandoah: Remove duplicate region filtering logic#30571

Open
earthling-amzn wants to merge 4 commits intoopenjdk:masterfrom
earthling-amzn:deduplicate-cset-region-filtering
Open

8381643: Shenandoah: Remove duplicate region filtering logic#30571
earthling-amzn wants to merge 4 commits intoopenjdk:masterfrom
earthling-amzn:deduplicate-cset-region-filtering

Conversation

@earthling-amzn
Copy link
Copy Markdown
Contributor

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

After recent refactoring, the difference between ShenandoahGenerationalHeuristics::choose_collection_set and ShenandoahHeuristics::choose_collection_set has shrunk to the point where the code duplication doesn't make sense anymore. There is an additional change here that splits a generational mode specific 'EvacuationInfoEvent' (JFR) into two events:

  • An EvacuationInfoEvent that is shared across all Shenandoah modes
  • A PromotionInfoEvent that is specific to the generational mode

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-8381643: Shenandoah: Remove duplicate region filtering logic (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30571

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 3, 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 3, 2026

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

}

void ShenandoahGenerationalHeuristics::choose_collection_set(ShenandoahCollectionSet* collection_set) {
void ShenandoahGenerationalHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* collection_set,
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.

This is method by which all subclasses of ShenandoahHeuristics are meant to refine the collection set candidates (RegionData*).

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Apr 3, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 3, 2026

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

  • hotspot
  • 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 3, 2026
heap->shenandoah_policy()->record_mixed_cycle();
}

if (!collection_set->is_empty() && _generation->is_global()) {
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.

This is a bug fixed by: #30543


protected:
// Subclasses override this to perform generation-specific region selection.
virtual void select_collection_set_regions(ShenandoahCollectionSet* set,
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.

This method is an override specifically for the young/global heuristics.

region->make_trash_immediate();
} else {
// This is our candidate for later consideration.
assert(region->get_top_before_promote() == nullptr,
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.

This is harmless in non-generational modes. They'll never promote in place so top_before_promote will always be nullptr.

for (size_t i = 0; i < num_regions; i++) {
ShenandoahHeapRegion* region = heap->get_region(i);

if (!_space_info->contains(region)) {
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.

contains is implemented to return true unconditionally for global/non-generational collections.


collection_set->clear();
ShenandoahHeapLocker locker(heap->lock());
heap->assert_pinned_region_status(this);
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.

Pulled this up so that heuristics can keep using the ShSpaceInfo abstraction. Even though it is only implemented by ShGeneration, removing it would clutter this PR (and is also not entirely straight forward because of include dependencies).

@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Apr 3, 2026

Webrevs

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

Labels

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

Development

Successfully merging this pull request may close these issues.

1 participant