Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/TestAllocHumongousFragment.java
32284 views
1
/*
2
* Copyright (c) 2016, 2018, Red Hat, Inc. All rights reserved.
3
*
4
* This code is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 2 only, as
6
* published by the Free Software Foundation.
7
*
8
* This code is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11
* version 2 for more details (a copy is included in the LICENSE file that
12
* accompanied this code).
13
*
14
* You should have received a copy of the GNU General Public License version
15
* 2 along with this work; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*
18
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19
* or visit www.oracle.com if you need additional information or have any
20
* questions.
21
*
22
*/
23
24
/*
25
* @test TestAllocHumongousFragment
26
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
27
* @key gc
28
*
29
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
30
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
31
* -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
32
* TestAllocHumongousFragment
33
*
34
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
35
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
36
* -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
37
* TestAllocHumongousFragment
38
*
39
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
40
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
41
* -XX:-ShenandoahDegeneratedGC
42
* TestAllocHumongousFragment
43
*
44
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
45
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
46
* -XX:+ShenandoahDegeneratedGC
47
* TestAllocHumongousFragment
48
*/
49
50
/*
51
* @test TestAllocHumongousFragment
52
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
53
* @key gc
54
*
55
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
56
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
57
* -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
58
* TestAllocHumongousFragment
59
*
60
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
61
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
62
* -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
63
* TestAllocHumongousFragment
64
*
65
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
66
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
67
* -XX:+ShenandoahOOMDuringEvacALot
68
* TestAllocHumongousFragment
69
*
70
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
71
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
72
* -XX:+ShenandoahAllocFailureALot
73
* TestAllocHumongousFragment
74
*
75
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
76
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
77
* -XX:+ShenandoahVerify
78
* TestAllocHumongousFragment
79
*/
80
81
/*
82
* @test TestAllocHumongousFragment
83
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
84
* @key gc
85
*
86
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
87
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
88
* TestAllocHumongousFragment
89
*/
90
91
/*
92
* @test TestAllocHumongousFragment
93
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
94
* @key gc
95
*
96
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
97
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
98
* TestAllocHumongousFragment
99
*/
100
101
/*
102
* @test TestAllocHumongousFragment
103
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
104
* @key gc
105
*
106
* @run main/othervm -Xmx1g -Xms1g -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
107
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
108
* TestAllocHumongousFragment
109
*/
110
111
/*
112
* @test TestAllocHumongousFragment
113
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
114
* @key gc
115
*
116
* @run main/othervm -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
117
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
118
* -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
119
* TestAllocHumongousFragment
120
*
121
* @run main/othervm -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
122
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
123
* -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
124
* TestAllocHumongousFragment
125
*
126
* @run main/othervm -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
127
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
128
* -XX:+ShenandoahOOMDuringEvacALot
129
* TestAllocHumongousFragment
130
*
131
* @run main/othervm -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
132
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
133
* -XX:+ShenandoahAllocFailureALot
134
* TestAllocHumongousFragment
135
*
136
* @run main/othervm -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
137
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
138
* -XX:+ShenandoahVerify
139
* TestAllocHumongousFragment
140
*/
141
142
/*
143
* @test TestAllocHumongousFragment
144
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
145
* @key gc
146
*
147
* @run main/othervm -verbose:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
148
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
149
* TestAllocHumongousFragment
150
*/
151
152
import java.util.*;
153
import java.util.concurrent.*;
154
155
public class TestAllocHumongousFragment {
156
157
static final long TARGET_MB = Long.getLong("target", 30_000); // 30 Gb allocations
158
static final long LIVE_MB = Long.getLong("occupancy", 700); // 700 Mb alive
159
160
static volatile Object sink;
161
162
static List<int[]> objects;
163
164
public static void main(String[] args) throws Exception {
165
final int min = 128 * 1024;
166
final int max = 16 * 1024 * 1024;
167
final long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
168
169
objects = new ArrayList<>();
170
long current = 0;
171
172
Random r = new Random();
173
for (long c = 0; c < count; c++) {
174
while (current > LIVE_MB * 1024 * 1024) {
175
int idx = ThreadLocalRandom.current().nextInt(objects.size());
176
int[] remove = objects.remove(idx);
177
current -= remove.length * 4 + 16;
178
}
179
180
int[] newObj = new int[min + r.nextInt(max - min)];
181
current += newObj.length * 4 + 16;
182
objects.add(newObj);
183
sink = new Object();
184
185
System.out.println("Allocated: " + (current / 1024 / 1024) + " Mb");
186
}
187
}
188
189
}
190
191