< prev index next >

test/gc/g1/plab/TestPLABPromotion.java

Print this page

        

*** 24,43 **** /* * @test TestPLABPromotion * @bug 8141278 * @summary Test PLAB promotion * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary /../../test/lib / * @modules java.management * @build ClassFileInstaller * sun.hotspot.WhiteBox * gc.g1.plab.lib.MemoryConsumer * gc.g1.plab.lib.LogParser * gc.g1.plab.lib.AppPLABPromotion * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission ! * @run main gc.g1.plab.TestPLABPromotion */ package gc.g1.plab; import java.util.List; import java.util.Map; --- 24,44 ---- /* * @test TestPLABPromotion * @bug 8141278 * @summary Test PLAB promotion * @requires vm.gc=="G1" | vm.gc=="null" + * @requires vm.opt.FlightRecorder != true * @library /testlibrary /../../test/lib / * @modules java.management * @build ClassFileInstaller * sun.hotspot.WhiteBox * gc.g1.plab.lib.MemoryConsumer * gc.g1.plab.lib.LogParser * gc.g1.plab.lib.AppPLABPromotion * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission ! * @run main/timeout=240 gc.g1.plab.TestPLABPromotion */ package gc.g1.plab; import java.util.List; import java.util.Map;
*** 60,72 **** // GC ID with survivor PLAB statistics private final static long GC_ID_SURVIVOR_STATS = 1l; // GC ID with old PLAB statistics private final static long GC_ID_OLD_STATS = 2l; ! // Threshold to determine whether the correct amount of objects were promoted. ! // This is only an approximate threshold for these checks. ! private final static long MEM_CONSUMPTION_THRESHOLD = 256l * 1024l; private static final int PLAB_SIZE_SMALL = 1024; private static final int PLAB_SIZE_MEDIUM = 4096; private static final int PLAB_SIZE_HIGH = 65536; private static final int OBJECT_SIZE_SMALL = 10; --- 61,72 ---- // GC ID with survivor PLAB statistics private final static long GC_ID_SURVIVOR_STATS = 1l; // GC ID with old PLAB statistics private final static long GC_ID_OLD_STATS = 2l; ! // Allowable difference for memory consumption (percentage) ! private final static long MEM_DIFFERENCE_PCT = 5; private static final int PLAB_SIZE_SMALL = 1024; private static final int PLAB_SIZE_MEDIUM = 4096; private static final int PLAB_SIZE_HIGH = 65536; private static final int OBJECT_SIZE_SMALL = 10;
*** 145,199 **** System.out.printf("Old PLAB allocated:%17d Direct allocated: %17d Mem consumed:%17d%n", plabAllocatedOld, directAllocatedOld, memAllocated); // Unreachable objects case if (testCase.isDeadObjectCase()) { // No dead objects should be promoted ! if (plabAllocatedSurvivor > MEM_CONSUMPTION_THRESHOLD || directAllocatedSurvivor > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Unreachable objects should not be allocated using PLAB or direct allocated to Survivor"); } ! if (plabAllocatedOld > MEM_CONSUMPTION_THRESHOLD || directAllocatedOld > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Unreachable objects should not be allocated using PLAB or direct allocated to Old"); } } else { // Live objects case if (testCase.isPromotedByPLAB()) { // All live small objects should be promoted using PLAB ! if (Math.abs(plabAllocatedSurvivor - memAllocated) > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Expect that Survivor PLAB allocation are similar to all mem consumed"); } ! if (Math.abs(plabAllocatedOld - memAllocated) > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Expect that Old PLAB allocation are similar to all mem consumed"); } } else { // All big objects should be directly allocated ! if (Math.abs(directAllocatedSurvivor - memAllocated) > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Survivor direct allocation are similar to all mem consumed"); } ! if (Math.abs(directAllocatedOld - memAllocated) > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Old direct allocation are similar to all mem consumed"); } } // All promoted objects size should be similar to all consumed memory ! if (Math.abs(plabAllocatedSurvivor + directAllocatedSurvivor - memAllocated) > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Survivor gen total allocation are similar to all mem consumed"); } ! if (Math.abs(plabAllocatedOld + directAllocatedOld - memAllocated) > MEM_CONSUMPTION_THRESHOLD) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Old gen total allocation are similar to all mem consumed"); } } System.out.println("Test passed!"); } private static Map<String, Long> getPlabStats(LogParser logParser, LogParser.ReportType type, long gc_id) { Map<String, Long> survivorStats = logParser.getEntries() .get(gc_id) .get(type); --- 145,207 ---- System.out.printf("Old PLAB allocated:%17d Direct allocated: %17d Mem consumed:%17d%n", plabAllocatedOld, directAllocatedOld, memAllocated); // Unreachable objects case if (testCase.isDeadObjectCase()) { // No dead objects should be promoted ! if (!(checkRatio(plabAllocatedSurvivor, memAllocated) && checkRatio(directAllocatedSurvivor, memAllocated))) { System.out.println(output); throw new RuntimeException("Unreachable objects should not be allocated using PLAB or direct allocated to Survivor"); } ! if (!(checkRatio(plabAllocatedOld, memAllocated) && checkRatio(directAllocatedOld, memAllocated))) { System.out.println(output); throw new RuntimeException("Unreachable objects should not be allocated using PLAB or direct allocated to Old"); } } else { // Live objects case if (testCase.isPromotedByPLAB()) { // All live small objects should be promoted using PLAB ! if (!checkDifferenceRatio(plabAllocatedSurvivor, memAllocated)) { System.out.println(output); throw new RuntimeException("Expect that Survivor PLAB allocation are similar to all mem consumed"); } ! if (!checkDifferenceRatio(plabAllocatedOld, memAllocated)) { System.out.println(output); throw new RuntimeException("Expect that Old PLAB allocation are similar to all mem consumed"); } } else { // All big objects should be directly allocated ! if (!checkDifferenceRatio(directAllocatedSurvivor, memAllocated)) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Survivor direct allocation are similar to all mem consumed"); } ! if (!checkDifferenceRatio(directAllocatedOld, memAllocated)) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Old direct allocation are similar to all mem consumed"); } } // All promoted objects size should be similar to all consumed memory ! if (!checkDifferenceRatio(plabAllocatedSurvivor + directAllocatedSurvivor, memAllocated)) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Survivor gen total allocation are similar to all mem consumed"); } ! if (!checkDifferenceRatio(plabAllocatedOld + directAllocatedOld, memAllocated)) { System.out.println(output); throw new RuntimeException("Test fails. Expect that Old gen total allocation are similar to all mem consumed"); } } System.out.println("Test passed!"); } + private static boolean checkRatio(long checkedValue, long controlValue) { + return (Math.abs(checkedValue) / controlValue) * 100L < MEM_DIFFERENCE_PCT; + } + + private static boolean checkDifferenceRatio(long checkedValue, long controlValue) { + return (Math.abs(checkedValue - controlValue) / controlValue) * 100L < MEM_DIFFERENCE_PCT; + } + private static Map<String, Long> getPlabStats(LogParser logParser, LogParser.ReportType type, long gc_id) { Map<String, Long> survivorStats = logParser.getEntries() .get(gc_id) .get(type);
< prev index next >