-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8353184: ZGC: Simplify and correct tlab_used() tracking #24814
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 sjohanss! A progress list of the required criteria for merging this PR into |
|
@kstefanj 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 326 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 |
Webrevs
|
stefank
left a comment
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 like this change. I've added a few comments below.
|
|
||
|
|
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.
| precond(size <= _used); | ||
| Atomic::sub(&_used, size, memory_order_relaxed); |
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.
| precond(size <= _used); | |
| Atomic::sub(&_used, size, memory_order_relaxed); | |
| precond(size <= _used); | |
| Atomic::sub(&_used, size, memory_order_relaxed); |
| } | ||
|
|
||
| void ZTLABUsage::reset() { | ||
| const size_t current_used = Atomic::xchg(&_used, (size_t) 0); |
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.
Does this work instead?
| const size_t current_used = Atomic::xchg(&_used, (size_t) 0); | |
| const size_t current_used = Atomic::xchg(&_used, 0u); |
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.
No, 0ul works on Linux, but Windows fails with that.
| } | ||
|
|
||
| // Save the old values for logging | ||
| const size_t old_used = used(); |
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.
It's not immediately obvious what _used is compared to used() Could one of these be renamed so that readers don't mistakenly assume that used() returns _used.
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.
Talked a bit about this offline, will add some comments and rename used() and capacity() to tlab_used() and tlab_capacity() to make it a bit more clear that they are not directly connected and also better match the ZHeap interface.
xmas92
left a comment
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.
lgtm.
|
Going to push as commit 526f543.
Your commit was automatically rebased without conflicts. |
Please review this change to improve TLAB handling in ZGC.
Summary
In ZGC the maximum TLAB size is 256k and in many cases we want the TLABs to be this big. But for threads only allocating a fraction of this, using TLABs of this size will render significant waste. This is normally handled by the shared TLAB sizing heuristic, but there have been a few things in ZGC which have prevented this mechanism to work as expected.
The heuristic bases the resizing on several things, and the GC is responsible for providing the amount used memory for TLABs (
tlab_used()) and the capacity available for TLABs (tlab_capacity()). Capacity is more or less the size of Eden for the other GCs, but ZGC does not have any generation sizes there is no given size for Eden. Before this change we returned the heap capacity as the TLAB capacity, since in theory we can use what is left for TLABs. Returning this, more or less disables the sizing heuristic since we only sample the usage when this holds:So we need to come up with a better value to return as capacity, we could use the amount of free memory, but this is also an over estimation of what will actually be used. The proposed approach is to use an average over the last 10 values of what was actually used for TLABs as the capacity. This will provide a good estimate of what the expected TLAB capacity is and the sizing heuristic will work as expected.
Another problem in this area is that since ZGC does TLAB retiring concurrently, the used value returned has previously been reset before used in the sizing heuristic. So to be able to use consisten values, we need to snapshot the usage in the mark start pause for the young generation and use those value for any TLAB retired after this pause.
How we track the TLAB used value is also changed. Before this change, TLAB used was tracked per-cpu and the way it was implemented let to some unwanted overhead. We added two additional fields that were tracked for all ages, but only used for Eden. These fields were cleared in the mark start pause, and when having many CPUs this actually affect the pause time. The new code tracks the Eden usage in the page-allocator instead.
This change also fixes to that the maximum TLAB size returned from ZGC is in words not bytes, which will mostly help logging, since the actual sizing is still enforced correctly.
Testing
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24814/head:pull/24814$ git checkout pull/24814Update a local copy of the PR:
$ git checkout pull/24814$ git pull https://git.openjdk.org/jdk.git pull/24814/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24814View PR using the GUI difftool:
$ git pr show -t 24814Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24814.diff
Using Webrev
Link to Webrev Comment