Skip to content

Provide minor GC residency estimates

Currently, the residency statistics (e.g. max residency and current residency) are only updated when a major garbage collection occurs. While this is the only way to ensure an accurate residency count, there are times when a residency estimate would be desirable, since only taking the sample on major GC can be somewhat low resolution. We already collect and report this information on verbose GC stats, so all that needs to be done is to expose it via GHC.Stats. Should be an easy patch, good for someone who wants to play around in the RTS.

Here is a simple patch that switches residency to the inaccurate version:

diff --git a/rts/Stats.c b/rts/Stats.c
index c19f23c..c71d0fb 100644
--- a/rts/Stats.c
+++ b/rts/Stats.c
@@ -449,7 +449,6 @@ stat_endGC (Capability *cap, gc_thread *gct,
                           CAPSET_HEAP_DEFAULT,
                           mblocks_allocated * MBLOCK_SIZE_W * sizeof(W_));
 
-       if (gen == RtsFlags.GcFlags.generations-1) { /* major GC? */
            if (live > max_residency) {
                max_residency = live;
            }
@@ -459,7 +458,6 @@ stat_endGC (Capability *cap, gc_thread *gct,
            traceEventHeapLive(cap, 
                               CAPSET_HEAP_DEFAULT,
                               live * sizeof(W_));
-       }
 
         if (slop > max_slop) max_slop = slop;
     }
Trac metadata
Trac field Value
Version 7.7
Type FeatureRequest
TypeOfFailure OtherFailure
Priority lowest
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC simonmar
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information