[commit: ghc] wip/T16185: Fix negative mutator time in GC stats in prof builds (19670bc)

git at git.haskell.org git at git.haskell.org
Tue Jan 15 17:43:02 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T16185
Link       : http://ghc.haskell.org/trac/ghc/changeset/19670bc397d858b04eb9b4eb01480f7f8c59e2f5/ghc

>---------------------------------------------------------------

commit 19670bc397d858b04eb9b4eb01480f7f8c59e2f5
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Fri Dec 28 13:51:28 2018 +0300

    Fix negative mutator time in GC stats in prof builds
    
    Because garbage collector calls `retainerProfile()` and `heapCensus()`,
    GC times normally include some of PROF times too. To fix this we have
    these lines:
    
        // heapCensus() is called by the GC, so RP and HC time are
        // included in the GC stats.  We therefore subtract them to
        // obtain the actual GC cpu time.
        stats.gc_cpu_ns      -=  prof_cpu;
        stats.gc_elapsed_ns  -=  prof_elapsed;
    
    These variables are later used for calculating GC time excluding the
    final GC (which should be attributed to EXIT).
    
        exit_gc_elapsed      = stats.gc_elapsed_ns - start_exit_gc_elapsed;
    
    The problem is if we subtract PROF times from `gc_elapsed_ns` and then
    subtract `start_exit_gc_elapsed` from the result, we end up subtracting
    PROF times twice, because `start_exit_gc_elapsed` also includes PROF
    times.
    
    We now subtract PROF times from GC after the calculations for EXIT and
    MUT times. The existing assertion that checks
    
        INIT + MUT + GC + EXIT = TOTAL
    
    now holds. When we subtract PROF numbers from GC, and a new assertion
    
        INIT + MUT + GC + PROF + EXIT = TOTAL
    
    also holds.
    
    Fixes #15897. New assertions added in this commit also revealed #16102,
    which is also fixed by this commit.


>---------------------------------------------------------------

19670bc397d858b04eb9b4eb01480f7f8c59e2f5
 rts/Schedule.c                                 |   4 +
 rts/Stats.c                                    | 114 ++++++++++++++-----------
 rts/Stats.h                                    |   1 +
 testsuite/tests/profiling/should_run/Makefile  |   8 ++
 testsuite/tests/profiling/should_run/T15897.hs |   7 ++
 testsuite/tests/profiling/should_run/all.T     |   5 ++
 6 files changed, 90 insertions(+), 49 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 19670bc397d858b04eb9b4eb01480f7f8c59e2f5


More information about the ghc-commits mailing list