/* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.37 1999/02/17 17:47:09 simonm Exp $
+ * $Id: GC.c,v 1.38 1999/02/23 15:45:06 simonm Exp $
*
* (c) The GHC Team 1998-1999
*
{
bdescr *bd;
step *step;
- lnat live, allocated, collected = 0;
+ lnat live, allocated, collected = 0, copied = 0;
nat g, s;
#ifdef PROFILING
step->hpLim = step->hp + BLOCK_SIZE_W;
step->hp_bd = bd;
step->to_space = bd;
- step->to_blocks = 1; /* ???? */
+ step->to_blocks = 1;
step->scan = bd->start;
step->scan_bd = bd;
step->new_large_objects = NULL;
step->scavenged_large_objects = NULL;
+ new_blocks++;
/* mark the large objects as not evacuated yet */
for (bd = step->large_objects; bd; bd = bd->link) {
bd->evacuated = 0;
step->hp_bd = bd;
step->blocks = bd;
step->n_blocks = 1;
+ new_blocks++;
}
/* Set the scan pointer for older generations: remember we
* still have to scavenge objects that have been promoted. */
loop2:
for (gen = RtsFlags.GcFlags.generations-1; gen >= 0; gen--) {
for (st = generations[gen].n_steps-1; st >= 0 ; st--) {
- if (gen == 0 && st == 0) {
+ if (gen == 0 && st == 0 && RtsFlags.GcFlags.generations > 1) {
continue;
}
step = &generations[gen].steps[st];
/* run through all the generations/steps and tidy up
*/
+ copied = new_blocks * BLOCK_SIZE_W;
for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
if (g <= N) {
/* Tidy the end of the to-space chains */
step->hp_bd->free = step->hp;
step->hp_bd->link = NULL;
+ /* stats information: how much we copied */
+ if (g <= N) {
+ copied -= step->hp_bd->start + BLOCK_SIZE_W -
+ step->hp_bd->free;
+ }
}
/* for generations we collected... */
/* Guess the amount of live data for stats. */
live = calcLive();
+ /* Free the small objects allocated via allocate(), since this will
+ * all have been copied into G0S1 now.
+ */
+ if (small_alloc_list != NULL) {
+ freeChain(small_alloc_list);
+ }
+ small_alloc_list = NULL;
+ alloc_blocks = 0;
+ alloc_blocks_lim = RtsFlags.GcFlags.minAllocAreaSize;
+
/* Two-space collector:
* Free the old to-space, and estimate the amount of live data.
*/
}
current_nursery = g0s0->blocks;
- /* Free the small objects allocated via allocate(), since this will
- * all have been copied into G0S1 now.
- */
- if (small_alloc_list != NULL) {
- freeChain(small_alloc_list);
- }
- small_alloc_list = NULL;
- alloc_blocks = 0;
- alloc_blocks_lim = RtsFlags.GcFlags.minAllocAreaSize;
-
/* start any pending finalizers */
scheduleFinalizers(old_weak_ptr_list);
IF_DEBUG(sanity, memInventory());
/* ok, GC over: tell the stats department what happened. */
- stat_endGC(allocated, collected, live, N);
+ stat_endGC(allocated, collected, live, copied, N);
}
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Stats.c,v 1.8 1999/02/23 12:02:57 simonm Exp $
+ * $Id: Stats.c,v 1.9 1999/02/23 15:45:08 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
static double InitElapsedTime = 0.0;
static ullong GC_tot_alloc = 0;
+static ullong GC_tot_copied = 0;
static double GC_start_time, GC_tot_time = 0; /* User GC Time */
static double GCe_start_time, GCe_tot_time = 0; /* Elapsed GC time */
-------------------------------------------------------------------------- */
void
-stat_endGC(lnat alloc, lnat collect, lnat live, lnat gen)
+stat_endGC(lnat alloc, lnat collect, lnat live, lnat copied, lnat gen)
{
FILE *sf = RtsFlags.GcFlags.statsFile;
GC_coll_times[gen] += time-GC_start_time;
- GC_tot_alloc += (ullong) alloc;
- GC_tot_time += time-GC_start_time;
- GCe_tot_time += etime-GCe_start_time;
+ GC_tot_copied += (ullong) copied;
+ GC_tot_alloc += (ullong) alloc;
+ GC_tot_time += time-GC_start_time;
+ GCe_tot_time += etime-GCe_start_time;
if (gen == RtsFlags.GcFlags.generations-1) { /* major GC? */
if (live > MaxResidency) {
ullong_format_string(GC_tot_alloc*sizeof(W_), temp, rtsTrue/*commas*/);
fprintf(sf, "%11s bytes allocated in the heap\n", temp);
+ ullong_format_string(GC_tot_copied*sizeof(W_), temp, rtsTrue/*commas*/);
+ fprintf(sf, "%11s bytes copied during GC\n", temp);
+
if ( ResidencySamples > 0 ) {
ullong_format_string(MaxResidency*sizeof(W_), temp, rtsTrue/*commas*/);
fprintf(sf, "%11s bytes maximum residency (%ld sample(s))\n",
/* -----------------------------------------------------------------------------
- * $Id: Stats.h,v 1.4 1999/02/05 16:02:57 simonm Exp $
+ * $Id: Stats.h,v 1.5 1999/02/23 15:45:08 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
extern void end_init(void);
extern void stat_exit(int alloc);
extern void stat_startGC(void);
-extern void stat_endGC(lnat alloc, lnat collect, lnat live, lnat gen);
+extern void stat_endGC(lnat alloc, lnat collect, lnat live,
+ lnat copied, lnat gen);
extern void initStats(void);
extern void stat_describe_gens(void);