summaryrefslogtreecommitdiff
path: root/rts/sm
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-02-20 20:57:48 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-03-05 14:53:12 -0500
commitace618cd2294989e783bd453cee88e0e1c0dad77 (patch)
tree97d34db5521cf1781e57e786eb41f14087808cf9 /rts/sm
parentcedd6f3041de6abe64dfa3257bec7730a9dced9f (diff)
downloadhaskell-ace618cd2294989e783bd453cee88e0e1c0dad77.tar.gz
nonmoving-gc: Track time usage of nonmoving marking
Diffstat (limited to 'rts/sm')
-rw-r--r--rts/sm/GC.c16
-rw-r--r--rts/sm/GCThread.h8
-rw-r--r--rts/sm/NonMoving.c3
-rw-r--r--rts/sm/NonMovingMark.c3
4 files changed, 25 insertions, 5 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 526c84f411..16d8c77453 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -209,6 +209,14 @@ GarbageCollect (uint32_t collect_gen,
gc_thread *saved_gct;
#endif
uint32_t g, n;
+ // The time we should report our heap census as occurring at, if necessary.
+ Time mut_time = 0;
+
+ if (do_heap_census) {
+ RTSStats stats;
+ getRTSStats(&stats);
+ mut_time = stats.mutator_cpu_ns;
+ }
// necessary if we stole a callee-saves register for gct:
#if defined(THREADED_RTS)
@@ -846,7 +854,7 @@ GarbageCollect (uint32_t collect_gen,
if (do_heap_census) {
debugTrace(DEBUG_sched, "performing heap census");
RELEASE_SM_LOCK;
- heapCensus(gct->gc_start_cpu);
+ heapCensus(mut_time);
ACQUIRE_SM_LOCK;
}
@@ -927,9 +935,11 @@ GarbageCollect (uint32_t collect_gen,
#endif
// ok, GC over: tell the stats department what happened.
+ stat_endGCWorker(cap, gct);
stat_endGC(cap, gct, live_words, copied,
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,
any_work, no_work, scav_find_work);
@@ -1209,6 +1219,7 @@ gcWorkerThread (Capability *cap)
SET_GCT(gc_threads[cap->no]);
gct->id = osThreadId();
+ stat_startGCWorker (cap, gct);
// Wait until we're told to wake up
RELEASE_SPIN_LOCK(&gct->mut_spin);
@@ -1247,6 +1258,7 @@ gcWorkerThread (Capability *cap)
gct->wakeup = GC_THREAD_WAITING_TO_CONTINUE;
debugTrace(DEBUG_gc, "GC thread %d waiting to continue...",
gct->thread_index);
+ stat_endGCWorker (cap, gct);
ACQUIRE_SPIN_LOCK(&gct->mut_spin);
debugTrace(DEBUG_gc, "GC thread %d on my way...", gct->thread_index);
diff --git a/rts/sm/GCThread.h b/rts/sm/GCThread.h
index 3012f52f28..723bb00bf1 100644
--- a/rts/sm/GCThread.h
+++ b/rts/sm/GCThread.h
@@ -185,9 +185,11 @@ typedef struct gc_thread_ {
W_ no_work;
W_ scav_find_work;
- Time gc_start_cpu; // process CPU time
- Time gc_sync_start_elapsed; // start of GC sync
- Time gc_start_elapsed; // process elapsed time
+ Time gc_start_cpu; // thread CPU time
+ Time gc_end_cpu; // thread CPU time
+ Time gc_sync_start_elapsed; // start of GC sync
+ Time gc_start_elapsed; // process elapsed time
+ Time gc_end_elapsed; // process elapsed time
W_ gc_start_faults;
// -------------------
diff --git a/rts/sm/NonMoving.c b/rts/sm/NonMoving.c
index 0bd96d1800..2dd201f0f9 100644
--- a/rts/sm/NonMoving.c
+++ b/rts/sm/NonMoving.c
@@ -17,6 +17,7 @@
#include "GCThread.h"
#include "GCTDecl.h"
#include "Schedule.h"
+#include "Stats.h"
#include "NonMoving.h"
#include "NonMovingMark.h"
@@ -947,6 +948,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO *
{
ACQUIRE_LOCK(&nonmoving_collection_mutex);
debugTrace(DEBUG_nonmoving_gc, "Starting mark...");
+ stat_startNonmovingGc();
// Do concurrent marking; most of the heap will get marked here.
nonmovingMarkThreadsWeaks(mark_queue);
@@ -1098,6 +1100,7 @@ finish:
// We are done...
mark_thread = 0;
+ stat_endNonmovingGc();
// Signal that the concurrent collection is finished, allowing the next
// non-moving collection to proceed
diff --git a/rts/sm/NonMovingMark.c b/rts/sm/NonMovingMark.c
index 6d70ca21dd..3113e7f013 100644
--- a/rts/sm/NonMovingMark.c
+++ b/rts/sm/NonMovingMark.c
@@ -21,6 +21,7 @@
#include "Printer.h"
#include "Schedule.h"
#include "Weak.h"
+#include "Stats.h"
#include "STM.h"
#include "MarkWeak.h"
#include "sm/Storage.h"
@@ -316,6 +317,7 @@ void nonmovingBeginFlush(Task *task)
debugTrace(DEBUG_nonmoving_gc, "Starting update remembered set flush...");
traceConcSyncBegin();
upd_rem_set_flush_count = 0;
+ stat_startNonmovingGcSync();
stopAllCapabilitiesWith(NULL, task, SYNC_FLUSH_UPD_REM_SET);
// XXX: We may have been given a capability via releaseCapability (i.e. a
@@ -407,6 +409,7 @@ void nonmovingFinishFlush(Task *task)
debugTrace(DEBUG_nonmoving_gc, "Finished update remembered set flush...");
traceConcSyncEnd();
+ stat_endNonmovingGcSync();
releaseAllCapabilities(n_capabilities, NULL, task);
}
#endif