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/sm/BlockAlloc.c | |
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/sm/BlockAlloc.c')
-rw-r--r-- | rts/sm/BlockAlloc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c index 451c182ac3..6e67f2cc8d 100644 --- a/rts/sm/BlockAlloc.c +++ b/rts/sm/BlockAlloc.c @@ -984,11 +984,14 @@ countAllocdBlocks(bdescr *bd) return n; } -void returnMemoryToOS(uint32_t n /* megablocks */) +// Returns the number of blocks which were able to be freed +uint32_t returnMemoryToOS(uint32_t n /* megablocks */) { bdescr *bd; uint32_t node; StgWord size; + uint32_t init_n; + init_n = n; // ToDo: not fair, we free all the memory starting with node 0. for (node = 0; n > 0 && node < n_numa_nodes; node++) { @@ -1028,6 +1031,7 @@ void returnMemoryToOS(uint32_t n /* megablocks */) n); } ); + return (init_n - n); } /* ----------------------------------------------------------------------------- |