author | lkorinth |
Mon, 28 Jan 2019 15:53:56 +0100 | |
changeset 53523 | 4c5184c56dc2 |
parent 48791 | 6e079ff6c83c |
permissions | -rw-r--r-- |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
1 |
/* |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
48791
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
37498
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 |
|
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
48791
diff
changeset
|
24 |
package gc.stress; |
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
48791
diff
changeset
|
25 |
|
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
26 |
import java.io.PrintStream; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
27 |
import java.util.ArrayList; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
28 |
import java.util.List; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
29 |
import java.util.Map; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
30 |
import java.util.Random; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
31 |
import sun.hotspot.WhiteBox; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
32 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
33 |
/* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
34 |
* @test TestMultiThreadStressRSet.java |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
35 |
* @key stress |
39414
4adf52148100
8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents:
38930
diff
changeset
|
36 |
* @requires vm.gc.G1 |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
37 |
* @requires os.maxMemory > 2G |
38930
469cfb0d7eb3
8157954: [TESTBUG] G1 tests fail with defined MaxGCPauseMillis
mchernov
parents:
38152
diff
changeset
|
38 |
* @requires vm.opt.MaxGCPauseMillis == "null" |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
39 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
40 |
* @summary Stress G1 Remembered Set using multiple threads |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
37498
diff
changeset
|
41 |
* @modules java.base/jdk.internal.misc |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
42 |
* @library /test/lib |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
43 |
* @build sun.hotspot.WhiteBox |
48791
6e079ff6c83c
8186635: ClassFileInstaller should be run as a driver
iignatyev
parents:
47216
diff
changeset
|
44 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
45 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
46 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
47 |
* -XX:+UseG1GC -XX:G1SummarizeRSetStatsPeriod=1 -Xlog:gc |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
48791
diff
changeset
|
48 |
* -Xmx500m -XX:G1HeapRegionSize=1m -XX:MaxGCPauseMillis=1000 gc.stress.TestMultiThreadStressRSet 10 4 |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
49 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
50 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
51 |
* -XX:+UseG1GC -XX:G1SummarizeRSetStatsPeriod=100 -Xlog:gc |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
48791
diff
changeset
|
52 |
* -Xmx1G -XX:G1HeapRegionSize=8m -XX:MaxGCPauseMillis=1000 gc.stress.TestMultiThreadStressRSet 60 16 |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
53 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
54 |
* @run main/othervm/timeout=700 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
55 |
* -XX:+UseG1GC -XX:G1SummarizeRSetStatsPeriod=100 -Xlog:gc |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
48791
diff
changeset
|
56 |
* -Xmx500m -XX:G1HeapRegionSize=1m -XX:MaxGCPauseMillis=1000 gc.stress.TestMultiThreadStressRSet 600 32 |
37498
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
57 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
58 |
public class TestMultiThreadStressRSet { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
59 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
60 |
private static final Random RND = new Random(2015 * 2016); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
61 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
62 |
private static final int REF_SIZE = WB.getHeapOopSize(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
63 |
private static final int REGION_SIZE = WB.g1RegionSize(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
64 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
65 |
// How many regions to use for the storage |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
66 |
private static final int STORAGE_REGIONS = 20; |
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 |
// Size a single obj in the storage |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
69 |
private static final int OBJ_SIZE = 1024; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
70 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
71 |
// How many regions of young/old gen to use in the BUFFER |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
72 |
private static final int BUFFER_YOUNG_REGIONS = 60; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
73 |
private static final int BUFFER_OLD_REGIONS = 40; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
74 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
75 |
// Total number of objects in the storage. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
76 |
private final int N; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
77 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
78 |
// The storage of byte[] |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
79 |
private final List<Object> STORAGE; |
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 |
// Where references to the Storage will be stored |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
82 |
private final List<Object[]> BUFFER; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
83 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
84 |
// The length of a buffer element. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
85 |
// RSet deals with "cards" (areas of 512 bytes), not with single refs |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
86 |
// So, to affect the RSet the BUFFER refs should be allocated in different |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
87 |
// memory cards. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
88 |
private final int BUF_ARR_LEN = 100 * (512 / REF_SIZE); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
89 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
90 |
// Total number of objects in the young/old buffers |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
91 |
private final int YOUNG; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
92 |
private final int OLD; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
93 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
94 |
// To cause Remembered Sets change their coarse level the test uses a window |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
95 |
// within STORAGE. All the BUFFER elements refer to only STORAGE objects |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
96 |
// from the current window. The window is defined by a range. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
97 |
// The first element has got the index: 'windowStart', |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
98 |
// the last one: 'windowStart + windowSize - 1' |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
99 |
// The window is shifting periodically. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
100 |
private int windowStart; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
101 |
private final int windowSize; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
102 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
103 |
// Counter of created worker threads |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
104 |
private int counter = 0; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
105 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
106 |
private volatile String errorMessage = null; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
107 |
private volatile boolean isEnough = false; |
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 |
public static void main(String args[]) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
110 |
if (args.length != 2) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
111 |
throw new IllegalArgumentException("TEST BUG: wrong arg count " + args.length); |
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 |
long time = Long.parseLong(args[0]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
114 |
int threads = Integer.parseInt(args[1]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
115 |
new TestMultiThreadStressRSet().test(time * 1000, threads); |
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 |
|
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 |
* Initiates test parameters, fills out the STORAGE and BUFFER. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
120 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
121 |
public TestMultiThreadStressRSet() { |
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 |
N = (REGION_SIZE - 1) * STORAGE_REGIONS / OBJ_SIZE + 1; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
124 |
STORAGE = new ArrayList<>(N); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
125 |
int bytes = OBJ_SIZE - 20; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
126 |
for (int i = 0; i < N - 1; i++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
127 |
STORAGE.add(new byte[bytes]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
128 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
129 |
STORAGE.add(new byte[REGION_SIZE / 2 + 100]); // humongous |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
130 |
windowStart = 0; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
131 |
windowSize = REGION_SIZE / OBJ_SIZE; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
132 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
133 |
BUFFER = new ArrayList<>(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
134 |
int sizeOfBufferObject = 20 + REF_SIZE * BUF_ARR_LEN; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
135 |
OLD = REGION_SIZE * BUFFER_OLD_REGIONS / sizeOfBufferObject; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
136 |
YOUNG = REGION_SIZE * BUFFER_YOUNG_REGIONS / sizeOfBufferObject; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
137 |
for (int i = 0; i < OLD + YOUNG; i++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
138 |
BUFFER.add(new Object[BUF_ARR_LEN]); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
139 |
} |
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 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
143 |
* Does the testing. Steps: |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
144 |
* <ul> |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
145 |
* <li> starts the Shifter thread |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
146 |
* <li> during the given time starts new Worker threads, keeping the number |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
147 |
* of live thread under limit. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
148 |
* <li> stops the Shifter thread |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
149 |
* </ul> |
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 |
* @param timeInMillis how long to stress |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
152 |
* @param maxThreads the maximum number of Worker thread working together. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
153 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
154 |
public void test(long timeInMillis, int maxThreads) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
155 |
if (timeInMillis <= 0 || maxThreads <= 0) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
156 |
throw new IllegalArgumentException("TEST BUG: be positive!"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
157 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
158 |
System.out.println("%% Time to work: " + timeInMillis / 1000 + "s"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
159 |
System.out.println("%% Number of threads: " + maxThreads); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
160 |
long finish = System.currentTimeMillis() + timeInMillis; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
161 |
Shifter shift = new Shifter(this, 1000, (int) (windowSize * 0.9)); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
162 |
shift.start(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
163 |
for (int i = 0; i < maxThreads; i++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
164 |
new Worker(this, 100).start(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
165 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
166 |
try { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
167 |
while (System.currentTimeMillis() < finish && errorMessage == null) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
168 |
Thread.sleep(100); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
169 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
170 |
} catch (Throwable t) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
171 |
printAllStackTraces(System.err); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
172 |
t.printStackTrace(System.err); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
173 |
this.errorMessage = t.getMessage(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
174 |
} finally { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
175 |
isEnough = true; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
176 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
177 |
System.out.println("%% Total work cycles: " + counter); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
178 |
if (errorMessage != null) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
179 |
throw new RuntimeException(errorMessage); |
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 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
182 |
|
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 |
* Returns an element from from the BUFFER (an object array) to keep |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
185 |
* references to the storage. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
186 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
187 |
* @return an Object[] from buffer. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
188 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
189 |
private Object[] getFromBuffer() { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
190 |
int index = counter % (OLD + YOUNG); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
191 |
synchronized (BUFFER) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
192 |
if (index < OLD) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
193 |
if (counter % 100 == (counter / 100) % 100) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
194 |
// need to generate garbage in the old gen to provoke mixed GC |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
195 |
return replaceInBuffer(index); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
196 |
} else { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
197 |
return BUFFER.get(index); |
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 |
} else { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
200 |
return replaceInBuffer(index); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
201 |
} |
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 |
private Object[] replaceInBuffer(int index) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
206 |
Object[] objs = new Object[BUF_ARR_LEN]; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
207 |
BUFFER.set(index, objs); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
208 |
return objs; |
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 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
212 |
* Returns a random object from the current window within the storage. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
213 |
* A storage element with index from windowStart to windowStart+windowSize. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
214 |
* |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
215 |
* @return a random element from the current window within the storage. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
216 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
217 |
private Object getRandomObject() { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
218 |
int index = (windowStart + RND.nextInt(windowSize)) % N; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
219 |
return STORAGE.get(index); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
220 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
221 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
222 |
private static void printAllStackTraces(PrintStream ps) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
223 |
Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
224 |
for (Thread t : traces.keySet()) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
225 |
ps.println(t.toString() + " " + t.getState()); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
226 |
for (StackTraceElement traceElement : traces.get(t)) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
227 |
ps.println("\tat " + traceElement); |
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 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
231 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
232 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
233 |
* Thread to create a number of references from BUFFER to STORAGE. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
234 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
235 |
private static class Worker extends Thread { |
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 |
final TestMultiThreadStressRSet boss; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
238 |
final int refs; // number of refs to OldGen |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
239 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
240 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
241 |
* @param boss the tests |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
242 |
* @param refsToOldGen how many references to the OldGen to create |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
243 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
244 |
Worker(TestMultiThreadStressRSet boss, int refsToOldGen) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
245 |
this.boss = boss; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
246 |
this.refs = refsToOldGen; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
247 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
248 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
249 |
@Override |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
250 |
public void run() { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
251 |
try { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
252 |
while (!boss.isEnough) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
253 |
Object[] objs = boss.getFromBuffer(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
254 |
int step = objs.length / refs; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
255 |
for (int i = 0; i < refs; i += step) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
256 |
objs[i] = boss.getRandomObject(); |
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 |
boss.counter++; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
259 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
260 |
} catch (Throwable t) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
261 |
t.printStackTrace(System.out); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
262 |
boss.errorMessage = t.getMessage(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
263 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
264 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
265 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
266 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
267 |
/** |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
268 |
* Periodically shifts the current STORAGE window, removing references |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
269 |
* in BUFFER that refer to objects outside the window. |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
270 |
*/ |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
271 |
private static class Shifter extends Thread { |
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 |
final TestMultiThreadStressRSet boss; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
274 |
final int sleepTime; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
275 |
final int shift; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
276 |
|
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
277 |
Shifter(TestMultiThreadStressRSet boss, int sleepTime, int shift) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
278 |
this.boss = boss; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
279 |
this.sleepTime = sleepTime; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
280 |
this.shift = shift; |
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 |
@Override |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
284 |
public void run() { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
285 |
try { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
286 |
while (!boss.isEnough) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
287 |
Thread.sleep(sleepTime); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
288 |
boss.windowStart += shift; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
289 |
for (int i = 0; i < boss.OLD; i++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
290 |
Object[] objs = boss.BUFFER.get(i); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
291 |
for (int j = 0; j < objs.length; j++) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
292 |
objs[j] = null; |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
293 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
294 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
295 |
if (!WB.g1InConcurrentMark()) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
296 |
System.out.println("%% start CMC"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
297 |
WB.g1StartConcMarkCycle(); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
298 |
} else { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
299 |
System.out.println("%% CMC is already in progress"); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
300 |
} |
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 |
} catch (Throwable t) { |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
303 |
t.printStackTrace(System.out); |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
304 |
boss.errorMessage = t.getMessage(); |
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 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
308 |
} |
c920466a3287
8153222: [TESTBUG] Move tests in stress/gc to gc/stress
mchernov
parents:
diff
changeset
|
309 |