summaryrefslogtreecommitdiff
path: root/rts/eventlog
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2012-10-15 00:52:32 +0100
committerDuncan Coutts <duncan@well-typed.com>2012-10-15 12:28:29 +0100
commita609027da31c7c9103d8b9741ba3fc6807b7b7b9 (patch)
treed0e5340b10ef2d2e3935c3d682e3b35e4737d1ac /rts/eventlog
parent8af2d940c786136a29a061fa9542e39f65e6d6fb (diff)
downloadhaskell-a609027da31c7c9103d8b9741ba3fc6807b7b7b9.tar.gz
Add a new traceMarker# primop for use in profiling output
In time-based profiling visualisations (e.g. heap profiles and ThreadScope) it would be useful to be able to mark particular points in the execution and have those points in time marked in the visualisation. The traceMarker# primop currently emits an event into the eventlog. In principle it could be extended to do something in the heap profiling too.
Diffstat (limited to 'rts/eventlog')
-rw-r--r--rts/eventlog/EventLog.c23
-rw-r--r--rts/eventlog/EventLog.h2
2 files changed, 25 insertions, 0 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index 81aaecb67d..ef6f69c6dd 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -80,6 +80,7 @@ char *EventDesc[] = {
[EVENT_CREATE_SPARK_THREAD] = "Create spark thread",
[EVENT_LOG_MSG] = "Log message",
[EVENT_USER_MSG] = "User message",
+ [EVENT_USER_MARKER] = "User marker",
[EVENT_GC_IDLE] = "GC idle",
[EVENT_GC_WORK] = "GC working",
[EVENT_GC_DONE] = "GC done",
@@ -369,6 +370,7 @@ initEventLogging(void)
case EVENT_LOG_MSG: // (msg)
case EVENT_USER_MSG: // (msg)
+ case EVENT_USER_MARKER: // (markername)
case EVENT_RTS_IDENTIFIER: // (capset, str)
case EVENT_PROGRAM_ARGS: // (capset, strvec)
case EVENT_PROGRAM_ENV: // (capset, strvec)
@@ -1086,6 +1088,27 @@ void postEventStartup(EventCapNo n_caps)
RELEASE_LOCK(&eventBufMutex);
}
+void postUserMarker(Capability *cap, char *markername)
+{
+ EventsBuf *eb;
+ int size = strlen(markername);
+
+ eb = &capEventBuf[cap->no];
+
+ if (!hasRoomForVariableEvent(eb, size)){
+ printAndClearEventBuf(eb);
+
+ if (!hasRoomForVariableEvent(eb, size)){
+ // Event size exceeds buffer size, bail out:
+ return;
+ }
+ }
+
+ postEventHeader(eb, EVENT_USER_MARKER);
+ postPayloadSize(eb, size);
+ postBuf(eb, (StgWord8*) markername, size);
+}
+
void postThreadLabel(Capability *cap,
EventThreadID id,
char *label)
diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h
index 5861f64757..85370e9843 100644
--- a/rts/eventlog/EventLog.h
+++ b/rts/eventlog/EventLog.h
@@ -49,6 +49,8 @@ void postUserMsg(Capability *cap, char *msg, va_list ap);
void postCapMsg(Capability *cap, char *msg, va_list ap);
+void postUserMarker(Capability *cap, char *markername);
+
void postEventStartup(EventCapNo n_caps);
/*