From 17987a4b665d4a270b1bebba1f61d67887f2653c Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Wed, 9 Oct 2019 14:32:13 +0100 Subject: eventlog: Dump cost centre stack on each sample With this change it is possible to reconstruct the timing portion of a `.prof` file after the fact. By logging the stacks at each time point a more precise executation trace of the program can be observed rather than all identical cost centres being identified in the report. There are two new events: 1. `EVENT_PROF_BEGIN` - emitted at the start of profiling to communicate the tick interval 2. `EVENT_PROF_SAMPLE_COST_CENTRE` - emitted on each tick to communicate the current call stack. Fixes #17322 --- rts/Profiling.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'rts/Profiling.c') diff --git a/rts/Profiling.c b/rts/Profiling.c index b91129ed98..a4247c7809 100644 --- a/rts/Profiling.c +++ b/rts/Profiling.c @@ -25,7 +25,7 @@ #include #include -#if defined(DEBUG) +#if defined(DEBUG) || defined(PROFILING) #include "Trace.h" #endif @@ -132,6 +132,19 @@ static void initProfilingLogFile ( void ); Initialise the profiling environment -------------------------------------------------------------------------- */ +static void +dumpCostCentresToEventLog(void) +{ +#if defined(PROFILING) + CostCentre *cc, *next; + for (cc = CC_LIST; cc != NULL; cc = next) { + next = cc->link; + traceHeapProfCostCentre(cc->ccID, cc->label, cc->module, + cc->srcloc, cc->is_caf); + } +#endif +} + void initProfiling (void) { // initialise our arena @@ -187,8 +200,12 @@ void initProfiling (void) if (RtsFlags.CcFlags.doCostCentres) { initTimeProfiling(); } + + dumpCostCentresToEventLog(); } + + // // Should be called after loading any new Haskell code. // @@ -278,6 +295,7 @@ initProfilingLogFile(void) void initTimeProfiling(void) { + traceProfBegin(); /* Start ticking */ startProfTimer(); }; -- cgit v1.2.1