Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/shenandoah/TestAllocHumongousFragment.java
40942 views
1
/*
2
* Copyright (c) 2016, 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
25
/*
26
* @test TestAllocHumongousFragment
27
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
28
* @key randomness
29
* @requires vm.gc.Shenandoah
30
* @library /test/lib
31
*
32
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
33
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
34
* -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
35
* TestAllocHumongousFragment
36
*
37
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
38
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
39
* -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
40
* TestAllocHumongousFragment
41
*
42
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
43
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
44
* -XX:-ShenandoahDegeneratedGC
45
* TestAllocHumongousFragment
46
*
47
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
48
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
49
* -XX:+ShenandoahDegeneratedGC
50
* TestAllocHumongousFragment
51
*/
52
53
/*
54
* @test TestAllocHumongousFragment
55
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
56
* @key randomness
57
* @requires vm.gc.Shenandoah
58
* @library /test/lib
59
*
60
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
61
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
62
* -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
63
* TestAllocHumongousFragment
64
*
65
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
66
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
67
* -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
68
* TestAllocHumongousFragment
69
*
70
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
71
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
72
* -XX:+ShenandoahOOMDuringEvacALot
73
* TestAllocHumongousFragment
74
*
75
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
76
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
77
* -XX:+ShenandoahAllocFailureALot
78
* TestAllocHumongousFragment
79
*/
80
81
/*
82
* @test TestAllocHumongousFragment
83
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
84
* @key randomness
85
* @requires vm.gc.Shenandoah
86
* @library /test/lib
87
*
88
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
89
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
90
* -XX:+ShenandoahVerify
91
* TestAllocHumongousFragment
92
*
93
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
94
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
95
* TestAllocHumongousFragment
96
*/
97
98
/*
99
* @test TestAllocHumongousFragment
100
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
101
* @key randomness
102
* @requires vm.gc.Shenandoah
103
* @library /test/lib
104
*
105
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
106
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
107
* TestAllocHumongousFragment
108
*/
109
110
/*
111
* @test TestAllocHumongousFragment
112
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
113
* @key randomness
114
* @requires vm.gc.Shenandoah
115
* @library /test/lib
116
*
117
* @run main/othervm -Xmx1g -Xms1g -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:ShenandoahTargetNumRegions=2048
118
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
119
* TestAllocHumongousFragment
120
*/
121
122
/*
123
* @test TestAllocHumongousFragment
124
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
125
* @key randomness
126
* @requires vm.gc.Shenandoah
127
* @library /test/lib
128
*
129
* @run main/othervm -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
130
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
131
* -XX:+ShenandoahOOMDuringEvacALot -XX:+ShenandoahVerify
132
* TestAllocHumongousFragment
133
*
134
* @run main/othervm -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
135
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
136
* -XX:+ShenandoahAllocFailureALot -XX:+ShenandoahVerify
137
* TestAllocHumongousFragment
138
*
139
* @run main/othervm -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
140
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
141
* -XX:+ShenandoahOOMDuringEvacALot
142
* TestAllocHumongousFragment
143
*
144
* @run main/othervm -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
145
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
146
* -XX:+ShenandoahAllocFailureALot
147
* TestAllocHumongousFragment
148
*/
149
150
/*
151
* @test TestAllocHumongousFragment
152
* @summary Make sure Shenandoah can recover from humongous allocation fragmentation
153
* @key randomness
154
* @requires vm.gc.Shenandoah
155
* @library /test/lib
156
*
157
* @run main/othervm -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
158
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
159
* -XX:+ShenandoahVerify
160
* TestAllocHumongousFragment
161
*
162
* @run main/othervm -Xlog:gc -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g -XX:ShenandoahTargetNumRegions=2048
163
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
164
* TestAllocHumongousFragment
165
*/
166
167
import java.util.*;
168
import jdk.test.lib.Utils;
169
170
public class TestAllocHumongousFragment {
171
172
static final long TARGET_MB = Long.getLong("target", 30_000); // 30 Gb allocations
173
static final long LIVE_MB = Long.getLong("occupancy", 700); // 700 Mb alive
174
175
static volatile Object sink;
176
177
static List<int[]> objects;
178
179
public static void main(String[] args) throws Exception {
180
final int min = 128 * 1024;
181
final int max = 16 * 1024 * 1024;
182
final long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2));
183
184
objects = new ArrayList<>();
185
long current = 0;
186
187
Random rng = Utils.getRandomInstance();
188
for (long c = 0; c < count; c++) {
189
while (current > LIVE_MB * 1024 * 1024) {
190
int idx = rng.nextInt(objects.size());
191
int[] remove = objects.remove(idx);
192
current -= remove.length * 4 + 16;
193
}
194
195
int[] newObj = new int[min + rng.nextInt(max - min)];
196
current += newObj.length * 4 + 16;
197
objects.add(newObj);
198
sink = new Object();
199
200
System.out.println("Allocated: " + (current / 1024 / 1024) + " Mb");
201
}
202
}
203
204
}
205
206