-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8350621: Code cache stops scheduling GC #26189
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
base: master
Are you sure you want to change the base?
8350621: Code cache stops scheduling GC #26189
Conversation
Hi all, please review this change to avoid CodeCache triggered GCs temporarily being ignored. In particular, G1 does not make sure when its `collect()` method is called during a concurrent cycle, that a `Remark` pause that does code unloading etc. actually occurs after that request. This makes it so that some internal flag is not reset appropriately, stuck until the next code unloading (caused by e.g. a regular concurrent cycle being triggered). Testing: tier1-5 Thanks, Thomas
👋 Welcome back tschatzl! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@tschatzl |
@tschatzl Syntax:
User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address. |
@tschatzl |
/contributor add Alexandre Jacob [email protected] |
@tschatzl |
Webrevs
|
Good finding! I think it looks good, but it should get reviewed by G1 experts.
Seems like there are several ways the VM can take. |
This is a test bug - for some reason the compiler triggered "Code Cache Aggressive" instead of "Code Cache Threshold" gcs. The former are a more urgent version of the latter, so for that test this is fine. The test only checks for the latter. |
- restructure code in `try_collect_concurrently` - fix asserts - they only worked in the test because of whitebox being active - fix comments * threalmdoerr review: - fix test to be more lenient
// ensure that progress is made. | ||
} else if (GCCause::is_codecache_requested_gc(cause) && op.marking_in_progress()) { | ||
// For a CodeCache requested GC, before marking, progress is ensured as the | ||
// following Remark pause unloads code (and signals the requestr such). |
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.
spelling: requestr
// | ||
// Request is finished if any of | ||
// (1) the VMOp successfully performed a GC, | ||
// (2) a concurrent cycle was already in progress, | ||
// (2) a concurrent cycle was already in progress and we were | ||
// before the Remark pause for CodeCache requested GCs, |
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 this comment change is no longer needed. Which is good, because I find it confusingly
ambiguous, but had trouble figuring out what it should say instead. I think the original is fine,
because we're in a non-codecache request context.
} else if (!GCCause::is_user_requested_gc(cause)) { | ||
// For an "automatic" (not user-requested) collection, we just need to | ||
// ensure that progress is made. | ||
} else if (GCCause::is_codecache_requested_gc(cause) && op.marking_in_progress()) { |
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 wonder if this might be simpler if the codecache-request case were
completely handled by it's own clause. This would involve "duplicating" some
of the user-request case. But I think that could be done by chunking that into
a couple helper functions, bounded by the existing assertions in the
user-request case. So something like this (I don't love the names of the
helpers here):
if (is_codecache_requested_gc(cause)) {
if (op.marking_in_progress()) {
LOG... ;
return true;
}
// is there some assert similar to the user-request assert that makes sense here?
if (wait_for_completion(old_marking_started_before,
old_marking_started_after,
old_marking_completed_after)) {
return true;
}
// is there some assert similar to the user-request assert that makes sense here?
if (need_normal_retry(op)) {
continue;
}
}
And similarly in the user-request case. And obviously with more comments :)
While looking at that, I noticed that the whitebox control stall in the
user-request case is doing exactly what the comment about it says not to do.
It is waiting for control to be released, while the comment says not to do
that. This of course means there could be multiple complete collections (and
not just STW full collections) before it can proceed. This seems to be in the
initial published webrev for JDK-8240239. The immediately preceding (draft,
non-public) webrev has that comment but different code, so it looks like the
code was changed but the comment wasn't updated. Bad Kim!
I will file a bug for that and assign it to myself. If you decide to adopt
something like the above suggested refactoring, just retain that code and
comment as-is. I'll see if I can recall what happened there, and update the
comment accordingly. Unfortunately, the (non-public) email discussion between
those versions doesn't make any mention of this change.
Hi all,
please review this change to avoid CodeCache triggered GCs temporarily being ignored.
In particular, G1 does not make sure when its
collect()
method is called during a concurrent cycle, that aRemark
pause that does code unloading etc. actually occurs after that request. This makes it so that some internal flag is not reset appropriately (via some callback to the caller). After this event, there will never be another attempt by the compiler threads to issue a garbage collection. The compiler threads are stuck until the next code unloading (caused by e.g. a regular concurrent cycle being triggered).The original PR also stated a similar with Parallel GC - however due to recent changes (https://bugs.openjdk.org/browse/JDK-8192647 and others) I do not think it is possible any more that the
collect()
call can silently be ignored. (I.e. gclocker could abort a full gc that is the only reason why code cache unloading and that callback will not occur as expected).So for G1, the change makes the caller of
collect()
(i.e. the compiler thread) wait until that situation passes and retry. With that the compiler thread is sure that the callback the compiler threads are waiting for occurs. This does have the disadvantage that that compiler thread may not be available for compilation any more for a bit.Testing: tier1-5, test case passing, failing before
Thanks,
Thomas
Progress
Issue
Contributors
<[email protected]>
<[email protected]>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26189/head:pull/26189
$ git checkout pull/26189
Update a local copy of the PR:
$ git checkout pull/26189
$ git pull https://git.openjdk.org/jdk.git pull/26189/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26189
View PR using the GUI difftool:
$ git pr show -t 26189
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26189.diff
Using Webrev
Link to Webrev Comment