diff options
author | Douglas Wilson <douglas.wilson@gmail.com> | 2017-07-11 11:54:09 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-07-11 13:41:54 -0400 |
commit | 7c9e356de1114ab3e31f2d6d03e83672076dd533 (patch) | |
tree | 5a89a142a31a53486e41c75673024548ce4c39ce /rts/sm | |
parent | 905dc8bc74bebf5370eb9237cc8756cd9fe871ae (diff) | |
download | haskell-7c9e356de1114ab3e31f2d6d03e83672076dd533.tar.gz |
Fix Work Balance computation in RTS stats
An additional stat is tracked per gc: par_balanced_copied This is the
the number of bytes copied by each gc thread under the balanced lmit,
which is simply (copied_bytes / num_gc_threads). The stat is added to
all the appropriate GC structures, so is visible in the eventlog and in
GHC.Stats.
A note is added explaining how work balance is computed.
Remove some end of line whitespace
Test Plan:
./validate
experiment with the program attached to the ticket
examine code changes carefully
Reviewers: simonmar, austin, hvr, bgamari, erikd
Reviewed By: simonmar
Subscribers: Phyx, rwbarton, thomie
GHC Trac Issues: #13830
Differential Revision: https://phabricator.haskell.org/D3658
Diffstat (limited to 'rts/sm')
-rw-r--r-- | rts/sm/GC.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c index 515a7fe6d8..aa804a8b76 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -188,7 +188,7 @@ GarbageCollect (uint32_t collect_gen, { bdescr *bd; generation *gen; - StgWord live_blocks, live_words, par_max_copied; + StgWord live_blocks, live_words, par_max_copied, par_balanced_copied; #if defined(THREADED_RTS) gc_thread *saved_gct; #endif @@ -460,8 +460,14 @@ GarbageCollect (uint32_t collect_gen, copied = 0; par_max_copied = 0; + par_balanced_copied = 0; { uint32_t i; + uint64_t par_balanced_copied_acc = 0; + + for (i=0; i < n_gc_threads; i++) { + copied += gc_threads[i]->copied; + } for (i=0; i < n_gc_threads; i++) { if (n_gc_threads > 1) { debugTrace(DEBUG_gc,"thread %d:", i); @@ -471,11 +477,20 @@ GarbageCollect (uint32_t collect_gen, debugTrace(DEBUG_gc," no_work %ld", gc_threads[i]->no_work); debugTrace(DEBUG_gc," scav_find_work %ld", gc_threads[i]->scav_find_work); } - copied += gc_threads[i]->copied; par_max_copied = stg_max(gc_threads[i]->copied, par_max_copied); + par_balanced_copied_acc += + stg_min(n_gc_threads * gc_threads[i]->copied, copied); } if (n_gc_threads == 1) { par_max_copied = 0; + par_balanced_copied = 0; + } + else + { + // See Note [Work Balance] for an explanation of this computation + par_balanced_copied = + (par_balanced_copied_acc - copied + (n_gc_threads - 1) / 2) / + (n_gc_threads - 1); } } @@ -782,7 +797,7 @@ GarbageCollect (uint32_t collect_gen, // ok, GC over: tell the stats department what happened. stat_endGC(cap, gct, live_words, copied, live_blocks * BLOCK_SIZE_W - live_words /* slop */, - N, n_gc_threads, par_max_copied); + N, n_gc_threads, par_max_copied, par_balanced_copied); #if defined(RTS_USER_SIGNALS) if (RtsFlags.MiscFlags.install_signal_handlers) { |