diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-04-13 21:12:53 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-11-21 13:13:29 -0500 |
commit | 7e93ae8b2257c17d5ae5ef7832db723e897c8e8b (patch) | |
tree | 89e8f5af3d57e78177da45d13a3037912ad9eb7d /rts/eventlog | |
parent | 69bfbc216c2278c9796aa999c7815c19c12b0f2c (diff) | |
download | haskell-7e93ae8b2257c17d5ae5ef7832db723e897c8e8b.tar.gz |
rts: Post ticky entry counts to the eventlog
We currently only post the entry counters, not the other global
counters as in my experience the former are more useful. We use the heap
profiler's census period to decide when to dump.
Also spruces up the documentation surrounding ticky-ticky a bit.
Diffstat (limited to 'rts/eventlog')
-rw-r--r-- | rts/eventlog/EventLog.c | 59 | ||||
-rw-r--r-- | rts/eventlog/EventLog.h | 5 |
2 files changed, 63 insertions, 1 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 11e8a5e0b6..d093d595c7 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -119,7 +119,9 @@ char *EventDesc[] = { [EVENT_CONC_SWEEP_BEGIN] = "Begin concurrent sweep", [EVENT_CONC_SWEEP_END] = "End concurrent sweep", [EVENT_CONC_UPD_REM_SET_FLUSH] = "Update remembered set flushed", - [EVENT_NONMOVING_HEAP_CENSUS] = "Nonmoving heap census" + [EVENT_NONMOVING_HEAP_CENSUS] = "Nonmoving heap census", + [EVENT_TICKY_COUNTER_DEF] = "Ticky-ticky entry counter definition", + [EVENT_TICKY_COUNTER_SAMPLE] = "Ticky-ticky entry counter sample", }; // Event type. @@ -487,6 +489,14 @@ init_event_types(void) eventTypes[t].size = 13; break; + case EVENT_TICKY_COUNTER_DEF: // (counter_id, arity, arg_kinds, name) + eventTypes[t].size = EVENT_SIZE_DYNAMIC; + break; + + case EVENT_TICKY_COUNTER_SAMPLE: // (counter_id, entry_count, allocs, allocd) + eventTypes[t].size = 8*4; + break; + default: continue; /* ignore deprecated events */ } @@ -1472,6 +1482,53 @@ void postProfBegin(void) } #endif /* PROFILING */ +#if defined(TICKY_TICKY) +static void postTickyCounterDef(EventsBuf *eb, StgEntCounter *p) +{ + StgWord len = 8 + 2 + strlen(p->arg_kinds)+1 + strlen(p->str)+1; + ensureRoomForVariableEvent(eb, len); + postEventHeader(eb, EVENT_TICKY_COUNTER_DEF); + postPayloadSize(eb, len); + postWord64(eb, (uint64_t) p); + postWord16(eb, (uint16_t) p->arity); + postString(eb, p->arg_kinds); + postString(eb, p->str); +} + +void postTickyCounterDefs(StgEntCounter *counters) +{ + ACQUIRE_LOCK(&eventBufMutex); + for (StgEntCounter *p = counters; p != NULL; p = p->link) { + postTickyCounterDef(&eventBuf, p); + } + RELEASE_LOCK(&eventBufMutex); +} + +static void postTickyCounterSample(EventsBuf *eb, StgEntCounter *p) +{ + if ( p->entry_count == 0 + && p->allocs == 0 + && p->allocd == 0) + return; + + ensureRoomForEvent(eb, EVENT_TICKY_COUNTER_SAMPLE); + postEventHeader(eb, EVENT_TICKY_COUNTER_SAMPLE); + postWord64(eb, (uint64_t) p); + postWord64(eb, p->entry_count); + postWord64(eb, p->allocs); + postWord64(eb, p->allocd); +} + +void postTickyCounterSamples(StgEntCounter *counters) +{ + ACQUIRE_LOCK(&eventBufMutex); + for (StgEntCounter *p = counters; p != NULL; p = p->link) { + postTickyCounterSample(&eventBuf, p); + } + RELEASE_LOCK(&eventBufMutex); +} +#endif /* TICKY_TICKY */ + void printAndClearEventBuf (EventsBuf *ebuf) { closeBlockMarker(ebuf); diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h index eca76619cd..cf94a25ed6 100644 --- a/rts/eventlog/EventLog.h +++ b/rts/eventlog/EventLog.h @@ -173,6 +173,11 @@ void postConcMarkEnd(StgWord32 marked_obj_count); void postNonmovingHeapCensus(int log_blk_size, const struct NonmovingAllocCensus *census); +#if defined(TICKY_TICKY) +void postTickyCounterDefs(StgEntCounter *p); +void postTickyCounterSamples(StgEntCounter *p); +#endif /* TICKY_TICKY */ + #else /* !TRACING */ INLINE_HEADER void postSchedEvent (Capability *cap STG_UNUSED, |