[commit: ghc] ghc-7.2: Fix heap profiling times (aeb8b95)
Ian Lynagh
igloo at earth.li
Sun Jul 24 20:25:41 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : ghc-7.2
http://hackage.haskell.org/trac/ghc/changeset/aeb8b95336bb98d993396493296b31183a7ea0f0
>---------------------------------------------------------------
commit aeb8b95336bb98d993396493296b31183a7ea0f0
Author: Ian Lynagh <igloo at earth.li>
Date: Sun Jul 24 00:01:54 2011 +0100
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.
>---------------------------------------------------------------
rts/ProfHeap.c | 4 ++--
rts/ProfHeap.h | 4 +++-
rts/Stats.c | 8 +++++++-
rts/Stats.h | 1 +
rts/sm/GC.c | 2 +-
5 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index e88d704..9d95b4c 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -1071,14 +1071,14 @@ heapCensusChain( Census *census, bdescr *bd )
}
void
-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
#ifdef PROFILING
diff --git a/rts/ProfHeap.h b/rts/ProfHeap.h
index c4a92e2..cf09c59 100644
--- a/rts/ProfHeap.h
+++ b/rts/ProfHeap.h
@@ -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);
diff --git a/rts/Stats.c b/rts/Stats.c
index 9fc702a..be0db06 100644
--- a/rts/Stats.c
+++ b/rts/Stats.c
@@ -84,11 +84,17 @@ Ticks stat_getElapsedTime(void)
------------------------------------------------------------------------ */
double
+mut_user_time_until( Ticks t )
+{
+ return TICK_TO_DBL(t - GC_tot_cpu - PROF_VAL(RP_tot_time + HC_tot_time));
+}
+
+double
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);
}
#ifdef PROFILING
diff --git a/rts/Stats.h b/rts/Stats.h
index 0c51787..8761be5 100644
--- a/rts/Stats.h
+++ b/rts/Stats.h
@@ -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);
#ifdef PROFILING
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 2b9ee9d..2252cfc 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -669,7 +669,7 @@ GarbageCollect (rtsBool force_major_gc,
if (do_heap_census) {
debugTrace(DEBUG_sched, "performing heap census");
RELEASE_SM_LOCK;
- heapCensus();
+ heapCensus(gct->gc_start_cpu);
ACQUIRE_SM_LOCK;
}
More information about the Cvs-ghc
mailing list