-
Notifications
You must be signed in to change notification settings - Fork 6k
8238687: Investigate memory uncommit during young collections in G1 #25832
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?
Conversation
/contributor add tschatzl |
👋 Welcome back iwalulya! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@walulyai |
/issue add JDK-8247843 |
@walulyai |
/issue add JDK-8248324 |
@walulyai |
Webrevs
|
/label add hotspot-gc |
@walulyai |
@walulyai this pull request can not be integrated into git checkout G1HeapResizePolicyV2
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
product(size_t, G1ShrinkByPercentOfAvailable, 50, EXPERIMENTAL, \ | ||
"When shrinking, maximum % of free space to claim.") \ | ||
range(0, 100) \ | ||
\ | ||
product(size_t, G1MinimumPercentOfGCTimeRatio, 25, EXPERIMENTAL, \ | ||
"Percentage of GCTimeRatio G1 will try to avoid going below.") \ | ||
range(0, 100) \ |
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.
If they are in [0,100], maybe uint
is enough?
@@ -47,7 +47,7 @@ class AbsSeq: public CHeapObj<mtInternal> { | |||
void init(double alpha); | |||
|
|||
protected: | |||
int _num; // the number of elements in the sequence | |||
uint _num; // the number of elements in the sequence |
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.
All int
-> uint
changes in this class/file are good; can they be extracted out to its own PR/ticket?
expand(resize_bytes, _workers); | ||
} else { | ||
shrink(resize_bytes); | ||
uncommit_regions_if_necessary(); |
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's more symmetric if this uncommit logic is inlined to shrink
.
@@ -127,6 +128,8 @@ class TruncatedSeq: public AbsSeq { | |||
double oldest() const; // the oldest valid value in the sequence | |||
double predict_next() const; // prediction based on linear regression | |||
|
|||
virtual void reset(); | |||
bool is_full() const { return _length == _num; } |
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.
Seems unused.
AbsSeq(alpha), _length(length), _next(0) { | ||
_sequence = NEW_C_HEAP_ARRAY(double, _length, mtInternal); | ||
for (int i = 0; i < _length; ++i) | ||
_sequence[i] = 0.0; | ||
TruncatedSeq::reset(); |
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.
Not sure why a new method (reset
) is needed inside this PR.
Hi all,
Please review this change to the G1 heap resizing policy, aimed at improving alignment with the configured GCTimeRatio. The GCTimeRatio is intended to manage the balance between GC time and Application execution time. G1's current implementation of GCTimeRatio appears to have drifted from its intended purpose over time. Therefore, we need to change G1’s use of the GCTimeRatio to better manage heap sizes without relying on additional magic constants.
The primary goal is to enable both heap expansion and shrinking at the end of any GC, rather than limiting shrinking to only the Remark or Full GC pauses as is currently done. We achieve this using heuristics that monitor both short-term and long-term GC time ratios relative to the configured GCTimeRatio.
The short-term policy adjusts a counter based on whether recent GC time is above or below a target range around GCTimeRatio (as defined by G1MinimumPercentOfGCTimeRatio). When the counter crosses predefined thresholds, the heap may be expanded or shrunk accordingly.
The long-term policy evaluates the GC time ratio over a long-term interval and triggers resizing if the number of recorded ratios exceeds a threshold and the GC time ratio over the long-term interval is outside the target range.
These heuristics allow for responsive heap resizing (both expansion and shrinking) at the end of any GC, guided by actual GC performance rather than fixed thresholds or constants.
We are increasing the default GCTimeRatio from 12 to 24, since under the new policy, the current default leads to overly aggressive heap shrinking as the GCTimeRatio allows for a lot more GC overhead.
Additionally, we are removing the heap resizing step at the end of the Remark pause which was based on MinHeapFreeRatio and MaxHeapFreeRatio. We keep this MinHeapFreeRatio-MaxHeapFreeRatio based resizing logic at the end of Full GC and Remark pauses that may have been triggered by PeriodicGCs.
As a result of these changes, some applications may settle at more appropriate and in some cases smaller heap sizes for the configured GCTimeRatio. While this may appear as a regression in some benchmarks that are sensitive to heap size, it represents more accurate G1 behavior with respect to the GCTimeRatio. Although smaller heap sizes may lead to more frequent GCs, this is the expected outcome, provided the cumulative GC overhead remains within the limits defined by the GCTimeRatio.
Testing: Mach5 Tier 1-7
Progress
Issues
Contributors
<[email protected]>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25832/head:pull/25832
$ git checkout pull/25832
Update a local copy of the PR:
$ git checkout pull/25832
$ git pull https://git.openjdk.org/jdk.git pull/25832/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25832
View PR using the GUI difftool:
$ git pr show -t 25832
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25832.diff
Using Webrev
Link to Webrev Comment