Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/gc/epsilon/TestManyThreads.java
66644 views
1
/*
2
* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package gc.epsilon;
25
26
/**
27
* @test TestManyThreads
28
* @requires vm.gc.Epsilon
29
* @summary Test allocations from many threads
30
*
31
* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k
32
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
33
* gc.epsilon.TestManyThreads
34
*
35
* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k
36
* -Xint
37
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
38
* gc.epsilon.TestManyThreads
39
*
40
* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k
41
* -Xbatch -Xcomp -XX:TieredStopAtLevel=1
42
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
43
* gc.epsilon.TestManyThreads
44
*
45
* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k
46
* -Xbatch -Xcomp -XX:-TieredCompilation
47
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
48
* gc.epsilon.TestManyThreads
49
*
50
* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k
51
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
52
* gc.epsilon.TestManyThreads
53
*
54
* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k
55
* -Xint
56
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
57
* gc.epsilon.TestManyThreads
58
*
59
* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k
60
* -Xbatch -Xcomp -XX:TieredStopAtLevel=1
61
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
62
* gc.epsilon.TestManyThreads
63
*
64
* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k
65
* -Xbatch -Xcomp -XX:-TieredCompilation
66
* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC
67
* gc.epsilon.TestManyThreads
68
*/
69
70
import java.util.concurrent.atomic.*;
71
72
public class TestManyThreads {
73
74
static int COUNT = Integer.getInteger("count", 128); // 128 * 4M max tlabs = 512M, would overflow without TLAB sizing
75
76
static volatile Object sink;
77
static volatile Throwable failed;
78
static final AtomicInteger allocated = new AtomicInteger();
79
80
public static void workload() {
81
try {
82
sink = new Object();
83
allocated.incrementAndGet();
84
Thread.sleep(3600 * 1000);
85
} catch (Throwable e) {
86
failed = e;
87
}
88
}
89
90
public static void main(String[] args) throws Throwable {
91
for (int c = 0; c < COUNT; c++) {
92
Thread t = new Thread(TestManyThreads::workload);
93
t.setDaemon(true);
94
t.start();
95
}
96
97
while ((failed == null) && (allocated.get() != COUNT)) {
98
Thread.sleep(100);
99
}
100
101
if (failed != null) {
102
throw failed;
103
}
104
}
105
106
}
107
108