Skip to content

Commit

Permalink
CMS ignored analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm3746 committed Jul 11, 2024
1 parent 580fb5c commit bde56f3
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/main/java/org/github/joa/JvmOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,17 @@ public class JvmOptions {
*/
private ArrayList<String> overconstrained = new ArrayList<String>();

/**
* The initial number of parallel gc threads for the CMS collector.
*
* For example:
*
* <pre>
* -XX:ParallelCMSThreads=4
* </pre>
*/
private String parallelCmsThreads;

/**
* The number of parallel gc threads. Default formula:
*
Expand Down Expand Up @@ -1922,6 +1933,7 @@ public class JvmOptions {
* </pre>
*/
private String shenandoahMinFreeThreshold;

/**
* Option to set the size (bytes) of the "soft" heap maximum for the Shenandoah collector. Used to minimize process
* size and still handling bursts. The JVM would only exceed the "soft" max heap size to avoid something like
Expand All @@ -1935,7 +1947,6 @@ public class JvmOptions {
* -XX:ShenandoahSoftMaxHeapSize=4294967296
*/
private String shenandoahSoftMaxHeapSize;

/**
* Experimental option (requires {@link #unlockExperimentalVmOptions} enabled) to specify the number of milliseconds
* before unused memory in the page cache is evicted (default 5 minutes). Setting below 1 second can cause
Expand Down Expand Up @@ -3302,7 +3313,10 @@ public JvmOptions(JvmContext jvmContext) {
} else if (option.matches("^-XX:[\\-+]OptimizeStringConcat$")) {
optimizeStringConcat = option;
key = "OptimizeStringConcat";
} else if (option.matches("^-XX:ParallelGCThreads=\\d{1,3}$")) {
} else if (option.matches("^-XX:ParallelCMSThreads=\\d{1,}$")) {
parallelCmsThreads = option;
key = "ParallelCMSThreads";
} else if (option.matches("^-XX:ParallelGCThreads=\\d{1,}$")) {
parallelGcThreads = option;
key = "ParallelGCThreads";
} else if (option.matches("^-XX:[\\-+]ParallelRefProcEnabled$")) {
Expand Down Expand Up @@ -4630,6 +4644,19 @@ public void doAnalysis() {
if (useStringCache != null) {
addAnalysis(Analysis.INFO_USE_STRING_CACHE_IGNORED);
}
// Check for CMS options when the CMS collector is not used)
if (!garbageCollectors.contains(GarbageCollector.CMS)
&& !garbageCollectors.contains(GarbageCollector.UNKNOWN)) {
if (cmsInitiatingOccupancyFraction != null) {
analysis.add(Analysis.INFO_CMS_INITIATING_OCCUPANCY_FRACTION_IGNORED);
}
if (parallelCmsThreads != null) {
analysis.add(Analysis.INFO_CMS_PARALLEL_CMS_THREADS_IGNORED);
}
if (useCmsInitiatingOccupancyOnly != null) {
analysis.add(Analysis.INFO_CMS_USE_CMS_INITIATING_OCCUPANCY_ONLY_IGNORED);
}
}
}
}

Expand Down Expand Up @@ -5384,6 +5411,10 @@ public ArrayList<String> getOverconstrained() {
return overconstrained;
}

public String getParallelCmsThreads() {
return parallelCmsThreads;
}

public String getParallelGcThreads() {
return parallelGcThreads;
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/github/joa/util/Analysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ public enum Analysis {
*/
INFO_CMS_INIT_OCCUPANCY_ONLY_MISSING("info.cms.init.occupancy.only.missing"),

/**
* Property key for -XX:CMSInitiatingOccupancyFraction when the CMS collector is not used.
*/
INFO_CMS_INITIATING_OCCUPANCY_FRACTION_IGNORED("info.cms.initiating.occupancy.fraction.ignored"),

/**
* Property key for -XX:ParallelCMSThreads when the CMS collector is not used.
*/
INFO_CMS_PARALLEL_CMS_THREADS_IGNORED("info.cms.parallel.cms.threads.ignored"),

/**
* Property key for -XX:(+|-)UseCMSInitiatingOccupancyOnly when the CMS collector is not used.
*/
INFO_CMS_USE_CMS_INITIATING_OCCUPANCY_ONLY_IGNORED("info.cms.use.cms.initiating.occupancy.only.ignored"),

/**
* Property key for setting the milliseconds the CMS collector will wait before starting an initial mark after a
* young collection with -XX:CMSWaitDuration=N.
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/org/github/joa/analysis.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ info.cms.disabled=The CMS collector is disabled with -XX:-UseParNewGC -XX:-UseCo
info.cms.eden.chunks.record.always=The flag to always record CMS parallel initial mark/remark eden chunks is set with -XX:(+|-)CMSEdenChunksRecordAlways. This is not a standard recommended option. Unless testing has shown this improves performance, consider removing this option to allow the default value to be applied.
info.cms.incremental.mode=The CMS collector is being run in incremental mode. Concurrent phases are periodically stopped so application threads can run. This is useful on systems with 1-2 processors that cannot afford to dedicate cpu to the concurrent phases. Remove -XX:+CMSIncrementalMode if > 2 cpu/cores.
info.cms.init.occupancy.only.missing=The CMS occupancy fraction, -XX:CMSInitiatingOccupancyFraction=N (default 92), is set without -XX:+UseCMSInitiatingOccupancyOnly enabled. Typically these options are used in combination with applications with large variances in object allocation and young generation promotion rates that prevent the CMS collector from accurately predicting when to start the CMS cycle. Consider adding/enabling -XX:+UseCMSInitiatingOccupancyOnly to disable heuristics (calculating anticipated promotions) and use only the occupancy fraction to determine when to trigger a CMS cycle.
info.cms.initiating.occupancy.fraction.ignored=-XX:CMSInitiatingOccupancyFraction is being ignored (the CMS collector is not used).
info.cms.parallel.cms.threads.ignored=-XX:ParallelCMSThreads is being ignored (the CMS collector is not used).
info.cms.use.cms.initiating.occupancy.only.ignored=-XX:(+|-)UseCMSInitiatingOccupancyOnly is being ignored (the CMS collector is not used).
info.cms.wait.duration=The milliseconds the CMS collector will wait before starting an initial mark after a young collection is set with -XX:CMSWaitDuration=N. This is not a standard recommended option. Unless testing has shown this improves performance, consider removing this option to allow the default value to be applied.
info.comp.class.size.comp.class.disabled=Compressed class pointers space size is not being used due to compressed class pointers being disabled (-XX:-UseCompressedClassPointers).
info.comp.class.size.comp.oops.disabled=Compressed class pointers space size is not being used due to compressed object references being disabled (-XX:-UseCompressedOops).
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/org/github/joa/TestJvmOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,14 @@ void testOnOutOfMemoryScript() {
"OnOutOfMemoryError not correct.");
}

@Test
void testParallelCmsThreads() {
String opts = "-Xms1g -XX:ParallelCMSThreads=2 -Xmx1g";
JvmContext context = new JvmContext(opts);
JvmOptions jvmOptions = new JvmOptions(context);
assertEquals("-XX:ParallelCMSThreads=2", jvmOptions.getParallelCmsThreads(), "ParallelCMSThreads not correct.");
}

@Test
void testPerMethodRecompilationCutoff() {
String opts = "-Xmx1g -XX:PerMethodRecompilationCutoff=10000 -XX:G1NewSizePercent=1";
Expand Down
45 changes: 45 additions & 0 deletions src/test/java/org/github/joa/util/TestAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,21 @@ void testCmsIncrementalModeWithInitatingOccupancyFractionCmsDisabled() {
Analysis.WARN_CMS_INC_MODE_WITH_INIT_OCCUP_FRACT + " analysis incorrectly identified.");
}

@Test
void testCmsInitiatingOccupancyFractionIgnored() {
String opts = "-XX:CMSInitiatingOccupancyFraction=75";
JvmContext context = new JvmContext(opts);
context.setContainer(true);
JvmOptions jvmOptions = new JvmOptions(context);
jvmOptions.doAnalysis();
assertFalse(jvmOptions.hasAnalysis(Analysis.INFO_CMS_INITIATING_OCCUPANCY_FRACTION_IGNORED.getKey()),
Analysis.INFO_CMS_INITIATING_OCCUPANCY_FRACTION_IGNORED + " analysis incorrectly identified.");
jvmOptions.getJvmContext().getGarbageCollectors().add(GarbageCollector.G1);
jvmOptions.doAnalysis();
assertTrue(jvmOptions.hasAnalysis(Analysis.INFO_CMS_INITIATING_OCCUPANCY_FRACTION_IGNORED.getKey()),
Analysis.INFO_CMS_INITIATING_OCCUPANCY_FRACTION_IGNORED + " analysis not identified.");
}

/**
* Test if PAR_NEW collector is enabled/disabled when the CMS collector is not used.
*/
Expand Down Expand Up @@ -1703,6 +1718,21 @@ void testParallelClassLoading() {
Analysis.WARN_DIAGNOSTIC_UNSYNCLOAD_CLASS + " analysis not identified.");
}

