author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 40631 | hotspot/test/gc/stress/TestStressRSetCoarsening.java@ed82623d7831 |
child 48791 | 6e079ff6c83c |
permissions | -rw-r--r-- |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
1 |
/* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
4 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
8 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
13 |
* accompanied this code). |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
14 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
18 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
21 |
* questions. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
22 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
23 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
24 |
import java.util.concurrent.TimeoutException; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
25 |
import sun.hotspot.WhiteBox; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
26 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
27 |
/* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
28 |
* @test TestStressRSetCoarsening.java |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
29 |
* @key stress |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
30 |
* @bug 8146984 8147087 |
39414
4adf52148100
8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents:
38930
diff
changeset
|
31 |
* @requires vm.gc.G1 |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
32 |
* @requires os.maxMemory > 3G |
38930
469cfb0d7eb3
8157954: [TESTBUG] G1 tests fail with defined MaxGCPauseMillis
mchernov
parents:
38728
diff
changeset
|
33 |
* @requires vm.opt.MaxGCPauseMillis == "null" |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
34 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
35 |
* @summary Stress G1 Remembered Set by creating a lot of cross region links |
37507 | 36 |
* @modules java.base/jdk.internal.misc |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
37 |
* @library /test/lib |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
38 |
* @build sun.hotspot.WhiteBox |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
39 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
40 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
41 |
* @run main/othervm/timeout=300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
42 |
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
43 |
* -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
44 |
* -Xmx500m -XX:G1HeapRegionSize=1m TestStressRSetCoarsening 1 0 300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
45 |
* @run main/othervm/timeout=300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
46 |
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
47 |
* -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
48 |
* -Xmx500m -XX:G1HeapRegionSize=8m TestStressRSetCoarsening 1 10 300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
49 |
* @run main/othervm/timeout=300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
50 |
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
51 |
* -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
52 |
* -Xmx500m -XX:G1HeapRegionSize=32m TestStressRSetCoarsening 42 10 300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
53 |
* @run main/othervm/timeout=300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
54 |
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
55 |
* -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
56 |
* -Xmx500m -XX:G1HeapRegionSize=1m TestStressRSetCoarsening 2 0 300 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
57 |
* @run main/othervm/timeout=1800 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
58 |
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
59 |
* -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
60 |
* -Xmx1G -XX:G1HeapRegionSize=1m TestStressRSetCoarsening 500 0 1800 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
61 |
* @run main/othervm/timeout=1800 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
62 |
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
63 |
* -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
64 |
* -Xmx1G -XX:G1HeapRegionSize=1m TestStressRSetCoarsening 10 10 1800 |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
65 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
66 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
67 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
68 |
* What the test does. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
69 |
* Preparation stage: |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
70 |
* Fill out ~90% of the heap with objects, each object is an object array. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
71 |
* If we want to allocate K objects per region, we calculate N to meet: |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
72 |
* sizeOf(Object[N]) ~= regionSize / K |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
73 |
* Stress stage: |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
74 |
* No more allocation, so no more GC. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
75 |
* We will perform a number of iterations. On each iteration i, |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
76 |
* for each pair of regions Rx and Ry we will set c[i] references |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
77 |
* from Rx to Ry. If c[i] less than c[i-1] at the end of iteration |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
78 |
* concurrent mark cycle will be initiated (to recalculate remembered sets). |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
79 |
* As the result RSet will be growing up and down, up and down many times. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
80 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
81 |
* The test expects: no crash and no timeouts. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
82 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
83 |
* Test Parameters: |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
84 |
* args[0] - number of objects per Heap Region (1 - means humongous) |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
85 |
* args[1] - number of regions to refresh to provoke GC at the end of cycle. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
86 |
* (0 - means no GC, i.e. no reading from RSet) |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
87 |
* args[2] - timeout in seconds (to stop execution to avoid jtreg timeout) |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
88 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
89 |
public class TestStressRSetCoarsening { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
90 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
91 |
public static void main(String... args) throws InterruptedException { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
92 |
if (args.length != 3) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
93 |
throw new IllegalArgumentException("Wrong number of arguments " + args.length); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
94 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
95 |
int objectsPerRegion = Integer.parseInt(args[0]); // 1 means humongous |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
96 |
int regsToRefresh = Integer.parseInt(args[1]); // 0 means no regions to refresh at the end of cycle |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
97 |
int timeout = Integer.parseInt(args[2]); // in seconds, test should stop working eariler |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
98 |
new TestStressRSetCoarsening(objectsPerRegion, regsToRefresh, timeout).go(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
99 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
100 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
101 |
private static final long KB = 1024; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
102 |
private static final long MB = 1024 * KB; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
103 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
104 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
105 |
|
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
106 |
public final ObjStorage storage; |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
107 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
108 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
109 |
* Number of objects per region. This is a test parameter. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
110 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
111 |
public final int K; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
112 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
113 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
114 |
* Length of object array: sizeOf(Object[N]) ~= regionSize / K |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
115 |
* N will be calculated as function of K. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
116 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
117 |
public final int N; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
118 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
119 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
120 |
* How many regions involved into testing. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
121 |
* Will be calculated as heapFractionToAllocate * freeRegionCount. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
122 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
123 |
public final int regionCount; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
124 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
125 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
126 |
* How much heap to use. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
127 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
128 |
public final float heapFractionToAllocate = 0.9f; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
129 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
130 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
131 |
* How many regions to be refreshed at the end of cycle. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
132 |
* This is a test parameter. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
133 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
134 |
public final int regsToRefresh; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
135 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
136 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
137 |
* Initial time. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
138 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
139 |
public final long start; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
140 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
141 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
142 |
* Time when the test should stop working. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
143 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
144 |
public final long finishAt; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
145 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
146 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
147 |
* Does pre-calculation and allocate necessary objects. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
148 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
149 |
* @param objPerRegions how many objects per G1 heap region |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
150 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
151 |
TestStressRSetCoarsening(int objPerRegions, int regsToRefresh, int timeout) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
152 |
this.K = objPerRegions; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
153 |
this.regsToRefresh = regsToRefresh; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
154 |
this.start = System.currentTimeMillis(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
155 |
this.finishAt = start + timeout * 900; // 10% ahead of jtreg timeout |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
156 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
157 |
long regionSize = WB.g1RegionSize(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
158 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
159 |
// How many free regions |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
160 |
Runtime rt = Runtime.getRuntime(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
161 |
long used = rt.totalMemory() - rt.freeMemory(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
162 |
long totalFree = rt.maxMemory() - used; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
163 |
regionCount = (int) ((totalFree / regionSize) * heapFractionToAllocate); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
164 |
long toAllocate = regionCount * regionSize; |
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
165 |
long freeMemoryLimit = totalFree - toAllocate; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
166 |
|
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
167 |
System.out.println("%% Test parameters"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
168 |
System.out.println("%% Objects per region : " + K); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
169 |
System.out.println("%% Heap fraction to allocate : " + (int) (heapFractionToAllocate * 100) + "%"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
170 |
System.out.println("%% Regions to refresh to provoke GC: " + regsToRefresh); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
171 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
172 |
System.out.println("%% Memory"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
173 |
System.out.println("%% used : " + used / MB + "M"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
174 |
System.out.println("%% available : " + totalFree / MB + "M"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
175 |
System.out.println("%% to allocate : " + toAllocate / MB + "M"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
176 |
System.out.println("%% (in regs) : " + regionCount); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
177 |
System.out.println("%% G1 Region Size: " + regionSize / MB + "M"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
178 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
179 |
int refSize = WB.getHeapOopSize(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
180 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
181 |
// Calculate N: K*sizeOf(Object[N]) ~= regionSize |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
182 |
// sizeOf(Object[N]) ~= (N+4)*refSize |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
183 |
// ==> |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
184 |
// N = regionSize / K / refSize - 4; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
185 |
int n = (int) ((regionSize / K) / refSize) - 5; // best guess |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
186 |
long objSize = WB.getObjectSize(new Object[n]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
187 |
while (K*objSize > regionSize) { // adjust to avoid OOME |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
188 |
n = n - 1; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
189 |
objSize = WB.getObjectSize(new Object[n]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
190 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
191 |
N = n; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
192 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
193 |
/* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
194 |
* -------------- |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
195 |
* region0 storage[0] = new Object[N] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
196 |
* ... |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
197 |
* storage[K-1] = new Object[N] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
198 |
* --------------- |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
199 |
* region1 storage[K] = new Object[N] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
200 |
* ... |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
201 |
* storage[2*K - 1] = new Object[N] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
202 |
* -------------- |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
203 |
* ... |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
204 |
* -------------- |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
205 |
* regionX storage[X*K] = new Object[N] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
206 |
* ... |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
207 |
* storage[(X+1)*K -1] = new Object[N] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
208 |
* where X = HeapFraction * TotalRegions |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
209 |
* ------------- |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
210 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
211 |
System.out.println("%% Objects"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
212 |
System.out.println("%% N (array length) : " + N); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
213 |
System.out.println("%% K (objects in regions): " + K); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
214 |
System.out.println("%% Object size : " + objSize + |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
215 |
" (sizeOf(new Object[" + N + "])"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
216 |
System.out.println("%% Reference size : " + refSize); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
217 |
|
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
218 |
// Maximum number of objects to allocate is regionCount * K. |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
219 |
storage = new ObjStorage(regionCount * K); |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
220 |
|
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
221 |
// Add objects as long as there is space in the storage |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
222 |
// and we haven't used more memory than planned. |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
223 |
while (!storage.isFull() && (rt.maxMemory() - used) > freeMemoryLimit) { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
224 |
storage.addArray(new Object[N]); |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
225 |
// Update used memory |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
226 |
used = rt.totalMemory() - rt.freeMemory(); |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
227 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
228 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
229 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
230 |
public void go() throws InterruptedException { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
231 |
// threshold for sparce -> fine |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
232 |
final int FINE = WB.getIntxVMFlag("G1RSetSparseRegionEntries").intValue(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
233 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
234 |
// threshold for fine -> coarse |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
235 |
final int COARSE = WB.getIntxVMFlag("G1RSetRegionEntries").intValue(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
236 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
237 |
// regToRegRefCounts - array of reference counts from region to region |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
238 |
// at the the end of iteration. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
239 |
// The number of test iterations is array length - 1. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
240 |
// If c[i] > c[i-1] then during the iteration i more references will |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
241 |
// be created. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
242 |
// If c[i] < c[i-1] then some referenes will be cleaned. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
243 |
int[] regToRegRefCounts = {0, FINE / 2, 0, FINE, (FINE + COARSE) / 2, 0, |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
244 |
COARSE, COARSE + 10, FINE + 1, FINE / 2, 0}; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
245 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
246 |
// For progress tracking |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
247 |
int[] progress = new int[regToRegRefCounts.length]; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
248 |
progress[0] = 0; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
249 |
for (int i = 1; i < regToRegRefCounts.length; i++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
250 |
progress[i] = progress[i - 1] + Math.abs(regToRegRefCounts[i] - regToRegRefCounts[i - 1]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
251 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
252 |
try { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
253 |
for (int i = 1; i < regToRegRefCounts.length; i++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
254 |
int pre = regToRegRefCounts[i - 1]; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
255 |
int cur = regToRegRefCounts[i]; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
256 |
float prog = ((float) progress[i - 1] / progress[progress.length - 1]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
257 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
258 |
System.out.println("%% step " + i |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
259 |
+ " out of " + (regToRegRefCounts.length - 1) |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
260 |
+ " (~" + (int) (100 * prog) + "% done)"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
261 |
System.out.println("%% " + pre + " --> " + cur); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
262 |
for (int to = 0; to < regionCount; to++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
263 |
// Select a celebrity object that we will install references to. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
264 |
// The celebrity will be referred from all other regions. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
265 |
// If the number of references after should be less than they |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
266 |
// were before, select NULL. |
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
267 |
Object celebrity = cur > pre ? storage.getArrayAt(to * K) : null; |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
268 |
for (int from = 0; from < regionCount; from++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
269 |
if (to == from) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
270 |
continue; // no need to refer to itself |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
271 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
272 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
273 |
int step = cur > pre ? +1 : -1; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
274 |
for (int rn = pre; rn != cur; rn += step) { |
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
275 |
Object[] rnArray = storage.getArrayAt(getY(to, from, rn)); |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
276 |
rnArray[getX(to, from, rn)] = celebrity; |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
277 |
if (System.currentTimeMillis() > finishAt) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
278 |
throw new TimeoutException(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
279 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
280 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
281 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
282 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
283 |
if (pre > cur) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
284 |
// Number of references went down. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
285 |
// Need to provoke recalculation of RSet. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
286 |
WB.g1StartConcMarkCycle(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
287 |
while (WB.g1InConcurrentMark()) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
288 |
Thread.sleep(1); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
289 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
290 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
291 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
292 |
// To force the use of rememebered set entries we need to provoke a GC. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
293 |
// To induce some fragmentation, and some mixed GCs, we need |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
294 |
// to make a few objects unreachable. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
295 |
for (int toClean = i * regsToRefresh; toClean < (i + 1) * regsToRefresh; toClean++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
296 |
int to = toClean % regionCount; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
297 |
// Need to remove all references from all regions to the region 'to' |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
298 |
for (int from = 0; from < regionCount; from++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
299 |
if (to == from) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
300 |
continue; // no need to refer to itself |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
301 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
302 |
for (int rn = 0; rn <= cur; rn++) { |
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
303 |
Object[] rnArray = storage.getArrayAt(getY(to, from, rn)); |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
304 |
rnArray[getX(to, from, rn)] = null; |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
305 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
306 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
307 |
// 'Refresh' storage elements for the region 'to' |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
308 |
// After that loop all 'old' objects in the region 'to' |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
309 |
// should become unreachable. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
310 |
for (int k = 0; k < K; k++) { |
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
311 |
storage.setArrayAt(to * K + k, new Object[N]); |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
312 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
313 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
314 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
315 |
} catch (TimeoutException e) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
316 |
System.out.println("%% TIMEOUT!!!"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
317 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
318 |
long now = System.currentTimeMillis(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
319 |
System.out.println("%% Summary"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
320 |
System.out.println("%% Time spent : " + ((now - start) / 1000) + " seconds"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
321 |
System.out.println("%% Free memory left : " + Runtime.getRuntime().freeMemory() / KB + "K"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
322 |
System.out.println("%% Test passed"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
323 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
324 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
325 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
326 |
* Returns X index in the Storage of the reference #rn from the region |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
327 |
* 'from' to the region 'to'. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
328 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
329 |
* @param to region # to refer to |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
330 |
* @param from region # to refer from |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
331 |
* @param rn number of reference |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
332 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
333 |
* @return X index in the range: [0 ... N-1] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
334 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
335 |
private int getX(int to, int from, int rn) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
336 |
return (rn * regionCount + to) % N; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
337 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
338 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
339 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
340 |
* Returns Y index in the Storage of the reference #rn from the region |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
341 |
* 'from' to the region 'to'. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
342 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
343 |
* @param to region # to refer to |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
344 |
* @param from region # to refer from |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
345 |
* @param rn number of reference |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
346 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
347 |
* @return Y index in the range: [0 ... K*regionCount -1] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
348 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
349 |
private int getY(int to, int from, int rn) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
350 |
return ((rn * regionCount + to) / N + from * K) % (regionCount * K); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
351 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
352 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
353 |
|
38728
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
354 |
//Helper class to encapsulate the object array storage. |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
355 |
class ObjStorage { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
356 |
public final Object[][] storage; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
357 |
public int usedCount; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
358 |
|
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
359 |
ObjStorage(int size) { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
360 |
storage = new Object[size][]; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
361 |
usedCount = 0; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
362 |
} |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
363 |
|
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
364 |
public boolean isFull() { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
365 |
return usedCount >= storage.length; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
366 |
} |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
367 |
|
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
368 |
public void addArray(Object[] objects) { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
369 |
if (isFull()) { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
370 |
throw new IllegalStateException("Storage full maximum number of allowed elements: " + usedCount); |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
371 |
} |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
372 |
storage[usedCount++] = objects; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
373 |
} |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
374 |
|
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
375 |
// Limit by usedCount since memory limits can cause the storage |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
376 |
// to have unused slots in the end. |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
377 |
public void setArrayAt(int i, Object[] objects) { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
378 |
storage[i % usedCount] = objects; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
379 |
} |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
380 |
|
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
381 |
// Limit by usedCount since memory limits can cause the storage |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
382 |
// to have unused slots in the end. |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
383 |
public Object[] getArrayAt(int i) { |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
384 |
return storage[i % usedCount]; |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
385 |
} |
3b18de52e85a
8157153: TestStressRSetCoarsening fails with OOM
sjohanss
parents:
37507
diff
changeset
|
386 |
} |