diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-02-26 15:40:18 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-08 07:32:15 -0500 |
commit | 33a4fd9939f8fc8e9ba4e61041270353f51ae55e (patch) | |
tree | 8bc3624fc179d11dc68a504646bae97b1ce48dcb /rts/eventlog | |
parent | 657b5538904f7d9e0b3ea5d84f4017af3c513df9 (diff) | |
download | haskell-33a4fd9939f8fc8e9ba4e61041270353f51ae55e.tar.gz |
eventlog: Add MEM_RETURN event to give information about fragmentation
See #19357
The event reports the
* Current number of megablocks allocated
* The number that the RTS thinks it needs
* The number is managed to return to the OS
When current > need then the difference is returned to the OS, the
successful number of returned mblocks is reported by 'returned'.
In a fragmented heap current > need but returned < current - need.
Diffstat (limited to 'rts/eventlog')
-rw-r--r-- | rts/eventlog/EventLog.c | 22 | ||||
-rw-r--r-- | rts/eventlog/EventLog.h | 7 |
2 files changed, 29 insertions, 0 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 0a1ed09f6f..237c9bad9d 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -129,6 +129,7 @@ char *EventDesc[] = { [EVENT_REQUEST_PAR_GC] = "Request parallel GC", [EVENT_GC_GLOBAL_SYNC] = "Synchronise stop-the-world GC", [EVENT_GC_STATS_GHC] = "GC statistics", + [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", @@ -466,6 +467,11 @@ init_event_types(void) + sizeof(StgWord32) + sizeof(StgWord64) * 3; break; + case EVENT_MEM_RETURN: // (heap_capset, current_mblocks + // , needed_mblocks, returned_mblocks) + eventTypes[t].size = sizeof(EventCapsetID) + + sizeof(StgWord32) * 3; + break; case EVENT_TASK_CREATE: // (taskId, cap, tid) eventTypes[t].size = sizeof(EventTaskId) @@ -1159,6 +1165,22 @@ void postEventGcStats (Capability *cap, postWord64(eb, par_balanced_copied); } +void postEventMemReturn (Capability *cap, + EventCapsetID heap_capset, + uint32_t current_mblocks, + uint32_t needed_mblocks, + uint32_t returned_mblocks) +{ + EventsBuf *eb = &capEventBuf[cap->no]; + ensureRoomForEvent(eb, EVENT_MEM_RETURN); + + postEventHeader(eb, EVENT_MEM_RETURN); + postCapsetID(eb, heap_capset); + postWord32(eb, current_mblocks); + postWord32(eb, needed_mblocks); + postWord32(eb, returned_mblocks); +} + void postTaskCreateEvent (EventTaskId taskId, EventCapNo capno, EventKernelThreadId tid) diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h index b0675db14d..9d3795f3ff 100644 --- a/rts/eventlog/EventLog.h +++ b/rts/eventlog/EventLog.h @@ -134,6 +134,13 @@ void postEventGcStats (Capability *cap, W_ par_tot_copied, W_ par_balanced_copied); +void postEventMemReturn (Capability *cap, + EventCapsetID heap_capset, + uint32_t current_mblocks, + uint32_t needed_mblocks, + uint32_t returned_mblocks + ); + void postTaskCreateEvent (EventTaskId taskId, EventCapNo cap, EventKernelThreadId tid); |