author | eosterlund |
Mon, 26 Feb 2018 09:34:12 +0100 | |
changeset 49164 | 7e958a8ebcd3 |
parent 48157 | 7c4d43c26352 |
child 49751 | c3a10df652c0 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. |
1374 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
26 |
#include "gc/g1/g1ConcurrentRefine.hpp" |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
27 |
#include "gc/g1/g1ConcurrentRefineThread.hpp" |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
28 |
#include "logging/log.hpp" |
48157 | 29 |
#include "memory/allocation.inline.hpp" |
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
30 |
#include "runtime/java.hpp" |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
31 |
#include "runtime/thread.hpp" |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
32 |
#include "utilities/debug.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
33 |
#include "utilities/globalDefinitions.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
34 |
#include "utilities/pair.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
35 |
#include <math.h> |
8926
717a49db1743
7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents:
8683
diff
changeset
|
36 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
37 |
G1ConcurrentRefineThread* G1ConcurrentRefineThreadControl::create_refinement_thread(uint worker_id, bool initializing) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
38 |
G1ConcurrentRefineThread* result = NULL; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
39 |
if (initializing || !InjectGCWorkerCreationFailure) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
40 |
result = new G1ConcurrentRefineThread(_cr, worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
41 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
42 |
if (result == NULL || result->osthread() == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
43 |
log_warning(gc)("Failed to create refinement thread %u, no more %s", |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
44 |
worker_id, |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
45 |
result == NULL ? "memory" : "OS threads"); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
46 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
47 |
return result; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
48 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
49 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
50 |
G1ConcurrentRefineThreadControl::G1ConcurrentRefineThreadControl() : |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
51 |
_cr(NULL), |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
52 |
_threads(NULL), |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
53 |
_num_max_threads(0) |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
54 |
{ |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
55 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
56 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
57 |
G1ConcurrentRefineThreadControl::~G1ConcurrentRefineThreadControl() { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
58 |
for (uint i = 0; i < _num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
59 |
G1ConcurrentRefineThread* t = _threads[i]; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
60 |
if (t != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
61 |
delete t; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
62 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
63 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
64 |
FREE_C_HEAP_ARRAY(G1ConcurrentRefineThread*, _threads); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
65 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
66 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
67 |
jint G1ConcurrentRefineThreadControl::initialize(G1ConcurrentRefine* cr, uint num_max_threads) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
68 |
assert(cr != NULL, "G1ConcurrentRefine must not be NULL"); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
69 |
_cr = cr; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
70 |
_num_max_threads = num_max_threads; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
71 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
72 |
_threads = NEW_C_HEAP_ARRAY_RETURN_NULL(G1ConcurrentRefineThread*, num_max_threads, mtGC); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
73 |
if (_threads == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
74 |
vm_shutdown_during_initialization("Could not allocate thread holder array."); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
75 |
return JNI_ENOMEM; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
76 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
77 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
78 |
for (uint i = 0; i < num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
79 |
if (UseDynamicNumberOfGCThreads && i != 0 /* Always start first thread. */) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
80 |
_threads[i] = NULL; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
81 |
} else { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
82 |
_threads[i] = create_refinement_thread(i, true); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
83 |
if (_threads[i] == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
84 |
vm_shutdown_during_initialization("Could not allocate refinement threads."); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
85 |
return JNI_ENOMEM; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
86 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
87 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
88 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
89 |
return JNI_OK; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
90 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
91 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
92 |
void G1ConcurrentRefineThreadControl::maybe_activate_next(uint cur_worker_id) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
93 |
assert(cur_worker_id < _num_max_threads, |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
94 |
"Activating another thread from %u not allowed since there can be at most %u", |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
95 |
cur_worker_id, _num_max_threads); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
96 |
if (cur_worker_id == (_num_max_threads - 1)) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
97 |
// Already the last thread, there is no more thread to activate. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
98 |
return; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
99 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
100 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
101 |
uint worker_id = cur_worker_id + 1; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
102 |
G1ConcurrentRefineThread* thread_to_activate = _threads[worker_id]; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
103 |
if (thread_to_activate == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
104 |
// Still need to create the thread... |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
105 |
_threads[worker_id] = create_refinement_thread(worker_id, false); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
106 |
thread_to_activate = _threads[worker_id]; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
107 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
108 |
if (thread_to_activate != NULL && !thread_to_activate->is_active()) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
109 |
thread_to_activate->activate(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
110 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
111 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
112 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
113 |
void G1ConcurrentRefineThreadControl::print_on(outputStream* st) const { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
114 |
for (uint i = 0; i < _num_max_threads; ++i) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
115 |
if (_threads[i] != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
116 |
_threads[i]->print_on(st); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
117 |
st->cr(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
118 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
119 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
120 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
121 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
122 |
void G1ConcurrentRefineThreadControl::worker_threads_do(ThreadClosure* tc) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
123 |
for (uint i = 0; i < _num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
124 |
if (_threads[i] != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
125 |
tc->do_thread(_threads[i]); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
126 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
127 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
128 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
129 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
130 |
void G1ConcurrentRefineThreadControl::stop() { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
131 |
for (uint i = 0; i < _num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
132 |
if (_threads[i] != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
133 |
_threads[i]->stop(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
134 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
135 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
136 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
137 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
138 |
// Arbitrary but large limits, to simplify some of the zone calculations. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
139 |
// The general idea is to allow expressions like |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
140 |
// MIN2(x OP y, max_XXX_zone) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
141 |
// without needing to check for overflow in "x OP y", because the |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
142 |
// ranges for x and y have been restricted. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
143 |
STATIC_ASSERT(sizeof(LP64_ONLY(jint) NOT_LP64(jshort)) <= (sizeof(size_t)/2)); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
144 |
const size_t max_yellow_zone = LP64_ONLY(max_jint) NOT_LP64(max_jshort); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
145 |
const size_t max_green_zone = max_yellow_zone / 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
146 |
const size_t max_red_zone = INT_MAX; // For dcqs.set_max_completed_queue. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
147 |
STATIC_ASSERT(max_yellow_zone <= max_red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
148 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
149 |
// Range check assertions for green zone values. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
150 |
#define assert_zone_constraints_g(green) \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
151 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
152 |
size_t azc_g_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
153 |
assert(azc_g_green <= max_green_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
154 |
"green exceeds max: " SIZE_FORMAT, azc_g_green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
155 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
156 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
157 |
// Range check assertions for green and yellow zone values. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
158 |
#define assert_zone_constraints_gy(green, yellow) \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
159 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
160 |
size_t azc_gy_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
161 |
size_t azc_gy_yellow = (yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
162 |
assert_zone_constraints_g(azc_gy_green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
163 |
assert(azc_gy_yellow <= max_yellow_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
164 |
"yellow exceeds max: " SIZE_FORMAT, azc_gy_yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
165 |
assert(azc_gy_green <= azc_gy_yellow, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
166 |
"green (" SIZE_FORMAT ") exceeds yellow (" SIZE_FORMAT ")", \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
167 |
azc_gy_green, azc_gy_yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
168 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
169 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
170 |
// Range check assertions for green, yellow, and red zone values. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
171 |
#define assert_zone_constraints_gyr(green, yellow, red) \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
172 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
173 |
size_t azc_gyr_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
174 |
size_t azc_gyr_yellow = (yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
175 |
size_t azc_gyr_red = (red); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
176 |
assert_zone_constraints_gy(azc_gyr_green, azc_gyr_yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
177 |
assert(azc_gyr_red <= max_red_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
178 |
"red exceeds max: " SIZE_FORMAT, azc_gyr_red); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
179 |
assert(azc_gyr_yellow <= azc_gyr_red, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
180 |
"yellow (" SIZE_FORMAT ") exceeds red (" SIZE_FORMAT ")", \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
181 |
azc_gyr_yellow, azc_gyr_red); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
182 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
183 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
184 |
// Logging tag sequence for refinement control updates. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
185 |
#define CTRL_TAGS gc, ergo, refine |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
186 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
187 |
// For logging zone values, ensuring consistency of level and tags. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
188 |
#define LOG_ZONES(...) log_debug( CTRL_TAGS )(__VA_ARGS__) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
189 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
190 |
// Package for pair of refinement thread activation and deactivation |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
191 |
// thresholds. The activation and deactivation levels are resp. the first |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
192 |
// and second values of the pair. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
193 |
typedef Pair<size_t, size_t> Thresholds; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
194 |
inline size_t activation_level(const Thresholds& t) { return t.first; } |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
195 |
inline size_t deactivation_level(const Thresholds& t) { return t.second; } |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
196 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
197 |
static Thresholds calc_thresholds(size_t green_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
198 |
size_t yellow_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
199 |
uint worker_i) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
200 |
double yellow_size = yellow_zone - green_zone; |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
201 |
double step = yellow_size / G1ConcurrentRefine::max_num_threads(); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
202 |
if (worker_i == 0) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
203 |
// Potentially activate worker 0 more aggressively, to keep |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
204 |
// available buffers near green_zone value. When yellow_size is |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
205 |
// large we don't want to allow a full step to accumulate before |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
206 |
// doing any processing, as that might lead to significantly more |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
207 |
// than green_zone buffers to be processed by update_rs. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
208 |
step = MIN2(step, ParallelGCThreads / 2.0); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
209 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
210 |
size_t activate_offset = static_cast<size_t>(ceil(step * (worker_i + 1))); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
211 |
size_t deactivate_offset = static_cast<size_t>(floor(step * worker_i)); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
212 |
return Thresholds(green_zone + activate_offset, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
213 |
green_zone + deactivate_offset); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
214 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
215 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
216 |
G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
217 |
size_t yellow_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
218 |
size_t red_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
219 |
size_t min_yellow_zone_size) : |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
220 |
_thread_control(), |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
221 |
_green_zone(green_zone), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
222 |
_yellow_zone(yellow_zone), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
223 |
_red_zone(red_zone), |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
224 |
_min_yellow_zone_size(min_yellow_zone_size) |
1374 | 225 |
{ |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
226 |
assert_zone_constraints_gyr(green_zone, yellow_zone, red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
227 |
} |
4481 | 228 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
229 |
jint G1ConcurrentRefine::initialize() { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
230 |
return _thread_control.initialize(this, max_num_threads()); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
231 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
232 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
233 |
static size_t calc_min_yellow_zone_size() { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
234 |
size_t step = G1ConcRefinementThresholdStep; |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
235 |
uint n_workers = G1ConcurrentRefine::max_num_threads(); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
236 |
if ((max_yellow_zone / step) < n_workers) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
237 |
return max_yellow_zone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
238 |
} else { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
239 |
return step * n_workers; |
4481 | 240 |
} |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
241 |
} |
4481 | 242 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
243 |
static size_t calc_init_green_zone() { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
244 |
size_t green = G1ConcRefinementGreenZone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
245 |
if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
246 |
green = ParallelGCThreads; |
4481 | 247 |
} |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
248 |
return MIN2(green, max_green_zone); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
249 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
250 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
251 |
static size_t calc_init_yellow_zone(size_t green, size_t min_size) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
252 |
size_t config = G1ConcRefinementYellowZone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
253 |
size_t size = 0; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
254 |
if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
255 |
size = green * 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
256 |
} else if (green < config) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
257 |
size = config - green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
258 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
259 |
size = MAX2(size, min_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
260 |
size = MIN2(size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
261 |
return MIN2(green + size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
262 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
263 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
264 |
static size_t calc_init_red_zone(size_t green, size_t yellow) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
265 |
size_t size = yellow - green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
266 |
if (!FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
267 |
size_t config = G1ConcRefinementRedZone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
268 |
if (yellow < config) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
269 |
size = MAX2(size, config - yellow); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
270 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
271 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
272 |
return MIN2(yellow + size, max_red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
273 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
274 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
275 |
G1ConcurrentRefine* G1ConcurrentRefine::create(jint* ecode) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
276 |
size_t min_yellow_zone_size = calc_min_yellow_zone_size(); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
277 |
size_t green_zone = calc_init_green_zone(); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
278 |
size_t yellow_zone = calc_init_yellow_zone(green_zone, min_yellow_zone_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
279 |
size_t red_zone = calc_init_red_zone(green_zone, yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
280 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
281 |
LOG_ZONES("Initial Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
282 |
"green: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
283 |
"yellow: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
284 |
"red: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
285 |
"min yellow size: " SIZE_FORMAT, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
286 |
green_zone, yellow_zone, red_zone, min_yellow_zone_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
287 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
288 |
G1ConcurrentRefine* cr = new G1ConcurrentRefine(green_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
289 |
yellow_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
290 |
red_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
291 |
min_yellow_zone_size); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
292 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
293 |
if (cr == NULL) { |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
294 |
*ecode = JNI_ENOMEM; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
295 |
vm_shutdown_during_initialization("Could not create G1ConcurrentRefine"); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
296 |
return NULL; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
297 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
298 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
299 |
*ecode = cr->initialize(); |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
300 |
return cr; |
1374 | 301 |
} |
302 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
303 |
void G1ConcurrentRefine::stop() { |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
304 |
_thread_control.stop(); |
4481 | 305 |
} |
306 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
307 |
G1ConcurrentRefine::~G1ConcurrentRefine() { |
1374 | 308 |
} |
309 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
310 |
void G1ConcurrentRefine::threads_do(ThreadClosure *tc) { |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
311 |
_thread_control.worker_threads_do(tc); |
17854
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
312 |
} |
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
313 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
314 |
uint G1ConcurrentRefine::max_num_threads() { |
26932
33d6fa41d290
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
26160
diff
changeset
|
315 |
return G1ConcRefinementThreads; |
1374 | 316 |
} |
4022 | 317 |
|
47790
4925ee84b4ac
8140255: Move the management of G1YoungRemSetSamplingThread from G1ConcurrentRefine
tschatzl
parents:
47789
diff
changeset
|
318 |
void G1ConcurrentRefine::print_threads_on(outputStream* st) const { |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
319 |
_thread_control.print_on(st); |
4022 | 320 |
} |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
321 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
322 |
static size_t calc_new_green_zone(size_t green, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
323 |
double update_rs_time, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
324 |
size_t update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
325 |
double goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
326 |
// Adjust green zone based on whether we're meeting the time goal. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
327 |
// Limit to max_green_zone. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
328 |
const double inc_k = 1.1, dec_k = 0.9; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
329 |
if (update_rs_time > goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
330 |
if (green > 0) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
331 |
green = static_cast<size_t>(green * dec_k); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
332 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
333 |
} else if (update_rs_time < goal_ms && |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
334 |
update_rs_processed_buffers > green) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
335 |
green = static_cast<size_t>(MAX2(green * inc_k, green + 1.0)); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
336 |
green = MIN2(green, max_green_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
337 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
338 |
return green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
339 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
340 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
341 |
static size_t calc_new_yellow_zone(size_t green, size_t min_yellow_size) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
342 |
size_t size = green * 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
343 |
size = MAX2(size, min_yellow_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
344 |
return MIN2(green + size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
345 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
346 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
347 |
static size_t calc_new_red_zone(size_t green, size_t yellow) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
348 |
return MIN2(yellow + (yellow - green), max_red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
349 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
350 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
351 |
void G1ConcurrentRefine::update_zones(double update_rs_time, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
352 |
size_t update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
353 |
double goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
354 |
log_trace( CTRL_TAGS )("Updating Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
355 |
"update_rs time: %.3fms, " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
356 |
"update_rs buffers: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
357 |
"update_rs goal time: %.3fms", |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
358 |
update_rs_time, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
359 |
update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
360 |
goal_ms); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
361 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
362 |
_green_zone = calc_new_green_zone(_green_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
363 |
update_rs_time, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
364 |
update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
365 |
goal_ms); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
366 |
_yellow_zone = calc_new_yellow_zone(_green_zone, _min_yellow_zone_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
367 |
_red_zone = calc_new_red_zone(_green_zone, _yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
368 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
369 |
assert_zone_constraints_gyr(_green_zone, _yellow_zone, _red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
370 |
LOG_ZONES("Updated Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
371 |
"green: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
372 |
"yellow: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
373 |
"red: " SIZE_FORMAT, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
374 |
_green_zone, _yellow_zone, _red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
375 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
376 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
377 |
void G1ConcurrentRefine::adjust(double update_rs_time, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
378 |
size_t update_rs_processed_buffers, |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
379 |
double goal_ms) { |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
380 |
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
381 |
|
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
382 |
if (G1UseAdaptiveConcRefinement) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
383 |
update_zones(update_rs_time, update_rs_processed_buffers, goal_ms); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
384 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
385 |
// Change the barrier params |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
386 |
if (max_num_threads() == 0) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
387 |
// Disable dcqs notification when there are no threads to notify. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
388 |
dcqs.set_process_completed_threshold(INT_MAX); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
389 |
} else { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
390 |
// Worker 0 is the primary; wakeup is via dcqs notification. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
391 |
STATIC_ASSERT(max_yellow_zone <= INT_MAX); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
392 |
size_t activate = activation_threshold(0); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
393 |
dcqs.set_process_completed_threshold((int)activate); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
394 |
} |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
395 |
dcqs.set_max_completed_queue((int)red_zone()); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
396 |
} |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
397 |
|
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
398 |
size_t curr_queue_size = dcqs.completed_buffers_num(); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
399 |
if (curr_queue_size >= yellow_zone()) { |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
400 |
dcqs.set_completed_queue_padding(curr_queue_size); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
401 |
} else { |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
402 |
dcqs.set_completed_queue_padding(0); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
403 |
} |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
404 |
dcqs.notify_if_necessary(); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
405 |
} |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
406 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
407 |
size_t G1ConcurrentRefine::activation_threshold(uint worker_id) const { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
408 |
Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
409 |
return activation_level(thresholds); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
410 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
411 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
412 |
size_t G1ConcurrentRefine::deactivation_threshold(uint worker_id) const { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
413 |
Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
414 |
return deactivation_level(thresholds); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
415 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
416 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
417 |
uint G1ConcurrentRefine::worker_id_offset() { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
418 |
return DirtyCardQueueSet::num_par_ids(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
419 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
420 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
421 |
void G1ConcurrentRefine::maybe_activate_more_threads(uint worker_id, size_t num_cur_buffers) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
422 |
if (num_cur_buffers > activation_threshold(worker_id + 1)) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
423 |
_thread_control.maybe_activate_next(worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
424 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
425 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
426 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
427 |
bool G1ConcurrentRefine::do_refinement_step(uint worker_id) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
428 |
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
429 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
430 |
size_t curr_buffer_num = dcqs.completed_buffers_num(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
431 |
// If the number of the buffers falls down into the yellow zone, |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
432 |
// that means that the transition period after the evacuation pause has ended. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
433 |
// Since the value written to the DCQS is the same for all threads, there is no |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
434 |
// need to synchronize. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
435 |
if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= yellow_zone()) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
436 |
dcqs.set_completed_queue_padding(0); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
437 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
438 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
439 |
maybe_activate_more_threads(worker_id, curr_buffer_num); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
440 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
441 |
// Process the next buffer, if there are enough left. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
442 |
return dcqs.refine_completed_buffer_concurrently(worker_id + worker_id_offset(), |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
443 |
deactivation_threshold(worker_id)); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
444 |
} |