-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
8253971: ZGC: Flush mark stacks after processing concurrent roots #495
Conversation
👋 Welcome back pliden! A progress list of the required criteria for merging this PR into |
69cc4ad
to
1dd5cb7
Compare
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 it makes sense to unify this PR with the same logic in ZMarkRootsTask
to a function, sth like PostRootsScan
. Additionally, such flushing is only needed if ParallelGCThreads != ConcGCThreads
, right?
@albertnetymk Yes, the problem stems from ZWorkers::nconcurrent() potentially being less than ZWorkers::nworkers(). |
Thanks for the explanation. I am curious if it's worth the trouble to make the flush conditional. |
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. We might also want to poke out mark stacks on the VM thread when we handshake threads, using a concurrent VM operation. But maybe that is a problem for another day.
@pliden 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 more 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 5 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
I don't think we need to special-case the flushing. This condition is almost always true, and flushing out local mark stacks is inexpensive. I also think it's a somewhat nice/simplifying invariant, that all stacks are published on the stripes when worker threads start working. |
Yes, I do that in a separate patch I have in the works (which aims to simplify mark termination/flushing, and make it more robust). |
/integrate |
@pliden Since your change was applied there have been 8 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 65cab55. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
I looked into why almost all mark cycles see non-zero "mark completions". In other words, we almost always have some amount of mark work left to handle in the mark end pause. It turns out that worker threads don't flush their mark stacks in ZMarkConcurrentRootsTask::work(), which means they can hide work (in their thread local mark stacks) until those stacks are finally flushed out in ZMark::try_end(). The reason work can be hidden is that the set of worker threads executing ZMarkConcurrentRootsTask is not necessarily the same set of worker threads executing ZMarkTask. As a result, the mark end pause often becomes longer than it otherwise would have.
After fixing this, I did some tests with Dacapo, which shows the following improvement:
Before: Mark End Pause (avg/max): 0.391 / 1.142 ms
After: Mark End Pause (avg/max): 0.130 / 0.294 ms
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/495/head:pull/495
$ git checkout pull/495