summaryrefslogtreecommitdiff
path: root/rts/Trace.c
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2012-07-03 19:28:40 +0100
committerMikolaj Konarski <mikolaj@well-typed.com>2012-07-10 17:53:34 +0200
commit54c98b687a5e23f3371604dc4918dfb3106a74f8 (patch)
tree6f35fbe69fec9f26d14da6f0a146aef5a4a925f1 /rts/Trace.c
parent647ae1cfbb5ea3e2d3b1541c2bc12ea5db321134 (diff)
downloadhaskell-54c98b687a5e23f3371604dc4918dfb3106a74f8.tar.gz
Define the task-tracking events
Based on initial patches by Mikolaj Konarski <mikolaj@well-typed.com> These new eventlog events are to let profiling tools keep track of all the OS threads that belong to an RTS capability at any moment in time. In the RTS, OS threads correspond to the Task abstraction, so that is what we track. There are events for tasks being created, migrated between capabilities and deleted. In particular the task creation event also records the kernel thread id which lets us match up the OS thread with data collected by others tools (in the initial use case with Linux's perf tool, but in principle also with DTrace).
Diffstat (limited to 'rts/Trace.c')
-rw-r--r--rts/Trace.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/rts/Trace.c b/rts/Trace.c
index 9fa8eb177b..a946f2c5d3 100644
--- a/rts/Trace.c
+++ b/rts/Trace.c
@@ -574,6 +574,52 @@ void traceSparkCounters_ (Capability *cap,
}
}
+void traceTaskCreate_ (Task *task,
+ Capability *cap)
+{
+#ifdef DEBUG
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
+ /* We currently don't do debug tracing of tasks but we must
+ test for TRACE_STDERR because of the !eventlog_enabled case. */
+ } else
+#endif
+ {
+ EventTaskId taskid = serialisableTaskId(task);
+ EventKernelThreadId tid = kernelThreadId();
+ postTaskCreateEvent(taskid, cap->no, tid);
+ }
+}
+
+void traceTaskMigrate_ (Task *task,
+ Capability *cap,
+ Capability *new_cap)
+{
+#ifdef DEBUG
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
+ /* We currently don't do debug tracing of tasks but we must
+ test for TRACE_STDERR because of the !eventlog_enabled case. */
+ } else
+#endif
+ {
+ EventTaskId taskid = serialisableTaskId(task);
+ postTaskMigrateEvent(taskid, cap->no, new_cap->no);
+ }
+}
+
+void traceTaskDelete_ (Task *task)
+{
+#ifdef DEBUG
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
+ /* We currently don't do debug tracing of tasks but we must
+ test for TRACE_STDERR because of the !eventlog_enabled case. */
+ } else
+#endif
+ {
+ EventTaskId taskid = serialisableTaskId(task);
+ postTaskDeleteEvent(taskid);
+ }
+}
+
#ifdef DEBUG
static void traceCap_stderr(Capability *cap, char *msg, va_list ap)
{