author | kbarrett |
Wed, 13 Nov 2019 18:00:30 -0500 | |
changeset 59067 | f080b08daace |
parent 57663 | bf8e76d86d05 |
permissions | -rw-r--r-- |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
1 |
/* |
53983
7935353a466a
8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents:
53360
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
4 |
* |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
8 |
* |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
13 |
* accompanied this code). |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
14 |
* |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
18 |
* |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
21 |
* questions. |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
22 |
* |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
23 |
*/ |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
24 |
|
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
26 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
37039
79f62b89a7a6
8151178: Move the collection set out of the G1 collector policy
mgerdin
parents:
36402
diff
changeset
|
27 |
#include "gc/g1/g1CollectionSet.hpp" |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
28 |
#include "gc/g1/g1ConcurrentMark.inline.hpp" |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
29 |
#include "gc/g1/g1ConcurrentMarkThread.inline.hpp" |
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37081
diff
changeset
|
30 |
#include "gc/g1/g1Policy.hpp" |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
31 |
#include "gc/g1/g1YoungRemSetSamplingThread.hpp" |
36365
bcc9c9afda49
8150390: Move rs length sampling data to the sampling thread
mgerdin
parents:
35916
diff
changeset
|
32 |
#include "gc/g1/heapRegion.inline.hpp" |
bcc9c9afda49
8150390: Move rs length sampling data to the sampling thread
mgerdin
parents:
35916
diff
changeset
|
33 |
#include "gc/g1/heapRegionRemSet.hpp" |
47647
64dba69fc528
8189276: Make SuspendibleThreadSet and related code available to other GCs
rkennke
parents:
47216
diff
changeset
|
34 |
#include "gc/shared/suspendibleThreadSet.hpp" |
54786 | 35 |
#include "memory/universe.hpp" |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
36 |
#include "runtime/mutexLocker.hpp" |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
37 |
|
36378
d63bca5c1439
8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents:
36365
diff
changeset
|
38 |
G1YoungRemSetSamplingThread::G1YoungRemSetSamplingThread() : |
d63bca5c1439
8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents:
36365
diff
changeset
|
39 |
ConcurrentGCThread(), |
d63bca5c1439
8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents:
36365
diff
changeset
|
40 |
_monitor(Mutex::nonleaf, |
d63bca5c1439
8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents:
36365
diff
changeset
|
41 |
"G1YoungRemSetSamplingThread monitor", |
d63bca5c1439
8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents:
36365
diff
changeset
|
42 |
true, |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
43 |
Monitor::_safepoint_check_never), |
53034
de99beff5c0e
8214946: G1: Initialize all class members on construction
lkorinth
parents:
52918
diff
changeset
|
44 |
_last_periodic_gc_attempt_s(os::elapsedTime()), |
de99beff5c0e
8214946: G1: Initialize all class members on construction
lkorinth
parents:
52918
diff
changeset
|
45 |
_vtime_accum(0) { |
35916
23189249c2c1
8147884: Names of GC threads should be set before the threads start
asmotrak
parents:
33608
diff
changeset
|
46 |
set_name("G1 Young RemSet Sampling"); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
47 |
create_and_start(); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
48 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
49 |
|
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
50 |
void G1YoungRemSetSamplingThread::sleep_before_next_cycle() { |
54645
05aaccf7d558
8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents:
54623
diff
changeset
|
51 |
MonitorLocker ml(&_monitor, Mutex::_no_safepoint_check_flag); |
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
37039
diff
changeset
|
52 |
if (!should_terminate()) { |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
53 |
uintx waitms = G1ConcRefinementServiceIntervalMillis; |
54645
05aaccf7d558
8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents:
54623
diff
changeset
|
54 |
ml.wait(waitms); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
55 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
56 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
57 |
|
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
58 |
bool G1YoungRemSetSamplingThread::should_start_periodic_gc() { |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
59 |
// If we are currently in a concurrent mark we are going to uncommit memory soon. |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
60 |
if (G1CollectedHeap::heap()->concurrent_mark()->cm_thread()->during_cycle()) { |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
61 |
log_debug(gc, periodic)("Concurrent cycle in progress. Skipping."); |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
62 |
return false; |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
63 |
} |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
64 |
|
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
65 |
// Check if enough time has passed since the last GC. |
53354
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
66 |
uintx time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc(); |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
67 |
if ((time_since_last_gc < G1PeriodicGCInterval)) { |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
68 |
log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.", |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
69 |
time_since_last_gc, G1PeriodicGCInterval); |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
70 |
return false; |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
71 |
} |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
72 |
|
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
73 |
// Check if load is lower than max. |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
74 |
double recent_load; |
53090
759266b1c89b
8215548: G1PeriodicGCSystemLoadThreshold needs to be a double
tschatzl
parents:
52918
diff
changeset
|
75 |
if ((G1PeriodicGCSystemLoadThreshold > 0.0f) && |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
76 |
(os::loadavg(&recent_load, 1) == -1 || recent_load > G1PeriodicGCSystemLoadThreshold)) { |
53090
759266b1c89b
8215548: G1PeriodicGCSystemLoadThreshold needs to be a double
tschatzl
parents:
52918
diff
changeset
|
77 |
log_debug(gc, periodic)("Load %1.2f is higher than threshold %1.2f. Skipping.", |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
78 |
recent_load, G1PeriodicGCSystemLoadThreshold); |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
79 |
return false; |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
80 |
} |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
81 |
|
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
82 |
return true; |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
83 |
} |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
84 |
|
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
85 |
void G1YoungRemSetSamplingThread::check_for_periodic_gc(){ |
53354
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
86 |
// If disabled, just return. |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
87 |
if (G1PeriodicGCInterval == 0) { |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
88 |
return; |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
89 |
} |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
90 |
if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) { |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
91 |
log_debug(gc, periodic)("Checking for periodic GC."); |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
92 |
if (should_start_periodic_gc()) { |
59067
f080b08daace
8232588: G1 concurrent System.gc can return early or late
kbarrett
parents:
57663
diff
changeset
|
93 |
if (!G1CollectedHeap::heap()->try_collect(GCCause::_g1_periodic_collection)) { |
53983
7935353a466a
8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents:
53360
diff
changeset
|
94 |
log_debug(gc, periodic)("GC request denied. Skipping."); |
7935353a466a
8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents:
53360
diff
changeset
|
95 |
} |
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
96 |
} |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
97 |
_last_periodic_gc_attempt_s = os::elapsedTime(); |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
98 |
} |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
99 |
} |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
100 |
|
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
101 |
void G1YoungRemSetSamplingThread::run_service() { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
102 |
double vtime_start = os::elapsedVTime(); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
103 |
|
53354
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
104 |
// Print a message about periodic GC configuration. |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
105 |
if (G1PeriodicGCInterval != 0) { |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
106 |
log_info(gc)("Periodic GC enabled with interval " UINTX_FORMAT "ms", G1PeriodicGCInterval); |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
107 |
} else { |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
108 |
log_info(gc)("Periodic GC disabled"); |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
109 |
} |
528207d2e73e
8216490: Spammy periodic GC log message contains random time stamp with periodic gc disabled
tschatzl
parents:
53090
diff
changeset
|
110 |
|
37081
7656f5356a5d
8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents:
37039
diff
changeset
|
111 |
while (!should_terminate()) { |
57663
bf8e76d86d05
8228503: Rename "rs_lengths" to "rs_length" in ergo code
tschatzl
parents:
54786
diff
changeset
|
112 |
sample_young_list_rs_length(); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
113 |
|
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
114 |
if (os::supports_vtime()) { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
115 |
_vtime_accum = (os::elapsedVTime() - vtime_start); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
116 |
} else { |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
117 |
_vtime_accum = 0.0; |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
118 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
119 |
|
52918
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
120 |
check_for_periodic_gc(); |
f94c7929a44b
8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents:
48969
diff
changeset
|
121 |
|
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
122 |
sleep_before_next_cycle(); |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
123 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
124 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
125 |
|
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
126 |
void G1YoungRemSetSamplingThread::stop_service() { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54466
diff
changeset
|
127 |
MutexLocker x(&_monitor, Mutex::_no_safepoint_check_flag); |
36378
d63bca5c1439
8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents:
36365
diff
changeset
|
128 |
_monitor.notify(); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
129 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
130 |
|
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
131 |
class G1YoungRemSetSamplingClosure : public HeapRegionClosure { |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
132 |
SuspendibleThreadSetJoiner* _sts; |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
133 |
size_t _regions_visited; |
57663
bf8e76d86d05
8228503: Rename "rs_lengths" to "rs_length" in ergo code
tschatzl
parents:
54786
diff
changeset
|
134 |
size_t _sampled_rs_length; |
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
135 |
public: |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
136 |
G1YoungRemSetSamplingClosure(SuspendibleThreadSetJoiner* sts) : |
57663
bf8e76d86d05
8228503: Rename "rs_lengths" to "rs_length" in ergo code
tschatzl
parents:
54786
diff
changeset
|
137 |
HeapRegionClosure(), _sts(sts), _regions_visited(0), _sampled_rs_length(0) { } |
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
138 |
|
48969 | 139 |
virtual bool do_heap_region(HeapRegion* r) { |
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
140 |
size_t rs_length = r->rem_set()->occupied(); |
57663
bf8e76d86d05
8228503: Rename "rs_lengths" to "rs_length" in ergo code
tschatzl
parents:
54786
diff
changeset
|
141 |
_sampled_rs_length += rs_length; |
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
142 |
|
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
143 |
// Update the collection set policy information for this region |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
144 |
G1CollectedHeap::heap()->collection_set()->update_young_region_prediction(r, rs_length); |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
145 |
|
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
146 |
_regions_visited++; |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
147 |
|
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
148 |
if (_regions_visited == 10) { |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
149 |
if (_sts->should_yield()) { |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
150 |
_sts->yield(); |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
151 |
// A gc may have occurred and our sampling data is stale and further |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
152 |
// traversal of the collection set is unsafe |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
153 |
return true; |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
154 |
} |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
155 |
_regions_visited = 0; |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
156 |
} |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
157 |
return false; |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
158 |
} |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
159 |
|
57663
bf8e76d86d05
8228503: Rename "rs_lengths" to "rs_length" in ergo code
tschatzl
parents:
54786
diff
changeset
|
160 |
size_t sampled_rs_length() const { return _sampled_rs_length; } |
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
161 |
}; |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
162 |
|
57663
bf8e76d86d05
8228503: Rename "rs_lengths" to "rs_length" in ergo code
tschatzl
parents:
54786
diff
changeset
|
163 |
void G1YoungRemSetSamplingThread::sample_young_list_rs_length() { |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
164 |
SuspendibleThreadSetJoiner sts; |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
165 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
53985
0da5c17f5e43
8219747: Remove g1_ prefix to g1_remset and g1_policy members in G1CollectedHeap
tschatzl
parents:
53983
diff
changeset
|
166 |
G1Policy* policy = g1h->policy(); |
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
167 |
|
54466
58751415d5f8
8222105: Add "use_" prefix to G1Policy::adaptive_young_list_length
tschatzl
parents:
53985
diff
changeset
|
168 |
if (policy->use_adaptive_young_list_length()) { |
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
169 |
G1YoungRemSetSamplingClosure cl(&sts); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
170 |
|
39698
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
171 |
G1CollectionSet* g1cs = g1h->collection_set(); |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
172 |
g1cs->iterate(&cl); |
4016de4e596b
8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents:
38183
diff
changeset
|
173 |
|
48969 | 174 |
if (cl.is_complete()) { |
57663
bf8e76d86d05
8228503: Rename "rs_lengths" to "rs_length" in ergo code
tschatzl
parents:
54786
diff
changeset
|
175 |
policy->revise_young_list_target_length_if_necessary(cl.sampled_rs_length()); |
33608
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
176 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
177 |
} |
7afc768e4d62
8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff
changeset
|
178 |
} |