author | tschatzl |
Mon, 06 Nov 2017 14:25:18 +0100 | |
changeset 47790 | 4925ee84b4ac |
parent 47789 | a77a7d3bc4f6 |
child 48103 | 26dbe08d1c17 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. |
1374 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5033
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
26 |
#include "gc/g1/g1ConcurrentRefine.hpp" |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
27 |
#include "gc/g1/g1ConcurrentRefineThread.hpp" |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
28 |
#include "logging/log.hpp" |
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
29 |
#include "runtime/java.hpp" |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
30 |
#include "runtime/thread.hpp" |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
31 |
#include "utilities/debug.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
32 |
#include "utilities/globalDefinitions.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
33 |
#include "utilities/pair.hpp" |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
34 |
#include <math.h> |
8926
717a49db1743
7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents:
8683
diff
changeset
|
35 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
36 |
// 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
|
37 |
// 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
|
38 |
// MIN2(x OP y, max_XXX_zone) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
39 |
// 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
|
40 |
// 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
|
41 |
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
|
42 |
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
|
43 |
const size_t max_green_zone = max_yellow_zone / 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
44 |
const size_t max_red_zone = INT_MAX; // For dcqs.set_max_completed_queue. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
45 |
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
|
46 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
47 |
// Range check assertions for green zone values. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
48 |
#define assert_zone_constraints_g(green) \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
49 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
50 |
size_t azc_g_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
51 |
assert(azc_g_green <= max_green_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
52 |
"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
|
53 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
54 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
55 |
// 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
|
56 |
#define assert_zone_constraints_gy(green, yellow) \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
57 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
58 |
size_t azc_gy_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
59 |
size_t azc_gy_yellow = (yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
60 |
assert_zone_constraints_g(azc_gy_green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
61 |
assert(azc_gy_yellow <= max_yellow_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
62 |
"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
|
63 |
assert(azc_gy_green <= azc_gy_yellow, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
64 |
"green (" SIZE_FORMAT ") exceeds yellow (" SIZE_FORMAT ")", \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
65 |
azc_gy_green, azc_gy_yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
66 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
67 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
68 |
// 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
|
69 |
#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
|
70 |
do { \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
71 |
size_t azc_gyr_green = (green); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
72 |
size_t azc_gyr_yellow = (yellow); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
73 |
size_t azc_gyr_red = (red); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
74 |
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
|
75 |
assert(azc_gyr_red <= max_red_zone, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
76 |
"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
|
77 |
assert(azc_gyr_yellow <= azc_gyr_red, \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
78 |
"yellow (" SIZE_FORMAT ") exceeds red (" SIZE_FORMAT ")", \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
79 |
azc_gyr_yellow, azc_gyr_red); \ |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
80 |
} while (0) |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
81 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
82 |
// Logging tag sequence for refinement control updates. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
83 |
#define CTRL_TAGS gc, ergo, refine |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
84 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
85 |
// 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
|
86 |
#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
|
87 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
88 |
// 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
|
89 |
// 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
|
90 |
// and second values of the pair. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
91 |
typedef Pair<size_t, size_t> Thresholds; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
95 |
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
|
96 |
size_t yellow_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
97 |
uint worker_i) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
98 |
double yellow_size = yellow_zone - green_zone; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
99 |
double step = yellow_size / G1ConcurrentRefine::thread_num(); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
100 |
if (worker_i == 0) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
101 |
// 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
|
102 |
// 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
|
103 |
// 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
|
104 |
// doing any processing, as that might lead to significantly more |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
105 |
// than green_zone buffers to be processed by update_rs. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
106 |
step = MIN2(step, ParallelGCThreads / 2.0); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
107 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
108 |
size_t activate_offset = static_cast<size_t>(ceil(step * (worker_i + 1))); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
109 |
size_t deactivate_offset = static_cast<size_t>(floor(step * worker_i)); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
110 |
return Thresholds(green_zone + activate_offset, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
111 |
green_zone + deactivate_offset); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
112 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
113 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
114 |
G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
115 |
size_t yellow_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
116 |
size_t red_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
117 |
size_t min_yellow_zone_size) : |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
118 |
_threads(NULL), |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
119 |
_n_worker_threads(thread_num()), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
120 |
_green_zone(green_zone), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
121 |
_yellow_zone(yellow_zone), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
122 |
_red_zone(red_zone), |
38172
90f405aac699
8155524: HotCardCache shouldn't be part of ConcurrentG1Refine
kbarrett
parents:
37985
diff
changeset
|
123 |
_min_yellow_zone_size(min_yellow_zone_size) |
1374 | 124 |
{ |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
125 |
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
|
126 |
} |
4481 | 127 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
128 |
static size_t calc_min_yellow_zone_size() { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
129 |
size_t step = G1ConcRefinementThresholdStep; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
130 |
uint n_workers = G1ConcurrentRefine::thread_num(); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
131 |
if ((max_yellow_zone / step) < n_workers) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
132 |
return max_yellow_zone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
133 |
} else { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
134 |
return step * n_workers; |
4481 | 135 |
} |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
136 |
} |
4481 | 137 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
138 |
static size_t calc_init_green_zone() { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
139 |
size_t green = G1ConcRefinementGreenZone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
140 |
if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
141 |
green = ParallelGCThreads; |
4481 | 142 |
} |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
143 |
return MIN2(green, max_green_zone); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
144 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
145 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
146 |
static size_t calc_init_yellow_zone(size_t green, size_t min_size) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
147 |
size_t config = G1ConcRefinementYellowZone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
148 |
size_t size = 0; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
149 |
if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
150 |
size = green * 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
151 |
} else if (green < config) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
152 |
size = config - green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
153 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
154 |
size = MAX2(size, min_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
155 |
size = MIN2(size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
156 |
return MIN2(green + size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
157 |
} |
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 |
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
|
160 |
size_t size = yellow - green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
161 |
if (!FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
162 |
size_t config = G1ConcRefinementRedZone; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
163 |
if (yellow < config) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
164 |
size = MAX2(size, config - yellow); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
165 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
166 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
167 |
return MIN2(yellow + size, max_red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
168 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
169 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
170 |
G1ConcurrentRefine* G1ConcurrentRefine::create(jint* ecode) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
171 |
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
176 |
LOG_ZONES("Initial Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
177 |
"green: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
178 |
"yellow: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
179 |
"red: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
180 |
"min yellow size: " SIZE_FORMAT, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
181 |
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
|
182 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
183 |
G1ConcurrentRefine* cr = new G1ConcurrentRefine(green_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
184 |
yellow_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
185 |
red_zone, |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
186 |
min_yellow_zone_size); |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
187 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
188 |
if (cr == NULL) { |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
189 |
*ecode = JNI_ENOMEM; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
190 |
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
|
191 |
return NULL; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
192 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
193 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
194 |
cr->_threads = NEW_C_HEAP_ARRAY_RETURN_NULL(G1ConcurrentRefineThread*, cr->_n_worker_threads, mtGC); |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
195 |
if (cr->_threads == NULL) { |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
196 |
*ecode = JNI_ENOMEM; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
197 |
vm_shutdown_during_initialization("Could not allocate an array for G1ConcurrentRefineThread"); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
198 |
return NULL; |
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
199 |
} |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
200 |
|
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
22551
diff
changeset
|
201 |
uint worker_id_offset = DirtyCardQueueSet::num_par_ids(); |
17327
4bd0581aa231
7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents:
13289
diff
changeset
|
202 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
203 |
G1ConcurrentRefineThread *next = NULL; |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
204 |
for (uint i = cr->_n_worker_threads - 1; i != UINT_MAX; i--) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
205 |
Thresholds thresholds = calc_thresholds(green_zone, yellow_zone, i); |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
206 |
G1ConcurrentRefineThread* t = |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
207 |
new G1ConcurrentRefineThread(cr, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
208 |
next, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
209 |
worker_id_offset, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
210 |
i, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
211 |
activation_level(thresholds), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
212 |
deactivation_level(thresholds)); |
4481 | 213 |
assert(t != NULL, "Conc refine should have been created"); |
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
214 |
if (t->osthread() == NULL) { |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
215 |
*ecode = JNI_ENOMEM; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
216 |
vm_shutdown_during_initialization("Could not create G1ConcurrentRefineThread"); |
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
217 |
return NULL; |
22220
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
218 |
} |
eb467dfb9585
8029326: G1 does not check if threads gets created
ehelin
parents:
17854
diff
changeset
|
219 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
220 |
assert(t->cr() == cr, "Conc refine thread should refer to this"); |
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
221 |
cr->_threads[i] = t; |
4481 | 222 |
next = t; |
1374 | 223 |
} |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
224 |
|
32738
a1adf25202fd
8135025: Error message is repeated for large value at G1ConcRefinementThreads
sangheki
parents:
30876
diff
changeset
|
225 |
*ecode = JNI_OK; |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
226 |
return cr; |
1374 | 227 |
} |
228 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
229 |
void G1ConcurrentRefine::stop() { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
230 |
for (uint i = 0; i < _n_worker_threads; i++) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
231 |
_threads[i]->stop(); |
2881 | 232 |
} |
233 |
} |
|
234 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
235 |
void G1ConcurrentRefine::update_thread_thresholds() { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
236 |
for (uint i = 0; i < _n_worker_threads; i++) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
237 |
Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, i); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
238 |
_threads[i]->update_thresholds(activation_level(thresholds), |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
239 |
deactivation_level(thresholds)); |
4481 | 240 |
} |
241 |
} |
|
242 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
243 |
G1ConcurrentRefine::~G1ConcurrentRefine() { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
244 |
for (uint i = 0; i < _n_worker_threads; i++) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
245 |
delete _threads[i]; |
1374 | 246 |
} |
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
247 |
FREE_C_HEAP_ARRAY(G1ConcurrentRefineThread*, _threads); |
1374 | 248 |
} |
249 |
||
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
250 |
void G1ConcurrentRefine::threads_do(ThreadClosure *tc) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
251 |
for (uint i = 0; i < _n_worker_threads; i++) { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
252 |
tc->do_thread(_threads[i]); |
17854
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
253 |
} |
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
254 |
} |
d65bc1546091
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents:
17327
diff
changeset
|
255 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
256 |
uint G1ConcurrentRefine::thread_num() { |
26932
33d6fa41d290
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
26160
diff
changeset
|
257 |
return G1ConcRefinementThreads; |
1374 | 258 |
} |
4022 | 259 |
|
47790
4925ee84b4ac
8140255: Move the management of G1YoungRemSetSamplingThread from G1ConcurrentRefine
tschatzl
parents:
47789
diff
changeset
|
260 |
void G1ConcurrentRefine::print_threads_on(outputStream* st) const { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
32738
diff
changeset
|
261 |
for (uint i = 0; i < _n_worker_threads; ++i) { |
4022 | 262 |
_threads[i]->print_on(st); |
263 |
st->cr(); |
|
264 |
} |
|
265 |
} |
|
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
266 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
267 |
static size_t calc_new_green_zone(size_t green, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
268 |
double update_rs_time, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
269 |
size_t update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
270 |
double goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
271 |
// 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
|
272 |
// Limit to max_green_zone. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
273 |
const double inc_k = 1.1, dec_k = 0.9; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
274 |
if (update_rs_time > goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
275 |
if (green > 0) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
276 |
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
|
277 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
278 |
} else if (update_rs_time < goal_ms && |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
279 |
update_rs_processed_buffers > green) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
280 |
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
|
281 |
green = MIN2(green, max_green_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
282 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
283 |
return green; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
284 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
285 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
286 |
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
|
287 |
size_t size = green * 2; |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
288 |
size = MAX2(size, min_yellow_size); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
289 |
return MIN2(green + size, max_yellow_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
290 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
291 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
292 |
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
|
293 |
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
|
294 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
295 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
296 |
void G1ConcurrentRefine::update_zones(double update_rs_time, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
297 |
size_t update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
298 |
double goal_ms) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
299 |
log_trace( CTRL_TAGS )("Updating Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
300 |
"update_rs time: %.3fms, " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
301 |
"update_rs buffers: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
302 |
"update_rs goal time: %.3fms", |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
303 |
update_rs_time, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
304 |
update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
305 |
goal_ms); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
306 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
307 |
_green_zone = calc_new_green_zone(_green_zone, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
308 |
update_rs_time, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
309 |
update_rs_processed_buffers, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
310 |
goal_ms); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
311 |
_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
|
312 |
_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
|
313 |
|
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
314 |
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
|
315 |
LOG_ZONES("Updated Refinement Zones: " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
316 |
"green: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
317 |
"yellow: " SIZE_FORMAT ", " |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
318 |
"red: " SIZE_FORMAT, |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
319 |
_green_zone, _yellow_zone, _red_zone); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
320 |
} |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
321 |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47216
diff
changeset
|
322 |
void G1ConcurrentRefine::adjust(double update_rs_time, |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
323 |
size_t update_rs_processed_buffers, |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
324 |
double goal_ms) { |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
325 |
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
326 |
|
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
327 |
if (G1UseAdaptiveConcRefinement) { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
328 |
update_zones(update_rs_time, update_rs_processed_buffers, goal_ms); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
329 |
update_thread_thresholds(); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
330 |
|
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
331 |
// Change the barrier params |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
332 |
if (_n_worker_threads == 0) { |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
333 |
// Disable dcqs notification when there are no threads to notify. |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
334 |
dcqs.set_process_completed_threshold(INT_MAX); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
335 |
} else { |
37510
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
336 |
// 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
|
337 |
STATIC_ASSERT(max_yellow_zone <= INT_MAX); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
338 |
size_t activate = _threads[0]->activation_threshold(); |
cf066fe4531b
8133051: Concurrent refinement threads may be activated and deactivated at random
kbarrett
parents:
37158
diff
changeset
|
339 |
dcqs.set_process_completed_threshold((int)activate); |
37158
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
340 |
} |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
341 |
dcqs.set_max_completed_queue((int)red_zone()); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
342 |
} |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
343 |
|
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
344 |
size_t curr_queue_size = dcqs.completed_buffers_num(); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
345 |
if (curr_queue_size >= yellow_zone()) { |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
346 |
dcqs.set_completed_queue_padding(curr_queue_size); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
347 |
} else { |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
348 |
dcqs.set_completed_queue_padding(0); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
349 |
} |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
350 |
dcqs.notify_if_necessary(); |
b882bbfa1af0
8152101: Move G1 concurrent refinement adjustment code out of G1CollectorPolicy
mgerdin
parents:
36371
diff
changeset
|
351 |
} |