From: simonm Date: Tue, 23 Feb 1999 15:45:08 +0000 (+0000) Subject: [project @ 1999-02-23 15:45:06 by simonm] X-Git-Tag: Approximately_9120_patches~6519 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c046089ef9722a733396759b87fd24bae37e70d9;p=ghc-hetmet.git [project @ 1999-02-23 15:45:06 by simonm] - Fix a bug in 2-space (-G1) collection - Calculate an estimate of the number of bytes copied during GC for GC stats. --- diff --git a/ghc/rts/GC.c b/ghc/rts/GC.c index 86acf16..d35d83b 100644 --- a/ghc/rts/GC.c +++ b/ghc/rts/GC.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $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 * @@ -144,7 +144,7 @@ void GarbageCollect(void (*get_roots)(void)) { bdescr *bd; step *step; - lnat live, allocated, collected = 0; + lnat live, allocated, collected = 0, copied = 0; nat g, s; #ifdef PROFILING @@ -243,11 +243,12 @@ void GarbageCollect(void (*get_roots)(void)) 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; @@ -272,6 +273,7 @@ void GarbageCollect(void (*get_roots)(void)) 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. */ @@ -399,7 +401,7 @@ void GarbageCollect(void (*get_roots)(void)) 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]; @@ -456,6 +458,7 @@ void GarbageCollect(void (*get_roots)(void)) /* 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) { @@ -470,6 +473,11 @@ void GarbageCollect(void (*get_roots)(void)) /* 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... */ @@ -545,6 +553,16 @@ void GarbageCollect(void (*get_roots)(void)) /* 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. */ @@ -661,16 +679,6 @@ void GarbageCollect(void (*get_roots)(void)) } 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); @@ -694,7 +702,7 @@ void GarbageCollect(void (*get_roots)(void)) 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); } /* ----------------------------------------------------------------------------- diff --git a/ghc/rts/Stats.c b/ghc/rts/Stats.c index c5a3687..c6f7f74 100644 --- a/ghc/rts/Stats.c +++ b/ghc/rts/Stats.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $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 * @@ -85,6 +85,7 @@ static double InitUserTime = 0.0; 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 */ @@ -271,7 +272,7 @@ stat_startGC(void) -------------------------------------------------------------------------- */ 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; @@ -299,9 +300,10 @@ stat_endGC(lnat alloc, lnat collect, lnat live, lnat gen) 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) { @@ -350,6 +352,9 @@ stat_exit(int alloc) 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", diff --git a/ghc/rts/Stats.h b/ghc/rts/Stats.h index 9908e1c..f5da72c 100644 --- a/ghc/rts/Stats.h +++ b/ghc/rts/Stats.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $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 * @@ -13,6 +13,7 @@ extern StgDouble usertime(void); 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);