@Test
void testParallelCmsThreadsIgnored() {
String opts = "-XX:ParallelCMSThreads=2";
JvmContext context = new JvmContext(opts);
context.setContainer(true);
JvmOptions jvmOptions = new JvmOptions(context);
jvmOptions.doAnalysis();
assertFalse(jvmOptions.hasAnalysis(Analysis.INFO_CMS_PARALLEL_CMS_THREADS_IGNORED.getKey()),
Analysis.INFO_CMS_PARALLEL_CMS_THREADS_IGNORED + " analysis incorrectly identified.");
jvmOptions.getJvmContext().getGarbageCollectors().add(GarbageCollector.G1);
jvmOptions.doAnalysis();
assertTrue(jvmOptions.hasAnalysis(Analysis.INFO_CMS_PARALLEL_CMS_THREADS_IGNORED.getKey()),
Analysis.INFO_CMS_PARALLEL_CMS_THREADS_IGNORED + " analysis not identified.");
}

@Test
void testParallelInitialMarkDisabledCms() {
String opts = "-Xms1024m -Xmx2048m -XX:MaxPermSize=256m -XX:-CMSParallelInitialMarkEnabled";
Expand Down Expand Up @@ -2634,6 +2664,21 @@ void testUseCmsCompactAtFullCollectionEnabled() {
Analysis.ERROR_JDK8_USE_CMS_COMPACTION_AT_FULL_GC_ENABLED + " analysis not identified.");
}

