summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2020-04-15 04:26:43 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-15 17:49:24 -0400
commitec77b2f16a78b13f54794c954953d8878dea9db2 (patch)
tree004e8b67b2a560f44f4bd476c83577f0c417ac38 /rts
parent22cc8e513fcfa89a4391f075534d903596a05895 (diff)
downloadhaskell-ec77b2f16a78b13f54794c954953d8878dea9db2.tar.gz
rts: ProfHeap: Fix wrong time in last heap profile sample
We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places.
Diffstat (limited to 'rts')
-rw-r--r--rts/ProfHeap.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index 03c99a0d49..43bce78b76 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -552,8 +552,6 @@ initHeapProfiling(void)
void
endHeapProfiling(void)
{
- StgDouble seconds;
-
if (! RtsFlags.ProfFlags.doHeapProfile) {
return;
}
@@ -596,7 +594,10 @@ endHeapProfiling(void)
stgFree(censuses);
- seconds = mut_user_time();
+ RTSStats stats;
+ getRTSStats(&stats);
+ Time mut_time = stats.mutator_cpu_ns;
+ StgDouble seconds = TimeToSecondsDbl(mut_time);
printSample(true, seconds);
printSample(false, seconds);
fclose(hp_file);