jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8338977: Parallel: Improve heap resizing heuristics

Open albertnetymk opened this issue 7 months ago • 9 comments

This patch refines Parallel's sizing strategy to improve overall memory management and performance.

The young generation layout has been reconfigured from the previous eden-from/to arrangement to a new from/to-eden order. This new layout facilitates young generation resizing, since we perform resizing after a successful young GC when all live objects are located at the beginning of the young generation. Previously, resizing was often inhibited by live objects residing in the middle of the young generation (from-space). The new layout is illustrated in parallelScavengeHeap.hpp.

NumberSeq is now used to track various runtime metrics, such as minor/major GC pause durations, promoted/survived bytes after a young GC, highest old generation usage, etc. This tracking primarily lives in AdaptiveSizePolicy and its subclass PSAdaptiveSizePolicy.

GC overhead checking, which was previously entangled with adaptive resizing logic, has been extracted and is now largely encapsulated in ParallelScavengeHeap::is_gc_overhead_limit_reached.

Performance evaluation

  • SPECjvm2008-Compress shows ~8% improvement on Linux/AArch64 and Linux/x64 (restoring the regression reported in JDK-8332485 and JDK-8338689).
  • Fixes the surprising behavior when using a non-default (smaller) value of GCTimeRatio with Heapothesys/Hyperalloc, as discussed in this thread.
  • Performance is mostly neutral across other tested benchmarks: DaCapo, SPECjbb2005, SPECjbb2015, SPECjvm2008, and CacheStress. The number of young-gc sometimes goes up a bit and the total heap-size decreases a bit, because promotion-size-to-old-gen goes down with the more effective eden/survivor-space resizing.

PS: I have opportunistically set the obsolete/expired version to ~~25/26~~ 26/27 for now. I will update them accordingly before merging.

Test: tier1-8


Progress

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

Issues

  • JDK-8338977: Parallel: Improve heap resizing heuristics (Enhancement - P4)
  • JDK-8356071: Parallel: Improve heap resizing heuristics (CSR)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25000

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

Using diff file

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

Using Webrev

Link to Webrev Comment

albertnetymk avatar May 02 '25 10:05 albertnetymk

:wave: Welcome back ayang! 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.

bridgekeeper[bot] avatar May 02 '25 10:05 bridgekeeper[bot]

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

8338977: Parallel: Improve heap resizing heuristics

Reviewed-by: zgu, gli, iwalulya

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

  • 594c080b2bde81a48ecccda85ac765218fc93856: 8359760: Remove the jdk.jsobject module
  • e6ebefaa404daa4160bdc1c5d9c954c040e2c0c2: 8333857: Test sun/security/ssl/SSLSessionImpl/ResumeChecksServer.java failed: Existing session was used
  • 38cd860daa9504bbe5add8c2d045d78c75fb7e38: 8363816: Refactor array name creation
  • ... and 52 more: https://git.openjdk.org/jdk/compare/7da274ded4a36c6314702b687fcafcda80ae08c4...master

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[bot] avatar May 02 '25 10:05 openjdk[bot]

@albertnetymk The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

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.

openjdk[bot] avatar May 02 '25 10:05 openjdk[bot]

/cc hotspot-gc

albertnetymk avatar May 02 '25 10:05 albertnetymk

@albertnetymk The hotspot-gc label was successfully added.

openjdk[bot] avatar May 02 '25 10:05 openjdk[bot]

Thanks for the aliasmap update, looks good.

I think alias sun.gc.policy.boundaryMoved is removed here as it's already redundant, the rest all match with the counter being removed in the change.

There is a case for removing those old e.g. 1.4.1 aliases separately, in a future change.

kevinjwalls avatar Jun 04 '25 09:06 kevinjwalls

Do we have other uses of class AdaptiveSizePolicy except for parallelGC?

walulyai avatar Jun 23 '25 07:06 walulyai

Do we have other uses of class AdaptiveSizePolicy except for parallelGC?

No. A followup cleanup can be to merge this class into its sole subclass, used by Parallel.

albertnetymk avatar Jun 23 '25 08:06 albertnetymk

Thanks for review.

/integrate

albertnetymk avatar Jul 23 '25 20:07 albertnetymk

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

  • 2292246f8c11f735f50e2046ec6606e89289e9f5: 8350621: Code cache stops scheduling GC
  • 03e9ea169b7e45ae3c2ac23b5fe73d39ae57506f: 8358530: Properties#list should warn against non-String values
  • 594c080b2bde81a48ecccda85ac765218fc93856: 8359760: Remove the jdk.jsobject module
  • ... and 54 more: https://git.openjdk.org/jdk/compare/7da274ded4a36c6314702b687fcafcda80ae08c4...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Jul 23 '25 20:07 openjdk[bot]

@albertnetymk Pushed as commit ad510fb25e47098d136515c355164e5177c5b419.

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

openjdk[bot] avatar Jul 23 '25 20:07 openjdk[bot]