diff options
author | Duncan Coutts <duncan@well-typed.com> | 2011-11-02 12:02:09 +0000 |
---|---|---|
committer | Duncan Coutts <duncan@well-typed.com> | 2011-11-04 14:13:10 +0000 |
commit | c739d845f9b3fc67ee20aa3de7e876cb1327bb1a (patch) | |
tree | c3139330cdaa227854aa5fda007dd37e213d9295 /rts/eventlog | |
parent | d416d943ef59bafa0add5685ee0687f25db2d276 (diff) | |
download | haskell-c739d845f9b3fc67ee20aa3de7e876cb1327bb1a.tar.gz |
Add eventlog event for thread labels
The existing GHC.Conc.labelThread will now also emit the the thread
label into the eventlog. Profiling tools like ThreadScope could then
use the thread labels rather than thread numbers.
Diffstat (limited to 'rts/eventlog')
-rw-r--r-- | rts/eventlog/EventLog.c | 27 | ||||
-rw-r--r-- | rts/eventlog/EventLog.h | 13 |
2 files changed, 40 insertions, 0 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 09e12a2fa3..9547e7c788 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -62,6 +62,7 @@ char *EventDesc[] = { [EVENT_MIGRATE_THREAD] = "Migrate thread", [EVENT_SHUTDOWN] = "Shutdown", [EVENT_THREAD_WAKEUP] = "Wakeup thread", + [EVENT_THREAD_LABEL] = "Thread label", [EVENT_GC_START] = "Starting GC", [EVENT_GC_END] = "Finished GC", [EVENT_REQUEST_SEQ_GC] = "Request sequential GC", @@ -332,6 +333,7 @@ initEventLogging(void) case EVENT_RTS_IDENTIFIER: // (capset, str) case EVENT_PROGRAM_ARGS: // (capset, strvec) case EVENT_PROGRAM_ENV: // (capset, strvec) + case EVENT_THREAD_LABEL: // (thread, str) eventTypes[t].size = 0xffff; break; @@ -791,6 +793,31 @@ void postEventStartup(EventCapNo n_caps) RELEASE_LOCK(&eventBufMutex); } +void postThreadLabel(Capability *cap, + EventThreadID id, + char *label) +{ + EventsBuf *eb; + int strsize = strlen(label); + int size = strsize + sizeof(EventCapsetID); + + 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_THREAD_LABEL); + postPayloadSize(eb, size); + postThreadID(eb, id); + postBuf(eb, (StgWord8*) label, strsize); +} + void closeBlockMarker (EventsBuf *ebuf) { StgInt8* save_pos; diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h index d7368c30bf..667f34867d 100644 --- a/rts/eventlog/EventLog.h +++ b/rts/eventlog/EventLog.h @@ -83,6 +83,13 @@ void postSparkCountersEvent (Capability *cap, SparkCounters counters, StgWord remaining); +/* + * Post an event to annotate a thread with a label + */ +void postThreadLabel(Capability *cap, + EventThreadID id, + char *label); + #else /* !TRACING */ INLINE_HEADER void postSchedEvent (Capability *cap STG_UNUSED, @@ -105,6 +112,12 @@ INLINE_HEADER void postCapMsg (Capability *cap STG_UNUSED, va_list ap STG_UNUSED) { /* nothing */ } + +INLINE_HEADER void postThreadLabel(Capability *cap STG_UNUSED, + EventThreadID id STG_UNUSED, + char *label STG_UNUSED) +{ /* nothing */ } + #endif #include "EndPrivate.h" |