author | kbarrett |
Tue, 12 Jun 2018 18:12:59 -0400 | |
changeset 50532 | a18c60527166 |
parent 49392 | 2956d0ece7a9 |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
48103
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, 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 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
25 |
#ifndef SHARE_VM_GC_G1_G1CONCURRENTREFINE_HPP |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
26 |
#define SHARE_VM_GC_G1_G1CONCURRENTREFINE_HPP |
7397 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "utilities/globalDefinitions.hpp" |
|
30 |
||
1374 | 31 |
// Forward decl |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37510
diff
changeset
|
32 |
class CardTableEntryClosure; |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
33 |
class G1ConcurrentRefine; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
34 |
class G1ConcurrentRefineThread; |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37510
diff
changeset
|
35 |
class outputStream; |
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37510
diff
changeset
|
36 |
class ThreadClosure; |
1374 | 37 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
38 |
// Helper class for refinement thread management. Used to start, stop and |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
39 |
// iterate over them. |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
48103
diff
changeset
|
40 |
class G1ConcurrentRefineThreadControl { |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
41 |
G1ConcurrentRefine* _cr; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
42 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
43 |
G1ConcurrentRefineThread** _threads; |
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
44 |
uint _num_max_threads; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
45 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
46 |
// Create the refinement thread for the given worker id. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
47 |
// If initializing is true, ignore InjectGCWorkerCreationFailure. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
48 |
G1ConcurrentRefineThread* create_refinement_thread(uint worker_id, bool initializing); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
49 |
public: |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
50 |
G1ConcurrentRefineThreadControl(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
51 |
~G1ConcurrentRefineThreadControl(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
52 |
|
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
53 |
jint initialize(G1ConcurrentRefine* cr, uint num_max_threads); |
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 |
// If there is a "successor" thread that can be activated given the current id, |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
56 |
// activate it. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
57 |
void maybe_activate_next(uint cur_worker_id); |
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 |
void print_on(outputStream* st) const; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
60 |
void worker_threads_do(ThreadClosure* tc); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
61 |
void stop(); |
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 |
// Controls refinement threads and their activation based on the number of completed |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
65 |
// buffers currently available in the global dirty card queue. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
66 |
// Refinement threads pick work from the queue based on these thresholds. They are activated |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
67 |
// gradually based on the amount of work to do. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
68 |
// Refinement thread n activates thread n+1 if the instance of this class determines there |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
69 |
// is enough work available. Threads deactivate themselves if the current amount of |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
70 |
// completed buffers falls below their individual threshold. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
71 |
class G1ConcurrentRefine : public CHeapObj<mtGC> { |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
72 |
G1ConcurrentRefineThreadControl _thread_control; |
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 |
* The value of the completed dirty card queue length falls into one of 3 zones: |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
75 |
* green, yellow, red. If the value is in [0, green) nothing is |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
76 |
* done, the buffers are left unprocessed to enable the caching effect of the |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
77 |
* dirtied cards. In the yellow zone [green, yellow) the concurrent refinement |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
78 |
* threads are gradually activated. In [yellow, red) all threads are |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
79 |
* running. If the length becomes red (max queue length) the mutators start |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
80 |
* processing the buffers. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
81 |
* |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
82 |
* There are some interesting cases (when G1UseAdaptiveConcRefinement |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
83 |
* is turned off): |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
84 |
* 1) green = yellow = red = 0. In this case the mutator will process all |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
85 |
* buffers. Except for those that are created by the deferred updates |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
86 |
* machinery during a collection. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
87 |
* 2) green = 0. Means no caching. Can be a good way to minimize the |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
88 |
* amount of time spent updating remembered sets during a collection. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
89 |
*/ |
36371
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
33608
diff
changeset
|
90 |
size_t _green_zone; |
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
33608
diff
changeset
|
91 |
size_t _yellow_zone; |
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
33608
diff
changeset
|
92 |
size_t _red_zone; |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
93 |
size_t _min_yellow_zone_size; |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
94 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
95 |
G1ConcurrentRefine(size_t green_zone, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
96 |
size_t yellow_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
97 |
size_t red_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
98 |
size_t min_yellow_zone_size); |
3590
a268fa66d7fb
6819077: G1: first GC thread coming late into the GC.
johnc
parents:
3589
diff
changeset
|
99 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
100 |
// Update green/yellow/red zone values based on how well goals are being met. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
101 |
void update_zones(double update_rs_time, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
102 |
size_t update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
103 |
double goal_ms); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
104 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
105 |
static uint worker_id_offset(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
106 |
void maybe_activate_more_threads(uint worker_id, size_t num_cur_buffers); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30764
diff
changeset
|
107 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
108 |
jint initialize(); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
109 |
public: |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
110 |
~G1ConcurrentRefine(); |
1374 | 111 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
112 |
// Returns a G1ConcurrentRefine instance if succeeded to create/initialize the |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
113 |
// G1ConcurrentRefine instance. Otherwise, returns NULL with error code. |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
114 |
static G1ConcurrentRefine* create(jint* ecode); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30764
diff
changeset
|
115 |
|
2881 | 116 |
void stop(); |
1374 | 117 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
118 |
// Adjust refinement thresholds based on work done during the pause and the goal time. |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
119 |
void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms); |
4481 | 120 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
121 |
size_t activation_threshold(uint worker_id) const; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
122 |
size_t deactivation_threshold(uint worker_id) const; |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
123 |
// Perform a single refinement step. Called by the refinement threads when woken up. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
124 |
bool do_refinement_step(uint worker_id); |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
125 |
|
47790
4925ee84b4ac
8140255: Move the management of G1YoungRemSetSamplingThread from G1ConcurrentRefine
tschatzl
parents:
47789
diff
changeset
|
126 |
// Iterate over all concurrent refinement threads applying the given closure. |
2881 | 127 |
void threads_do(ThreadClosure *tc); |
1374 | 128 |
|
48103
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
129 |
// Maximum number of refinement threads. |
26dbe08d1c17
8190426: Lazily initialize refinement threads with UseDynamicNumberOfGCThreads
tschatzl
parents:
47790
diff
changeset
|
130 |
static uint max_num_threads(); |
4022 | 131 |
|
47790
4925ee84b4ac
8140255: Move the management of G1YoungRemSetSamplingThread from G1ConcurrentRefine
tschatzl
parents:
47789
diff
changeset
|
132 |
void print_threads_on(outputStream* st) const; |
4481 | 133 |
|
36371
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
33608
diff
changeset
|
134 |
size_t green_zone() const { return _green_zone; } |
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
33608
diff
changeset
|
135 |
size_t yellow_zone() const { return _yellow_zone; } |
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
33608
diff
changeset
|
136 |
size_t red_zone() const { return _red_zone; } |
1374 | 137 |
}; |
7397 | 138 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
139 |
#endif // SHARE_VM_GC_G1_G1CONCURRENTREFINE_HPP |