Re-adding the -i flag for heap profiling.
The problem was that profiling forces 2-space collection,
and the census was done on *every* GC. Now, we still keep
the 2-space for profiling, but just do the census periodically,
according to a new flag, -i<secs>.
/* -----------------------------------------------------------------------------
- * $Id: ProfHeap.c,v 1.21 2001/03/14 11:18:18 sewardj Exp $
+ * $Id: ProfHeap.c,v 1.22 2001/07/19 07:28:00 andy Exp $
*
* (c) The GHC Team, 1998-2000
*
#endif /* PROFILING */
+static double time_of_last_heapCensus = 0.0;
+
void
heapCensus(void)
{
StgDouble time;
nat size;
StgPtr p;
-
+ nat elapsed;
+
#ifdef DEBUG_HEAP_PROF
switch (RtsFlags.ProfFlags.doHeapProfile) {
case HEAP_BY_INFOPTR:
#endif
#ifdef PROFILING
+ /*
+ * We only continue iff we've waited long enough,
+ * otherwise, we just dont do the census.
+ */
+
+ time = mut_user_time_during_GC();
+ elapsed = (time - time_of_last_heapCensus) * 1000;
+ if (elapsed < RtsFlags.ProfFlags.profileFrequency) {
+ return;
+ }
+ time_of_last_heapCensus = time;
+#endif
+
+
+#ifdef PROFILING
switch (RtsFlags.ProfFlags.doHeapProfile) {
case NO_HEAP_PROFILING:
return;
ASSERT(RtsFlags.GcFlags.generations == 1);
bd = g0s0->to_space;
- time = mut_user_time_during_GC();
fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", time);
while (bd != NULL) {
/* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.38 2001/03/22 03:51:10 hwloidl Exp $
+ * $Id: RtsFlags.c,v 1.39 2001/07/19 07:28:00 andy Exp $
*
* (c) The AQUA Project, Glasgow University, 1994-1997
* (c) The GHC Team, 1998-1999
#ifdef PROFILING
RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
+ RtsFlags.ProfFlags.profileFrequency = 20;
RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
RtsFlags.ProfFlags.modSelector = NULL;
RtsFlags.ProfFlags.descrSelector = NULL;
" -hd{des,des...} closures with specified closure descriptions",
" -hy{typ,typ...} closures with specified type descriptions",
"",
+" -i<sec> how often to sample heap",
+"",
" -xc Show current cost centre stack on raising an exception",
# endif
#endif /* PROFILING or PAR */
)
#endif
- break;
+ break;
+
+#if defined(PROFILING)
+ case 'i': /* heap sample interval */
+ if (rts_argv[arg][2] == '\0') {
+ /* use default */
+ } else {
+ I_ cst; /* tmp */
+
+ /* Convert to milliseconds */
+ cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
+ cst = (cst / CS_MIN_MILLISECS) * CS_MIN_MILLISECS;
+ if (cst != 0 && cst < CS_MIN_MILLISECS)
+ cst = CS_MIN_MILLISECS;
+
+ RtsFlags.ProfFlags.profileFrequency = cst;
+ }
+
+ break;
+
+#endif
/* =========== CONCURRENT ========================= */
case 'C': /* context switch interval */
/* -----------------------------------------------------------------------------
- * $Id: RtsFlags.h,v 1.32 2001/03/22 03:51:10 hwloidl Exp $
+ * $Id: RtsFlags.h,v 1.33 2001/07/19 07:28:00 andy Exp $
*
* (c) The GHC Team, 1998-1999
*
struct PROFILING_FLAGS {
unsigned int doHeapProfile;
+ nat profileFrequency; /* how often do you want */
+ /* to sample (in ms) */
+
+
# define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
# define HEAP_BY_CCS 1
# define HEAP_BY_MOD 2
char* typeSelector;
char* ccSelector;
+
};
#elif defined(DEBUG)
# define NO_HEAP_PROFILING 0
# define HEAP_BY_INFOPTR 1
# define HEAP_BY_CLOSURE_TYPE 2
struct PROFILING_FLAGS {
- unsigned int doHeapProfile; /* heap profile using symbol table */
+ unsigned int doHeapProfile; /* heap profile using symbol table */
+
};
#endif /* DEBUG || PROFILING */
/* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.38 2001/05/25 18:35:29 sof Exp $
+ * $Id: Storage.c,v 1.39 2001/07/19 07:28:00 andy Exp $
*
* (c) The GHC Team, 1998-1999
*
* fixed-size allocation area so that we get roughly even-spaced
* samples.
*/
+
+ /* As an experiment, try a 2 generation collector
+ */
+
#if defined(PROFILING) || defined(DEBUG)
if (RtsFlags.ProfFlags.doHeapProfile) {
RtsFlags.GcFlags.generations = 1;