36
37 import java.util.Arrays;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.ArrayList;
41 import java.util.Collections;
42 import java.util.regex.Pattern;
43 import java.util.stream.Collectors;
44
45 import jdk.test.lib.OutputAnalyzer;
46 import jdk.test.lib.ProcessTools;
47 import jdk.test.lib.Utils;
48
49 import gc.g1.plab.lib.LogParser;
50 import gc.g1.plab.lib.AppPLABEvacuationFailure;
51 import gc.g1.plab.lib.PlabInfo;
52
53 /**
54 * The test runs the AppPLABEvacuationFailure application to provoke a number of
55 * Evacuation Failures, parses GC log and analyzes PLAB statistics. The test checks
56 * that both fields 'falure_waste' and 'failure_used' for Evacuation Failure statistic
57 * are non zero, and zero for other statistics.
58 */
59 public class TestPLABEvacuationFailure {
60
61 /* PLAB statistics fields which are checked.
62 * Test expects to find 0 in this fields in survivor statistics.
63 * Expects to find 0 in old statistics for GC when evacuation failure
64 * did not happen. And expects to find not 0 in old statistics in case when
65 * GC causes to evacuation failure.
66 */
67 private static final List<String> FAILURE_STAT_FIELDS = new ArrayList<>(Arrays.asList(
68 "failure used",
69 "failure wasted"));
70
71 private static final String[] COMMON_OPTIONS = {
72 "-Xlog:gc=debug,gc+plab=debug,gc+phases=trace",
73 "-XX:+UseG1GC",
74 "-XX:G1HeapRegionSize=1m"};
75
76 private static final Pattern GC_ID_PATTERN = Pattern.compile("GC\\((\\d+)\\)");
77 private static List<Long> evacuationFailureIDs;
78 private static LogParser logParser;
79 private static String appPlabEvacFailureOutput;
80
81 public static void main(String[] args) throws Throwable {
82 // ParallelGCBufferWastePct, PLAB Size, ParallelGCBufferWastePct, MaxHeapSize, is plab fixed.
83 runTest(10, 1024, 3, 16, true);
84 runTest(15, 2048, 4, 256, true);
85 runTest(20, 65536, 7, 128, false);
86 runTest(25, 1024, 3, 16, true);
87 runTest(30, 16384, 7, 256, false);
88 runTest(10, 65536, 4, 32, false);
89 }
90
91 private static void runTest(int wastePct, int plabSize, int parGCThreads, int heapSize, boolean plabIsFixed) throws Throwable {
92 System.out.println("Test case details:");
93 System.out.println(" Heap size : " + heapSize + "M");
|
36
37 import java.util.Arrays;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.ArrayList;
41 import java.util.Collections;
42 import java.util.regex.Pattern;
43 import java.util.stream.Collectors;
44
45 import jdk.test.lib.OutputAnalyzer;
46 import jdk.test.lib.ProcessTools;
47 import jdk.test.lib.Utils;
48
49 import gc.g1.plab.lib.LogParser;
50 import gc.g1.plab.lib.AppPLABEvacuationFailure;
51 import gc.g1.plab.lib.PlabInfo;
52
53 /**
54 * The test runs the AppPLABEvacuationFailure application to provoke a number of
55 * Evacuation Failures, parses GC log and analyzes PLAB statistics. The test checks
56 * that both fields 'failure_waste' and 'failure_used' for Evacuation Failure statistic
57 * are non zero, and zero for other statistics.
58 */
59 public class TestPLABEvacuationFailure {
60
61 /* PLAB statistics fields which are checked.
62 * Test expects to find 0 in this fields in survivor statistics.
63 * Expects to find 0 in old statistics for GC when evacuation failure
64 * did not happen. And expects to find not 0 in old statistics in case when
65 * GC causes to evacuation failure.
66 */
67 private static final List<String> FAILURE_STAT_FIELDS = new ArrayList<>(Arrays.asList(
68 "failure used",
69 "failure wasted"));
70
71 private static final String[] COMMON_OPTIONS = {
72 "-Xlog:gc=debug,gc+plab=debug,gc+phases=trace",
73 "-XX:+UseG1GC",
74 "-XX:InitiatingHeapOccupancyPercent=100",
75 "-XX:-G1UseAdaptiveIHOP",
76 "-XX:G1HeapRegionSize=1m"};
77
78 private static final Pattern GC_ID_PATTERN = Pattern.compile("GC\\((\\d+)\\)");
79 private static List<Long> evacuationFailureIDs;
80 private static LogParser logParser;
81 private static String appPlabEvacFailureOutput;
82
83 public static void main(String[] args) throws Throwable {
84 // ParallelGCBufferWastePct, PLAB Size, ParallelGCBufferWastePct, MaxHeapSize, is plab fixed.
85 runTest(10, 1024, 3, 16, true);
86 runTest(15, 2048, 4, 256, true);
87 runTest(20, 65536, 7, 128, false);
88 runTest(25, 1024, 3, 16, true);
89 runTest(30, 16384, 7, 256, false);
90 runTest(10, 65536, 4, 32, false);
91 }
92
93 private static void runTest(int wastePct, int plabSize, int parGCThreads, int heapSize, boolean plabIsFixed) throws Throwable {
94 System.out.println("Test case details:");
95 System.out.println(" Heap size : " + heapSize + "M");
|