Mercurial > hg > truffle
annotate test/gc/metaspace/TestPerfCountersAndMemoryPools.java @ 17716:cdb71841f4bc
6498581: ThreadInterruptTest3 produces wrong output on Windows
Summary: There is race condition between os::interrupt and os::is_interrupted on Windows. In JVM_Sleep(Thread.sleep), check if thread gets interrupted, it may see interrupted but not really interrupted so cause spurious waking up (early return from sleep). Fix by checking if interrupt event really gets set thus prevent false return. For intrinsic of _isInterrupted, on Windows, go fastpath only on bit not set.
Reviewed-by: acorn, kvn
Contributed-by: david.holmes@oracle.com, yumin.qi@oracle.com
author | minqi |
---|---|
date | Wed, 26 Feb 2014 15:20:41 -0800 |
parents | 6e22e7042433 |
children |
rev | line source |
---|---|
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
1 /* |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
4 * |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
8 * |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
13 * accompanied this code). |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
14 * |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
18 * |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
21 * questions. |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
22 */ |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
23 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
24 import java.util.List; |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
25 import java.lang.management.*; |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
26 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
27 import com.oracle.java.testlibrary.*; |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
28 import static com.oracle.java.testlibrary.Asserts.*; |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
29 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
30 /* @test TestPerfCountersAndMemoryPools |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
31 * @bug 8023476 |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
32 * @library /testlibrary |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
33 * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
34 * report the same data. |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
35 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools |
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
36 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
37 */ |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
38 public class TestPerfCountersAndMemoryPools { |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
39 public static void main(String[] args) throws Exception { |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
40 checkMemoryUsage("Metaspace", "sun.gc.metaspace"); |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
41 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
42 if (InputArguments.contains("-XX:+UseCompressedKlassPointers") && Platform.is64bit()) { |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
43 checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace"); |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
44 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
45 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
46 |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
47 private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) { |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
48 List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans(); |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
49 for (MemoryPoolMXBean pool : pools) { |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
50 if (pool.getName().equals(memoryPoolName)) { |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
51 return pool; |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
52 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
53 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
54 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
55 throw new RuntimeException("Excpted to find a memory pool with name " + |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
56 memoryPoolName); |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
57 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
58 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
59 private static void checkMemoryUsage(String memoryPoolName, String perfNS) |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
60 throws Exception { |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
61 MemoryPoolMXBean pool = getMemoryPool(memoryPoolName); |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
62 |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
63 // Must do a GC to update performance counters |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
64 System.gc(); |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
65 assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit()); |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
66 |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
67 // Must do a second GC to update the perfomance counters again, since |
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
68 // the call pool.getUsage().getInit() could have allocated some |
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
69 // metadata. |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
70 System.gc(); |
12348
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
71 assertEQ(getUsed(perfNS), pool.getUsage().getUsed()); |
6e22e7042433
8025226: TestPerfCountersAndMemoryPools.java fails with -Xmixed or -Xcomp
ehelin
parents:
12248
diff
changeset
|
72 assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted()); |
12248
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
73 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
74 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
75 private static long getMinCapacity(String ns) throws Exception { |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
76 return PerfCounters.findByName(ns + ".minCapacity").longValue(); |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
77 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
78 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
79 private static long getCapacity(String ns) throws Exception { |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
80 return PerfCounters.findByName(ns + ".capacity").longValue(); |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
81 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
82 |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
83 private static long getUsed(String ns) throws Exception { |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
84 return PerfCounters.findByName(ns + ".used").longValue(); |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
85 } |
73d0d0218068
8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents:
diff
changeset
|
86 } |