author | lkorinth |
Mon, 28 Jan 2019 15:53:56 +0100 | |
changeset 53523 | 4c5184c56dc2 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
1 |
/* |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
41705
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
4 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
7 |
* published by the Free Software Foundation. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
8 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
13 |
* accompanied this code). |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
14 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
18 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
21 |
* questions. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
22 |
*/ |
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
23 |
|
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
24 |
package gc.arguments; |
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
25 |
|
32625
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
26 |
import java.lang.management.ManagementFactory; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
27 |
import java.lang.management.MemoryPoolMXBean; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
28 |
import java.lang.management.MemoryUsage; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
29 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
30 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
31 |
* Utility class used by tests to get heap region usage. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
32 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
33 |
public final class HeapRegionUsageTool { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
34 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
35 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
36 |
* Get MemoryUsage from MemoryPoolMXBean which name matches passed string. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
37 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
38 |
* @param name |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
39 |
* @return MemoryUsage |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
40 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
41 |
private static MemoryUsage getUsage(String name){ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
42 |
for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
43 |
if (pool.getName().matches(name)) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
44 |
return pool.getUsage(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
45 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
46 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
47 |
return null; |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
48 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
49 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
50 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
51 |
* Get MemoryUsage of Eden space. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
52 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
53 |
* @return MemoryUsage |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
54 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
55 |
public static MemoryUsage getEdenUsage() { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
56 |
return getUsage(".*Eden.*"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
57 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
58 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
59 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
60 |
* Get MemoryUsage of Survivor space. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
61 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
62 |
* @return MemoryUsage |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
63 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
64 |
public static MemoryUsage getSurvivorUsage() { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
65 |
return getUsage(".*Survivor.*"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
66 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
67 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
68 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
69 |
* Get memory usage of Tenured space |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
70 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
71 |
* @return MemoryUsage |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
72 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
73 |
public static MemoryUsage getOldUsage() { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
74 |
return getUsage(".*(Old|Tenured).*"); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
75 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
76 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
77 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
78 |
* Get heap usage. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
79 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
80 |
* @return MemoryUsage |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
81 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
82 |
public static MemoryUsage getHeapUsage() { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
83 |
return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
84 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
85 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
86 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
87 |
* Helper function to align up. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
88 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
89 |
* @param value |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
90 |
* @param alignment |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
91 |
* @return aligned value |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
92 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
93 |
public static long alignUp(long value, long alignment) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
94 |
return (value + alignment - 1) & ~(alignment - 1); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
95 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
96 |
|
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
97 |
/** |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
98 |
* Helper function to align down. |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
99 |
* |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
100 |
* @param value |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
101 |
* @param alignment |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
102 |
* @return aligned value |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
103 |
*/ |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
104 |
public static long alignDown(long value, long alignment) { |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
105 |
return value & ~(alignment - 1); |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
106 |
} |
054d452e4e06
8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents:
diff
changeset
|
107 |
} |