-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8357218: G1: Remove loop in G1CollectedHeap::try_collect_fullgc #25296
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
Conversation
👋 Welcome back ayang! A progress list of the required criteria for merging this PR into |
@albertnetymk 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:
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 27 new commits pushed to the
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 |
@albertnetymk The following label will be automatically applied to this pull request:
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. |
Webrevs
|
|
||
// Request is trivially finished. | ||
if (!GCCause::is_explicit_full_gc(cause) || op.gc_succeeded()) { | ||
return op.gc_succeeded(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete removal of this part isn't correct. The premise of this change, that "full-gc always
run-to-completion" is not correct. A _g1_periodic_collection
may be cancelled:
jdk/src/hotspot/share/gc/g1/g1VMOperations.cpp
Lines 39 to 48 in 50a7c61
bool VM_G1CollectFull::skip_operation() const { | |
// There is a race between the periodic collection task's checks for | |
// wanting a collection and processing its request. A collection in that | |
// gap should cancel the request. | |
if ((_gc_cause == GCCause::_g1_periodic_collection) && | |
(G1CollectedHeap::heap()->total_collections() != _gc_count_before)) { | |
return true; | |
} | |
return VM_GC_Operation::skip_operation(); | |
} |
Such a collection is not an explicit full-gc, so that part of the test may be true, when this function
returns false because the gc did not succeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the description. The overall result of !GCCause::is_explicit_full_gc(cause) || op.gc_succeeded()
is always true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Somehow comments seem to have disappeared, probably my fault. anyway:)
This method returns false
if the VM op has not been executed (skipped). The new code always returns true
, which is wrong afaict.
@@ -1864,24 +1864,12 @@ bool G1CollectedHeap::try_collect_fullgc(GCCause::Cause cause, | |||
const G1GCCounters& counters_before) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There does not seem to be a reason to keep this helper method. It's the same complexity as the attempt to do a young collection in try_collect()
now.
Or move the attempt to do a young collection to a helper method for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw, there is G1CollectedHeap::do_collection_pause()
that might fit exactly already.
counters_before.total_full_collections(), | ||
cause); | ||
VMThread::execute(&op); | ||
return op.prologue_succeeded(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They might now be the same value, but gc_succeeded()
seems like a better semantic fit here.
Looking around a little, it's not obvious why prologue_succeeded()
is ever the right name for a
client-accessible test for what seems like gc-completion. But that's a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about introducing a local var to better reflect the semantics?
// GCs always run-to-completion once prologue succeeds.
bool is_gc_succeeded = op.prologue_succeeded();
return is_gc_succeeded;
This way we don't need to maintain a "redundant" field in VM_G1CollectFull
.
(Thomas also asked whether the same field in VM_G1CollectForAllocation
is actually needed -- seems that _gc_succeeded == prologue_succeeded()
holds as well, so we can potential remove that one as well.)
If you dislike the suggestion, I will add back the removed field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field does not need to be re-added in the full gc VM op, just add an accessor gc_succeeded()
that returns the internal prologue_succeeded()
.
I will file a bug for removing the _gc_succeeded
field in VM_G1CollectForAllocation
, because it is always true if doit
ran.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the question that clients care about is whether the gc succeeded.
Whether the prologue succeeded or not might be used as part of the
implementation of that. That is, I think gc_succeeded ought to be part of the
public API for GC operations, and prologue_succeeded shouldn't be, with some
gc_succeeded operations being implemented as just a call to
prologue_succeeded.
That probably shouldn't be part of this change though. Instead, I'd prefer
this change maintain the status quo in this area. Or do what @tschatzl
suggested, which I saw as I was about to post this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added back the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the question that clients care about is whether the gc succeeded.
Whether the prologue succeeded or not might be used as part of the
implementation of that. That is, I think gc_succeeded ought to be part of the
public API for GC operations, and prologue_succeeded shouldn't be, with some
gc_succeeded operations being implemented as just a call to
prologue_succeeded.
Agree. Filed JDK-8357307.
counters_before.total_full_collections(), | ||
cause); | ||
VMThread::execute(&op); | ||
return op.prologue_succeeded(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the question that clients care about is whether the gc succeeded.
Whether the prologue succeeded or not might be used as part of the
implementation of that. That is, I think gc_succeeded ought to be part of the
public API for GC operations, and prologue_succeeded shouldn't be, with some
gc_succeeded operations being implemented as just a call to
prologue_succeeded.
That probably shouldn't be part of this change though. Instead, I'd prefer
this change maintain the status quo in this area. Or do what @tschatzl
suggested, which I saw as I was about to post this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Thanks for review. /integrate |
Going to push as commit e6750a5.
Your commit was automatically rebased without conflicts. |
@albertnetymk Pushed as commit e6750a5. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Simple removing unnecessary loop in "caller" of
VM_G1CollectFull
, because an explicit full-gc always run-to-completion.Test: tier1-3
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25296/head:pull/25296
$ git checkout pull/25296
Update a local copy of the PR:
$ git checkout pull/25296
$ git pull https://git.openjdk.org/jdk.git pull/25296/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25296
View PR using the GUI difftool:
$ git pr show -t 25296
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25296.diff
Using Webrev
Link to Webrev Comment