summaryrefslogtreecommitdiff
path: root/rts/Timer.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-12-16 12:21:46 -0500
committerBen Gamari <ben@smart-cactus.org>2020-12-16 13:51:01 -0500
commit02bc4b4f1a4fe07a46018738e7e12ec861aaf3df (patch)
tree4f289e9a4d3f608aeff18722787f67738f86e075 /rts/Timer.c
parentb58cb63afd3353beb3a6e11ba7fa557fdedb8941 (diff)
downloadhaskell-wip/eventlog-flush-interval.tar.gz
rts: Introduce --eventlog-flush-interval flagwip/eventlog-flush-interval
This introduces a flag, --eventlog-flush-interval, which can be used to set an upper bound on the amount of time for which an eventlog event will remain enqueued. This can be useful in real-time monitoring settings.
Diffstat (limited to 'rts/Timer.c')
-rw-r--r--rts/Timer.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/rts/Timer.c b/rts/Timer.c
index 97d87ad989..d60d09e726 100644
--- a/rts/Timer.c
+++ b/rts/Timer.c
@@ -24,6 +24,7 @@
#include "Ticker.h"
#include "Capability.h"
#include "RtsSignals.h"
+#include "rts/EventLogWriter.h"
// This global counter is used to allow multiple threads to stop the
// timer temporarily with a stopTimer()/startTimer() pair. If
@@ -37,6 +38,9 @@ static StgWord timer_disabled;
/* ticks left before next pre-emptive context switch */
static int ticks_to_ctxt_switch = 0;
+/* ticks left before next next forced eventlog flush */
+static int ticks_to_eventlog_flush = 0;
+
/*
Note [GC During Idle Time]
@@ -111,6 +115,15 @@ handle_tick(int unused STG_UNUSED)
}
}
+ if (eventLogStatus() == EVENTLOG_RUNNING
+ && RtsFlags.TraceFlags.eventlogFlushTicks > 0) {
+ ticks_to_eventlog_flush--;
+ if (ticks_to_eventlog_flush <= 0) {
+ ticks_to_eventlog_flush = RtsFlags.TraceFlags.eventlogFlushTicks;
+ flushEventLog(NULL);
+ }
+ }
+
/*
* If we've been inactive for idleGCDelayTime (set by +RTS
* -I), tell the scheduler to wake up and do a GC, to check