-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8321815: Shenandoah: gc state should be synchronized to java threads only once per safepoint #17112
Conversation
👋 Welcome back wkemper! A progress list of the required criteria for merging this PR into |
@earthling-amzn The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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.
Am wondering if we measure any improvement in time-at-safepoints for workloads with large number of threads?
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.
This seems reasonable. How many unnecessary state change distributions to threads do we save from this, so as to quantify the savings?
It would seem as if, as a verification mechanism that no state changes were dropped from distribution, it might be a good idea to assert in both prologue and epilogue of ShenandoahHeap stop-world ops that the _gc_state_changed
flag is false, indicating that the last state change was "consumed and distributed" by any stop-world op?
This instrumentation isn't included in this PR, but it shows how often GC state changes in a typical cycle:
And for some degenerated cycles, many of these changes may happen on the same safepoint:
I can add the assertions you described in the prologue and epilogue methods. For what it's worth, changes to the gc state already assert the changes occur on a safepoint. |
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 the data and for the extra verification checks.
🚢
@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:
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 52 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@ysramakrishna) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@earthling-amzn |
/sponsor |
Going to push as commit 808a039.
Your commit was automatically rebased without conflicts. |
@ysramakrishna @earthling-amzn Pushed as commit 808a039. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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.
(Late for the party here!)
The idea looks good, but there are two minor problems with it:
- Thread-local gc-state is supposed to be used from the barriers. This is why we can coalesce the thread-local gc-state within a safepoint, as long as we have the proper setup after the safepoint. However, I think it is a happy accident that we don't poll thread-local gc-state from current native barrier code, and thread-local gc-state is only used by java threads. If we ever did access from non-java (gc) threads, this would subtly break GC within e.g. final-mark vmop.
- It is fairly weird that now
ShenandoahHeap::set_gc_state_all_threads
does the actual modification, whileShenandoahHeap::set_gc_state_mask
does not! The names of the methods do not highlight the difference in semantics.
I guess we can hit two birds with one stone if we rename the methods to mention java threads and record/set split, and assert that non-java threads do not touch the ShenandoahThreadLocalData::_gc_state
. Something like SH::set_gc_state
(changes the global, sets the propagation flag) and SH::propagate_gc_state_java_threads
(propagates global to thread-local java threads)?
I'll open a new PR to rename these methods and add an assert that non-java threads never touch the thread local copy of gc state. |
Presently, every change to the gc change is distributed to all java threads. The gc state is only changed on safepoints. For applications with a very large number of java threads this may increase time on the safepoint. It would be better to synchronize the gc state only once per safepoint.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17112/head:pull/17112
$ git checkout pull/17112
Update a local copy of the PR:
$ git checkout pull/17112
$ git pull https://git.openjdk.org/jdk.git pull/17112/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17112
View PR using the GUI difftool:
$ git pr show -t 17112
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17112.diff
Webrev
Link to Webrev Comment