JDK-8153578 : Default NewRatio is ignored when UseConcMarkSweepGC is used as GC algorithm
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2016-03-15
  • Updated: 2017-04-26
  • Resolved: 2016-06-04
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 9
9Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux host 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
When we run 
java -server -Xms6144m -Xmx6144m -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -version

The par new genearation heap is set to 166MB instead of 1.8GB.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run :
java -server -Xms6144m -Xmx6144m -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -version

Check size of Heap of par new generation

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If the Xms and Xmx is 6GB, par new generation   total should be 1887488K instead of 153344K,
ACTUAL -
In Sun JDK there were few bugs previously with subject ���JDK-6872335 : NewRatio ignored when UseConcMarkSweepGC set���. 

http://bugs.java.com/view_bug.do?bug_id=6872335
http://bugs.java.com/view_bug.do?bug_id=6862534

Although these bugs are fixed, but IMO the bug still exists for default settings of NewRatio when UseConcMarkSweepGC is used.


We still have the bug where the default NewRatio=2 is not considered along with UseConcMarkSweepGC

Option #1 : Default GC (-XX:+UseParallelGC) : PSYoungGen      total 1835008K = 1.75GB (As it considered the default NewRatio=2)
 /usr/bin/java -server -Xms6144m -Xmx6144m -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -version
-XX:InitialHeapSize=6442450944 -XX:MaxHeapSize=6442450944 -XX:MaxMetaspaceSize=268435456 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Heap
PSYoungGen      total 1835008K, used 94372K [0x0000000740000000, 0x00000007c0000000, 0x00000007c0000000)
  eden space 1572864K, 6% used [0x0000000740000000,0x0000000745c29180,0x00000007a0000000)
  from space 262144K, 0% used [0x00000007b0000000,0x00000007b0000000,0x00000007c0000000)
  to   space 262144K, 0% used [0x00000007a0000000,0x00000007a0000000,0x00000007b0000000)
ParOldGen       total 4194304K, used 0K [0x0000000640000000, 0x0000000740000000, 0x0000000740000000)
  object space 4194304K, 0% used [0x0000000640000000,0x0000000640000000,0x0000000740000000)
Metaspace       used 2189K, capacity 4480K, committed 4480K, reserved 1056768K
  class space    used 240K, capacity 384K, committed 384K, reserved 1048576K


Option #2 : UseConcMarkSweepGC only (-XX:+ UseConcMarkSweepGC) : par new generation   total 153344K = 149.75 MB (Here ���XX:NewRatio=2 is ignored which is set by default)

 /usr/bin/java -server -Xms6144m -Xmx6144m -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -version
-XX:InitialHeapSize=6442450944 -XX:MaxHeapSize=6442450944 -XX:MaxMetaspaceSize=268435456 -XX:MaxNewSize=174485504 -XX:MaxTenuringThreshold=6 -XX:NewSize=174485504 -XX:OldPLABSize=16 -XX:OldSize=348971008 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Heap
par new generation   total 153344K, used 8179K [0x0000000640000000, 0x000000064a660000, 0x000000064a660000)
  eden space 136320K,   6% used [0x0000000640000000, 0x00000006407fcf00, 0x0000000648520000)
  from space 17024K,   0% used [0x0000000648520000, 0x0000000648520000, 0x00000006495c0000)
  to   space 17024K,   0% used [0x00000006495c0000, 0x00000006495c0000, 0x000000064a660000)
concurrent mark-sweep generation total 6121088K, used 0K [0x000000064a660000, 0x00000007c0000000, 0x00000007c0000000)
Metaspace       used 2190K, capacity 4480K, committed 4480K, reserved 1056768K
  class space    used 240K, capacity 384K, committed 384K, reserved 1048576K


Option #3 : UseConcMarkSweepGC along with NewRatio=2 (-XX:+ UseConcMarkSweepGC ���XX:NewRatio=2) : par new generation   total 1887488K = 1.8 GB (Here ���XX:NewRatio=2 is considered when set explicitly)

 /usr/bin/java -server -Xms6144m -Xmx6144m -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:NewRatio=2 -version
-XX:InitialHeapSize=6442450944 -XX:MaxHeapSize=6442450944 -XX:MaxMetaspaceSize=268435456 -XX:MaxTenuringThreshold=6 -XX:NewRatio=2 -XX:OldPLABSize=16 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Heap
par new generation   total 1887488K, used 100669K [0x0000000640000000, 0x00000006c0000000, 0x00000006c0000000)
  eden space 1677824K,   6% used [0x0000000640000000, 0x000000064624f7f0, 0x00000006a6680000)
  from space 209664K,   0% used [0x00000006a6680000, 0x00000006a6680000, 0x00000006b3340000)
  to   space 209664K,   0% used [0x00000006b3340000, 0x00000006b3340000, 0x00000006c0000000)
