summaryrefslogtreecommitdiff
path: root/rts/Trace.h
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2011-07-14 19:06:45 +0100
committerDuncan Coutts <duncan@well-typed.com>2011-07-18 16:31:18 +0100
commit084b64f22717b203b8d8c2ab7c057fb747e39593 (patch)
treec44a67dcb28b288ac1ad445a83f68b75f1352c92 /rts/Trace.h
parent46b70749971341678c3e4d5cdb2b1ab1a13d039e (diff)
downloadhaskell-084b64f22717b203b8d8c2ab7c057fb747e39593.tar.gz
Add new fully-accurate per-spark trace/eventlog events
Replaces the existing EVENT_RUN/STEAL_SPARK events with 7 new events covering all stages of the spark lifcycle: create, dud, overflow, run, steal, fizzle, gc The sampled spark events are still available. There are now two event classes for sparks, the sampled and the fully accurate. They can be enabled/disabled independently. By default +RTS -l includes the sampled but not full detail spark events. Use +RTS -lf-p to enable the detailed 'f' and disable the sampled 'p' spark. Includes work by Mikolaj <mikolaj.konarski@gmail.com>
Diffstat (limited to 'rts/Trace.h')
-rw-r--r--rts/Trace.h128
1 files changed, 90 insertions, 38 deletions
diff --git a/rts/Trace.h b/rts/Trace.h
index 676fa58515..40a4522a26 100644
--- a/rts/Trace.h
+++ b/rts/Trace.h
@@ -63,7 +63,8 @@ extern int DEBUG_sparks;
// events
extern int TRACE_sched;
extern int TRACE_gc;
-extern int TRACE_spark;
+extern int TRACE_spark_sampled;
+extern int TRACE_spark_full;
// -----------------------------------------------------------------------------
// Posting events
@@ -95,11 +96,6 @@ void traceEnd (void);
traceSchedEvent_(cap, tag, tso, info1, info2); \
}
-#define traceSparkEvent(cap, tag, tso, other) \
- if (RTS_UNLIKELY(TRACE_spark)) { \
- traceSchedEvent_(cap, tag, tso, other, 0); \
- }
-
void traceSchedEvent_ (Capability *cap, EventTypeNum tag,
StgTSO *tso, StgWord info1, StgWord info2);
@@ -113,6 +109,21 @@ void traceSchedEvent_ (Capability *cap, EventTypeNum tag,
void traceGcEvent_ (Capability *cap, EventTypeNum tag);
+/*
+ * Record a spark event
+ */
+#define traceSparkEvent(cap, tag) \
+ if (RTS_UNLIKELY(TRACE_spark_full)) { \
+ traceSparkEvent_(cap, tag, 0); \
+ }
+
+#define traceSparkEvent2(cap, tag, other) \
+ if (RTS_UNLIKELY(TRACE_spark_full)) { \
+ traceSparkEvent_(cap, tag, other); \
+ }
+
+void traceSparkEvent_ (Capability *cap, EventTypeNum tag, StgWord info1);
+
// variadic macros are C99, and supported by gcc. However, the
// ##__VA_ARGS syntax is a gcc extension, which allows the variable
// argument list to be empty (see gcc docs for details).
@@ -199,7 +210,8 @@ void traceSparkCounters_ (Capability *cap,
#define traceSchedEvent(cap, tag, tso, other) /* nothing */
#define traceSchedEvent2(cap, tag, tso, other, info) /* nothing */
#define traceGcEvent(cap, tag) /* nothing */
-#define traceSparkEvent(cap, tag, tso, other) /* nothing */
+#define traceSparkEvent(cap, tag) /* nothing */
+#define traceSparkEvent2(cap, tag, other) /* nothing */
#define traceCap(class, cap, msg, ...) /* nothing */
#define trace(class, msg, ...) /* nothing */
#define debugTrace(class, str, ...) /* nothing */
@@ -237,10 +249,6 @@ void dtraceUserMsgWrapper(Capability *cap, char *msg);
HASKELLEVENT_THREAD_RUNNABLE(cap, tid)
#define dtraceMigrateThread(cap, tid, new_cap) \
HASKELLEVENT_MIGRATE_THREAD(cap, tid, new_cap)
-#define dtraceRunSpark(cap, tid) \
- HASKELLEVENT_RUN_SPARK(cap, tid)
-#define dtraceStealSpark(cap, tid, victim_cap) \
- HASKELLEVENT_STEAL_SPARK(cap, tid, victim_cap)
#define dtraceShutdown(cap) \
HASKELLEVENT_SHUTDOWN(cap)
#define dtraceThreadWakeup(cap, tid, other_cap) \
@@ -276,6 +284,20 @@ INLINE_HEADER void dtraceStartup (int num_caps) {
HASKELLEVENT_CAPSET_REMOVE_CAP(capset, capno)
#define dtraceSparkCounters(cap, a, b, c, d, e, f, g) \
HASKELLEVENT_SPARK_COUNTERS(cap, a, b, c, d, e, f, g)
+#define dtraceSparkCreate(cap) \
+ HASKELLEVENT_SPARK_CREATE(cap)
+#define dtraceSparkDud(cap) \
+ HASKELLEVENT_SPARK_DUD(cap)
+#define dtraceSparkOverflow(cap) \
+ HASKELLEVENT_SPARK_OVERFLOW(cap)
+#define dtraceSparkRun(cap) \
+ HASKELLEVENT_SPARK_RUN(cap)
+#define dtraceSparkSteal(cap, victim_cap) \
+ HASKELLEVENT_SPARK_STEAL(cap, victim_cap)
+#define dtraceSparkFizzle(cap) \
+ HASKELLEVENT_SPARK_FIZZLE(cap)
+#define dtraceSparkGc(cap) \
+ HASKELLEVENT_SPARK_GC(cap)
#else /* !defined(DTRACE) */
@@ -284,8 +306,6 @@ INLINE_HEADER void dtraceStartup (int num_caps) {
#define dtraceStopThread(cap, tid, status, info) /* nothing */
#define dtraceThreadRunnable(cap, tid) /* nothing */
#define dtraceMigrateThread(cap, tid, new_cap) /* nothing */
-#define dtraceRunSpark(cap, tid) /* nothing */
-#define dtraceStealSpark(cap, tid, victim_cap) /* nothing */
#define dtraceShutdown(cap) /* nothing */
#define dtraceThreadWakeup(cap, tid, other_cap) /* nothing */
#define dtraceGcStart(cap) /* nothing */
@@ -303,6 +323,13 @@ INLINE_HEADER void dtraceStartup (int num_caps STG_UNUSED) {};
#define dtraceCapsetAssignCap(capset, capno) /* nothing */
#define dtraceCapsetRemoveCap(capset, capno) /* nothing */
#define dtraceSparkCounters(cap, a, b, c, d, e, f, g) /* nothing */
+#define dtraceSparkCreate(cap) /* nothing */
+#define dtraceSparkDud(cap) /* nothing */
+#define dtraceSparkOverflow(cap) /* nothing */
+#define dtraceSparkRun(cap) /* nothing */
+#define dtraceSparkSteal(cap, victim_cap) /* nothing */
+#define dtraceSparkFizzle(cap) /* nothing */
+#define dtraceSparkGc(cap) /* nothing */
#endif
@@ -424,30 +451,6 @@ INLINE_HEADER void traceEventGcDone(Capability *cap STG_UNUSED)
dtraceGcDone((EventCapNo)cap->no);
}
-
-INLINE_HEADER void traceEventRunSpark(Capability *cap STG_UNUSED,
- StgTSO *tso STG_UNUSED)
-{
- traceSparkEvent(cap, EVENT_RUN_SPARK, tso, 0);
- dtraceRunSpark((EventCapNo)cap->no, (EventThreadID)tso->id);
-}
-
-INLINE_HEADER void traceEventStealSpark(Capability *cap STG_UNUSED,
- StgTSO *tso STG_UNUSED,
- nat victim_cap STG_UNUSED)
-{
- traceSparkEvent(cap, EVENT_STEAL_SPARK, tso, victim_cap);
- dtraceStealSpark((EventCapNo)cap->no, (EventThreadID)tso->id,
- (EventCapNo)victim_cap);
-}
-
-INLINE_HEADER void traceEventCreateSparkThread(Capability *cap STG_UNUSED,
- StgThreadID spark_tid STG_UNUSED)
-{
- traceSparkEvent(cap, EVENT_CREATE_SPARK_THREAD, 0, spark_tid);
- dtraceCreateSparkThread((EventCapNo)cap->no, (EventThreadID)spark_tid);
-}
-
INLINE_HEADER void traceEventStartup(void)
{
int n_caps;
@@ -496,10 +499,17 @@ INLINE_HEADER void traceOSProcessInfo(void)
* is available to DTrace directly */
}
+INLINE_HEADER void traceEventCreateSparkThread(Capability *cap STG_UNUSED,
+ StgThreadID spark_tid STG_UNUSED)
+{
+ traceSparkEvent2(cap, EVENT_CREATE_SPARK_THREAD, spark_tid);
+ dtraceCreateSparkThread((EventCapNo)cap->no, (EventThreadID)spark_tid);
+}
+
INLINE_HEADER void traceSparkCounters(Capability *cap STG_UNUSED)
{
#ifdef THREADED_RTS
- if (RTS_UNLIKELY(TRACE_spark)) {
+ if (RTS_UNLIKELY(TRACE_spark_sampled)) {
traceSparkCounters_(cap, cap->spark_stats, sparkPoolSize(cap->sparks));
}
#endif
@@ -513,6 +523,48 @@ INLINE_HEADER void traceSparkCounters(Capability *cap STG_UNUSED)
sparkPoolSize(cap->sparks));
}
+INLINE_HEADER void traceEventSparkCreate(Capability *cap STG_UNUSED)
+{
+ traceSparkEvent(cap, EVENT_SPARK_CREATE);
+ dtraceSparkCreate((EventCapNo)cap->no);
+}
+
+INLINE_HEADER void traceEventSparkDud(Capability *cap STG_UNUSED)
+{
+ traceSparkEvent(cap, EVENT_SPARK_DUD);
+ dtraceSparkDud((EventCapNo)cap->no);
+}
+
+INLINE_HEADER void traceEventSparkOverflow(Capability *cap STG_UNUSED)
+{
+ traceSparkEvent(cap, EVENT_SPARK_OVERFLOW);
+ dtraceSparkOverflow((EventCapNo)cap->no);
+}
+
+INLINE_HEADER void traceEventSparkRun(Capability *cap STG_UNUSED)
+{
+ traceSparkEvent(cap, EVENT_SPARK_RUN);
+ dtraceSparkRun((EventCapNo)cap->no);
+}
+
+INLINE_HEADER void traceEventSparkSteal(Capability *cap STG_UNUSED,
+ nat victim_cap STG_UNUSED)
+{
+ traceSparkEvent2(cap, EVENT_SPARK_STEAL, victim_cap);
+ dtraceSparkSteal((EventCapNo)cap->no, (EventCapNo)victim_cap);
+}
+
+INLINE_HEADER void traceEventSparkFizzle(Capability *cap STG_UNUSED)
+{
+ traceSparkEvent(cap, EVENT_SPARK_FIZZLE);
+ dtraceSparkFizzle((EventCapNo)cap->no);
+}
+
+INLINE_HEADER void traceEventSparkGC(Capability *cap STG_UNUSED)
+{
+ traceSparkEvent(cap, EVENT_SPARK_GC);
+ dtraceSparkGc((EventCapNo)cap->no);
+}
#include "EndPrivate.h"