Skip to content

Commit 3b123c9

Browse files
pf0nXiaolong Peng
authored andcommitted
8386202: Genshen: Regulator thread reporting hiccup times proportional to safepoint times
Reviewed-by: wkemper, kdnilsen
1 parent d46298d commit 3b123c9

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,22 +221,22 @@ void ShenandoahControlThread::run_service() {
221221
// Wait before performing the next action. If allocation happened during this wait,
222222
// we exit sooner, to let heuristics re-evaluate new conditions. If we are at idle,
223223
// back off exponentially.
224-
const double before_sleep = most_recent_wake_time;
225224
if (heap->has_changed()) {
226225
sleep = ShenandoahControlIntervalMin;
227-
} else if ((before_sleep - last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){
226+
} else if ((most_recent_wake_time - last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){
228227
sleep = MIN2<int>(ShenandoahControlIntervalMax, MAX2(1, sleep * 2));
229-
last_sleep_adjust_time = before_sleep;
228+
last_sleep_adjust_time = most_recent_wake_time;
230229
}
231230
MonitorLocker ml(&_control_lock, Mutex::_no_safepoint_check_flag);
231+
const double before_sleep_time = os::elapsedTime();
232232
ml.wait(sleep);
233+
most_recent_wake_time = os::elapsedTime();
233234
// Record a conservative estimate of the longest anticipated sleep duration until we sample again.
234235
double planned_sleep_interval = MIN2<int>(ShenandoahControlIntervalMax, MAX2(1, sleep * 2)) / 1000.0;
235-
most_recent_wake_time = os::elapsedTime();
236236
heuristics->update_should_start_query_times(most_recent_wake_time, planned_sleep_interval);
237237
if (LogTarget(Debug, gc, thread)::is_enabled()) {
238-
double elapsed = most_recent_wake_time - before_sleep;
239-
double hiccup = elapsed - double(sleep);
238+
double elapsed = most_recent_wake_time - before_sleep_time;
239+
double hiccup = elapsed - double(sleep) / 1000.0;
240240
if (hiccup > 0.001) {
241241
log_debug(gc, thread)("Control Thread hiccup time: %.3fs", hiccup);
242242
}

src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,21 @@ void ShenandoahRegulatorThread::regulator_sleep() {
116116
// Wait before performing the next action. If allocation happened during this wait,
117117
// we exit sooner, to let heuristics re-evaluate new conditions. If we are at idle,
118118
// back off exponentially.
119-
double before_sleep_time = _most_recent_wake_time;
120119
if (ShenandoahHeap::heap()->has_changed()) {
121120
_sleep = ShenandoahControlIntervalMin;
122-
} else if ((before_sleep_time - _last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){
121+
} else if ((_most_recent_wake_time - _last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){
123122
_sleep = MIN2<uint>(ShenandoahControlIntervalMax, MAX2(1u, _sleep * 2));
124-
_last_sleep_adjust_time = before_sleep_time;
123+
_last_sleep_adjust_time = _most_recent_wake_time;
125124
}
126125

127126
SuspendibleThreadSetLeaver leaver;
127+
const double before_sleep_time = os::elapsedTime();
128128
os::naked_short_sleep(_sleep);
129-
double wake_time = os::elapsedTime();
130-
_most_recent_period = wake_time - _most_recent_wake_time;
131-
_most_recent_wake_time = wake_time;
129+
_most_recent_wake_time = os::elapsedTime();
132130
_young_heuristics->update_should_start_query_times(_most_recent_wake_time, double(_sleep) / 1000.0);
133131
if (LogTarget(Debug, gc, thread)::is_enabled()) {
134132
double elapsed = _most_recent_wake_time - before_sleep_time;
135-
double hiccup = elapsed - double(_sleep);
133+
double hiccup = elapsed - double(_sleep) / 1000.0;
136134
if (hiccup > 0.001) {
137135
log_debug(gc, thread)("Regulator hiccup time: %.3fs", hiccup);
138136
}

src/hotspot/share/gc/shenandoah/shenandoahRegulatorThread.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class ShenandoahRegulatorThread: public ConcurrentGCThread {
8282
// duration of planned regulator sleep period, in ms
8383
uint _sleep;
8484
double _most_recent_wake_time;
85-
double _most_recent_period;
8685
double _last_sleep_adjust_time;
8786
};
8887

0 commit comments

Comments
 (0)