JDK-8238858 : G1 Mixed gc young gen sizing might cause the first mixed gc to immediately follow the prepare mixed gc
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-02-11
  • Updated: 2024-11-13
  • Resolved: 2020-06-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b04Fixed
Related Reports
Relates :  
Description
G1 sizes young gen to the minimum value allowed (G1NewSizePercent) during mixed gc by default, as default MaxGCPauseIntervalMillis is MaxGCPauseMillis+1.

This causes very small young gens (and edens i.e. 1 region) during mixed gc; particularly the first mixed gc after the Prepare Mixed gc will follow it very quickly because the survivor space for the prepare mixed gc is calculated using the current (young only) young gen. This means that for the next (mixed) gc, eden will be *very* small up to only 1 region.

E.g. heap size 3.5g, log output:

Young gc:
44,337s: GC(42) Eden regions: 755->0(726)
44,337s: GC(42) Survivor regions: 90->91(106) // i.e. at end of young-only gc there are 91 survivor regions, max capacity is 106

[Concurrent mark happens as GC(43)]

Prepare Mixed gc (~2s later):
46,288s: GC(44) Eden regions: 726->0(1)
46,288s: GC(44) Survivor regions: 91->92(103) // i.e. at the end of prepare-mixed gc there are 92 survivor regions, max capacity is 103. This is a problem because the number of survivor regions is already larger than the total young gen size allowed during the next mixed gc (87 according to G1NewSizePercent). So the next (mixed) gc will get 1 eden regions (the minimum allowed), which will make that next mixed gc occur almost instantly which breaks the MMU goal.

"Technically" only because by default the goal is 200/201 (in that configuration), but gctimeratio will spike quite a bit.

Mixed GC (~50ms later!):
46,340s: GC(45) Eden regions: 1->0(75)
46,340s: GC(45) Survivor regions: 92->12(12)

One solution would be sizing the survivor regions in Prepare Mixed based on the next (i.e. Mixed gc) young gen size and the MMU. This does not happen though at the moment.
Comments
Changeset: 0f2ac202 Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2020-06-25 16:07:43 +0000 URL: https://git.openjdk.java.net/amber/commit/0f2ac202
02-07-2020

Changeset: 0f2ac202 Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2020-06-25 16:07:43 +0000 URL: https://git.openjdk.java.net/mobile/commit/0f2ac202
02-07-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/38ecd000c722 User: tschatzl Date: 2020-06-25 14:08:46 +0000
25-06-2020

Reproducable on specjbb2015 with the following benchmark/VM settings: Benchmark: -Dspecjbb.comm.connect.type=HTTP_Jetty -Dspecjbb.controller.type=PRESET -Dspecjbb.controller.presett.ir=5000 -Dspecjbb.controller.preset.duration=10800000" VM: -Xms2g -Xmx8g -XX:GCTimeRatio=4 -XX:+UseStringDeduplication (I do not think gctimeratio makes a difference here, or string dedup). Other environment also described in this email on hotspot-gc-dev: https://mail.openjdk.java.net/pipermail/hotspot-gc-dev/2020-February/028511.html In this test, the problem occurs in almost every marking cycle because specjbb2015 allows such a large young gen.
11-02-2020