Commit ec77b2f1 authored by Daniel Gröber (dxld)'s avatar Daniel Gröber (dxld) Committed by Marge Bot

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.
parent 22cc8e51
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment