39 ConcurrentGCThread(),
40 _monitor(Mutex::nonleaf,
41 "G1YoungRemSetSamplingThread monitor",
42 true,
43 Monitor::_safepoint_check_never),
44 _last_periodic_gc_attempt_s(os::elapsedTime()),
45 _vtime_accum(0) {
46 set_name("G1 Young RemSet Sampling");
47 create_and_start();
48 }
49
50 void G1YoungRemSetSamplingThread::sleep_before_next_cycle() {
51 MonitorLocker ml(&_monitor, Mutex::_no_safepoint_check_flag);
52 if (!should_terminate()) {
53 uintx waitms = G1ConcRefinementServiceIntervalMillis;
54 ml.wait(waitms);
55 }
56 }
57
58 bool G1YoungRemSetSamplingThread::should_start_periodic_gc() {
59 // If we are currently in a concurrent mark we are going to uncommit memory soon.
60 if (G1CollectedHeap::heap()->concurrent_mark()->cm_thread()->during_cycle()) {
61 log_debug(gc, periodic)("Concurrent cycle in progress. Skipping.");
62 return false;
63 }
64
65 // Check if enough time has passed since the last GC.
66 uintx time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc();
67 if ((time_since_last_gc < G1PeriodicGCInterval)) {
68 log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
69 time_since_last_gc, G1PeriodicGCInterval);
70 return false;
71 }
72
73 // Check if load is lower than max.
74 double recent_load;
75 if ((G1PeriodicGCSystemLoadThreshold > 0.0f) &&
76 (os::loadavg(&recent_load, 1) == -1 || recent_load > G1PeriodicGCSystemLoadThreshold)) {
77 log_debug(gc, periodic)("Load %1.2f is higher than threshold %1.2f. Skipping.",
78 recent_load, G1PeriodicGCSystemLoadThreshold);
79 return false;
80 }
81
82 return true;
83 }
84
85 void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
86 // If disabled, just return.
|
39 ConcurrentGCThread(),
40 _monitor(Mutex::nonleaf,
41 "G1YoungRemSetSamplingThread monitor",
42 true,
43 Monitor::_safepoint_check_never),
44 _last_periodic_gc_attempt_s(os::elapsedTime()),
45 _vtime_accum(0) {
46 set_name("G1 Young RemSet Sampling");
47 create_and_start();
48 }
49
50 void G1YoungRemSetSamplingThread::sleep_before_next_cycle() {
51 MonitorLocker ml(&_monitor, Mutex::_no_safepoint_check_flag);
52 if (!should_terminate()) {
53 uintx waitms = G1ConcRefinementServiceIntervalMillis;
54 ml.wait(waitms);
55 }
56 }
57
58 bool G1YoungRemSetSamplingThread::should_start_periodic_gc() {
59 G1CollectedHeap* g1h = G1CollectedHeap::heap();
60 // If we are currently in a concurrent mark we are going to uncommit memory soon.
61 if (g1h->concurrent_mark()->cm_thread()->during_cycle()) {
62 log_debug(gc, periodic)("Concurrent cycle in progress. Skipping.");
63 return false;
64 }
65
66 // Check if enough time has passed since the last GC.
67 uintx time_since_last_gc = (uintx)g1h->time_since_last_collection().milliseconds();
68 if ((time_since_last_gc < G1PeriodicGCInterval)) {
69 log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
70 time_since_last_gc, G1PeriodicGCInterval);
71 return false;
72 }
73
74 // Check if load is lower than max.
75 double recent_load;
76 if ((G1PeriodicGCSystemLoadThreshold > 0.0f) &&
77 (os::loadavg(&recent_load, 1) == -1 || recent_load > G1PeriodicGCSystemLoadThreshold)) {
78 log_debug(gc, periodic)("Load %1.2f is higher than threshold %1.2f. Skipping.",
79 recent_load, G1PeriodicGCSystemLoadThreshold);
80 return false;
81 }
82
83 return true;
84 }
85
86 void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
87 // If disabled, just return.
|