23
23
*/
24
24
25
25
#include " precompiled.hpp"
26
- #include " gc/g1/g1CollectedHeap.inline.hpp"
27
- #include " gc/g1/g1ConcurrentMark.inline.hpp"
28
- #include " gc/g1/g1ConcurrentMarkThread.inline.hpp"
29
26
#include " gc/g1/g1ServiceThread.hpp"
30
- #include " memory/universe .hpp"
27
+ #include " logging/log .hpp"
31
28
#include " runtime/mutexLocker.hpp"
29
+ #include " runtime/timer.hpp"
32
30
#include " runtime/os.hpp"
33
31
34
32
G1SentinelTask::G1SentinelTask () : G1ServiceTask(" Sentinel Task" ) {
@@ -40,77 +38,17 @@ void G1SentinelTask::execute() {
40
38
guarantee (false , " Sentinel service task should never be executed." );
41
39
}
42
40
43
- // Task handling periodic GCs
44
- class G1PeriodicGCTask : public G1ServiceTask {
45
- bool should_start_periodic_gc () {
46
- G1CollectedHeap* g1h = G1CollectedHeap::heap ();
47
- // If we are currently in a concurrent mark we are going to uncommit memory soon.
48
- if (g1h->concurrent_mark ()->cm_thread ()->in_progress ()) {
49
- log_debug (gc, periodic)(" Concurrent cycle in progress. Skipping." );
50
- return false ;
51
- }
52
-
53
- // Check if enough time has passed since the last GC.
54
- uintx time_since_last_gc = (uintx)g1h->time_since_last_collection ().milliseconds ();
55
- if ((time_since_last_gc < G1PeriodicGCInterval)) {
56
- log_debug (gc, periodic)(" Last GC occurred " UINTX_FORMAT " ms before which is below threshold " UINTX_FORMAT " ms. Skipping." ,
57
- time_since_last_gc, G1PeriodicGCInterval);
58
- return false ;
59
- }
60
-
61
- // Check if load is lower than max.
62
- double recent_load;
63
- if ((G1PeriodicGCSystemLoadThreshold > 0 .0f ) &&
64
- (os::loadavg (&recent_load, 1 ) == -1 || recent_load > G1PeriodicGCSystemLoadThreshold)) {
65
- log_debug (gc, periodic)(" Load %1.2f is higher than threshold %1.2f. Skipping." ,
66
- recent_load, G1PeriodicGCSystemLoadThreshold);
67
- return false ;
68
- }
69
- return true ;
70
- }
71
-
72
- void check_for_periodic_gc (){
73
- // If disabled, just return.
74
- if (G1PeriodicGCInterval == 0 ) {
75
- return ;
76
- }
77
-
78
- log_debug (gc, periodic)(" Checking for periodic GC." );
79
- if (should_start_periodic_gc ()) {
80
- if (!G1CollectedHeap::heap ()->try_collect (GCCause::_g1_periodic_collection)) {
81
- log_debug (gc, periodic)(" GC request denied. Skipping." );
82
- }
83
- }
84
- }
85
- public:
86
- G1PeriodicGCTask (const char * name) : G1ServiceTask(name) { }
87
-
88
- virtual void execute () {
89
- check_for_periodic_gc ();
90
- // G1PeriodicGCInterval is a manageable flag and can be updated
91
- // during runtime. If no value is set, wait a second and run it
92
- // again to see if the value has been updated. Otherwise use the
93
- // real value provided.
94
- schedule (G1PeriodicGCInterval == 0 ? 1000 : G1PeriodicGCInterval);
95
- }
96
- };
97
-
98
41
G1ServiceThread::G1ServiceThread () :
99
42
ConcurrentGCThread(),
100
43
_monitor(Mutex::nonleaf,
101
44
" G1ServiceThread monitor" ,
102
45
true ,
103
46
Monitor::_safepoint_check_never),
104
- _task_queue(),
105
- _periodic_gc_task(new G1PeriodicGCTask(" Periodic GC Task" )) {
47
+ _task_queue() {
106
48
set_name (" G1 Service" );
107
49
create_and_start ();
108
50
}
109
51
110
- G1ServiceThread::~G1ServiceThread () {
111
- delete _periodic_gc_task;
112
- }
113
-
114
52
void G1ServiceThread::register_task (G1ServiceTask* task, jlong delay_ms) {
115
53
guarantee (!task->is_registered (), " Task already registered" );
116
54
guarantee (task->next () == NULL , " Task already in queue" );
@@ -215,9 +153,6 @@ void G1ServiceThread::run_task(G1ServiceTask* task) {
215
153
}
216
154
217
155
void G1ServiceThread::run_service () {
218
- // Register the tasks handled by the service thread.
219
- register_task (_periodic_gc_task);
220
-
221
156
while (!should_terminate ()) {
222
157
G1ServiceTask* task = pop_due_task ();
223
158
if (task != NULL ) {
1 commit comments
openjdk-notifier[bot] commentedon Nov 30, 2020
Review
Issues