author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58508 | d6058bd73982 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
52726
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, 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" |
49751
c3a10df652c0
8201316: Move G1-related static members from JavaThread to G1BarrierSet
pliden
parents:
48157
diff
changeset
|
26 |
#include "gc/g1/g1BarrierSet.hpp" |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
27 |
#include "gc/g1/g1ConcurrentRefine.hpp" |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
28 |
#include "gc/g1/g1ConcurrentRefineThread.hpp" |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
52726
diff
changeset
|
29 |
#include "gc/g1/g1DirtyCardQueue.hpp" |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
30 |
#include "logging/log.hpp" |
48157 | 31 |
#include "memory/allocation.inline.hpp" |
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
32 |
#include "runtime/java.hpp" |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
33 |
#include "runtime/thread.hpp" |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
34 |
#include "utilities/debug.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
35 |
#include "utilities/globalDefinitions.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
36 |
#include "utilities/pair.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
37 |
#include <math.h> |
8926
717a49db1743
7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents:
8683
diff
changeset
|
38 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
39 |
G1ConcurrentRefineThread* G1ConcurrentRefineThreadControl::create_refinement_thread(uint worker_id, bool initializing) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
40 |
G1ConcurrentRefineThread* result = NULL; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
41 |
if (initializing || !InjectGCWorkerCreationFailure) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
42 |
result = new G1ConcurrentRefineThread(_cr, worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
43 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
44 |
if (result == NULL || result->osthread() == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
45 |
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
|
46 |
worker_id, |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
47 |
result == NULL ? "memory" : "OS threads"); |
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 |
return result; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
50 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
51 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
52 |
G1ConcurrentRefineThreadControl::G1ConcurrentRefineThreadControl() : |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
53 |
_cr(NULL), |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
54 |
_threads(NULL), |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
55 |
_num_max_threads(0) |
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 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
58 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
59 |
G1ConcurrentRefineThreadControl::~G1ConcurrentRefineThreadControl() { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
60 |
for (uint i = 0; i < _num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
61 |
G1ConcurrentRefineThread* t = _threads[i]; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
62 |
if (t != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
63 |
delete t; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
64 |
} |
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 |
FREE_C_HEAP_ARRAY(G1ConcurrentRefineThread*, _threads); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
67 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
68 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
69 |
jint G1ConcurrentRefineThreadControl::initialize(G1ConcurrentRefine* cr, uint num_max_threads) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
70 |
assert(cr != NULL, "G1ConcurrentRefine must not be NULL"); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
71 |
_cr = cr; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
72 |
_num_max_threads = num_max_threads; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
73 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
74 |
_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
|
75 |
if (_threads == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
76 |
vm_shutdown_during_initialization("Could not allocate thread holder array."); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
77 |
return JNI_ENOMEM; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
78 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
79 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
80 |
for (uint i = 0; i < num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
81 |
if (UseDynamicNumberOfGCThreads && i != 0 /* Always start first thread. */) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
82 |
_threads[i] = NULL; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
83 |
} else { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
84 |
_threads[i] = create_refinement_thread(i, true); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
85 |
if (_threads[i] == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
86 |
vm_shutdown_during_initialization("Could not allocate refinement threads."); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
87 |
return JNI_ENOMEM; |
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 |
} |
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 |
return JNI_OK; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
92 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
93 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
94 |
void G1ConcurrentRefineThreadControl::maybe_activate_next(uint cur_worker_id) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
95 |
assert(cur_worker_id < _num_max_threads, |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
96 |
"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
|
97 |
cur_worker_id, _num_max_threads); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
98 |
if (cur_worker_id == (_num_max_threads - 1)) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
99 |
// Already the last thread, there is no more thread to activate. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
100 |
return; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
101 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
102 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
103 |
uint worker_id = cur_worker_id + 1; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
104 |
G1ConcurrentRefineThread* thread_to_activate = _threads[worker_id]; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
105 |
if (thread_to_activate == NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
106 |
// Still need to create the thread... |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
107 |
_threads[worker_id] = create_refinement_thread(worker_id, false); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
108 |
thread_to_activate = _threads[worker_id]; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
109 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
110 |
if (thread_to_activate != NULL && !thread_to_activate->is_active()) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
111 |
thread_to_activate->activate(); |
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 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
114 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
115 |
void G1ConcurrentRefineThreadControl::print_on(outputStream* st) const { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
116 |
for (uint i = 0; i < _num_max_threads; ++i) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
117 |
if (_threads[i] != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
118 |
_threads[i]->print_on(st); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
119 |
st->cr(); |
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 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
123 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
124 |
void G1ConcurrentRefineThreadControl::worker_threads_do(ThreadClosure* tc) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
125 |
for (uint i = 0; i < _num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
126 |
if (_threads[i] != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
127 |
tc->do_thread(_threads[i]); |
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 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
131 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
132 |
void G1ConcurrentRefineThreadControl::stop() { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
133 |
for (uint i = 0; i < _num_max_threads; i++) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
134 |
if (_threads[i] != NULL) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
135 |
_threads[i]->stop(); |
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 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
138 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
139 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
140 |
// 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
|
141 |
// 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
|
142 |
// MIN2(x OP y, max_XXX_zone) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
143 |
// 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
|
144 |
// 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
|
145 |
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
|
146 |
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
|
147 |
const size_t max_green_zone = max_yellow_zone / 2; |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
148 |
const size_t max_red_zone = INT_MAX; // For dcqs.set_max_cards. |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
149 |
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
|
150 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
151 |
// Range check assertions for green zone values. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
152 |
#define assert_zone_constraints_g(green) \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
153 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
154 |
size_t azc_g_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
155 |
assert(azc_g_green <= max_green_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
156 |
"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
|
157 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
158 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
159 |
// 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
|
160 |
#define assert_zone_constraints_gy(green, yellow) \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
161 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
162 |
size_t azc_gy_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
163 |
size_t azc_gy_yellow = (yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
164 |
assert_zone_constraints_g(azc_gy_green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
165 |
assert(azc_gy_yellow <= max_yellow_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
166 |
"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
|
167 |
assert(azc_gy_green <= azc_gy_yellow, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
168 |
"green (" SIZE_FORMAT ") exceeds yellow (" SIZE_FORMAT ")", \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
169 |
azc_gy_green, azc_gy_yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
170 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
171 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
172 |
// 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
|
173 |
#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
|
174 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
175 |
size_t azc_gyr_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
176 |
size_t azc_gyr_yellow = (yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
177 |
size_t azc_gyr_red = (red); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
178 |
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
|
179 |
assert(azc_gyr_red <= max_red_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
180 |
"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
|
181 |
assert(azc_gyr_yellow <= azc_gyr_red, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
182 |
"yellow (" SIZE_FORMAT ") exceeds red (" SIZE_FORMAT ")", \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
183 |
azc_gyr_yellow, azc_gyr_red); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
184 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
185 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
186 |
// Logging tag sequence for refinement control updates. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
187 |
#define CTRL_TAGS gc, ergo, refine |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
188 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
189 |
// 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
|
190 |
#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
|
191 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
192 |
// 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
|
193 |
// 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
|
194 |
// and second values of the pair. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
195 |
typedef Pair<size_t, size_t> Thresholds; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
196 |
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
|
197 |
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
|
198 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
199 |
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
|
200 |
size_t yellow_zone, |
58264
4e96939a5746
8231189: Rename worker_i parameters to worker_id
tschatzl
parents:
57953
diff
changeset
|
201 |
uint worker_id) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
202 |
double yellow_size = yellow_zone - green_zone; |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
203 |
double step = yellow_size / G1ConcurrentRefine::max_num_threads(); |
58264
4e96939a5746
8231189: Rename worker_i parameters to worker_id
tschatzl
parents:
57953
diff
changeset
|
204 |
if (worker_id == 0) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
205 |
// 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
|
206 |
// 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
|
207 |
// 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
|
208 |
// doing any processing, as that might lead to significantly more |
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53747
diff
changeset
|
209 |
// than green_zone buffers to be processed during scanning. |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
210 |
step = MIN2(step, ParallelGCThreads / 2.0); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
211 |
} |
58264
4e96939a5746
8231189: Rename worker_i parameters to worker_id
tschatzl
parents:
57953
diff
changeset
|
212 |
size_t activate_offset = static_cast<size_t>(ceil(step * (worker_id + 1))); |
4e96939a5746
8231189: Rename worker_i parameters to worker_id
tschatzl
parents:
57953
diff
changeset
|
213 |
size_t deactivate_offset = static_cast<size_t>(floor(step * worker_id)); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
214 |
return Thresholds(green_zone + activate_offset, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
215 |
green_zone + deactivate_offset); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
216 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
217 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
218 |
G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
219 |
size_t yellow_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
220 |
size_t red_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
221 |
size_t min_yellow_zone_size) : |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
222 |
_thread_control(), |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
223 |
_green_zone(green_zone), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
224 |
_yellow_zone(yellow_zone), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
225 |
_red_zone(red_zone), |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
226 |
_min_yellow_zone_size(min_yellow_zone_size) |
1374 | 227 |
{ |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
228 |
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
|
229 |
} |
4481 | 230 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
231 |
jint G1ConcurrentRefine::initialize() { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
232 |
return _thread_control.initialize(this, max_num_threads()); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
233 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
234 |
|
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
235 |
static size_t buffers_to_cards(size_t value) { |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
236 |
return value * G1UpdateBufferSize; |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
237 |
} |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
238 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
239 |
static size_t calc_min_yellow_zone_size() { |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
240 |
size_t step = buffers_to_cards(G1ConcRefinementThresholdStep); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
241 |
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
|
242 |
if ((max_yellow_zone / step) < n_workers) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
243 |
return max_yellow_zone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
244 |
} else { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
245 |
return step * n_workers; |
4481 | 246 |
} |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
247 |
} |
4481 | 248 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
249 |
static size_t calc_init_green_zone() { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
250 |
size_t green = G1ConcRefinementGreenZone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
251 |
if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
252 |
green = ParallelGCThreads; |
4481 | 253 |
} |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
254 |
green = buffers_to_cards(green); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
255 |
return MIN2(green, max_green_zone); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
256 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
257 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
258 |
static size_t calc_init_yellow_zone(size_t green, size_t min_size) { |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
259 |
size_t config = buffers_to_cards(G1ConcRefinementYellowZone); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
260 |
size_t size = 0; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
261 |
if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
262 |
size = green * 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
263 |
} else if (green < config) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
264 |
size = config - green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
265 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
266 |
size = MAX2(size, min_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
267 |
size = MIN2(size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
268 |
return MIN2(green + size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
269 |
} |
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 |
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
|
272 |
size_t size = yellow - green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
273 |
if (!FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) { |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
274 |
size_t config = buffers_to_cards(G1ConcRefinementRedZone); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
275 |
if (yellow < config) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
276 |
size = MAX2(size, config - yellow); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
277 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
278 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
279 |
return MIN2(yellow + size, max_red_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 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
282 |
G1ConcurrentRefine* G1ConcurrentRefine::create(jint* ecode) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
288 |
LOG_ZONES("Initial Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
289 |
"green: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
290 |
"yellow: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
291 |
"red: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
292 |
"min yellow size: " SIZE_FORMAT, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
293 |
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
|
294 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
295 |
G1ConcurrentRefine* cr = new G1ConcurrentRefine(green_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
296 |
yellow_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
297 |
red_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
298 |
min_yellow_zone_size); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
299 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
300 |
if (cr == NULL) { |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
301 |
*ecode = JNI_ENOMEM; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
302 |
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
|
303 |
return NULL; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
304 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
305 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
306 |
*ecode = cr->initialize(); |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
307 |
return cr; |
1374 | 308 |
} |
309 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
310 |
void G1ConcurrentRefine::stop() { |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
311 |
_thread_control.stop(); |
4481 | 312 |
} |
313 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
314 |
G1ConcurrentRefine::~G1ConcurrentRefine() { |
1374 | 315 |
} |
316 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
317 |
void G1ConcurrentRefine::threads_do(ThreadClosure *tc) { |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
318 |
_thread_control.worker_threads_do(tc); |
17854
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
319 |
} |
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
320 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
321 |
uint G1ConcurrentRefine::max_num_threads() { |
26932
33d6fa41d290
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
26160
diff
changeset
|
322 |
return G1ConcRefinementThreads; |
1374 | 323 |
} |
4022 | 324 |
|
47790
4925ee84b4ac
8140255: Move the management of G1YoungRemSetSamplingThread from G1ConcurrentRefine
tschatzl
parents:
47789
diff
changeset
|
325 |
void G1ConcurrentRefine::print_threads_on(outputStream* st) const { |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
326 |
_thread_control.print_on(st); |
4022 | 327 |
} |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
328 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
329 |
static size_t calc_new_green_zone(size_t green, |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
330 |
double logged_cards_scan_time, |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
331 |
size_t processed_logged_cards, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
332 |
double goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
333 |
// 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
|
334 |
// Limit to max_green_zone. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
335 |
const double inc_k = 1.1, dec_k = 0.9; |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
336 |
if (logged_cards_scan_time > goal_ms) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
337 |
if (green > 0) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
338 |
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
|
339 |
} |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
340 |
} else if (logged_cards_scan_time < goal_ms && |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
341 |
processed_logged_cards > green) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
342 |
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
|
343 |
green = MIN2(green, max_green_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
344 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
345 |
return green; |
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 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
348 |
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
|
349 |
size_t size = green * 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
350 |
size = MAX2(size, min_yellow_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
351 |
return MIN2(green + size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
352 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
353 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
354 |
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
|
355 |
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
|
356 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
357 |
|
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
358 |
void G1ConcurrentRefine::update_zones(double logged_cards_scan_time, |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
359 |
size_t processed_logged_cards, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
360 |
double goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
361 |
log_trace( CTRL_TAGS )("Updating Refinement Zones: " |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
362 |
"logged cards scan time: %.3fms, " |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
363 |
"processed cards: " SIZE_FORMAT ", " |
55510
3e31a8beaae4
8213108: Improve work distribution during remembered set scan
tschatzl
parents:
53747
diff
changeset
|
364 |
"goal time: %.3fms", |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
365 |
logged_cards_scan_time, |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
366 |
processed_logged_cards, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
367 |
goal_ms); |
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 |
_green_zone = calc_new_green_zone(_green_zone, |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
370 |
logged_cards_scan_time, |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
371 |
processed_logged_cards, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
372 |
goal_ms); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
373 |
_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
|
374 |
_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
|
375 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
376 |
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
|
377 |
LOG_ZONES("Updated Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
378 |
"green: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
379 |
"yellow: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
380 |
"red: " SIZE_FORMAT, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
381 |
_green_zone, _yellow_zone, _red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
382 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
383 |
|
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
384 |
void G1ConcurrentRefine::adjust(double logged_cards_scan_time, |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
385 |
size_t processed_logged_cards, |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
386 |
double goal_ms) { |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
52726
diff
changeset
|
387 |
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
388 |
|
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
389 |
if (G1UseAdaptiveConcRefinement) { |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
390 |
update_zones(logged_cards_scan_time, processed_logged_cards, goal_ms); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
391 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
392 |
// Change the barrier params |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
393 |
if (max_num_threads() == 0) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
394 |
// Disable dcqs notification when there are no threads to notify. |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
395 |
dcqs.set_process_cards_threshold(G1DirtyCardQueueSet::ProcessCardsThresholdNever); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
396 |
} else { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
397 |
// 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
|
398 |
STATIC_ASSERT(max_yellow_zone <= INT_MAX); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
399 |
size_t activate = activation_threshold(0); |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
400 |
dcqs.set_process_cards_threshold(activate); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
401 |
} |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
402 |
dcqs.set_max_cards(red_zone()); |
37158
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 |
|
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
405 |
size_t curr_queue_size = dcqs.num_cards(); |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
406 |
if ((dcqs.max_cards() > 0) && |
52726
9cfa2e273b77
8214278: Cleanup process_completed_threshold and related state
kbarrett
parents:
49751
diff
changeset
|
407 |
(curr_queue_size >= yellow_zone())) { |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
408 |
dcqs.set_max_cards_padding(curr_queue_size); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
409 |
} else { |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
410 |
dcqs.set_max_cards_padding(0); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
411 |
} |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
412 |
dcqs.notify_if_necessary(); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
413 |
} |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
414 |
|
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
415 |
G1ConcurrentRefine::RefinementStats G1ConcurrentRefine::total_refinement_stats() const { |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
416 |
struct CollectData : public ThreadClosure { |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
417 |
Tickspan _total_time; |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
418 |
size_t _total_cards; |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
419 |
CollectData() : _total_time(), _total_cards(0) {} |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
420 |
virtual void do_thread(Thread* t) { |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
421 |
G1ConcurrentRefineThread* crt = static_cast<G1ConcurrentRefineThread*>(t); |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
422 |
_total_time += crt->total_refinement_time(); |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
423 |
_total_cards += crt->total_refined_cards(); |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
424 |
} |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
425 |
} collector; |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
426 |
// Cast away const so we can call non-modifying closure on threads. |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
427 |
const_cast<G1ConcurrentRefine*>(this)->threads_do(&collector); |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
428 |
return RefinementStats(collector._total_time, collector._total_cards); |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
429 |
} |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
430 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
431 |
size_t G1ConcurrentRefine::activation_threshold(uint worker_id) const { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
432 |
Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
433 |
return activation_level(thresholds); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
434 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
435 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
436 |
size_t G1ConcurrentRefine::deactivation_threshold(uint worker_id) const { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
437 |
Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
438 |
return deactivation_level(thresholds); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
439 |
} |
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 |
uint G1ConcurrentRefine::worker_id_offset() { |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
52726
diff
changeset
|
442 |
return G1DirtyCardQueueSet::num_par_ids(); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
443 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
444 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
445 |
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
|
446 |
if (num_cur_buffers > activation_threshold(worker_id + 1)) { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
447 |
_thread_control.maybe_activate_next(worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
448 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
449 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
450 |
|
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
451 |
bool G1ConcurrentRefine::do_refinement_step(uint worker_id, |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
452 |
size_t* total_refined_cards) { |
53747
13acc8e38a29
8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents:
52726
diff
changeset
|
453 |
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
454 |
|
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
455 |
size_t curr_cards = dcqs.num_cards(); |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
456 |
// If the number of the cards falls down into the yellow zone, |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
457 |
// 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
|
458 |
// 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
|
459 |
// need to synchronize. |
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
460 |
if (dcqs.max_cards_padding() > 0 && curr_cards <= yellow_zone()) { |
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
461 |
dcqs.set_max_cards_padding(0); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
462 |
} |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
463 |
|
57953
d78c910f9069
8230109: G1DirtyCardQueueSet should use card counts rather than buffer counts
kbarrett
parents:
57507
diff
changeset
|
464 |
maybe_activate_more_threads(worker_id, curr_cards); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
465 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
466 |
// Process the next buffer, if there are enough left. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
467 |
return dcqs.refine_completed_buffer_concurrently(worker_id + worker_id_offset(), |
58508
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
468 |
deactivation_threshold(worker_id), |
d6058bd73982
8231153: Improve concurrent refinement statistics
kbarrett
parents:
58264
diff
changeset
|
469 |
total_refined_cards); |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
470 |
} |