summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2019-05-29 16:56:08 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-07 10:21:57 -0400
commit0b7372f68c0bc9cafc30e227b574abf1d5b16df5 (patch)
treef1b33e977ed5fb858ba102815260136a89d1735c /rts
parente963beb54a243f011396942d2add644e3f3dd8ae (diff)
downloadhaskell-0b7372f68c0bc9cafc30e227b574abf1d5b16df5.tar.gz
Add HEAP_PROF_SAMPLE_END event to mark end of samples
This allows a user to observe how long a sampling period lasts so that the time taken can be removed from the profiling output. Fixes #16697
Diffstat (limited to 'rts')
-rw-r--r--rts/ProfHeap.c1
-rw-r--r--rts/Trace.c7
-rw-r--r--rts/Trace.h2
-rw-r--r--rts/eventlog/EventLog.c14
-rw-r--r--rts/eventlog/EventLog.h1
5 files changed, 25 insertions, 0 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index 5e3f8940a0..6fbfb6ea88 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -884,6 +884,7 @@ dumpCensus( Census *census )
fprintf(hp_file, "\t%" FMT_Word "\n", (W_)count * sizeof(W_));
}
+ traceHeapProfSampleEnd(era);
printSample(false, census->time);
}
diff --git a/rts/Trace.c b/rts/Trace.c
index 4475054509..e345377eef 100644
--- a/rts/Trace.c
+++ b/rts/Trace.c
@@ -623,6 +623,13 @@ void traceHeapProfSampleBegin(StgInt era)
}
}
+void traceHeapProfSampleEnd(StgInt era)
+{
+ if (eventlog_enabled) {
+ postHeapProfSampleEnd(era);
+ }
+}
+
void traceHeapProfSampleString(StgWord8 profile_id,
const char *label, StgWord residency)
{
diff --git a/rts/Trace.h b/rts/Trace.h
index 74b960ce31..17e3dc7040 100644
--- a/rts/Trace.h
+++ b/rts/Trace.h
@@ -288,6 +288,7 @@ void traceTaskDelete_ (Task *task);
void traceHeapProfBegin(StgWord8 profile_id);
void traceHeapProfSampleBegin(StgInt era);
+void traceHeapProfSampleEnd(StgInt era);
void traceHeapProfSampleString(StgWord8 profile_id,
const char *label, StgWord residency);
#if defined(PROFILING)
@@ -335,6 +336,7 @@ void flushTrace(void);
#define traceHeapProfBegin(profile_id) /* nothing */
#define traceHeapProfCostCentre(ccID, label, module, srcloc, is_caf) /* nothing */
#define traceHeapProfSampleBegin(era) /* nothing */
+#define traceHeapProfSampleEnd(era) /* nothing */
#define traceHeapProfSampleCostCentre(profile_id, stack, residency) /* nothing */
#define traceHeapProfSampleString(profile_id, label, residency) /* nothing */
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index ff79425a4c..c853492f09 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -103,6 +103,7 @@ char *EventDesc[] = {
[EVENT_HEAP_PROF_BEGIN] = "Start of heap profile",
[EVENT_HEAP_PROF_COST_CENTRE] = "Cost center definition",
[EVENT_HEAP_PROF_SAMPLE_BEGIN] = "Start of heap profile sample",
+ [EVENT_HEAP_PROF_SAMPLE_END] = "End of heap profile sample",
[EVENT_HEAP_PROF_SAMPLE_STRING] = "Heap profile string sample",
[EVENT_HEAP_PROF_SAMPLE_COST_CENTRE] = "Heap profile cost-centre sample",
[EVENT_USER_BINARY_MSG] = "User binary message"
@@ -430,6 +431,10 @@ postHeaderEvents(void)
eventTypes[t].size = 8;
break;
+ case EVENT_HEAP_PROF_SAMPLE_END:
+ eventTypes[t].size = 8;
+ break;
+
case EVENT_HEAP_PROF_SAMPLE_STRING:
eventTypes[t].size = EVENT_SIZE_DYNAMIC;
break;
@@ -1210,6 +1215,15 @@ void postHeapProfSampleBegin(StgInt era)
RELEASE_LOCK(&eventBufMutex);
}
+void postHeapProfSampleEnd(StgInt era)
+{
+ ACQUIRE_LOCK(&eventBufMutex);
+ ensureRoomForEvent(&eventBuf, EVENT_HEAP_PROF_SAMPLE_END);
+ postEventHeader(&eventBuf, EVENT_HEAP_PROF_SAMPLE_END);
+ postWord64(&eventBuf, era);
+ RELEASE_LOCK(&eventBufMutex);
+}
+
void postHeapProfSampleString(StgWord8 profile_id,
const char *label,
StgWord64 residency)
diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h
index 1fb7c4a071..8935e61985 100644
--- a/rts/eventlog/EventLog.h
+++ b/rts/eventlog/EventLog.h
@@ -140,6 +140,7 @@ void postTaskDeleteEvent (EventTaskId taskId);
void postHeapProfBegin(StgWord8 profile_id);
void postHeapProfSampleBegin(StgInt era);
+void postHeapProfSampleEnd(StgInt era);
void postHeapProfSampleString(StgWord8 profile_id,
const char *label,