Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8331048: G1: Prune rebuild candidates based on G1HeapWastePercent early #18970

Closed
wants to merge 13 commits into from

Conversation

walulyai
Copy link
Member

@walulyai walulyai commented Apr 26, 2024

Hi,

Please review this change that moves the G1CollectionSetChooser::build out of the cleanup pause into the remark pause. This prunes the rebuild candidates based on G1HeapWastePercent, thereby reducing the rebuild time in cases where pruning happens.

Testing: Tier 1 - 5

concurrent_rebuild


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-8331048: G1: Prune rebuild candidates based on G1HeapWastePercent early (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18970

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 26, 2024

👋 Welcome back iwalulya! 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 Apr 26, 2024

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

8331048: G1: Prune rebuild candidates based on G1HeapWastePercent early

Reviewed-by: ayang, tschatzl

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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
Copy link

openjdk bot commented Apr 26, 2024

@walulyai 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 hotspot-gc hotspot-gc-dev@openjdk.org label Apr 26, 2024
@walulyai walulyai marked this pull request as ready for review April 26, 2024 10:59
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 26, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 26, 2024

Webrevs

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 26, 2024
Comment on lines 1443 to 1448
if (_needs_remembered_set_rebuild) {
// Prune rebuild candidates based on G1HeapWastePercent.
// Improves rebuild time in addition to remembered set memory usage.
G1CollectionSetChooser::build(_g1h->workers(), _g1h->num_regions(), _g1h->policy()->candidates());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to put this block into above block so that it is part of the "Select For Rebuild and Reclaim Empty Regions" measurement.

if (_needs_remembered_set_rebuild) {
// Prune rebuild candidates based on G1HeapWastePercent.
// Improves rebuild time in addition to remembered set memory usage.
G1CollectionSetChooser::build(_g1h->workers(), _g1h->num_regions(), _g1h->policy()->candidates());
Copy link
Contributor

Choose a reason for hiding this comment

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

The build method sorts according to gc efficiency and prunes.

GC efficiency can not be properly determined at this point and is entirely based on occupancy (remsets are empty); so basically what this does is sort and prune by live objects.

The whole gc-efficiency calculation can then be removed.

Actually I am not sure making the efficiency only based on free space is problematic, however we shouldn't pretend we care then.

An alternative I tried long time ago has been counting incoming references during marking as a substitute for the remset size metric. However in reality, the remembered set is a metric based on cards, so it will potentially be hard to assign cost for remembered set processing based on incoming references.

@walulyai walulyai requested a review from albertnetymk May 2, 2024 11:17
@@ -95,6 +95,21 @@ void G1CollectionCandidateList::verify() {
#endif

int G1CollectionCandidateList::compare(G1CollectionSetCandidateInfo* ci1, G1CollectionSetCandidateInfo* ci2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if the old comparison function would be renamed as well similarly to the other, e.g. compare_by_efficiencies.

Comment on lines 127 to 129
if (reclaimable1 == reclaimable2) return 0;
if (reclaimable1 > reclaimable2) return -1;
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the same style for this if-elseif-else cascade than for the other one.

HeapRegion* hr = (*iter)->_r;
(*iter)->_gc_efficiency = hr->calc_gc_efficiency();
}
_marking_regions.sort_by_efficiency();
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a bit surprising that this method also sorts by efficiency. I would almost say that the sorting is more important than the calculations.
I.e. something like sort_by_gc_efficiency seems better.

Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. Lgtm.

Copy link
Member

@albertnetymk albertnetymk left a comment

Choose a reason for hiding this comment

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

Now that pruning occurs in remark, I wonder if those pruned regions should/can switch to remset-untracked instead.

@@ -199,7 +225,7 @@ void G1CollectionSetCandidates::set_candidates_from_marking(G1CollectionSetCandi
verify();
}

void G1CollectionSetCandidates::sort_by_efficiency() {
void G1CollectionSetCandidates::sort_retained_by_efficiency() {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this renaming? Checking its callers, I feel the postcondition is that both kinds of candidates are sorted -- marking-candidates can be skipped seems an impl detail.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me revert this!

@@ -129,7 +129,9 @@ class G1CollectionCandidateList : public CHeapObj<mtGC> {
// Comparison function to order regions in decreasing GC efficiency order. This
// will cause regions with a lot of live objects and large remembered sets to end
// up at the end of the list.
static int compare(G1CollectionSetCandidateInfo* ci1, G1CollectionSetCandidateInfo* ci2);
static int compare_gc_efficiency(G1CollectionSetCandidateInfo* ci1, G1CollectionSetCandidateInfo* ci2);
Copy link
Member

Choose a reason for hiding this comment

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

Preexisting: I wonder if these can be static functions in cpp file, i.e. not in hpp at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Possible, but then they end up in different .cpp files, not sure if that is cleaner

@walulyai
Copy link
Member Author

walulyai commented May 3, 2024

Now that pruning occurs in remark, I wonder if those pruned regions should/can switch to remset-untracked instead.

iiuc, the rem_set()->clear() does that

@walulyai
Copy link
Member Author

walulyai commented May 3, 2024

Thanks @albertnetymk and @tschatzl for your reviews!

/integrate

@openjdk
Copy link

openjdk bot commented May 3, 2024

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

  • 58ef9e4: 8331402: G1: Remove is_active() calls in G1HRPrinter logging
  • 3c77dad: 8331507: JFR: Improve example usage in -XX:StartFlightRecording:help
  • 8ed3190: 8331401: G1: Make G1HRPrinter AllStatic
  • 1f6d38f: 8294978: Convert 5 test/jdk/jdk/jfr tests from ASM library to Classfile API
  • c60474b: 8323707: Adjust Classfile API's type arg model to better represent the embodied type
  • f78fa05: 8331636: [BACKOUT] Build failure after 8330076
  • f665e07: 8331540: [BACKOUT] NMT: add/make a mandatory MEMFLAGS argument to family of os::reserve/commit/uncommit memory API

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 3, 2024

@walulyai Pushed as commit ce73fec.

💡 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
Development

Successfully merging this pull request may close these issues.

3 participants