Skip to content

Commit

Permalink
Additional options.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm3746 committed Jul 31, 2024
1 parent cce1dc4 commit b85f9c0
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
57 changes: 56 additions & 1 deletion src/main/java/org/github/joa/JvmOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ public class JvmOptions {
*/
private String autoBoxCacheMax;

/**
* Experimental option (requires <code>-XX:+UnlockExperimentalVMOptions</code>) added in JDK17 that sets the number
* of remembered set entries a humongous region otherwise eligible for eager reclaim may have to be a candidate for
* eager reclaim. Selected ergonomically by default.
*
* For example:
*
* <pre>
* -XX:G1EagerReclaimRemSetThreshold=8
* </pre>
*/
private String g1EagerReclaimRemSetThreshold;

/**
* Option to enable/disable background compilation of bytecode. For example:
*
Expand Down Expand Up @@ -848,6 +861,15 @@ public class JvmOptions {
*/
private String gcTimeRatio;

/**
* Sets the number of entries to try to leave on the stack during parallel gc. For example:
*
* <pre>
* -XX:GCDrainStackTargetSize=64
* </pre>
*/
private String gcDrainStackTargetSize;

/**
* Diagnostic option (requires <code>-XX:+UnlockDiagnosticVMOptions</code>) to set a minimal safepoint interval
* (ms). For example:
Expand Down Expand Up @@ -1251,6 +1273,17 @@ public class JvmOptions {
*/
private String minHeapDeltaBytes;

/**
* The minimum heap space in bytes. '0' means use ergonomics.
*
* For example:
*
* <pre>
* --XX:MinHeapSize=123456
* </pre>
*/
private String minHeapSize;

/**
* The minimum percentage of free space to avoid expanding the heap size. Default 40.
*
Expand Down Expand Up @@ -1947,6 +1980,7 @@ 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 @@ -1979,7 +2013,6 @@ public class JvmOptions {
* </pre>
*/
private String softRefLRUPolicyMSPerMB;

/**
* The option for starting JDK Flight Recorder (JFR). For example:
*
Expand Down Expand Up @@ -3128,6 +3161,10 @@ public JvmOptions(JvmContext jvmContext) {
} else if (option.matches("^-XX:G1ConcRefinementThreads=\\d{1,}$")) {
g1ConcRefinementThreads = option;
key = "G1ConcRefinementThreads";
} else if (option.matches("^-XX:G1EagerReclaimRemSetThreshold=\\d{1,}$")) {
g1EagerReclaimRemSetThreshold = option;
key = "G1EagerReclaimRemSetThreshold";
experimental.add(option);
} else if (option.matches("^-XX:G1HeapRegionSize=" + JdkRegEx.OPTION_SIZE_BYTES + "$")) {
g1HeapRegionSize = option;
key = "G1HeapRegionSize";
Expand Down Expand Up @@ -3165,6 +3202,9 @@ public JvmOptions(JvmContext jvmContext) {
} else if (option.matches("^-XX:G1SummarizeRSetStatsPeriod=\\d$")) {
g1SummarizeRSetStatsPeriod = option;
key = "G1SummarizeRSetStatsPeriod";
} else if (option.matches("^-XX:GCDrainStackTargetSize=\\d{1,}$")) {
gcDrainStackTargetSize = option;
key = "GCDrainStackTargetSize";
} else if (option.matches("^-XX:GCLockerRetryAllocationCount=\\d{1,}$")) {
gcLockerRetryAllocationCount = option;
key = "GCLockerRetryAllocationCount";
Expand Down Expand Up @@ -3274,6 +3314,9 @@ public JvmOptions(JvmContext jvmContext) {
} else if (option.matches("^-XX:MinHeapFreeRatio=\\d{1,3}$")) {
minHeapFreeRatio = option;
key = "MinHeapFreeRatio";
} else if (option.matches("^-XX:MinHeapSize=\\d{1,}$")) {
minHeapSize = option;
key = "MinHeapSize";
} else if (option.matches("^-XX:MinMetaspaceFreeRatio=\\d{1,3}$")) {
minMetaspaceFreeRatio = option;
key = "MinMetaspaceFreeRatio";
Expand Down Expand Up @@ -5135,6 +5178,10 @@ public String getG1ConcRefinementThreads() {
return g1ConcRefinementThreads;
}

public String getG1EagerReclaimRemSetThreshold() {
return g1EagerReclaimRemSetThreshold;
}

public String getG1HeapRegionSize() {
return g1HeapRegionSize;
}
Expand Down Expand Up @@ -5179,6 +5226,10 @@ public String getG1SummarizeRSetStatsPeriod() {
return g1SummarizeRSetStatsPeriod;
}

public String getGcDrainStackTargetSize() {
return gcDrainStackTargetSize;
}

public String getGcLockerRetryAllocationCount() {
return gcLockerRetryAllocationCount;
}
Expand Down Expand Up @@ -5347,6 +5398,10 @@ public String getMinHeapFreeRatio() {
return minHeapFreeRatio;
}

public String getMinHeapSize() {
return minHeapSize;
}

public String getMinMetaspaceFreeRatio() {
return minMetaspaceFreeRatio;
}
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/org/github/joa/TestJvmOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@ void testG1ConcRefinementThreads() {
"G1ConcRefinementThreads not correct.");
}

@Test
void testG1EagerReclaimRemSetThreshold() {
String opts = "-Xms1g -XX:+UnlockExperimentalVMOptions -XX:G1EagerReclaimRemSetThreshold=8 -Xmx1g";
JvmContext context = new JvmContext(opts);
JvmOptions jvmOptions = new JvmOptions(context);
assertEquals("-XX:G1EagerReclaimRemSetThreshold=8", jvmOptions.getG1EagerReclaimRemSetThreshold(),
"G1EagerReclaimRemSetThreshold not correct.");
assertEquals(0, jvmOptions.getUndefined().size(), "Undefined options not correct.");
}

@Test
void testG1MixedGCCountTarget() {
String opts = "-Xms1000m -XX:G1MixedGCCountTarget=4 -Xmx1500m";
Expand Down Expand Up @@ -543,6 +553,15 @@ void testGarbageCollectorsSerialSerialOld() {
GarbageCollector.SERIAL_OLD + " collector not identified.");
}

@Test
void testGcDrainStackTargetSize() {
String opts = "-Xmx1g -XX:GCDrainStackTargetSize=64";
JvmContext context = new JvmContext(opts);
JvmOptions jvmOptions = new JvmOptions(context);
assertEquals("-XX:GCDrainStackTargetSize=64", jvmOptions.getGcDrainStackTargetSize(),
"GCDrainStackTargetSize not correct.");
}

@Test
void testGCLockerRetryAllocationCount() {
String opts = "-Xmx1g -XX:+UnlockDiagnosticVMOptions -XX:GCLockerRetryAllocationCount=21";
Expand Down Expand Up @@ -820,6 +839,15 @@ void testMinHeapDeltaBytes() {
"MinHeapDeltaBytes not correct.");
}

@Test
void testMinHeapSize() {
String opts = "-Xmx1g -XX:MinHeapSize=8388608";
JvmContext context = new JvmContext(opts);
JvmOptions jvmOptions = new JvmOptions(context);
assertEquals("-XX:MinHeapSize=8388608", jvmOptions.getMinHeapSize(),
"MinHeapSize not correct.");
}

@Test
void testMinMetaspaceFreeRatio() {
String opts = "-Xms1g -XX:MinMetaspaceFreeRatio=50 -Xmx1g";
Expand Down

0 comments on commit b85f9c0

Please sign in to comment.