mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8150183: gc/g1/plab/TestPLABResize.java - previous PLAB size should be less than current
Reviewed-by: jmasa, dfazunen
This commit is contained in:
parent
df20815bbb
commit
a956d2a0a0
3 changed files with 33 additions and 40 deletions
|
@ -122,29 +122,23 @@ public class TestPLABResize {
|
|||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
// Check that desired plab size was changed during iterations.
|
||||
// It should decrease during first half of iterations
|
||||
// and increase after.
|
||||
List<Long> decreasedPlabs = plabSizes.subList(testCase.getIterations(), testCase.getIterations() * 2);
|
||||
List<Long> increasedPlabs = plabSizes.subList(testCase.getIterations() * 2, testCase.getIterations() * 3);
|
||||
// The test case does 3 rounds of allocations. The second round of N allocations and GC's
|
||||
// has a decreasing size of allocations so that iterations N to 2*N -1 will be of decreasing size.
|
||||
// The third round with iterations 2*N to 3*N -1 has increasing sizes of allocation.
|
||||
long startDesiredPLABSize = plabSizes.get(testCase.getIterations());
|
||||
long endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2 - 1);
|
||||
|
||||
Long prev = decreasedPlabs.get(0);
|
||||
for (int index = 1; index < decreasedPlabs.size(); ++index) {
|
||||
Long current = decreasedPlabs.get(index);
|
||||
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;
|
||||
if (startDesiredPLABSize < endDesiredPLABSize) {
|
||||
System.out.println(output);
|
||||
throw new RuntimeException("Test failed! Expect that initial PLAB size should be greater than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize);
|
||||
}
|
||||
|
||||
prev = increasedPlabs.get(0);
|
||||
for (int index = 1; index < increasedPlabs.size(); ++index) {
|
||||
Long current = increasedPlabs.get(index);
|
||||
if (prev > current) {
|
||||
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);
|
||||
}
|
||||
prev = current;
|
||||
startDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2);
|
||||
endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 3 - 1);
|
||||
|
||||
if (startDesiredPLABSize > endDesiredPLABSize) {
|
||||
System.out.println(output);
|
||||
throw new RuntimeException("Test failed! Expect that initial PLAB size should be less than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize);
|
||||
}
|
||||
|
||||
System.out.println("Test passed!");
|
||||
|
@ -195,7 +189,6 @@ public class TestPLABResize {
|
|||
return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads,
|
||||
"-XX:ParallelGCBufferWastePct=" + wastePct,
|
||||
"-XX:+ResizePLAB",
|
||||
"-Dthreads=" + parGCThreads,
|
||||
"-Dchunk.size=" + chunkSize,
|
||||
"-Diterations=" + iterations,
|
||||
"-XX:NewSize=16m",
|
||||
|
|
|
@ -38,7 +38,6 @@ import sun.hotspot.WhiteBox;
|
|||
* Expects the following properties to be set:
|
||||
* - iterations - amount of iteration per cycle.
|
||||
* - chunk.size - size of objects to be allocated
|
||||
* - threads - number of gc threads (-XX:ParallelGCThreads) to calculate PLAB sizes.
|
||||
*/
|
||||
final public class AppPLABResize {
|
||||
|
||||
|
@ -47,7 +46,6 @@ final public class AppPLABResize {
|
|||
// Defined by properties.
|
||||
private static final int ITERATIONS = Integer.getInteger("iterations");
|
||||
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();
|
||||
|
||||
|
@ -59,13 +57,13 @@ final public class AppPLABResize {
|
|||
*/
|
||||
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");
|
||||
}
|
||||
|
||||
long wordSize = Platform.is32bit() ? 4l : 8l;
|
||||
// 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.
|
||||
long memChangeStep = initialMemorySize / 2 / ITERATIONS;
|
||||
|
|
|
@ -57,7 +57,8 @@ final public class LogParser {
|
|||
|
||||
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
|
||||
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+");
|
||||
|
||||
/**
|
||||
* Construct LogParser Object
|
||||
* Construct LogParser object, parse log file with PLAB statistics and store it into report.
|
||||
*
|
||||
* @param log - VM Output
|
||||
*/
|
||||
|
@ -74,43 +75,44 @@ final public class LogParser {
|
|||
throw new IllegalArgumentException("Parameter log should not be null.");
|
||||
}
|
||||
this.log = log;
|
||||
reportHolder = parseLines();
|
||||
report = parseLines();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return log which is being processed
|
||||
* @return log which was processed
|
||||
*/
|
||||
public String getLog() {
|
||||
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() {
|
||||
return reportHolder;
|
||||
public Map<Long, Map<ReportType, Map<String, Long>>> getEntries() {
|
||||
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);
|
||||
Map<Long,Map<ReportType, Map<String,Long>>> allocationStatistics = new HashMap<>();
|
||||
Map<Long, Map<ReportType, Map<String, Long>>> allocationStatistics = new HashMap<>();
|
||||
Optional<Long> gc_id;
|
||||
while (lineScanner.hasNextLine()) {
|
||||
String line = lineScanner.nextLine();
|
||||
gc_id = getGcId(line);
|
||||
if ( gc_id.isPresent() ) {
|
||||
if (gc_id.isPresent()) {
|
||||
Matcher matcher = PAIRS_PATTERN.matcher(line);
|
||||
if (matcher.find()) {
|
||||
Map<ReportType,Map<String, Long>> oneReportItem;
|
||||
Map<ReportType, Map<String, Long>> oneReportItem;
|
||||
ReportType reportType;
|
||||
|
||||
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;
|
||||
} else {
|
||||
reportType = ReportType.OLD_STATS;
|
||||
|
@ -118,7 +120,7 @@ final public class LogParser {
|
|||
|
||||
oneReportItem = allocationStatistics.get(gc_id.get());
|
||||
if (!oneReportItem.containsKey(reportType)) {
|
||||
oneReportItem.put(reportType,new HashMap<String, Long>());
|
||||
oneReportItem.put(reportType, new HashMap<>());
|
||||
}
|
||||
|
||||
// Extract all pairs from log.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue