Commit 4f8cfaf9 authored by Ian Lynagh's avatar Ian Lynagh

Fix heap profiling times

Now that the heap census runs in the middle of garbage collections,
the "CPU time" it was calculating included any CPU time used so far
in the current GC. This could cause CPU time to appear to go down,
which means hp2ps complained about "samples out of sequence".

I'm not sure if this is the nicest way to solve this (maybe resurrecting
mut_user_time_during_GC would be better?) but it gets things working again.
parent 2b42de78
......@@ -1071,14 +1071,14 @@ heapCensusChain( Census *census, bdescr *bd )
heapCensus( void )
heapCensus( Ticks t )
nat g, n;
Census *census;
gen_workspace *ws;
census = &censuses[era];
census->time = mut_user_time();
census->time = mut_user_time_until(t);
// calculate retainer sets if necessary
......@@ -9,9 +9,11 @@
#ifndef PROFHEAP_H
#define PROFHEAP_H
#include "GetTime.h" // for Ticks
#include "BeginPrivate.h"
void heapCensus (void);
void heapCensus (Ticks t);
nat initHeapProfiling (void);
void endHeapProfiling (void);
rtsBool strMatchesSelector (char* str, char* sel);
......@@ -83,12 +83,18 @@ Ticks stat_getElapsedTime(void)
Measure the current MUT time, for profiling
------------------------------------------------------------------------ */
mut_user_time_until( Ticks t )
return TICK_TO_DBL(t - GC_tot_cpu - PROF_VAL(RP_tot_time + HC_tot_time));
mut_user_time( void )
Ticks cpu;
cpu = getProcessCPUTime();
return TICK_TO_DBL(cpu - GC_tot_cpu - PROF_VAL(RP_tot_time + HC_tot_time));
return mut_user_time_until(cpu);
......@@ -50,6 +50,7 @@ void initStats0(void);
void initStats1(void);
double mut_user_time_during_GC(void);
double mut_user_time_until(Ticks t);
double mut_user_time(void);
......@@ -669,7 +669,7 @@ GarbageCollect (rtsBool force_major_gc,
if (do_heap_census) {
debugTrace(DEBUG_sched, "performing heap census");
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