diff options
author | Simon Marlow <simonmar@microsoft.com> | 2007-09-03 13:25:23 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2007-09-03 13:25:23 +0000 |
commit | 8d71be7cbd079f5eab23484a53a43b59dd0399e5 (patch) | |
tree | 8772a7455fbba0e62f11b858dfecded04f68094e /rts/Timer.c | |
parent | 37e27d92a0fc14105e4533514c3995fccd6da9fe (diff) | |
download | haskell-8d71be7cbd079f5eab23484a53a43b59dd0399e5.tar.gz |
FIX #1623: disable the timer signal when the system is idle (threaded RTS only)
Having a timer signal go off regularly is bad for power consumption,
and generally bad practice anyway (it means the app cannot be
completely swapped out, for example). Fortunately the threaded RTS
already had a way to detect when the system was idle, so that it can
trigger a GC and thereby find deadlocks. After performing the GC, we
now turn off timer signals, and re-enable them again just before
running any Haskell code.
Diffstat (limited to 'rts/Timer.c')
-rw-r--r-- | rts/Timer.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/rts/Timer.c b/rts/Timer.c index 586991a4db..9822239b33 100644 --- a/rts/Timer.c +++ b/rts/Timer.c @@ -64,15 +64,21 @@ handle_tick(int unused STG_UNUSED) RtsFlags.MiscFlags.tickInterval; break; case ACTIVITY_MAYBE_NO: - if (ticks_to_gc == 0) break; /* 0 ==> no idle GC */ - ticks_to_gc--; if (ticks_to_gc == 0) { - ticks_to_gc = RtsFlags.GcFlags.idleGCDelayTime / - RtsFlags.MiscFlags.tickInterval; - recent_activity = ACTIVITY_INACTIVE; - blackholes_need_checking = rtsTrue; - /* hack: re-use the blackholes_need_checking flag */ - wakeUpRts(); + /* 0 ==> no idle GC */ + recent_activity = ACTIVITY_DONE_GC; + // disable timer signals (see #1623) + stopTimer(); + } else { + ticks_to_gc--; + if (ticks_to_gc == 0) { + ticks_to_gc = RtsFlags.GcFlags.idleGCDelayTime / + RtsFlags.MiscFlags.tickInterval; + recent_activity = ACTIVITY_INACTIVE; + blackholes_need_checking = rtsTrue; + /* hack: re-use the blackholes_need_checking flag */ + wakeUpRts(); + } } break; default: @@ -82,18 +88,34 @@ handle_tick(int unused STG_UNUSED) } void +initTimer(void) +{ + initProfTimer(); + if (RtsFlags.MiscFlags.tickInterval != 0) { + initTicker(RtsFlags.MiscFlags.tickInterval, handle_tick); + } +} + +void startTimer(void) { - initProfTimer(); - if (RtsFlags.MiscFlags.tickInterval != 0) { - startTicker(RtsFlags.MiscFlags.tickInterval, handle_tick); - } + if (RtsFlags.MiscFlags.tickInterval != 0) { + startTicker(); + } } void stopTimer(void) { - if (RtsFlags.MiscFlags.tickInterval != 0) { - stopTicker(); - } + if (RtsFlags.MiscFlags.tickInterval != 0) { + stopTicker(); + } +} + +void +exitTimer(void) +{ + if (RtsFlags.MiscFlags.tickInterval != 0) { + exitTicker(); + } } |