Skip to content

8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc#29137

Closed
walulyai wants to merge 6 commits intoopenjdk:masterfrom
walulyai:G1ResizeAfterFullGC_v1
Closed

8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc#29137
walulyai wants to merge 6 commits intoopenjdk:masterfrom
walulyai:G1ResizeAfterFullGC_v1

Conversation

@walulyai
Copy link
Copy Markdown
Member

@walulyai walulyai commented Jan 9, 2026

Hi,

Please review this change which modifies the defaults for the MinHeapFreeRatio and MaxHeapFreeRatio flags in G1 so that they do not affect heap sizing unless explicitly set by the user.

Previously, these flags could trigger heap resizing at the end of Full GC, potentially overriding the G1 ergonomic heap sizing heuristics, which may be unexpected for the user. In particular, for workloads that frequently invoke System.gc(), the heap could shrink at the end of the Full GC and then expand aggressively during subsequent GCs (see image below).

shrink_expand_flip_flop

With this update, the default values for MinHeapFreeRatio and MaxHeapFreeRatio no longer affect heap resizing. These flags will only take effect when explicitly set by the user..

Additionally, pause times from user-triggered System.gc() invocations will be excluded from the data used to update heap sizing heuristics. Because these GCs are user-initiated and do not reflect actual GC pressure, including their pause times can skew GC Pause Time ratios used for heap sizing decisions.

Testing: Tier 1 and JavaPerf.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Change requires CSR request JDK-8375300 to be approved
  • Commit message must refer to an issue

Issues

  • JDK-8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc (Bug - P4)
  • JDK-8375300: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/29137/head:pull/29137
$ git checkout pull/29137

Update a local copy of the PR:
$ git checkout pull/29137
$ git pull https://git.openjdk.org/jdk.git pull/29137/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 29137

View PR using the GUI difftool:
$ git pr show -t 29137

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/29137.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Jan 9, 2026

👋 Welcome back iwalulya! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 9, 2026

@walulyai 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:

8238686: G1 may waste lots of space or fail to uncommit when observing MinHeapFreeRatio during sizing after full gc

Reviewed-by: tschatzl, sjohanss

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 70 new commits pushed to the master branch:

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 master branch, type /integrate in a new comment.

@openjdk openjdk Bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Jan 9, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 9, 2026

@walulyai The following label will be automatically applied to this pull request:

  • hotspot-gc

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@walulyai walulyai marked this pull request as ready for review January 9, 2026 11:52
@openjdk openjdk Bot added the rfr Pull request is ready for review label Jan 9, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Jan 9, 2026

Webrevs

@walulyai
Copy link
Copy Markdown
Member Author

Split the changes because the change in flag defaults needs to have a compatibility review.

@tschatzl
Copy link
Copy Markdown
Contributor

/csr needed

@openjdk openjdk Bot added ready Pull request is ready to be integrated csr Pull request needs approved CSR before integration labels Jan 14, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 14, 2026

@tschatzl has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@walulyai please create a CSR request for issue JDK-8238686 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@openjdk openjdk Bot removed the ready Pull request is ready to be integrated label Jan 14, 2026
@openjdk openjdk Bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Jan 20, 2026
@walulyai
Copy link
Copy Markdown
Member Author

Thanks @kstefanj and @tschatzl for the reviews!

/integrate

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 21, 2026

Going to push as commit b134030.
Since your change was applied there have been 92 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Jan 21, 2026
@openjdk openjdk Bot closed this Jan 21, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 21, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 21, 2026

@walulyai Pushed as commit b134030.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants