8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current

Reviewed-by: jmasa, dfazunen
This commit is contained in:
Michail Chernov 2016-03-03 16:12:38 +03:00
parent df20815bbb
commit a956d2a0a0
3 changed files with 33 additions and 40 deletions

View file

@ -122,29 +122,23 @@ public class TestPLABResize {
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
// Check that desired plab size was changed during iterations. // Check that desired plab size was changed during iterations.
// It should decrease during first half of iterations // The test case does 3 rounds of allocations. The second round of N allocations and GC's
// and increase after. // has a decreasing size of allocations so that iterations N to 2*N -1 will be of decreasing size.
List<Long> decreasedPlabs = plabSizes.subList(testCase.getIterations(), testCase.getIterations() * 2); // The third round with iterations 2*N to 3*N -1 has increasing sizes of allocation.
List<Long> increasedPlabs = plabSizes.subList(testCase.getIterations() * 2, testCase.getIterations() * 3); long startDesiredPLABSize = plabSizes.get(testCase.getIterations());
long endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2 - 1);
Long prev = decreasedPlabs.get(0); if (startDesiredPLABSize < endDesiredPLABSize) {
for (int index = 1; index < decreasedPlabs.size(); ++index) { System.out.println(output);
Long current = decreasedPlabs.get(index); throw new RuntimeException("Test failed! Expect that initial PLAB size should be greater than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize);
if (prev < current) {
System.out.println(output);
throw new RuntimeException("Test failed! Expect that previous PLAB size should be greater than current. Prev.size: " + prev + " Current size:" + current);
}
prev = current;
} }
prev = increasedPlabs.get(0); startDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2);
for (int index = 1; index < increasedPlabs.size(); ++index) { endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 3 - 1);
Long current = increasedPlabs.get(index);
if (prev > current) { if (startDesiredPLABSize > endDesiredPLABSize) {
System.out.println(output); System.out.println(output);
throw new RuntimeException("Test failed! Expect that previous PLAB size should be less than current. Prev.size: " + prev + " Current size:" + current); throw new RuntimeException("Test failed! Expect that initial PLAB size should be less than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize);
}
prev = current;
} }
System.out.println("Test passed!"); System.out.println("Test passed!");
@ -195,7 +189,6 @@ public class TestPLABResize {
return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads, return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads,
"-XX:ParallelGCBufferWastePct=" + wastePct, "-XX:ParallelGCBufferWastePct=" + wastePct,
"-XX:+ResizePLAB", "-XX:+ResizePLAB",
"-Dthreads=" + parGCThreads,
"-Dchunk.size=" + chunkSize, "-Dchunk.size=" + chunkSize,
"-Diterations=" + iterations, "-Diterations=" + iterations,
"-XX:NewSize=16m", "-XX:NewSize=16m",

View file

@ -38,7 +38,6 @@ import sun.hotspot.WhiteBox;
* Expects the following properties to be set: * Expects the following properties to be set:
* - iterations - amount of iteration per cycle. * - iterations - amount of iteration per cycle.
* - chunk.size - size of objects to be allocated * - chunk.size - size of objects to be allocated
* - threads - number of gc threads (-XX:ParallelGCThreads) to calculate PLAB sizes.
*/ */
final public class AppPLABResize { final public class AppPLABResize {
@ -47,7 +46,6 @@ final public class AppPLABResize {
// Defined by properties. // Defined by properties.
private static final int ITERATIONS = Integer.getInteger("iterations"); private static final int ITERATIONS = Integer.getInteger("iterations");
private static final long CHUNK = Long.getLong("chunk.size"); private static final long CHUNK = Long.getLong("chunk.size");
private static final int GC_THREADS = Integer.getInteger("threads");
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
@ -59,13 +57,13 @@ final public class AppPLABResize {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
if (ITERATIONS == 0 || CHUNK == 0 || GC_THREADS == 0) { if (ITERATIONS == 0 || CHUNK == 0) {
throw new IllegalArgumentException("Properties should be set"); throw new IllegalArgumentException("Properties should be set");
} }
long wordSize = Platform.is32bit() ? 4l : 8l; long wordSize = Platform.is32bit() ? 4l : 8l;
// PLAB size is shared between threads. // PLAB size is shared between threads.
long initialMemorySize = wordSize * GC_THREADS * MEM_ALLOC_WORDS; long initialMemorySize = wordSize * MEM_ALLOC_WORDS;
// Expect changing memory to half during all iterations. // Expect changing memory to half during all iterations.
long memChangeStep = initialMemorySize / 2 / ITERATIONS; long memChangeStep = initialMemorySize / 2 / ITERATIONS;

View file

@ -57,7 +57,8 @@ final public class LogParser {
private final String log; private final String log;
private final Map<Long, Map<ReportType, Map<String,Long>>> reportHolder; // Contains Map of PLAB statistics for given log.
private final Map<Long, Map<ReportType, Map<String, Long>>> report;
// GC ID // GC ID
private static final Pattern GC_ID_PATTERN = Pattern.compile("\\[gc,plab\\s*\\] GC\\((\\d+)\\)"); private static final Pattern GC_ID_PATTERN = Pattern.compile("\\[gc,plab\\s*\\] GC\\((\\d+)\\)");
@ -65,7 +66,7 @@ final public class LogParser {
private static final Pattern PAIRS_PATTERN = Pattern.compile("\\w* \\w+:\\s+\\d+"); private static final Pattern PAIRS_PATTERN = Pattern.compile("\\w* \\w+:\\s+\\d+");
/** /**
* Construct LogParser Object * Construct LogParser object, parse log file with PLAB statistics and store it into report.
* *
* @param log - VM Output * @param log - VM Output
*/ */
@ -74,43 +75,44 @@ final public class LogParser {
throw new IllegalArgumentException("Parameter log should not be null."); throw new IllegalArgumentException("Parameter log should not be null.");
} }
this.log = log; this.log = log;
reportHolder = parseLines(); report = parseLines();
} }
/** /**
* @return log which is being processed * @return log which was processed
*/ */
public String getLog() { public String getLog() {
return log; return log;
} }
/** /**
* Returns list of log entries. * Returns the GC log entries for Survivor and Old stats.
* The entries are represented as a map of gcID to the StatMap.
* *
* @return list of Pair with ReportType and Map of parameters/values. * @return The log entries for the Survivor and Old stats.
*/ */
public Map<Long,Map<ReportType, Map<String,Long>>> getEntries() { public Map<Long, Map<ReportType, Map<String, Long>>> getEntries() {
return reportHolder; return report;
} }
private Map<Long,Map<ReportType, Map<String,Long>>> parseLines() throws NumberFormatException { private Map<Long, Map<ReportType, Map<String, Long>>> parseLines() throws NumberFormatException {
Scanner lineScanner = new Scanner(log); Scanner lineScanner = new Scanner(log);
Map<Long,Map<ReportType, Map<String,Long>>> allocationStatistics = new HashMap<>(); Map<Long, Map<ReportType, Map<String, Long>>> allocationStatistics = new HashMap<>();
Optional<Long> gc_id; Optional<Long> gc_id;
while (lineScanner.hasNextLine()) { while (lineScanner.hasNextLine()) {
String line = lineScanner.nextLine(); String line = lineScanner.nextLine();
gc_id = getGcId(line); gc_id = getGcId(line);
if ( gc_id.isPresent() ) { if (gc_id.isPresent()) {
Matcher matcher = PAIRS_PATTERN.matcher(line); Matcher matcher = PAIRS_PATTERN.matcher(line);
if (matcher.find()) { if (matcher.find()) {
Map<ReportType,Map<String, Long>> oneReportItem; Map<ReportType, Map<String, Long>> oneReportItem;
ReportType reportType; ReportType reportType;
if (!allocationStatistics.containsKey(gc_id.get())) { if (!allocationStatistics.containsKey(gc_id.get())) {
allocationStatistics.put(gc_id.get(), new EnumMap<>(ReportType.class)); allocationStatistics.put(gc_id.get(), new EnumMap<>(ReportType.class));
} }
if ( line.contains("Young") ) { if (line.contains("Young")) {
reportType = ReportType.SURVIVOR_STATS; reportType = ReportType.SURVIVOR_STATS;
} else { } else {
reportType = ReportType.OLD_STATS; reportType = ReportType.OLD_STATS;
@ -118,7 +120,7 @@ final public class LogParser {
oneReportItem = allocationStatistics.get(gc_id.get()); oneReportItem = allocationStatistics.get(gc_id.get());
if (!oneReportItem.containsKey(reportType)) { if (!oneReportItem.containsKey(reportType)) {
oneReportItem.put(reportType,new HashMap<String, Long>()); oneReportItem.put(reportType, new HashMap<>());
} }
// Extract all pairs from log. // Extract all pairs from log.