< prev index next >

test/gc/metaspace/TestMetaspacePerfCounters.java

Print this page
rev 11781 : 8163413: gc/metaspace/TestMetaspacePerfCounters failure
Reviewed-by:

*** 19,43 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ import java.util.List; import java.util.ArrayList; - import jdk.test.lib.*; import static jdk.test.lib.Asserts.*; /* @test TestMetaspacePerfCounters * @bug 8014659 * @requires vm.gc=="null" * @library /testlibrary * @summary Tests that performance counters for metaspace and compressed class * space exists and works. * @modules java.base/jdk.internal.misc * java.compiler ! * java.management * jdk.jvmstat/sun.jvmstat.monitor * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters * --- 19,45 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.lang.management.GarbageCollectorMXBean; import java.util.List; import java.util.ArrayList; import jdk.test.lib.*; + import sun.management.ManagementFactoryHelper; + import static jdk.test.lib.Asserts.*; /* @test TestMetaspacePerfCounters * @bug 8014659 * @requires vm.gc=="null" * @library /testlibrary * @summary Tests that performance counters for metaspace and compressed class * space exists and works. * @modules java.base/jdk.internal.misc * java.compiler ! * java.management/sun.management * jdk.jvmstat/sun.jvmstat.monitor * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters *
*** 46,55 **** --- 48,58 ---- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters */ public class TestMetaspacePerfCounters { public static Class fooClass = null; private static final String[] counterNames = {"minCapacity", "maxCapacity", "capacity", "used"}; + private static final List<GarbageCollectorMXBean> gcBeans = ManagementFactoryHelper.getGarbageCollectorMXBeans(); public static void main(String[] args) throws Exception { String metaspace = "sun.gc.metaspace"; String ccs = "sun.gc.compressedclassspace";
*** 63,76 **** checkUsedIncreasesWhenLoadingClass(metaspace); } } private static void checkPerfCounters(String ns) throws Exception { ! long minCapacity = getMinCapacity(ns); ! long maxCapacity = getMaxCapacity(ns); ! long capacity = getCapacity(ns); ! long used = getUsed(ns); assertGTE(minCapacity, 0L); assertGTE(used, minCapacity); assertGTE(capacity, used); assertGTE(maxCapacity, capacity); --- 66,96 ---- checkUsedIncreasesWhenLoadingClass(metaspace); } } private static void checkPerfCounters(String ns) throws Exception { ! long gcCountBefore; ! long gcCountAfter; ! long minCapacity; ! long maxCapacity; ! long capacity; ! long used; ! ! // The perf counter values are updated during GC and to be able to ! // do the assertions below we need to ensure that the values are from ! // the same GC cycle. ! do { ! gcCountBefore = currentGCCount(); ! ! minCapacity = getMinCapacity(ns); ! maxCapacity = getMaxCapacity(ns); ! capacity = getCapacity(ns); ! used = getUsed(ns); ! ! gcCountAfter = currentGCCount(); ! assertGTE(gcCountAfter, gcCountBefore); ! } while(gcCountAfter > gcCountBefore); assertGTE(minCapacity, 0L); assertGTE(used, minCapacity); assertGTE(capacity, used); assertGTE(maxCapacity, capacity);
*** 125,130 **** --- 145,158 ---- } private static long getUsed(String ns) throws Exception { return PerfCounters.findByName(ns + ".used").longValue(); } + + private static long currentGCCount() { + long gcCount = 0; + for (GarbageCollectorMXBean bean : gcBeans) { + gcCount += bean.getCollectionCount(); + } + return gcCount; + } }
< prev index next >