Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp
40957 views
1
/*
2
* Copyright (c) 2018, 2021, 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
#include "precompiled.hpp"
26
#include "gc/shared/gcArguments.hpp"
27
#include "gc/shared/tlab_globals.hpp"
28
#include "gc/shared/workerPolicy.hpp"
29
#include "gc/shenandoah/shenandoahArguments.hpp"
30
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
31
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
32
#include "gc/shenandoah/shenandoahHeapRegion.hpp"
33
#include "runtime/globals_extension.hpp"
34
#include "runtime/java.hpp"
35
#include "utilities/defaultStream.hpp"
36
37
void ShenandoahArguments::initialize() {
38
#if !(defined AARCH64 || defined AMD64 || defined IA32)
39
vm_exit_during_initialization("Shenandoah GC is not supported on this platform.");
40
#endif
41
42
#if 0 // leave this block as stepping stone for future platforms
43
log_warning(gc)("Shenandoah GC is not fully supported on this platform:");
44
log_warning(gc)(" concurrent modes are not supported, only STW cycles are enabled;");
45
log_warning(gc)(" arch-specific barrier code is not implemented, disabling barriers;");
46
47
FLAG_SET_DEFAULT(ShenandoahGCHeuristics, "passive");
48
49
FLAG_SET_DEFAULT(ShenandoahSATBBarrier, false);
50
FLAG_SET_DEFAULT(ShenandoahLoadRefBarrier, false);
51
FLAG_SET_DEFAULT(ShenandoahIUBarrier, false);
52
FLAG_SET_DEFAULT(ShenandoahCASBarrier, false);
53
FLAG_SET_DEFAULT(ShenandoahCloneBarrier, false);
54
55
FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers, false);
56
#endif
57
58
if (UseLargePages && (MaxHeapSize / os::large_page_size()) < ShenandoahHeapRegion::MIN_NUM_REGIONS) {
59
warning("Large pages size (" SIZE_FORMAT "K) is too large to afford page-sized regions, disabling uncommit",
60
os::large_page_size() / K);
61
FLAG_SET_DEFAULT(ShenandoahUncommit, false);
62
}
63
64
// Enable NUMA by default. While Shenandoah is not NUMA-aware, enabling NUMA makes
65
// storage allocation code NUMA-aware.
66
if (FLAG_IS_DEFAULT(UseNUMA)) {
67
FLAG_SET_DEFAULT(UseNUMA, true);
68
}
69
70
// Set up default number of concurrent threads. We want to have cycles complete fast
71
// enough, but we also do not want to steal too much CPU from the concurrently running
72
// application. Using 1/4 of available threads for concurrent GC seems a good
73
// compromise here.
74
bool ergo_conc = FLAG_IS_DEFAULT(ConcGCThreads);
75
if (ergo_conc) {
76
FLAG_SET_DEFAULT(ConcGCThreads, MAX2(1, os::initial_active_processor_count() / 4));
77
}
78
79
if (ConcGCThreads == 0) {
80
vm_exit_during_initialization("Shenandoah expects ConcGCThreads > 0, check -XX:ConcGCThreads=#");
81
}
82
83
// Set up default number of parallel threads. We want to have decent pauses performance
84
// which would use parallel threads, but we also do not want to do too many threads
85
// that will overwhelm the OS scheduler. Using 1/2 of available threads seems to be a fair
86
// compromise here. Due to implementation constraints, it should not be lower than
87
// the number of concurrent threads.
88
bool ergo_parallel = FLAG_IS_DEFAULT(ParallelGCThreads);
89
if (ergo_parallel) {
90
FLAG_SET_DEFAULT(ParallelGCThreads, MAX2(1, os::initial_active_processor_count() / 2));
91
}
92
93
if (ParallelGCThreads == 0) {
94
vm_exit_during_initialization("Shenandoah expects ParallelGCThreads > 0, check -XX:ParallelGCThreads=#");
95
}
96
97
// Make sure ergonomic decisions do not break the thread count invariants.
98
// This may happen when user overrides one of the flags, but not the other.
99
// When that happens, we want to adjust the setting that was set ergonomically.
100
if (ParallelGCThreads < ConcGCThreads) {
101
if (ergo_conc && !ergo_parallel) {
102
FLAG_SET_DEFAULT(ConcGCThreads, ParallelGCThreads);
103
} else if (!ergo_conc && ergo_parallel) {
104
FLAG_SET_DEFAULT(ParallelGCThreads, ConcGCThreads);
105
} else if (ergo_conc && ergo_parallel) {
106
// Should not happen, check the ergonomic computation above. Fail with relevant error.
107
vm_exit_during_initialization("Shenandoah thread count ergonomic error");
108
} else {
109
// User settings error, report and ask user to rectify.
110
vm_exit_during_initialization("Shenandoah expects ConcGCThreads <= ParallelGCThreads, check -XX:ParallelGCThreads, -XX:ConcGCThreads");
111
}
112
}
113
114
if (ShenandoahRegionSampling && FLAG_IS_DEFAULT(PerfDataMemorySize)) {
115
// When sampling is enabled, max out the PerfData memory to get more
116
// Shenandoah data in, including Matrix.
117
FLAG_SET_DEFAULT(PerfDataMemorySize, 2048*K);
118
}
119
120
#ifdef COMPILER2
121
// Shenandoah cares more about pause times, rather than raw throughput.
122
if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) {
123
FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true);
124
if (FLAG_IS_DEFAULT(LoopStripMiningIter)) {
125
FLAG_SET_DEFAULT(LoopStripMiningIter, 1000);
126
}
127
}
128
#ifdef ASSERT
129
// C2 barrier verification is only reliable when all default barriers are enabled
130
if (ShenandoahVerifyOptoBarriers &&
131
(!FLAG_IS_DEFAULT(ShenandoahSATBBarrier) ||
132
!FLAG_IS_DEFAULT(ShenandoahLoadRefBarrier) ||
133
!FLAG_IS_DEFAULT(ShenandoahIUBarrier) ||
134
!FLAG_IS_DEFAULT(ShenandoahCASBarrier) ||
135
!FLAG_IS_DEFAULT(ShenandoahCloneBarrier)
136
)) {
137
warning("Unusual barrier configuration, disabling C2 barrier verification");
138
FLAG_SET_DEFAULT(ShenandoahVerifyOptoBarriers, false);
139
}
140
#else
141
guarantee(!ShenandoahVerifyOptoBarriers, "Should be disabled");
142
#endif // ASSERT
143
#endif // COMPILER2
144
145
// Record more information about previous cycles for improved debugging pleasure
146
if (FLAG_IS_DEFAULT(LogEventsBufferEntries)) {
147
FLAG_SET_DEFAULT(LogEventsBufferEntries, 250);
148
}
149
150
if ((InitialHeapSize == MaxHeapSize) && ShenandoahUncommit) {
151
log_info(gc)("Min heap equals to max heap, disabling ShenandoahUncommit");
152
FLAG_SET_DEFAULT(ShenandoahUncommit, false);
153
}
154
155
// If class unloading is disabled, no unloading for concurrent cycles as well.
156
if (!ClassUnloading) {
157
FLAG_SET_DEFAULT(ClassUnloadingWithConcurrentMark, false);
158
}
159
160
// TLAB sizing policy makes resizing decisions before each GC cycle. It averages
161
// historical data, assigning more recent data the weight according to TLABAllocationWeight.
162
// Current default is good for generational collectors that run frequent young GCs.
163
// With Shenandoah, GC cycles are much less frequent, so we need we need sizing policy
164
// to converge faster over smaller number of resizing decisions.
165
if (FLAG_IS_DEFAULT(TLABAllocationWeight)) {
166
FLAG_SET_DEFAULT(TLABAllocationWeight, 90);
167
}
168
}
169
170
size_t ShenandoahArguments::conservative_max_heap_alignment() {
171
size_t align = ShenandoahMaxRegionSize;
172
if (UseLargePages) {
173
align = MAX2(align, os::large_page_size());
174
}
175
return align;
176
}
177
178
void ShenandoahArguments::initialize_alignments() {
179
// Need to setup sizes early to get correct alignments.
180
ShenandoahHeapRegion::setup_sizes(MaxHeapSize);
181
182
// This is expected by our algorithm for ShenandoahHeap::heap_region_containing().
183
size_t align = ShenandoahHeapRegion::region_size_bytes();
184
if (UseLargePages) {
185
align = MAX2(align, os::large_page_size());
186
}
187
SpaceAlignment = align;
188
HeapAlignment = align;
189
}
190
191
CollectedHeap* ShenandoahArguments::create_heap() {
192
return new ShenandoahHeap(new ShenandoahCollectorPolicy());
193
}
194
195