diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-02-26 16:08:18 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-08 07:32:15 -0500 |
commit | ffc9643986bc83429c78910135614e830a131a7d (patch) | |
tree | d230aacf66f588a85b21e4392343a98fa3297601 /rts | |
parent | 33a4fd9939f8fc8e9ba4e61041270353f51ae55e (diff) | |
download | haskell-ffc9643986bc83429c78910135614e830a131a7d.tar.gz |
eventlog: Add BLOCKS_SIZE event
The BLOCKS_SIZE event reports the size of the currently allocated blocks
in bytes.
It is like the HEAP_SIZE event, but reports about the blocks rather than
megablocks.
You can work out the current heap fragmentation by looking at the
difference between HEAP_SIZE and BLOCKS_SIZE.
Fixes #19357
Diffstat (limited to 'rts')
-rw-r--r-- | rts/RtsProbes.d | 1 | ||||
-rw-r--r-- | rts/Stats.c | 3 | ||||
-rw-r--r-- | rts/Trace.h | 11 | ||||
-rw-r--r-- | rts/eventlog/EventLog.c | 5 |
4 files changed, 19 insertions, 1 deletions
diff --git a/rts/RtsProbes.d b/rts/RtsProbes.d index e7b39e5a15..2a21ec9099 100644 --- a/rts/RtsProbes.d +++ b/rts/RtsProbes.d @@ -75,6 +75,7 @@ provider HaskellEvent { probe heap__allocated (EventCapNo, EventCapsetID, StgWord64); probe heap__size (EventCapsetID, StgWord); probe heap__live (EventCapsetID, StgWord); + probe blocks__size (EventCapsetID, StgWord); /* capability events */ probe startup (EventCapNo); diff --git a/rts/Stats.c b/rts/Stats.c index 2770696b66..55e05974f5 100644 --- a/rts/Stats.c +++ b/rts/Stats.c @@ -633,6 +633,9 @@ stat_endGC (Capability *cap, gc_thread *initiating_gct, W_ live, W_ copied, W_ s traceEventHeapSize(cap, CAPSET_HEAP_DEFAULT, mblocks_allocated * MBLOCK_SIZE); + traceEventBlocksSize(cap, + CAPSET_HEAP_DEFAULT, + n_alloc_blocks * BLOCK_SIZE); } RELEASE_LOCK(&stats_mutex); } diff --git a/rts/Trace.h b/rts/Trace.h index eed362e7b6..a4b4cc173b 100644 --- a/rts/Trace.h +++ b/rts/Trace.h @@ -473,6 +473,8 @@ void dtraceUserMarkerWrapper(Capability *cap, char *msg); allocated) #define dtraceEventHeapSize(heap_capset, size) \ HASKELLEVENT_HEAP_SIZE(heap_capset, size) +#define dtraceEventBlocksSize(heap_capset, size) \ + HASKELLEVENT_BLOCKS_SIZE(heap_capset, size) #define dtraceEventHeapLive(heap_capset, live) \ HASKELLEVENT_HEAP_LIVE(heap_capset, live) #define dtraceCapsetCreate(capset, capset_type) \ @@ -539,6 +541,7 @@ void dtraceUserMarkerWrapper(Capability *cap, char *msg); #define dtraceEventHeapAllocated(cap, heap_capset, \ allocated) /* nothing */ #define dtraceEventHeapSize(heap_capset, size) /* nothing */ +#define dtraceEventBlocksSize(heap_capset, size) /* nothing */ #define dtraceEventHeapLive(heap_capset, live) /* nothing */ #define dtraceCapCreate(cap) /* nothing */ #define dtraceCapDelete(cap) /* nothing */ @@ -796,6 +799,14 @@ INLINE_HEADER void traceEventHeapSize(Capability *cap STG_UNUSED, dtraceEventHeapSize(heap_capset, heap_size); } +INLINE_HEADER void traceEventBlocksSize(Capability *cap STG_UNUSED, + CapsetID heap_capset STG_UNUSED, + W_ heap_size STG_UNUSED) +{ + traceHeapEvent(cap, EVENT_BLOCKS_SIZE, heap_capset, heap_size); + dtraceEventBlocksSize(heap_capset, heap_size); +} + INLINE_HEADER void traceEventHeapLive(Capability *cap STG_UNUSED, CapsetID heap_capset STG_UNUSED, W_ heap_live STG_UNUSED) diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 237c9bad9d..ebb44a7c9e 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -132,7 +132,8 @@ char *EventDesc[] = { [EVENT_MEM_RETURN] = "Memory return statistics", [EVENT_HEAP_INFO_GHC] = "Heap static parameters", [EVENT_HEAP_ALLOCATED] = "Total heap mem ever allocated", - [EVENT_HEAP_SIZE] = "Current heap size", + [EVENT_HEAP_SIZE] = "Current heap size (size of allocated mblocks)", + [EVENT_BLOCKS_SIZE] = "Current heap size (size of allocated blocks)", [EVENT_HEAP_LIVE] = "Current heap live data", [EVENT_CREATE_SPARK_THREAD] = "Create spark thread", [EVENT_LOG_MSG] = "Log message", @@ -443,6 +444,7 @@ init_event_types(void) case EVENT_HEAP_ALLOCATED: // (heap_capset, alloc_bytes) case EVENT_HEAP_SIZE: // (heap_capset, size_bytes) + case EVENT_BLOCKS_SIZE: // (heap_capset, size_bytes) case EVENT_HEAP_LIVE: // (heap_capset, live_bytes) eventTypes[t].size = sizeof(EventCapsetID) + sizeof(StgWord64); break; @@ -1099,6 +1101,7 @@ void postHeapEvent (Capability *cap, switch (tag) { case EVENT_HEAP_ALLOCATED: // (heap_capset, alloc_bytes) case EVENT_HEAP_SIZE: // (heap_capset, size_bytes) + case EVENT_BLOCKS_SIZE: // (heap_capset, size_bytes) case EVENT_HEAP_LIVE: // (heap_capset, live_bytes) { postCapsetID(eb, heap_capset); |