summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-04-15 16:42:56 -0400
committerBen Gamari <ben@smart-cactus.org>2019-10-22 12:17:00 -0400
commit6f1731812331d4ddb4326fdfcefa095b867547e9 (patch)
treebc1fb4a5d0b41b98e50e38dcfea0c20748439ce6 /rts
parent0d31819ed27f6763f5d253df0c1226d4c844e802 (diff)
downloadhaskell-6f1731812331d4ddb4326fdfcefa095b867547e9.tar.gz
NonmovingCensus: Emit samples to eventlogwip/gc/instrumentation
Diffstat (limited to 'rts')
-rw-r--r--rts/RtsFlags.c5
-rw-r--r--rts/Trace.c10
-rw-r--r--rts/Trace.h5
-rw-r--r--rts/eventlog/EventLog.c19
-rw-r--r--rts/eventlog/EventLog.h3
-rw-r--r--rts/sm/NonMovingCensus.c18
-rw-r--r--rts/sm/NonMovingCensus.h3
7 files changed, 62 insertions, 1 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 7d486824ab..c606d86418 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -222,6 +222,7 @@ void initRtsFlagsDefaults(void)
RtsFlags.TraceFlags.timestamp = false;
RtsFlags.TraceFlags.scheduler = false;
RtsFlags.TraceFlags.gc = false;
+ RtsFlags.TraceFlags.nonmoving_gc = false;
RtsFlags.TraceFlags.sparks_sampled= false;
RtsFlags.TraceFlags.sparks_full = false;
RtsFlags.TraceFlags.user = false;
@@ -2131,6 +2132,10 @@ static void read_trace_flags(const char *arg)
RtsFlags.TraceFlags.gc = enabled;
enabled = true;
break;
+ case 'n':
+ RtsFlags.TraceFlags.nonmoving_gc = enabled;
+ enabled = true;
+ break;
case 'u':
RtsFlags.TraceFlags.user = enabled;
enabled = true;
diff --git a/rts/Trace.c b/rts/Trace.c
index 10ad5031ab..ecc28d8fec 100644
--- a/rts/Trace.c
+++ b/rts/Trace.c
@@ -30,6 +30,7 @@
// events
int TRACE_sched;
int TRACE_gc;
+int TRACE_nonmoving_gc;
int TRACE_spark_sampled;
int TRACE_spark_full;
int TRACE_user;
@@ -72,6 +73,9 @@ void initTracing (void)
RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS;
}
+ TRACE_nonmoving_gc =
+ RtsFlags.TraceFlags.nonmoving_gc;
+
TRACE_spark_sampled =
RtsFlags.TraceFlags.sparks_sampled;
@@ -844,6 +848,12 @@ void traceConcUpdRemSetFlush(Capability *cap)
postConcUpdRemSetFlush(cap);
}
+void traceNonmovingHeapCensus(uint32_t log_blk_size,
+ const struct NonmovingAllocCensus *census)
+{
+ if (eventlog_enabled && TRACE_nonmoving_gc)
+ postNonmovingHeapCensus(log_blk_size, census);
+}
void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG)
{
diff --git a/rts/Trace.h b/rts/Trace.h
index 9b52c3cb65..7f72fd8093 100644
--- a/rts/Trace.h
+++ b/rts/Trace.h
@@ -9,6 +9,7 @@
#pragma once
#include "rts/EventLogFormat.h"
+#include "sm/NonMovingCensus.h"
#include "Capability.h"
#if defined(DTRACE)
@@ -72,6 +73,7 @@ extern int TRACE_spark_sampled;
extern int TRACE_spark_full;
/* extern int TRACE_user; */ // only used in Trace.c
extern int TRACE_cap;
+extern int TRACE_nonmoving_gc;
// -----------------------------------------------------------------------------
// Posting events
@@ -311,6 +313,8 @@ void traceConcSyncEnd(void);
void traceConcSweepBegin(void);
void traceConcSweepEnd(void);
void traceConcUpdRemSetFlush(Capability *cap);
+void traceNonmovingHeapCensus(uint32_t log_blk_size,
+ const struct NonmovingAllocCensus *census);
void flushTrace(void);
@@ -359,6 +363,7 @@ void flushTrace(void);
#define traceConcSweepBegin() /* nothing */
#define traceConcSweepEnd() /* nothing */
#define traceConcUpdRemSetFlush(cap) /* nothing */
+#define traceNonmovingHeapCensus(blk_size, census) /* nothing */
#define flushTrace() /* nothing */
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index a9bb603523..8683ad9972 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -114,7 +114,8 @@ char *EventDesc[] = {
[EVENT_CONC_SYNC_END] = "End concurrent GC synchronisation",
[EVENT_CONC_SWEEP_BEGIN] = "Begin concurrent sweep",
[EVENT_CONC_SWEEP_END] = "End concurrent sweep",
- [EVENT_CONC_UPD_REM_SET_FLUSH] = "Update remembered set flushed"
+ [EVENT_CONC_UPD_REM_SET_FLUSH] = "Update remembered set flushed",
+ [EVENT_NONMOVING_HEAP_CENSUS] = "Nonmoving heap census"
};
// Event type.
@@ -470,6 +471,10 @@ init_event_types(void)
sizeof(EventCapNo);
break;
+ case EVENT_NONMOVING_HEAP_CENSUS: // (cap, blk_size, active_segs, filled_segs, live_blks)
+ eventTypes[t].size = 13;
+ break;
+
default:
continue; /* ignore deprecated events */
}
@@ -1182,6 +1187,18 @@ void postConcMarkEnd(StgWord32 marked_obj_count)
RELEASE_LOCK(&eventBufMutex);
}
+void postNonmovingHeapCensus(int log_blk_size,
+ const struct NonmovingAllocCensus *census)
+{
+ ACQUIRE_LOCK(&eventBufMutex);
+ postEventHeader(&eventBuf, EVENT_NONMOVING_HEAP_CENSUS);
+ postWord8(&eventBuf, log_blk_size);
+ postWord32(&eventBuf, census->n_active_segs);
+ postWord32(&eventBuf, census->n_filled_segs);
+ postWord32(&eventBuf, census->n_live_blocks);
+ RELEASE_LOCK(&eventBufMutex);
+}
+
void closeBlockMarker (EventsBuf *ebuf)
{
if (ebuf->marker)
diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h
index 16c7670cb3..0d439b836a 100644
--- a/rts/eventlog/EventLog.h
+++ b/rts/eventlog/EventLog.h
@@ -11,6 +11,7 @@
#include "rts/EventLogFormat.h"
#include "rts/EventLogWriter.h"
#include "Capability.h"
+#include "sm/NonMovingCensus.h"
#include "BeginPrivate.h"
@@ -162,6 +163,8 @@ void postHeapProfSampleCostCentre(StgWord8 profile_id,
void postConcUpdRemSetFlush(Capability *cap);
void postConcMarkEnd(StgWord32 marked_obj_count);
+void postNonmovingHeapCensus(int log_blk_size,
+ const struct NonmovingAllocCensus *census);
#else /* !TRACING */
diff --git a/rts/sm/NonMovingCensus.c b/rts/sm/NonMovingCensus.c
index 1f28f4e813..670d51263c 100644
--- a/rts/sm/NonMovingCensus.c
+++ b/rts/sm/NonMovingCensus.c
@@ -90,6 +90,9 @@ nonmovingAllocatorCensus(struct NonmovingAllocator *alloc)
void nonmovingPrintAllocatorCensus()
{
+ if (!RtsFlags.GcFlags.useNonmoving)
+ return;
+
for (int i=0; i < NONMOVING_ALLOCA_CNT; i++) {
struct NonmovingAllocCensus census =
nonmovingAllocatorCensus(nonmovingHeap.allocators[i]);
@@ -109,3 +112,18 @@ void nonmovingPrintAllocatorCensus()
occupancy);
}
}
+
+void nonmovingTraceAllocatorCensus()
+{
+#if defined(TRACING)
+ if (!RtsFlags.GcFlags.useNonmoving && !TRACE_nonmoving_gc)
+ return;
+
+ for (int i=0; i < NONMOVING_ALLOCA_CNT; i++) {
+ const struct NonmovingAllocCensus census =
+ nonmovingAllocatorCensus(nonmovingHeap.allocators[i]);
+ const uint32_t log_blk_size = i + NONMOVING_ALLOCA0;
+ traceNonmovingHeapCensus(log_blk_size, &census);
+ }
+#endif
+}
diff --git a/rts/sm/NonMovingCensus.h b/rts/sm/NonMovingCensus.h
index 1c7c657cc1..7a66dc9b69 100644
--- a/rts/sm/NonMovingCensus.h
+++ b/rts/sm/NonMovingCensus.h
@@ -8,6 +8,8 @@
#pragma once
+#include "NonMoving.h"
+
struct NonmovingAllocCensus {
uint32_t n_active_segs;
uint32_t n_filled_segs;
@@ -23,3 +25,4 @@ struct NonmovingAllocCensus
nonmovingAllocatorCensus(struct NonmovingAllocator *alloc);
void nonmovingPrintAllocatorCensus(void);
+void nonmovingTraceAllocatorCensus(void);