From: simonmar Date: Wed, 8 Aug 2001 14:14:09 +0000 (+0000) Subject: [project @ 2001-08-08 14:14:08 by simonmar] X-Git-Tag: Approximately_9120_patches~1311 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=f3d40a6e45424480276d701f20b1ab4ea4278af4;p=ghc-hetmet.git [project @ 2001-08-08 14:14:08 by simonmar] Flag tweaks: +RTS -c now means "enable compaction all the time" (previously there was no way to do this *and* run without a maximum heap size). The heuristics for determining the generation sizes are also slightly better now. --- diff --git a/ghc/includes/RtsFlags.h b/ghc/includes/RtsFlags.h index 7ecb437..4e1bcc1 100644 --- a/ghc/includes/RtsFlags.h +++ b/ghc/includes/RtsFlags.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RtsFlags.h,v 1.36 2001/08/07 10:11:05 simonmar Exp $ + * $Id: RtsFlags.h,v 1.37 2001/08/08 14:14:09 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -35,7 +35,7 @@ struct GC_FLAGS { nat steps; rtsBool squeezeUpdFrames; - rtsBool compact; + rtsBool compact; /* True <=> "compact all the time" */ double compactThreshold; rtsBool ringBell; diff --git a/ghc/rts/GC.c b/ghc/rts/GC.c index 66d7d86..e0a665e 100644 --- a/ghc/rts/GC.c +++ b/ghc/rts/GC.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: GC.c,v 1.117 2001/08/08 13:45:02 simonmar Exp $ + * $Id: GC.c,v 1.118 2001/08/08 14:14:08 simonmar Exp $ * * (c) The GHC Team 1998-1999 * @@ -735,14 +735,28 @@ GarbageCollect ( void (*get_roots)(evac_fn), rtsBool force_major_gc ) RtsFlags.GcFlags.minOldGenSize); // minimum size for generation zero - min_alloc = (RtsFlags.GcFlags.pcFreeHeap * max) / 200; + min_alloc = stg_max((RtsFlags.GcFlags.pcFreeHeap * max) / 200, + RtsFlags.GcFlags.minAllocAreaSize); + + // Auto-enable compaction when the residency reaches a + // certain percentage of the maximum heap size (default: 30%). + if (RtsFlags.GcFlags.compact || + (max > 0 && + oldest_gen->steps[0].n_blocks > + (RtsFlags.GcFlags.compactThreshold * max) / 100)) { + oldest_gen->steps[0].is_compacted = 1; +// fprintf(stderr,"compaction: on\n", live); + } else { + oldest_gen->steps[0].is_compacted = 0; +// fprintf(stderr,"compaction: off\n", live); + } // if we're going to go over the maximum heap size, reduce the // size of the generations accordingly. The calculation is // different if compaction is turned on, because we don't need // to double the space required to collect the old generation. if (max != 0) { - if (RtsFlags.GcFlags.compact) { + if (oldest_gen->steps[0].is_compacted) { if ( (size + (size - 1) * (gens - 2) * 2) + min_alloc > max ) { size = (max - min_alloc) / ((gens - 1) * 2 - 1); } @@ -765,19 +779,6 @@ GarbageCollect ( void (*get_roots)(evac_fn), rtsBool force_major_gc ) for (g = 0; g < gens; g++) { generations[g].max_blocks = size; } - - // Auto-enable compaction when the residency reaches a - // certain percentage of the maximum heap size (default: 30%). - if (RtsFlags.GcFlags.compact && - max > 0 && - oldest_gen->steps[0].n_blocks > - (RtsFlags.GcFlags.compactThreshold * max) / 100) { - oldest_gen->steps[0].is_compacted = 1; -// fprintf(stderr,"compaction: on\n", live); - } else { - oldest_gen->steps[0].is_compacted = 0; -// fprintf(stderr,"compaction: off\n", live); - } } // Guess the amount of live data for stats. diff --git a/ghc/rts/RtsFlags.c b/ghc/rts/RtsFlags.c index 5f6244e..3f44ccb 100644 --- a/ghc/rts/RtsFlags.c +++ b/ghc/rts/RtsFlags.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RtsFlags.c,v 1.45 2001/08/07 10:37:04 simonmar Exp $ + * $Id: RtsFlags.c,v 1.46 2001/08/08 14:14:08 simonmar Exp $ * * (c) The AQUA Project, Glasgow University, 1994-1997 * (c) The GHC Team, 1998-1999 @@ -237,7 +237,7 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.steps = 2; RtsFlags.GcFlags.squeezeUpdFrames = rtsTrue; #endif - RtsFlags.GcFlags.compact = rtsTrue; + RtsFlags.GcFlags.compact = rtsFalse; RtsFlags.GcFlags.compactThreshold = 30.0; #ifdef RTS_GTK_FRONTPANEL RtsFlags.GcFlags.frontpanel = rtsFalse; @@ -391,7 +391,7 @@ usage_text[] = { " -T Number of steps in younger generations (default: 2)", " -c Auto-enable compaction of the oldest generation when live data is", " at least % of the maximum heap size set with -M (default: 30%)", -" -c Disable compaction", +" -c Enable compaction for all major collections", "", " -t One-line GC statistics (default file: .stat)", " -s Summary GC statistics (with -Sstderr going to stderr)", @@ -654,11 +654,10 @@ error = rtsTrue; case 'c': if (rts_argv[arg][2] != '\0') { - RtsFlags.GcFlags.compact = rtsTrue; RtsFlags.GcFlags.compactThreshold = atof(rts_argv[arg]+2); } else { - RtsFlags.GcFlags.compact = rtsFalse; + RtsFlags.GcFlags.compact = rtsTrue; } break; diff --git a/ghc/rts/Storage.c b/ghc/rts/Storage.c index c98d2bf..51720d1 100644 --- a/ghc/rts/Storage.c +++ b/ghc/rts/Storage.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Storage.c,v 1.45 2001/08/08 11:27:17 simonmar Exp $ + * $Id: Storage.c,v 1.46 2001/08/08 14:14:08 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -162,7 +162,10 @@ initStorage( void ) generations[g].steps[s].to = &generations[g+1].steps[0]; } - /* The oldest generation has one step. */ + /* The oldest generation has one step and it is compacted. */ + if (RtsFlags.GcFlags.compact) { + oldest_gen->steps[0].is_compacted = 1; + } oldest_gen->steps[0].to = &oldest_gen->steps[0]; /* generation 0 is special: that's the nursery */