• Duncan Coutts's avatar
    Emit final heap alloc events and rearrange code to calculate alloc totals · 1f809ce6
    Duncan Coutts authored
    In stat_exit we want to emit a final EVENT_HEAP_ALLOCATED for each cap
    so that we get the same total allocation count as reported via +RTS -s.
    To do so we need to update the per-cap total_allocated counts.
    
    Previously we had a single calcAllocated(rtsBool) function that counted
    the large allocations and optionally the nurseries for all caps. The GC
    would always call it with false, and the stat_exit always with true.
    The reason for these two modes is that the GC counts the nurseries via
    clearNurseries() (which also updates the per-cap total_allocated
    counts), so it's only the stat_exit() path that needs to count them.
    
    We now split the calcAllocated() function into two: countLargeAllocated
    and updateNurseriesStats. As the name suggests, the latter now updates
    the per-cap total_allocated counts, in additon to returning a total.
    1f809ce6
Stats.c 31.3 KB