Skip to content

Commit

Permalink
Warn using zgc on smaller heaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm3746 committed Aug 29, 2024
1 parent 8d6ac94 commit 0673ed0
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 76 deletions.
75 changes: 39 additions & 36 deletions src/main/java/org/github/joa/JvmOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3842,57 +3842,60 @@ public void doAnalysis() {
}
if (bytesHeapMaxSize <= thirtyTwoGigabytes) {
// Max Heap unknown or <= 32g
if (!isCompressedOops() && !(jvmContext.getGarbageCollectors()
.contains(GarbageCollector.ZGC_GENERATIONAL)
if (jvmContext.getGarbageCollectors().contains(GarbageCollector.ZGC_GENERATIONAL)
|| jvmContext.getGarbageCollectors().contains(GarbageCollector.ZGC_NON_GENERATIONAL)
|| getExpectedGarbageCollectors().contains(GarbageCollector.ZGC_GENERATIONAL)
|| getExpectedGarbageCollectors().contains(GarbageCollector.ZGC_NON_GENERATIONAL))) {
if (bytesHeapMaxSize < 0) {
addAnalysis(Analysis.WARN_COMP_OOPS_DISABLED_HEAP_UNK);
} else {
addAnalysis(Analysis.WARN_COMP_OOPS_DISABLED_HEAP_32G_LTE);
|| getExpectedGarbageCollectors().contains(GarbageCollector.ZGC_NON_GENERATIONAL)) {
addAnalysis(Analysis.WARN_ZGC_HEAP_32G_LT);
} else {
if (!isCompressedOops()) {
if (bytesHeapMaxSize < 0) {
addAnalysis(Analysis.WARN_COMP_OOPS_DISABLED_HEAP_UNK);
} else {
addAnalysis(Analysis.WARN_COMP_OOPS_DISABLED_HEAP_32G_LT);
}
}
}
if (!isCompressedClassPointers()) {
if (bytesHeapMaxSize < 0) {
addAnalysis(Analysis.WARN_COMP_CLASS_DISABLED_HEAP_UNK);
} else {
addAnalysis(Analysis.WARN_COMP_CLASS_DISABLED_HEAP_32G_LTE);
if (!isCompressedClassPointers()) {
if (bytesHeapMaxSize < 0) {
addAnalysis(Analysis.WARN_COMP_CLASS_DISABLED_HEAP_UNK);
} else {
addAnalysis(Analysis.WARN_COMP_CLASS_DISABLED_HEAP_32G_LT);
}
}
}
// Check if MaxMetaspaceSize is less than CompressedClassSpaceSize.
if (maxMetaspaceSize != null) {
long compressedClassSpaceBytes;
if (compressedClassSpaceSize != null) {
compressedClassSpaceBytes = JdkUtil
.getByteOptionBytes(JdkUtil.getByteOptionValue(compressedClassSpaceSize));
} else {
// Default is 1G
compressedClassSpaceBytes = JdkUtil.convertSize(1, 'G', 'B');
// Check if MaxMetaspaceSize is less than CompressedClassSpaceSize.
if (maxMetaspaceSize != null) {
long compressedClassSpaceBytes;
if (compressedClassSpaceSize != null) {
compressedClassSpaceBytes = JdkUtil
.getByteOptionBytes(JdkUtil.getByteOptionValue(compressedClassSpaceSize));
} else {
// Default is 1G
compressedClassSpaceBytes = JdkUtil.convertSize(1, 'G', 'B');
}
if (JdkUtil.getByteOptionBytes(
JdkUtil.getByteOptionValue(maxMetaspaceSize)) < compressedClassSpaceBytes) {
addAnalysis(Analysis.WARN_METASPACE_LT_COMP_CLASS);
}
}
if (JdkUtil.getByteOptionBytes(
JdkUtil.getByteOptionValue(maxMetaspaceSize)) < compressedClassSpaceBytes) {
addAnalysis(Analysis.WARN_METASPACE_LT_COMP_CLASS);
// Check for settings being ignored
if (JdkUtil.isOptionDisabled(useCompressedOops) && compressedClassSpaceSize != null) {
addAnalysis(Analysis.INFO_COMP_CLASS_SIZE_COMP_OOPS_DISABLED);
}
if (JdkUtil.isOptionDisabled(useCompressedClassPointers) && compressedClassSpaceSize != null) {
addAnalysis(Analysis.INFO_COMP_CLASS_SIZE_COMP_CLASS_DISABLED);
}
}
// Check for settings being ignored
if (JdkUtil.isOptionDisabled(useCompressedOops) && compressedClassSpaceSize != null) {
addAnalysis(Analysis.INFO_COMP_CLASS_SIZE_COMP_OOPS_DISABLED);
}
if (JdkUtil.isOptionDisabled(useCompressedClassPointers) && compressedClassSpaceSize != null) {
addAnalysis(Analysis.INFO_COMP_CLASS_SIZE_COMP_CLASS_DISABLED);
}
} else {
// Max Heap >= 32g (should not use compressed pointers)
if (JdkUtil.isOptionEnabled(useCompressedOops)) {
addAnalysis(Analysis.WARN_COMP_OOPS_ENABLED_HEAP_32G_GT);
addAnalysis(Analysis.WARN_COMP_OOPS_ENABLED_HEAP_32G_GTE);
}
if (JdkUtil.isOptionEnabled(useCompressedClassPointers)) {
addAnalysis(Analysis.WARN_COMP_CLASS_ENABLED_HEAP_32G_GT);
addAnalysis(Analysis.WARN_COMP_CLASS_ENABLED_HEAP_32G_GTE);
}
// Should not be setting class pointer space size
if (compressedClassSpaceSize != null) {
addAnalysis(Analysis.WARN_COMP_CLASS_SIZE_HEAP_32G_GT);
addAnalysis(Analysis.WARN_COMP_CLASS_SIZE_HEAP_32G_GTE);
}
}
}
Expand Down
29 changes: 17 additions & 12 deletions src/main/java/org/github/joa/util/Analysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,39 +745,44 @@ public enum Analysis {
WARN_CMS_PARALLEL_REMARK_DISABLED("warn.cms.parallel.remark.disabled"),

/**
* Property key for compressed class pointers disabled (-XX:-UseCompressedClassPointers), and heap &lt; 32G.
* Property key for compressed class pointers disabled (-XX:-UseCompressedClassPointers) and heap &lt; 32G.
*/
WARN_COMP_CLASS_DISABLED_HEAP_32G_LTE("warn.comp.class.disabled.heap.32g.lte"),
WARN_COMP_CLASS_DISABLED_HEAP_32G_LT("warn.comp.class.disabled.heap.32g.lt"),

/**
* Property key for compressed class pointers disabled (-XX:-UseCompressedClassPointers), and heap size unknown.
* Property key for ZGC and heap &lt; 32G.
*/
WARN_ZGC_HEAP_32G_LT("warn.zgc.heap.32g.lt"),

/**
* Property key for compressed class pointers disabled (-XX:-UseCompressedClassPointers) and heap size unknown.
*/
WARN_COMP_CLASS_DISABLED_HEAP_UNK("warn.comp.class.disabled.heap.unk"),

/**
* Property key for compressed class pointers enabled (-XX:+UseCompressedClassPointers), and heap &gt;= 32G.
* Property key for compressed class pointers enabled (-XX:+UseCompressedClassPointers) and heap &gt;= 32G.
*/
WARN_COMP_CLASS_ENABLED_HEAP_32G_GT("warn.comp.class.enabled.heap.32g.gt"),
WARN_COMP_CLASS_ENABLED_HEAP_32G_GTE("warn.comp.class.enabled.heap.32g.gte"),

/**
* Property key for compressed class pointers space size set (-XX:CompressedClassSpaceSize), and heap &gt;= 32G.
* Property key for compressed class pointers space size set (-XX:CompressedClassSpaceSize) and heap &gt;= 32G.
*/
WARN_COMP_CLASS_SIZE_HEAP_32G_GT("warn.comp.class.size.heap.32g.gt"),
WARN_COMP_CLASS_SIZE_HEAP_32G_GTE("warn.comp.class.size.heap.32g.gte"),

/**
* Property key for compressed object references disabled (-XX:-UseCompressedOops), and heap &lt; 32G.
* Property key for compressed object references disabled (-XX:-UseCompressedOops) and heap &lt; 32G.
*/
WARN_COMP_OOPS_DISABLED_HEAP_32G_LTE("warn.comp.oops.disabled.heap.32g.lte"),
WARN_COMP_OOPS_DISABLED_HEAP_32G_LT("warn.comp.oops.disabled.heap.32g.lt"),

/**
* Property key for compressed object references disabled (-XX:-UseCompressedOops), and heap size unknown.
* Property key for compressed object references disabled (-XX:-UseCompressedOops) and heap size unknown.
*/
WARN_COMP_OOPS_DISABLED_HEAP_UNK("warn.comp.oops.disabled.heap.unk"),

/**
* Property key for compressed object references enabled (-XX:+UseCompressedOops), and heap &gt;= 32G.
* Property key for compressed object references enabled (-XX:+UseCompressedOops) and heap &gt;= 32G.
*/
WARN_COMP_OOPS_ENABLED_HEAP_32G_GT("warn.comp.oops.enabled.heap.32g.gt"),
WARN_COMP_OOPS_ENABLED_HEAP_32G_GTE("warn.comp.oops.enabled.heap.32g.gte"),

/**
* Property key for -Xconcurrentio.
Expand Down
13 changes: 7 additions & 6 deletions src/main/resources/org/github/joa/analysis.properties
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ warn.cms.inc.mode.with.init.occup.fract=When the CMS collector is run in increme
warn.cms.parallel.initial.mark.disabled=Multi-threaded CMS initial mark is disabled with -XX:-CMSParallelInitialMarkEnabled. Remove -XX:-CMSParallelInitialMarkEnabled and let the JVM determine the setting based on resources.
warn.cms.parallel.remark.disabled=Multi-threaded CMS remark is disabled with -XX:-CMSParallelRemarkEnabled. Remove -XX:-CMSParallelRemarkEnabled and let the JVM determine the setting based on resources.
warn.comp.class.disabled.heap.unk=Compressed class pointers are disabled with -XX:-UseCompressedClassPointers. One disadvantage of 64-bit is increased heap size due to increased pointer size. Compressed class pointers can be used on heaps < 32G to compress references to 32 bits, allowing class pointer and heap sizes on the order of 32-bit. Remove -XX:-UseCompressedClassPointers and let the JVM determine the setting based on resources.
warn.comp.class.disabled.heap.32g.lte=Compressed class pointers are disabled with -XX:-UseCompressedClassPointers, and heap < 32G. One disadvantage of 64-bit is increased heap size due to increased pointer size. Compressed class pointers can be used on heaps < 32G to compress references to 32 bits, allowing class pointer and heap sizes on the order of 32-bit. Remove -XX:-UseCompressedClassPointers and let the JVM determine the setting based on resources.
warn.comp.class.enabled.heap.32g.gt=Compressed class pointers are enabled with -XX:+UseCompressedClassPointers, and heap >= 32G. Compressed object references cannot be used on heaps >= 32G. Remove -XX-UseCompressedClassPointers and let the JVM determine the setting based on resources.
warn.comp.class.size.heap.32g.gt=Compressed class pointers space size is set (-XX:CompressedClassSpaceSize), and heap >= 32G. Remove -XX:CompressedClassSpaceSize, as compressed object references should not be used on heaps >= 32G.
warn.comp.oops.disabled.heap.32g.lte=Compressed object references are disabled with -XX:-UseCompressedOops, and heap < 32G. One disadvantage of 64-bit is increased heap size due to increased pointer size. Compressed class pointers can be used on heaps < 32G to compress references to 32 bits, allowing class pointer and heap sizes on the order of 32-bit. Remove -XX:-UseCompressedOops and let the JVM determine the setting based on resources.
warn.comp.class.disabled.heap.32g.lt=Compressed class pointers are disabled with -XX:-UseCompressedClassPointers and heap < 32G. One disadvantage of 64-bit is increased heap size due to increased pointer size. Compressed class pointers can be used on heaps < 32G to compress references to 32 bits, allowing class pointer and heap sizes on the order of 32-bit. Remove -XX:-UseCompressedClassPointers and let the JVM determine the setting based on resources.
warn.comp.class.enabled.heap.32g.gte=Compressed class pointers are enabled with -XX:+UseCompressedClassPointers and heap >= 32G. Compressed object references cannot be used on heaps >= 32G. Remove -XX-UseCompressedClassPointers and let the JVM determine the setting based on resources.
warn.comp.class.size.heap.32g.gte=Compressed class pointers space size is set (-XX:CompressedClassSpaceSize) and heap >= 32G. Remove -XX:CompressedClassSpaceSize, as compressed object references should not be used on heaps >= 32G.
warn.comp.oops.disabled.heap.32g.lt=Compressed object references are disabled with -XX:-UseCompressedOops and heap < 32G. One disadvantage of 64-bit is increased heap size due to increased pointer size. Compressed class pointers can be used on heaps < 32G to compress references to 32 bits, allowing class pointer and heap sizes on the order of 32-bit. Remove -XX:-UseCompressedOops and let the JVM determine the setting based on resources.
warn.comp.oops.disabled.heap.unk=Compressed object references are disabled with -XX:-UseCompressedOops. One disadvantage of 64-bit is increased heap size due to increased pointer size. Compressed class pointers can be used on heaps < 32G to compress references to 32 bits, allowing class pointer and heap sizes on the order of 32-bit. Remove -XX:-UseCompressedOops and let the JVM determine the setting based on resources.
warn.comp.oops.enabled.heap.32g.gt=Compressed object references are enabled with -XX:+UseCompressedOops, and heap >= 32G. Compressed object references should not be used on heaps >= 32G. Remove -XX:+UseCompressedOops and let the JVM determine the setting based on resources.
warn.comp.oops.enabled.heap.32g.gte=Compressed object references are enabled with -XX:+UseCompressedOops and heap >= 32G. Compressed object references should not be used on heaps >= 32G. Remove -XX:+UseCompressedOops and let the JVM determine the setting based on resources.
warn.concurrentio=Remove -Xconcurrentio, an old/undocumented/non-standard option that was removed in JDK 12 due to having no known use cases. It makes changes to JVM settings that are contrary to best practices with modern JVMs. Reference: https://bugs.openjdk.org/browse/JDK-8213767.
warn.container.perf.data.disk=If this is a container environment, it is recommended to disable the writing of performance data to disk (/tmp/hsperfdata*) with -XX:+PerfDisableSharedMem. Disk IOPS (Input/output Operations Per Second) is shared among containers. Eliminating disk access will prevent one workload monopolizing disk from impacting all containers.
warn.container.support.disabled=Container support is disabled with -XX:-UseContainerSupport, resulting in the JVM ignoring cgroup settings and determining cpu/cores from the host machine.
Expand Down Expand Up @@ -201,4 +201,5 @@ warn.thread.stack.size.tiny=Thread stack size is less than 1K. Were units (e.g.
warn.use.cond.card.mark=Conditional dirty card marking enabled with -XX:+UseCondCardMark. This is not a standard recommended option and can negatively impact performance (e.g. on single cpu/cores). Unless testing has shown this improves performance, consider removing this option.
warn.use.membar=The -XX:+UseMembar option is used. This was a workaround for a bug in old versions of JDK 1.6 (see https://bugs.openjdk.org/browse/JDK-6822370) and is not necessary with modern JVMs. If there is not a good use case for using this option, remove it, as it causes the JVM to use a memory barrier that slows down the JVM.
warn.use.thread.priorities.disabled=The Java Thread API is disabled with -XX:+UseThreadPriorities.
warn.verify.none=Class verification during loading is disabled with -Xverify:none. This is unsupported and can result in corrupt or invalid classes being loaded, causing undetermined JVM behavior and crashes.
warn.verify.none=Class verification during loading is disabled with -Xverify:none. This is unsupported and can result in corrupt or invalid classes being loaded, causing undetermined JVM behavior and crashes.
warn.zgc.heap.32g.lt=ZGC and heap < 32G. ZGC is generally for larger heaps (e.g. it does not support compressed object references).
Loading

0 comments on commit 0673ed0

Please sign in to comment.