mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-26 10:10:19 +00:00
8145092: Use Unified Logging for the GC logging
JEP-271 Reviewed-by: sjohanss, brutisso
This commit is contained in:
parent
1d4561775d
commit
ac45dea45e
@ -62,7 +62,7 @@ public class CheckOrigin {
|
||||
ProcessBuilder pb = ProcessTools.
|
||||
createJavaProcessBuilder(
|
||||
"-XX:+UseConcMarkSweepGC", // this will cause UseParNewGC to be FLAG_SET_ERGO
|
||||
"-XX:+PrintGCDetails",
|
||||
"-XX:+UseCodeAging",
|
||||
"-XX:+UseCerealGC", // Should be ignored.
|
||||
"-XX:Flags=" + flagsFile.getAbsolutePath(),
|
||||
"-cp", System.getProperty("test.class.path"),
|
||||
@ -97,7 +97,7 @@ public class CheckOrigin {
|
||||
// Not set, so should be default
|
||||
checkOrigin("ManagementServer", Origin.DEFAULT);
|
||||
// Set on the command line
|
||||
checkOrigin("PrintGCDetails", Origin.VM_CREATION);
|
||||
checkOrigin("UseCodeAging", Origin.VM_CREATION);
|
||||
// Set in _JAVA_OPTIONS
|
||||
checkOrigin("TraceExceptions", Origin.ENVIRON_VAR);
|
||||
// Set in JAVA_TOOL_OPTIONS
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
* @author Mandy Chung
|
||||
*
|
||||
* @modules jdk.management
|
||||
* @run main/othervm -XX:+PrintGCDetails GetVMOption
|
||||
* @run main/othervm -XX:+HeapDumpOnOutOfMemoryError GetVMOption
|
||||
*/
|
||||
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
@ -38,7 +38,7 @@ import java.util.List;
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
public class GetVMOption {
|
||||
private static final String PRINT_GC_DETAILS = "PrintGCDetails";
|
||||
private static final String HEAP_DUMP_ON_OOM = "HeapDumpOnOutOfMemoryError";
|
||||
private static final String EXPECTED_VALUE = "true";
|
||||
private static final String BAD_OPTION = "BadOption";
|
||||
private static final String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
|
||||
@ -58,7 +58,7 @@ public class GetVMOption {
|
||||
}
|
||||
|
||||
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
|
||||
VMOption option = mbean.getVMOption(PRINT_GC_DETAILS);
|
||||
VMOption option = mbean.getVMOption(HEAP_DUMP_ON_OOM);
|
||||
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
|
||||
throw new RuntimeException("Unexpected value: " +
|
||||
option.getValue() + " expected: " + EXPECTED_VALUE);
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
* @author Jaroslav Bachorik
|
||||
*
|
||||
* @modules jdk.management
|
||||
* @run main/othervm -XX:+PrintGCDetails SetVMOption
|
||||
* @run main/othervm -XX:+HeapDumpOnOutOfMemoryError SetVMOption
|
||||
*/
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
@ -40,7 +40,7 @@ import com.sun.management.VMOption;
|
||||
import com.sun.management.VMOption.Origin;
|
||||
|
||||
public class SetVMOption {
|
||||
private static final String PRINT_GC_DETAILS = "PrintGCDetails";
|
||||
private static final String HEAP_DUMP_ON_OOM = "HeapDumpOnOutOfMemoryError";
|
||||
private static final String EXPECTED_VALUE = "true";
|
||||
private static final String BAD_VALUE = "yes";
|
||||
private static final String NEW_VALUE = "false";
|
||||
@ -51,7 +51,7 @@ public class SetVMOption {
|
||||
mbean =
|
||||
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
|
||||
|
||||
VMOption option = findPrintGCDetailsOption();
|
||||
VMOption option = findHeapDumpOnOomOption();
|
||||
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
|
||||
throw new RuntimeException("Unexpected value: " +
|
||||
option.getValue() + " expected: " + EXPECTED_VALUE);
|
||||
@ -61,14 +61,14 @@ public class SetVMOption {
|
||||
option.getOrigin() + " expected: VM_CREATION");
|
||||
}
|
||||
if (!option.isWriteable()) {
|
||||
throw new RuntimeException("Expected " + PRINT_GC_DETAILS +
|
||||
throw new RuntimeException("Expected " + HEAP_DUMP_ON_OOM +
|
||||
" to be writeable");
|
||||
}
|
||||
|
||||
// set VM option to a new value
|
||||
mbean.setVMOption(PRINT_GC_DETAILS, NEW_VALUE);
|
||||
mbean.setVMOption(HEAP_DUMP_ON_OOM, NEW_VALUE);
|
||||
|
||||
option = findPrintGCDetailsOption();
|
||||
option = findHeapDumpOnOomOption();
|
||||
if (!option.getValue().equalsIgnoreCase(NEW_VALUE)) {
|
||||
throw new RuntimeException("Unexpected value: " +
|
||||
option.getValue() + " expected: " + NEW_VALUE);
|
||||
@ -77,7 +77,7 @@ public class SetVMOption {
|
||||
throw new RuntimeException("Unexpected origin: " +
|
||||
option.getOrigin() + " expected: MANAGEMENT");
|
||||
}
|
||||
VMOption o = mbean.getVMOption(PRINT_GC_DETAILS);
|
||||
VMOption o = mbean.getVMOption(HEAP_DUMP_ON_OOM);
|
||||
if (!option.getValue().equals(o.getValue())) {
|
||||
throw new RuntimeException("Unmatched value: " +
|
||||
option.getValue() + " expected: " + o.getValue());
|
||||
@ -123,17 +123,17 @@ public class SetVMOption {
|
||||
}
|
||||
}
|
||||
|
||||
public static VMOption findPrintGCDetailsOption() {
|
||||
public static VMOption findHeapDumpOnOomOption() {
|
||||
List<VMOption> options = mbean.getDiagnosticOptions();
|
||||
VMOption gcDetails = null;
|
||||
for (VMOption o : options) {
|
||||
if (o.getName().equals(PRINT_GC_DETAILS)) {
|
||||
if (o.getName().equals(HEAP_DUMP_ON_OOM)) {
|
||||
gcDetails = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gcDetails == null) {
|
||||
throw new RuntimeException("VM option " + PRINT_GC_DETAILS +
|
||||
throw new RuntimeException("VM option " + HEAP_DUMP_ON_OOM +
|
||||
" not found");
|
||||
}
|
||||
return gcDetails;
|
||||
|
||||
@ -100,7 +100,7 @@ public class LowMemoryTest {
|
||||
opts.addAll(Arrays.asList(Utils.getTestJavaOpts()));
|
||||
opts.add("-cp");
|
||||
opts.add(System.getProperty("test.class.path", "test.class.path"));
|
||||
opts.add("-XX:+PrintGCDetails");
|
||||
opts.add("-Xlog:gc*=debug");
|
||||
opts.addAll(Arrays.asList(testOpts));
|
||||
opts.add(classMain);
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ public class RunUtil {
|
||||
opts.addAll(Arrays.asList(Utils.getTestJavaOpts()));
|
||||
opts.add("-cp");
|
||||
opts.add(System.getProperty("test.class.path", "test.class.path"));
|
||||
opts.add("-XX:+PrintGCDetails");
|
||||
opts.add("-Xlog:gc*=debug");
|
||||
|
||||
if (clearGcOpts) {
|
||||
opts = Utils.removeGcOpts(opts);
|
||||
|
||||
@ -48,8 +48,8 @@ runOne()
|
||||
|
||||
runOne InputArgument
|
||||
|
||||
runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails
|
||||
runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+UseFastJNIAccessors
|
||||
runOne -XX:+UseFastJNIAccessors -Xlog:gc*=debug InputArgument
|
||||
runOne -XX:+UseFastJNIAccessors -Xlog:gc*=debug InputArgument -XX:+UseFastJNIAccessors
|
||||
runOne "-Dprops=one two three" InputArgument "-Dprops=one two three"
|
||||
|
||||
exit 0
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
* getting reliable numbers. Otherwise GC activity may corrupt results.
|
||||
* As of jdk80b48 using "-Xms500m -Xmx500m -XX:NewSize=400m" covers
|
||||
* all cases.
|
||||
* - Optionally using "-XX:+printGC" option provides information that
|
||||
* - Optionally using "-Xlog:gc" option provides information that
|
||||
* helps checking any GC activity while benches are run.
|
||||
*
|
||||
* Vm Options:
|
||||
@ -60,7 +60,7 @@
|
||||
* non fast-path case: -Xms500m -Xmx500m -XX:NewSize=400m
|
||||
* or use worst case (non fast-path above) with both types of algorithm.
|
||||
*
|
||||
* - use -XX:+PrintGC to verify memory consumption of the benchmarks.
|
||||
* - use -Xlog:gc to verify memory consumption of the benchmarks.
|
||||
* (See "Checking Memory Consumption" below).
|
||||
*
|
||||
* Description:
|
||||
@ -166,7 +166,7 @@
|
||||
* but is not enough, since any unexpected incremental GC may lower
|
||||
* artificially the estimation of the memory consumption.
|
||||
*
|
||||
* Options to set are -Xms, -Xmx, -XX:NewSize, plus -XX:+PrintGC to evaluate
|
||||
* Options to set are -Xms, -Xmx, -XX:NewSize, plus -Xlog:gc to evaluate
|
||||
* correctly the values of these options. When running "-verbose", varying
|
||||
* numbers reported for memory consumption may indicate bad choices for these
|
||||
* options.
|
||||
@ -217,7 +217,7 @@ public class FormatMicroBenchmark {
|
||||
" getting reliable numbers. Otherwise GC activity may corrupt results.\n" +
|
||||
" As of jdk80b48 using \"-Xms500m -Xmx500m -XX:NewSize=400m\" covers \n" +
|
||||
" all cases.\n" +
|
||||
" - Optionally using \"-XX:+printGC\" option provides information that \n" +
|
||||
" - Optionally using \"-Xlog:gc\" option provides information that \n" +
|
||||
" helps checking any GC activity while benches are run.\n\n" +
|
||||
"Look at the heading comments and description in source code for " +
|
||||
"detailed information.\n");
|
||||
|
||||
@ -38,8 +38,7 @@ import java.util.List;
|
||||
* <pre>
|
||||
* {@code
|
||||
* JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
|
||||
* .addVMArg("-XX:+PrintGC");
|
||||
* .addVMArg("-XX:+PrintGCDetails")
|
||||
* .addVMArg("-Xlog:gc*=debug")
|
||||
* .addToolArg("-heap")
|
||||
* .addToolArg(pid);
|
||||
* ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
|
||||
|
||||
@ -60,30 +60,30 @@ public class JInfoRunningProcessFlagTest {
|
||||
}
|
||||
|
||||
private static void testFlagPlus() throws Exception {
|
||||
OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+PrintGC");
|
||||
OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+HeapDumpOnOutOfMemoryError");
|
||||
output.shouldHaveExitValue(0);
|
||||
output = JInfoHelper.jinfo("-flag", "PrintGC");
|
||||
output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain("+PrintGC");
|
||||
verifyIsEnabled("PrintGC");
|
||||
output.shouldContain("+HeapDumpOnOutOfMemoryError");
|
||||
verifyIsEnabled("HeapDumpOnOutOfMemoryError");
|
||||
}
|
||||
|
||||
private static void testFlagMinus() throws Exception {
|
||||
OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-PrintGC");
|
||||
OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-HeapDumpOnOutOfMemoryError");
|
||||
output.shouldHaveExitValue(0);
|
||||
output = JInfoHelper.jinfo("-flag", "PrintGC");
|
||||
output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain("-PrintGC");
|
||||
verifyIsDisabled("PrintGC");
|
||||
output.shouldContain("-HeapDumpOnOutOfMemoryError");
|
||||
verifyIsDisabled("HeapDumpOnOutOfMemoryError");
|
||||
}
|
||||
|
||||
private static void testFlagEqual() throws Exception {
|
||||
OutputAnalyzer output = JInfoHelper.jinfo("-flag", "PrintGC=1");
|
||||
OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError=1");
|
||||
output.shouldHaveExitValue(0);
|
||||
output = JInfoHelper.jinfo("-flag", "PrintGC");
|
||||
output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError");
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain("+PrintGC");
|
||||
verifyIsEnabled("PrintGC");
|
||||
output.shouldContain("+HeapDumpOnOutOfMemoryError");
|
||||
verifyIsEnabled("HeapDumpOnOutOfMemoryError");
|
||||
}
|
||||
|
||||
private static void testInvalidFlag() throws Exception {
|
||||
|
||||
@ -98,7 +98,7 @@ public final class JpsHelper {
|
||||
* -XX:+UsePerfData is required for running the tests on embedded platforms.
|
||||
*/
|
||||
public static final String[] VM_ARGS = {
|
||||
"-XX:+UsePerfData", "-Xmx512m", "-XX:+PrintGCDetails",
|
||||
"-XX:+UsePerfData", "-Xmx512m", "-Xlog:gc",
|
||||
"-Dmultiline.prop=value1\nvalue2\r\nvalue3"
|
||||
};
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user