// GC ID with survivor PLAB statistics privatefinalstaticlong GC_ID_SURVIVOR_STATS = 1l; // GC ID with old PLAB statistics privatefinalstaticlong GC_ID_OLD_STATS = 2l;
for (TestCase testCase : TEST_CASES) { // What we going to check.
testCase.print(System.out);
List<String> options = PLABUtils.prepareOptions(testCase.toOptions());
options.add(AppPLABPromotion.class.getName());
OutputAnalyzer out = ProcessTools.executeTestJvm(options);
PLABUtils.commonCheck(out);
output = out.getOutput();
checkResults(testCase);
}
}
privatestaticvoid checkResults(TestCase testCase) { long plabAllocatedSurvivor; long directAllocatedSurvivor; long plabAllocatedOld; long directAllocatedOld; long memAllocated = testCase.getMemToFill();
LogParser logParser = new LogParser(output);
System.out.printf("Survivor PLAB allocated:%17d Direct allocated: %17d Mem consumed:%17d%n", plabAllocatedSurvivor, directAllocatedSurvivor, memAllocated);
System.out.printf("Old PLAB allocated:%17d Direct allocated: %17d Mem consumed:%17d%n", plabAllocatedOld, directAllocatedOld, memAllocated);
// Unreachable objects case if (testCase.isDeadObjectCase()) {
checkDeadObjectsPromotion(plabAllocatedSurvivor, directAllocatedSurvivor, memAllocated);
checkDeadObjectsPromotion(plabAllocatedOld, directAllocatedOld, memAllocated);
} else { // Live objects case if (testCase.isPromotedByPLAB()) {
checkLiveObjectsPromotion(plabAllocatedSurvivor, memAllocated, "Expect that Survivor PLAB allocation are similar to all mem consumed");
checkLiveObjectsPromotion(plabAllocatedOld, memAllocated, "Expect that Old PLAB allocation are similar to all mem consumed");
} else { // All big objects should be directly allocated
checkLiveObjectsPromotion(directAllocatedSurvivor, memAllocated, "Expect that Survivor direct allocation are similar to all mem consumed");
checkLiveObjectsPromotion(directAllocatedOld, memAllocated, "Expect that Old direct allocation are similar to all mem consumed");
}
checkTotalPromotion(plabAllocatedSurvivor, directAllocatedSurvivor, memAllocated, "Expect that Survivor gen total allocation are similar to all mem consumed");
checkTotalPromotion(plabAllocatedOld, directAllocatedOld, memAllocated, "Expect that Old gen total allocation are similar to all mem consumed");
}
System.out.println("Test passed!");
}
privatestaticvoid checkTotalPromotion(long plabAllocatedSurvivor, long directAllocatedSurvivor, long memAllocated, String exceptionMessage) { // All promoted objects size should be similar to all consumed memory if (!checkDifferenceRatio(plabAllocatedSurvivor + directAllocatedSurvivor, memAllocated)) {
System.out.println(output); thrownew RuntimeException(exceptionMessage);
}
}
/** *Checksthatliveobjectswerepromotedasexpected. *@paramplabAllocated *@paramtotalMemAllocated *@paramexceptionMessage
*/ privatestaticvoid checkLiveObjectsPromotion(long plabAllocated, long totalMemAllocated, String exceptionMessage) { // All live small objects should be promoted using PLAB if (!checkDifferenceRatio(plabAllocated, totalMemAllocated)) {
System.out.println(output); thrownew RuntimeException(exceptionMessage);
}
}
/** *Checksthatdeadobjectsarenotpromoted. *@paramplabPromotedpromotedbyPLAB *@paramdirectlyPromoted *@parammemoryAllocatedtotalmemoryallocated
*/ privatestaticvoid checkDeadObjectsPromotion(long plabPromoted, long directlyPromoted, long memoryAllocated) { // No dead objects should be promoted if (!(checkRatio(plabPromoted, memoryAllocated) && checkRatio(directlyPromoted, memoryAllocated))) {
System.out.println(output); thrownew RuntimeException("Unreachable objects should not be allocated using PLAB or directly allocated to Survivor/Old");
}
}
/** *ChecksthatPLABstatisticscontainsexpectedfields. *@paraminfo
*/ privatestaticvoid checkFields(PlabInfo info) { if (!info.checkFields(FIELDS_TO_EXTRACT)) {
System.out.println(output); thrownew RuntimeException("PLAB log does not contain expected fields");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.