mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8163413: gc/metaspace/TestMetaspacePerfCounters failure
Reviewed-by: ehelin, dfazunen
This commit is contained in:
parent
11852cb5fa
commit
abc62e705c
1 changed files with 34 additions and 5 deletions
|
@ -21,6 +21,7 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.lang.management.GarbageCollectorMXBean;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ import jdk.test.lib.ByteCodeLoader;
|
||||||
import jdk.test.lib.InMemoryJavaCompiler;
|
import jdk.test.lib.InMemoryJavaCompiler;
|
||||||
import jdk.test.lib.Platform;
|
import jdk.test.lib.Platform;
|
||||||
|
|
||||||
|
import sun.management.ManagementFactoryHelper;
|
||||||
|
|
||||||
import static jdk.test.lib.Asserts.*;
|
import static jdk.test.lib.Asserts.*;
|
||||||
|
|
||||||
/* @test TestMetaspacePerfCounters
|
/* @test TestMetaspacePerfCounters
|
||||||
|
@ -38,7 +41,7 @@ import static jdk.test.lib.Asserts.*;
|
||||||
* space exists and works.
|
* space exists and works.
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.compiler
|
* java.compiler
|
||||||
* java.management
|
* java.management/sun.management
|
||||||
* jdk.jvmstat/sun.jvmstat.monitor
|
* 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:+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:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
|
||||||
|
@ -51,6 +54,7 @@ import static jdk.test.lib.Asserts.*;
|
||||||
public class TestMetaspacePerfCounters {
|
public class TestMetaspacePerfCounters {
|
||||||
public static Class fooClass = null;
|
public static Class fooClass = null;
|
||||||
private static final String[] counterNames = {"minCapacity", "maxCapacity", "capacity", "used"};
|
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 {
|
public static void main(String[] args) throws Exception {
|
||||||
String metaspace = "sun.gc.metaspace";
|
String metaspace = "sun.gc.metaspace";
|
||||||
|
@ -68,10 +72,27 @@ public class TestMetaspacePerfCounters {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkPerfCounters(String ns) throws Exception {
|
private static void checkPerfCounters(String ns) throws Exception {
|
||||||
long minCapacity = getMinCapacity(ns);
|
long gcCountBefore;
|
||||||
long maxCapacity = getMaxCapacity(ns);
|
long gcCountAfter;
|
||||||
long capacity = getCapacity(ns);
|
long minCapacity;
|
||||||
long used = getUsed(ns);
|
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(minCapacity, 0L);
|
||||||
assertGTE(used, minCapacity);
|
assertGTE(used, minCapacity);
|
||||||
|
@ -130,4 +151,12 @@ public class TestMetaspacePerfCounters {
|
||||||
private static long getUsed(String ns) throws Exception {
|
private static long getUsed(String ns) throws Exception {
|
||||||
return PerfCounters.findByName(ns + ".used").longValue();
|
return PerfCounters.findByName(ns + ".used").longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long currentGCCount() {
|
||||||
|
long gcCount = 0;
|
||||||
|
for (GarbageCollectorMXBean bean : gcBeans) {
|
||||||
|
gcCount += bean.getCollectionCount();
|
||||||
|
}
|
||||||
|
return gcCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue