diff --git a/includes/rts/EventLogFormat.h b/includes/rts/EventLogFormat.h index 667ed89eb1f3407be9c10dbc944864976b045531..b1933562dafb3dbf904a019fb153dfad8e70a699 100644 --- a/includes/rts/EventLogFormat.h +++ b/includes/rts/EventLogFormat.h @@ -157,8 +157,9 @@ copied_bytes, slop_bytes, frag_bytes, par_n_threads, par_max_copied, par_tot_copied) */ +#define EVENT_GC_GLOBAL_SYNC 54 /* () */ -/* Range 54 - 59 is available for new GHC and common events */ +/* Range 55 - 59 is available for new GHC and common events */ /* Range 60 - 80 is used by eden for parallel tracing * see http://www.mathematik.uni-marburg.de/~eden/ @@ -171,7 +172,7 @@ * ranges higher than this are reserved but not currently emitted by ghc. * This must match the size of the EventDesc[] array in EventLog.c */ -#define NUM_GHC_EVENT_TAGS 54 +#define NUM_GHC_EVENT_TAGS 55 #if 0 /* DEPRECATED EVENTS: */ /* we don't actually need to record the thread, it's implicit */ diff --git a/rts/RtsProbes.d b/rts/RtsProbes.d index 8d24f3a9ca04c71197cdcab39755e832be50575f..f5470dfe0b2b56b0d0a45832da003e7a7377eda6 100644 --- a/rts/RtsProbes.d +++ b/rts/RtsProbes.d @@ -55,6 +55,7 @@ provider HaskellEvent { probe gc__idle (EventCapNo); probe gc__work (EventCapNo); probe gc__done (EventCapNo); + probe gc__sync (EventCapNo); probe gc__stats (CapsetID, StgWord, StgWord, StgWord, StgWord, StgWord, StgWord, StgWord); probe heap__info (CapsetID, StgWord, StgWord, StgWord, StgWord, StgWord); probe heap__allocated (EventCapNo, CapsetID, StgWord64); diff --git a/rts/Stats.c b/rts/Stats.c index ddc9bb96aec8c2f82726f51df5709f6192af3065..cebb75343f2b3937ec3dbe2b57175bf79c7efcc4 100644 --- a/rts/Stats.c +++ b/rts/Stats.c @@ -349,6 +349,13 @@ stat_endGC (Capability *cap, gc_thread *gct, { Time cpu, elapsed, gc_cpu, gc_elapsed; + // Has to be emitted while all caps stopped for GC, but before GC_END. + // See trac.haskell.org/ThreadScope/wiki/RTSsummaryEvents + // for a detailed design rationale of the current setup + // of GC eventlog events. + traceEventGcGlobalSync(cap); + + // Emitted before GC_END on all caps, which simplifies tools code. traceEventGcStats(cap, CAPSET_HEAP_DEFAULT, gen, @@ -360,7 +367,7 @@ stat_endGC (Capability *cap, gc_thread *gct, par_n_threads, par_max_copied * sizeof(W_), par_tot_copied * sizeof(W_)); - + getProcessTimes(&cpu, &elapsed); // Post EVENT_GC_END with the same timestamp as used for stats diff --git a/rts/Trace.c b/rts/Trace.c index 995f8a2200ad32996faf41dfee12d79082cc8e8e..089bf24423bbf52b963828e804fdd3211df00070 100644 --- a/rts/Trace.c +++ b/rts/Trace.c @@ -282,6 +282,9 @@ static void traceGcEvent_stderr (Capability *cap, EventTypeNum tag) case EVENT_GC_DONE: // (cap) debugBelch("cap %d: GC done\n", cap->no); break; + case EVENT_GC_GLOBAL_SYNC: // (cap) + debugBelch("cap %d: all caps stopped for GC\n", cap->no); + break; default: barf("traceGcEvent: unknown event tag %d", tag); break; diff --git a/rts/Trace.h b/rts/Trace.h index 062666b50358f05e5af8080be9c0d7124158c7fd..c4c4e41608d8c62e5f4f046842977cd9ff5834ae 100644 --- a/rts/Trace.h +++ b/rts/Trace.h @@ -350,6 +350,8 @@ INLINE_HEADER void dtraceStartup (int num_caps) { HASKELLEVENT_GC_WORK(cap) #define dtraceGcDone(cap) \ HASKELLEVENT_GC_DONE(cap) +#define dtraceGcGlobalSync(cap) \ + HASKELLEVENT_GC_GLOBAL_SYNC(cap) #define dtraceEventGcStats(heap_capset, gens, \ copies, slop, fragmentation, \ par_n_threads, \ @@ -419,6 +421,7 @@ INLINE_HEADER void dtraceStartup (int num_caps STG_UNUSED) {}; #define dtraceGcIdle(cap) /* nothing */ #define dtraceGcWork(cap) /* nothing */ #define dtraceGcDone(cap) /* nothing */ +#define dtraceGcGlobalSync(cap) /* nothing */ #define dtraceEventGcStats(heap_capset, gens, \ copies, slop, fragmentation, \ par_n_threads, \ @@ -610,6 +613,12 @@ INLINE_HEADER void traceEventGcDone(Capability *cap STG_UNUSED) dtraceGcDone((EventCapNo)cap->no); } +INLINE_HEADER void traceEventGcGlobalSync(Capability *cap STG_UNUSED) +{ + traceGcEvent(cap, EVENT_GC_GLOBAL_SYNC); + dtraceGcGlobalSync((EventCapNo)cap->no); +} + INLINE_HEADER void traceEventGcStats(Capability *cap STG_UNUSED, CapsetID heap_capset STG_UNUSED, nat gen STG_UNUSED, diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index aab93bbd920d8602b387776a5d8742a2740f0b5e..a3103775d918852fdfbb6ddfcf6e1315c822d04d 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -71,6 +71,7 @@ char *EventDesc[] = { [EVENT_GC_END] = "Finished GC", [EVENT_REQUEST_SEQ_GC] = "Request sequential GC", [EVENT_REQUEST_PAR_GC] = "Request parallel GC", + [EVENT_GC_GLOBAL_SYNC] = "Synchronise stop-the-world GC", [EVENT_GC_STATS_GHC] = "GC statistics", [EVENT_HEAP_INFO_GHC] = "Heap static parameters", [EVENT_HEAP_ALLOCATED] = "Total heap mem ever allocated", @@ -341,6 +342,7 @@ initEventLogging(void) case EVENT_GC_IDLE: case EVENT_GC_WORK: case EVENT_GC_DONE: + case EVENT_GC_GLOBAL_SYNC: // (cap) case EVENT_SPARK_CREATE: // (cap) case EVENT_SPARK_DUD: // (cap) case EVENT_SPARK_OVERFLOW: // (cap)