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 /libraries | |
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 'libraries')
-rw-r--r-- | libraries/base/GHC/Stats.hsc | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/libraries/base/GHC/Stats.hsc b/libraries/base/GHC/Stats.hsc index c4e2e809f8..58fb12592f 100644 --- a/libraries/base/GHC/Stats.hsc +++ b/libraries/base/GHC/Stats.hsc @@ -81,8 +81,10 @@ data RTSStats = RTSStats { , copied_bytes :: Word64 -- | Sum of copied_bytes across all parallel GCs , par_copied_bytes :: Word64 - -- | Sum of par_max_copied_bytes across all parallel GCs + -- | Sum of par_max_copied_bytes across all parallel GCs. Deprecated. , cumulative_par_max_copied_bytes :: Word64 + -- | Sum of par_balanced_copied bytes across all parallel GCs + , cumulative_par_balanced_copied_bytes :: Word64 -- ----------------------------------- -- Cumulative stats about time use @@ -130,8 +132,11 @@ data GCDetails = GCDetails { , gcdetails_mem_in_use_bytes :: Word64 -- | Total amount of data copied during this GC , gcdetails_copied_bytes :: Word64 - -- | In parallel GC, the max amount of data copied by any one thread + -- | In parallel GC, the max amount of data copied by any one thread. + -- Deprecated. , gcdetails_par_max_copied_bytes :: Word64 + -- | In parallel GC, the amount of balanced data copied by all threads + , gcdetails_par_balanced_copied_bytes :: Word64 -- | The time elapsed during synchronisation before GC , gcdetails_sync_elapsed_ns :: RtsTime -- | The CPU time used during GC itself @@ -170,6 +175,8 @@ getRTSStats = do par_copied_bytes <- (# peek RTSStats, par_copied_bytes) p cumulative_par_max_copied_bytes <- (# peek RTSStats, cumulative_par_max_copied_bytes) p + cumulative_par_balanced_copied_bytes <- + (# peek RTSStats, cumulative_par_balanced_copied_bytes) p mutator_cpu_ns <- (# peek RTSStats, mutator_cpu_ns) p mutator_elapsed_ns <- (# peek RTSStats, mutator_elapsed_ns) p gc_cpu_ns <- (# peek RTSStats, gc_cpu_ns) p @@ -190,6 +197,8 @@ getRTSStats = do gcdetails_copied_bytes <- (# peek GCDetails, copied_bytes) pgc gcdetails_par_max_copied_bytes <- (# peek GCDetails, par_max_copied_bytes) pgc + gcdetails_par_balanced_copied_bytes <- + (# peek GCDetails, par_balanced_copied_bytes) pgc gcdetails_sync_elapsed_ns <- (# peek GCDetails, sync_elapsed_ns) pgc gcdetails_cpu_ns <- (# peek GCDetails, cpu_ns) pgc gcdetails_elapsed_ns <- (# peek GCDetails, elapsed_ns) pgc @@ -259,8 +268,19 @@ data GCStats = GCStats -- thread each GC. The ratio of 'parTotBytesCopied' divided by -- 'parMaxBytesCopied' approaches 1 for a maximally sequential -- run and approaches the number of threads (set by the RTS flag - -- @-N@) for a maximally parallel run. + -- @-N@) for a maximally parallel run. This is included for + -- backwards compatibility; to compute work balance use + -- `parBalancedBytesCopied`. , parMaxBytesCopied :: !Int64 + + -- | Sum of number of balanced bytes copied on each thread of each GC. + -- Balanced bytes are those up to a + -- limit = (parTotBytesCopied / num_gc_threads). + -- This number is normalized so that when balance is perfect + -- @parBalancedBytesCopied = parTotBytesCopied@ and when all + -- gc is done by a single thread @parBalancedBytesCopied = 0@. + , parBalancedBytesCopied :: !Int64 + } deriving (Show, Read) -- | Retrieves garbage collection and memory statistics as of the last @@ -306,6 +326,8 @@ getGCStats = do wallSeconds <- nsToSecs <$> (# peek RTSStats, elapsed_ns) p parTotBytesCopied <- (# peek RTSStats, par_copied_bytes) p parMaxBytesCopied <- (# peek RTSStats, cumulative_par_max_copied_bytes) p + parBalancedBytesCopied <- + (# peek RTSStats, cumulative_par_balanced_copied_bytes) p return GCStats { .. } nsToSecs :: Int64 -> Double |