concurrent mark-sweep generation total 4194304K, used 0K [0x00000006c0000000, 0x00000007c0000000, 0x00000007c0000000)
Metaspace       used 2189K, capacity 4480K, committed 4480K, reserved 1056768K
  class space    used 240K, capacity 384K, committed 384K, reserved 1048576K


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
To set -XX:NewRatio=2 explicitly if we are using -XX:+UseConcMarkSweepGC 


Comments
See Jon and Ramki's comments.
04-06-2016

My comments from the mail thread. ==================================================== The intention of this code is to ergonomically select a small young gen size to keep young GC pauses small. The value of default value of CMSYoungGenPerWorker was chosen such that 1 GC worker could collect that large a young gen in an "acceptable" pause time. "acceptable", of course, is in the eye of the beholder and is probably out of date but it allows the user to pick a value such that the young gen gets larger as the ability to collect the young gen in that "acceptable" pause time scales up with the number of GC workers. Bottom line is that this is not a bug. It is an unfortunate conflict between the default behavior of how the other GC's use NewRatio and how CMS uses NewRatio. I think there is a similiar conflict in G1. ==================================================== From mail with Ramki ===================================================== Hi Jon -- Yes, that was definitely the intention of that code -- it may or may not have used the "ergonomic" set_flag_* macros correctly though. And of course the associated parameters haven't been changed or tuned since they were pulled from the hat ages ago, so might need adjustment. I can take a look at the ticket and add some comments after looking at the code. -- ramki On Wed, May 25, 2016 at 10:31 AM, Jon Masamitsu <jon.masamitsu@oracle.com> wrote: Ramki, This CR complains that NewRatio is ignored when it is the default value. Instead of using NewRatio the value of CMSYoungGenPerWorker is used to calculate the young gen size. 1557 const size_t preferred_max_new_size_unaligned = 1558 MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * ParallelGCThreads)); 1559 size_t preferred_max_new_size = Was the intent of that code to keep the young gen size smaller to keep the young pauses smaller? https://bugs.openjdk.java.net/browse/JDK-8153578 Thanks. Yes, this goes way back. Jon ==================================================== The details of this CMS behavior should be documented and the CR closed as not-a-bug.
03-06-2016

Below are the results... 8uxx - Fail 9 ea b-110 - Fail
06-04-2016

when used -XX:+UseConcMarkSweepGC default value -XX:NewRatio (2) is completly ignored. If specified on the vm arguments -XX:NewRatio = 2 it works properly -sh-4.1$ /opt/java/jdk1.8.0_74/bin/java -server -Xms6144m -Xmx6144m -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -version -XX:InitialHeapSize=6442450944 -XX:MaxHeapSize=6442450944 -XX:MaxMetaspaceSize=268435456 -XX:MaxNewSize=348966912 -XX:MaxTenuringThreshold=6 -XX:NewSize=348966912 -XX:OldPLABSize=16 -XX:OldSize=697933824 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC java version "1.8.0_74" Java(TM) SE Runtime Environment (build 1.8.0_74-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode) Heap par new generation total 306688K, used 10905K [0x0000000640000000, 0x0000000654cc0000, 0x0000000654cc0000) eden space 272640K, 4% used [0x0000000640000000, 0x0000000640aa67e8, 0x0000000650a40000) from space 34048K, 0% used [0x0000000650a40000, 0x0000000650a40000, 0x0000000652b80000) to space 34048K, 0% used [0x0000000652b80000, 0x0000000652b80000, 0x0000000654cc0000) concurrent mark-sweep generation total 5950720K, used 0K [0x0000000654cc0000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2225K, capacity 4480K, committed 4480K, reserved 1056768K class space used 245K, capacity 384K, committed 384K, reserved 1048576K -sh-4.1$ /opt/java/jdk1.8.0_74/bin/java -server -Xms6144m -Xmx6144m -XX:NewRatio=2 -XX:MaxMetaspaceSize=256m -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -version -XX:InitialHeapSize=6442450944 -XX:MaxHeapSize=6442450944 -XX:MaxMetaspaceSize=268435456 -XX:MaxTenuringThreshold=6 -XX:NewRatio=2 -XX:OldPLABSize=16 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC java version "1.8.0_74" Java(TM) SE Runtime Environment (build 1.8.0_74-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode) Heap par new generation total 1887488K, used 67113K [0x0000000640000000, 0x00000006c0000000, 0x00000006c0000000) eden space 1677824K, 4% used [0x0000000640000000, 0x000000064418a558, 0x00000006a6680000) from space 209664K, 0% used [0x00000006a6680000, 0x00000006a6680000, 0x00000006b3340000) to space 209664K, 0% used [0x00000006b3340000, 0x00000006b3340000, 0x00000006c0000000) concurrent mark-sweep generation total 4194304K, used 0K [0x00000006c0000000, 0x00000007c0000000, 0x00000007c0000000) Metaspace used 2225K, capacity 4480K, committed 4480K, reserved 1056768K class space used 245K, capacity 384K, committed 384K, reserved 1048576K
06-04-2016