@Test
void testUseCmsInitiatingOccupancyOnly() {
String opts = "-XX:+UseCMSInitiatingOccupancyOnly";
JvmContext context = new JvmContext(opts);
context.setContainer(true);
JvmOptions jvmOptions = new JvmOptions(context);
jvmOptions.doAnalysis();
assertFalse(jvmOptions.hasAnalysis(Analysis.INFO_CMS_USE_CMS_INITIATING_OCCUPANCY_ONLY_IGNORED.getKey()),
Analysis.INFO_CMS_USE_CMS_INITIATING_OCCUPANCY_ONLY_IGNORED + " analysis incorrectly identified.");
jvmOptions.getJvmContext().getGarbageCollectors().add(GarbageCollector.G1);
jvmOptions.doAnalysis();
assertTrue(jvmOptions.hasAnalysis(Analysis.INFO_CMS_USE_CMS_INITIATING_OCCUPANCY_ONLY_IGNORED.getKey()),
Analysis.INFO_CMS_USE_CMS_INITIATING_OCCUPANCY_ONLY_IGNORED + " analysis not identified.");
}

@Test
void testUseCodeCacheFlushingDisabled() {
String opts = "-Xss128k -XX:-UseCodeCacheFlushing -Xmx2048M";
Expand Down

0 comments on commit bde56f3

Please sign in to comment.