Commit 074cfe0e authored by Ben Gamari's avatar Ben Gamari 🐢

rts/Stats: Track time usage of nonmoving collector

parent 3748326f
...@@ -151,6 +151,23 @@ typedef struct GCDetails_ { ...@@ -151,6 +151,23 @@ typedef struct GCDetails_ {
Time cpu_ns; Time cpu_ns;
// The time elapsed during GC itself // The time elapsed during GC itself
Time elapsed_ns; Time elapsed_ns;
//
// Concurrent garbage collector
//
// The CPU time used during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_sync_cpu_ns;
// The time elapsed during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_sync_elapsed_ns;
// The CPU time used during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_cpu_ns;
// The time elapsed during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_elapsed_ns;
} GCDetails; } GCDetails;
// //
...@@ -241,6 +258,28 @@ typedef struct _RTSStats { ...@@ -241,6 +258,28 @@ typedef struct _RTSStats {
// The number of times a GC thread has iterated it's outer loop across all // The number of times a GC thread has iterated it's outer loop across all
// parallel GCs // parallel GCs
uint64_t scav_find_work; uint64_t scav_find_work;
// ----------------------------------
// Concurrent garbage collector
// The CPU time used during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_sync_cpu_ns;
// The time elapsed during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_sync_elapsed_ns;
// The maximum time elapsed during the post-mark pause phase of the
// concurrent nonmoving GC.
Time nonmoving_gc_sync_max_elapsed_ns;
// The CPU time used during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_cpu_ns;
// The time elapsed during the post-mark pause phase of the concurrent
// nonmoving GC.
Time nonmoving_gc_elapsed_ns;
// The maximum time elapsed during the post-mark pause phase of the
// concurrent nonmoving GC.
Time nonmoving_gc_max_elapsed_ns;
} RTSStats; } RTSStats;
void getRTSStats (RTSStats *s); void getRTSStats (RTSStats *s);
......
...@@ -103,6 +103,25 @@ data RTSStats = RTSStats { ...@@ -103,6 +103,25 @@ data RTSStats = RTSStats {
-- | Total elapsed time (at the previous GC) -- | Total elapsed time (at the previous GC)
, elapsed_ns :: RtsTime , elapsed_ns :: RtsTime
-- | The CPU time used during the post-mark pause phase of the concurrent
-- nonmoving GC.
, nonmoving_gc_sync_cpu_ns :: RtsTime
-- | The time elapsed during the post-mark pause phase of the concurrent
-- nonmoving GC.
, nonmoving_gc_sync_elapsed_ns :: RtsTime
-- | The maximum time elapsed during the post-mark pause phase of the
-- concurrent nonmoving GC.
, nonmoving_gc_sync_max_elapsed_ns :: RtsTime
-- | The CPU time used during the post-mark pause phase of the concurrent
-- nonmoving GC.
, nonmoving_gc_cpu_ns :: RtsTime
-- | The time elapsed during the post-mark pause phase of the concurrent
-- nonmoving GC.
, nonmoving_gc_elapsed_ns :: RtsTime
-- | The maximum time elapsed during the post-mark pause phase of the
-- concurrent nonmoving GC.
, nonmoving_gc_max_elapsed_ns :: RtsTime
-- | Details about the most recent GC -- | Details about the most recent GC
, gc :: GCDetails , gc :: GCDetails
} deriving ( Read -- ^ @since 4.10.0.0 } deriving ( Read -- ^ @since 4.10.0.0
...@@ -146,6 +165,13 @@ data GCDetails = GCDetails { ...@@ -146,6 +165,13 @@ data GCDetails = GCDetails {
, gcdetails_cpu_ns :: RtsTime , gcdetails_cpu_ns :: RtsTime
-- | The time elapsed during GC itself -- | The time elapsed during GC itself
, gcdetails_elapsed_ns :: RtsTime , gcdetails_elapsed_ns :: RtsTime
-- | The CPU time used during the post-mark pause phase of the concurrent
-- nonmoving GC.
, gcdetails_nonmoving_gc_sync_cpu_ns :: RtsTime
-- | The time elapsed during the post-mark pause phase of the concurrent
-- nonmoving GC.
, gcdetails_nonmoving_gc_sync_elapsed_ns :: RtsTime
} deriving ( Read -- ^ @since 4.10.0.0 } deriving ( Read -- ^ @since 4.10.0.0
, Show -- ^ @since 4.10.0.0 , Show -- ^ @since 4.10.0.0
) )
...@@ -192,6 +218,12 @@ getRTSStats = do ...@@ -192,6 +218,12 @@ getRTSStats = do
gc_elapsed_ns <- (# peek RTSStats, gc_elapsed_ns) p gc_elapsed_ns <- (# peek RTSStats, gc_elapsed_ns) p
cpu_ns <- (# peek RTSStats, cpu_ns) p cpu_ns <- (# peek RTSStats, cpu_ns) p
elapsed_ns <- (# peek RTSStats, elapsed_ns) p elapsed_ns <- (# peek RTSStats, elapsed_ns) p
nonmoving_gc_sync_cpu_ns <- (# peek RTSStats, nonmoving_gc_sync_cpu_ns) p
nonmoving_gc_sync_elapsed_ns <- (# peek RTSStats, nonmoving_gc_sync_elapsed_ns) p
nonmoving_gc_sync_max_elapsed_ns <- (# peek RTSStats, nonmoving_gc_sync_max_elapsed_ns) p
nonmoving_gc_cpu_ns <- (# peek RTSStats, nonmoving_gc_cpu_ns) p
nonmoving_gc_elapsed_ns <- (# peek RTSStats, nonmoving_gc_elapsed_ns) p
nonmoving_gc_max_elapsed_ns <- (# peek RTSStats, nonmoving_gc_max_elapsed_ns) p
let pgc = (# ptr RTSStats, gc) p let pgc = (# ptr RTSStats, gc) p
gc <- do gc <- do
gcdetails_gen <- (# peek GCDetails, gen) pgc gcdetails_gen <- (# peek GCDetails, gen) pgc
...@@ -211,5 +243,7 @@ getRTSStats = do ...@@ -211,5 +243,7 @@ getRTSStats = do
gcdetails_sync_elapsed_ns <- (# peek GCDetails, sync_elapsed_ns) pgc gcdetails_sync_elapsed_ns <- (# peek GCDetails, sync_elapsed_ns) pgc
gcdetails_cpu_ns <- (# peek GCDetails, cpu_ns) pgc gcdetails_cpu_ns <- (# peek GCDetails, cpu_ns) pgc
gcdetails_elapsed_ns <- (# peek GCDetails, elapsed_ns) pgc gcdetails_elapsed_ns <- (# peek GCDetails, elapsed_ns) pgc
gcdetails_nonmoving_gc_sync_cpu_ns <- (# peek GCDetails, nonmoving_gc_sync_cpu_ns) pgc
gcdetails_nonmoving_gc_sync_elapsed_ns <- (# peek GCDetails, nonmoving_gc_sync_elapsed_ns) pgc
return GCDetails{..} return GCDetails{..}
return RTSStats{..} return RTSStats{..}
This diff is collapsed.
...@@ -30,13 +30,21 @@ void stat_endInit(void); ...@@ -30,13 +30,21 @@ void stat_endInit(void);
void stat_startGCSync(struct gc_thread_ *_gct); void stat_startGCSync(struct gc_thread_ *_gct);
void stat_startGC(Capability *cap, struct gc_thread_ *_gct); void stat_startGC(Capability *cap, struct gc_thread_ *_gct);
void stat_endGC (Capability *cap, struct gc_thread_ *_gct, W_ live, void stat_startGCWorker (Capability *cap, struct gc_thread_ *_gct);
W_ copied, W_ slop, uint32_t gen, uint32_t n_gc_threads, void stat_endGCWorker (Capability *cap, struct gc_thread_ *_gct);
void stat_endGC (Capability *cap, struct gc_thread_ *initiating_gct, W_ live,
W_ copied, W_ slop, uint32_t gen,
uint32_t n_gc_threads, struct gc_thread_ **gc_threads,
W_ par_max_copied, W_ par_balanced_copied, W_ par_max_copied, W_ par_balanced_copied,
W_ gc_spin_spin, W_ gc_spin_yield, W_ mut_spin_spin, W_ gc_spin_spin, W_ gc_spin_yield, W_ mut_spin_spin,
W_ mut_spin_yield, W_ any_work, W_ no_work, W_ mut_spin_yield, W_ any_work, W_ no_work,
W_ scav_find_work); W_ scav_find_work);
void stat_startNonmovingGcSync(void);
void stat_endNonmovingGcSync(void);
void stat_startNonmovingGc (void);
void stat_endNonmovingGc (void);
#if defined(PROFILING) #if defined(PROFILING)
void stat_startRP(void); void stat_startRP(void);
void stat_endRP(uint32_t, int, double); void stat_endRP(uint32_t, int, double);
......
...@@ -894,9 +894,11 @@ GarbageCollect (uint32_t collect_gen, ...@@ -894,9 +894,11 @@ GarbageCollect (uint32_t collect_gen,
#endif #endif
// ok, GC over: tell the stats department what happened. // ok, GC over: tell the stats department what happened.
stat_endGCWorker(cap, gct);
stat_endGC(cap, gct, live_words, copied, stat_endGC(cap, gct, live_words, copied,
live_blocks * BLOCK_SIZE_W - live_words /* slop */, live_blocks * BLOCK_SIZE_W - live_words /* slop */,
N, n_gc_threads, par_max_copied, par_balanced_copied, N, n_gc_threads, gc_threads,
par_max_copied, par_balanced_copied,
gc_spin_spin, gc_spin_yield, mut_spin_spin, mut_spin_yield, gc_spin_spin, gc_spin_yield, mut_spin_spin, mut_spin_yield,
any_work, no_work, scav_find_work); any_work, no_work, scav_find_work);
...@@ -1176,6 +1178,7 @@ gcWorkerThread (Capability *cap) ...@@ -1176,6 +1178,7 @@ gcWorkerThread (Capability *cap)
SET_GCT(gc_threads[cap->no]); SET_GCT(gc_threads[cap->no]);
gct->id = osThreadId(); gct->id = osThreadId();
stat_startGCWorker (cap, gct);
// Wait until we're told to wake up // Wait until we're told to wake up
RELEASE_SPIN_LOCK(&gct->mut_spin); RELEASE_SPIN_LOCK(&gct->mut_spin);
...@@ -1217,6 +1220,7 @@ gcWorkerThread (Capability *cap) ...@@ -1217,6 +1220,7 @@ gcWorkerThread (Capability *cap)
ACQUIRE_SPIN_LOCK(&gct->mut_spin); ACQUIRE_SPIN_LOCK(&gct->mut_spin);
debugTrace(DEBUG_gc, "GC thread %d on my way...", gct->thread_index); debugTrace(DEBUG_gc, "GC thread %d on my way...", gct->thread_index);
stat_endGCWorker (cap, gct);
SET_GCT(saved_gct); SET_GCT(saved_gct);
} }
......
...@@ -185,9 +185,11 @@ typedef struct gc_thread_ { ...@@ -185,9 +185,11 @@ typedef struct gc_thread_ {
W_ no_work; W_ no_work;
W_ scav_find_work; W_ scav_find_work;
Time gc_start_cpu; // process CPU time Time gc_start_cpu; // thread CPU time
Time gc_sync_start_elapsed; // start of GC sync Time gc_end_cpu; // thread CPU time
Time gc_start_elapsed; // process elapsed time Time gc_sync_start_elapsed; // start of GC sync
Time gc_start_elapsed; // thread elapsed time
Time gc_end_elapsed;
W_ gc_start_faults; W_ gc_start_faults;
// ------------------- // -------------------
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "GCThread.h" #include "GCThread.h"
#include "GCTDecl.h" #include "GCTDecl.h"
#include "Schedule.h" #include "Schedule.h"
#include "Stats.h"
#include "NonMoving.h" #include "NonMoving.h"
#include "NonMovingMark.h" #include "NonMovingMark.h"
...@@ -611,6 +612,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * ...@@ -611,6 +612,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO *
{ {
ACQUIRE_LOCK(&nonmoving_collection_mutex); ACQUIRE_LOCK(&nonmoving_collection_mutex);
debugTrace(DEBUG_nonmoving_gc, "Starting mark..."); debugTrace(DEBUG_nonmoving_gc, "Starting mark...");
stat_startNonmovingGc();
// Do concurrent marking; most of the heap will get marked here. // Do concurrent marking; most of the heap will get marked here.
nonmovingMarkThreadsWeaks(mark_queue); nonmovingMarkThreadsWeaks(mark_queue);
...@@ -761,6 +763,7 @@ finish: ...@@ -761,6 +763,7 @@ finish:
// We are done... // We are done...
mark_thread = 0; mark_thread = 0;
stat_endNonmovingGc();
// Signal that the concurrent collection is finished, allowing the next // Signal that the concurrent collection is finished, allowing the next
// non-moving collection to proceed // non-moving collection to proceed
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "Printer.h" #include "Printer.h"
#include "Schedule.h" #include "Schedule.h"
#include "Weak.h" #include "Weak.h"
#include "Stats.h"
#include "STM.h" #include "STM.h"
#include "MarkWeak.h" #include "MarkWeak.h"
#include "sm/Storage.h" #include "sm/Storage.h"
...@@ -254,6 +255,7 @@ void nonmovingBeginFlush(Task *task) ...@@ -254,6 +255,7 @@ void nonmovingBeginFlush(Task *task)
debugTrace(DEBUG_nonmoving_gc, "Starting update remembered set flush..."); debugTrace(DEBUG_nonmoving_gc, "Starting update remembered set flush...");
traceConcSyncBegin(); traceConcSyncBegin();
upd_rem_set_flush_count = 0; upd_rem_set_flush_count = 0;
stat_startNonmovingGcSync();
stopAllCapabilitiesWith(NULL, task, SYNC_FLUSH_UPD_REM_SET); stopAllCapabilitiesWith(NULL, task, SYNC_FLUSH_UPD_REM_SET);
// XXX: We may have been given a capability via releaseCapability (i.e. a // XXX: We may have been given a capability via releaseCapability (i.e. a
...@@ -345,6 +347,7 @@ void nonmovingFinishFlush(Task *task) ...@@ -345,6 +347,7 @@ void nonmovingFinishFlush(Task *task)
debugTrace(DEBUG_nonmoving_gc, "Finished update remembered set flush..."); debugTrace(DEBUG_nonmoving_gc, "Finished update remembered set flush...");
traceConcSyncEnd(); traceConcSyncEnd();
stat_endNonmovingGcSync();
releaseAllCapabilities(n_capabilities, NULL, task); releaseAllCapabilities(n_capabilities, NULL, task);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment