Permalink
Browse files

[project @ 1999-01-13 17:25:37 by simonm]

Added a generational garbage collector.

The collector is reliable but fairly untuned as yet.  It works with an
arbitrary number of generations: use +RTS -G<gens> to change the
number of generations used (default 2).

Stats: +RTS -Sstderr is quite useful, but to really see what's going
on compile the RTS with -DDEBUG and use +RTS -D32.

ARR_PTRS removed - it wasn't used anywhere.

Sanity checking improved:
	- free blocks are now spammed when sanity checking is turned on
	- a check for leaking blocks is performed after each GC.
  • Loading branch information...
1 parent dc49719 commit 4391e44f910ce579f269986faef9e5db8907a6c0 simonm committed Jan 13, 1999
@@ -63,18 +63,26 @@ operation, but there are several things that can be tweaked for
maximum performance.
<descrip>
+<tag>@-G<generations>@:</tag>
+<nidx>-G&lt;generations&gt; RTS option</nidx>
+<nidx>generations, number of</nidx>
+
+[Default: 2] Set the number of generations used by the garbage
+collector. The default of 2 seems to be good, but the garbage
+collector can support any number of generations. NOTE: -G1 (i.e. a
+two-space copying collector) is currently not supported.
+
<tag>@-A<size>@:</tag>
<nidx>-A&lt;size&gt; RTS option</nidx>
<nidx>allocation area, size</nidx>
-[Default: 256k] Set the minimum (and initial) allocation area size
-used by the garbage collector. The allocation area is resized after
-each garbage collection to be a multiple of the size of the current
-live data (currently a factor of 2).
+[Default: 256k] Set the allocation area size used by the garbage
+collector. The allocation area (actually generation 0 step 0) is
+fixed and is never resized.
-Increasing the minimum allocation area size will typically give better
-performance for programs which quickly generate a large amount of live
-data.
+Increasing the allocation area size may or may not give better
+performance (a bigger allocation area means worse cache behaviour but
+fewer garbage collections and less promotion).
<tag>@-k<size>@:</tag>
<nidx>-k&lt;size&gt; RTS option</nidx>
@@ -132,26 +140,26 @@ heap size based on the current amount of live data.
%PostScript), using the @stat2resid@<nidx>stat2resid</nidx> utility in
%the GHC distribution (@ghc/utils/stat2resid@).
-<tag>@-F2s@:</tag>
-<nidx>-F2s RTS option</nidx>
-
-Forces a program compiled for generational GC to use two-space copying
-collection. The two-space collector may outperform the generational
-collector for programs which have a very low heap residency. It can
-also be used to generate a statistics file from which a basic heap
-residency profile can be produced (see Section <ref name="stat2resid -
-residency info from GC stats" id="stat2resid">).
-
-There will still be a small execution overhead imposed by the
-generational compilation as the test for old generation updates will
-still be executed (of course none will actually happen). This
-overhead is typically less than 1\%.
-
-<tag>@-j<size>@:</tag>
-<nidx>-j&lt;size&gt; RTS option</nidx>
-Force a major garbage collection every @<size>@ bytes. (Normally
-used because you're keen on getting major-GC stats, notably heap residency
-info.)
+% <tag>@-F2s@:</tag>
+% <nidx>-F2s RTS option</nidx>
+%
+% Forces a program compiled for generational GC to use two-space copying
+% collection. The two-space collector may outperform the generational
+% collector for programs which have a very low heap residency. It can
+% also be used to generate a statistics file from which a basic heap
+% residency profile can be produced (see Section <ref name="stat2resid -
+% residency info from GC stats" id="stat2resid">).
+%
+% There will still be a small execution overhead imposed by the
+% generational compilation as the test for old generation updates will
+% still be executed (of course none will actually happen). This
+% overhead is typically less than 1\%.
+%
+% <tag>@-j<size>@:</tag>
+% <nidx>-j&lt;size&gt; RTS option</nidx>
+% Force a major garbage collection every @<size>@ bytes. (Normally
+% used because you're keen on getting major-GC stats, notably heap residency
+% info.)
</descrip>
View
@@ -2301,7 +2301,7 @@ sub process_ghc_timings {
$MaxResidency = $1; $ResidencySamples = $2;
}
- $GCs = $1 if /^\s*([0-9,]+) garbage collections? performed/;
+ $GCs = $1 if /^\s*([0-9,]+) (collections? in generation 0|garbage collections? performed)/;
# The presence of -? in the following pattern is only there to
# accommodate 0.29 && <= 2.05 RTS'
View
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $Id: Block.h,v 1.2 1998/12/02 13:20:53 simonm Exp $
+ * $Id: Block.h,v 1.3 1999/01/13 17:25:51 simonm Exp $
*
* Block structure for the storage manager
*
@@ -43,13 +43,14 @@ typedef struct _bdescr {
StgPtr free; /* first free byte of memory */
struct _bdescr *link; /* used for chaining blocks together */
struct _bdescr *back; /* used (occasionally) for doubly-linked lists*/
- StgNat32 gen; /* generation */
- StgNat32 step; /* step */
+ struct _generation *gen; /* generation */
+ struct _step *step; /* step */
StgNat32 blocks; /* no. of blocks (if grp head, 0 otherwise) */
+ StgNat32 evacuated; /* block is in to-space */
#if SIZEOF_VOID_P == 8
- StgNat32 _padding[5];
+ StgNat32 _padding[2];
#else
- StgNat32 _padding[1];
+ StgNat32 _padding[0];
#endif
} bdescr;
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
- * $Id: ClosureMacros.h,v 1.2 1998/12/02 13:20:58 simonm Exp $
+ * $Id: ClosureMacros.h,v 1.3 1999/01/13 17:25:52 simonm Exp $
*
* Macros for building and manipulating closures
*
@@ -186,8 +186,8 @@ static __inline__ StgOffset pap_sizeW( StgPAP* x )
*/
static __inline__ StgOffset arr_words_sizeW( StgArrWords* x )
{ return sizeofW(StgArrWords) + x->words; }
-static __inline__ StgOffset arr_ptrs_sizeW( StgArrPtrs* x )
-{ return sizeofW(StgArrPtrs) + x->ptrs; }
+static __inline__ StgOffset mut_arr_ptrs_sizeW( StgMutArrPtrs* x )
+{ return sizeofW(StgMutArrPtrs) + x->ptrs; }
static __inline__ StgWord bco_sizeW( StgBCO* bco )
{ return BCO_sizeW(bco->n_ptrs,bco->n_words,bco->n_instrs); }
@@ -241,8 +241,6 @@ static __inline__ StgWord tso_sizeW ( StgTSO *tso )
SET_TICKY_HDR((StgClosure *)(c),0); \
}
-/* works for all ARR_WORDS, ARR_PTRS variants (at the moment...) */
-
#define SET_ARR_HDR(c,info,costCentreStack,n_words) \
SET_HDR(c,info,costCentreStack); \
(c)->words = n_words;
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
- * $Id: ClosureTypes.h,v 1.2 1998/12/02 13:20:58 simonm Exp $
+ * $Id: ClosureTypes.h,v 1.3 1999/01/13 17:25:52 simonm Exp $
*
* Closure Type Constants
*
@@ -12,66 +12,53 @@
/* Object tag 0 raises an internal error */
#define INVALID_OBJECT 0
-
#define CONSTR 1
/* #define CONSTR_p_np */
#define CONSTR_INTLIKE 2
#define CONSTR_CHARLIKE 3
#define CONSTR_STATIC 4
#define CONSTR_NOCAF_STATIC 5
-
#define FUN 6
#define FUN_STATIC 7
-
#define THUNK 8
/* #define THUNK_p_np */
#define THUNK_STATIC 9
#define THUNK_SELECTOR 10
-
#define BCO 11
-
#define AP_UPD 12
#define PAP 13
-
#define IND 14
#define IND_OLDGEN 15
#define IND_PERM 16
#define IND_OLDGEN_PERM 17
#define IND_STATIC 18
-
#define CAF_UNENTERED 19
#define CAF_ENTERED 20
#define CAF_BLACKHOLE 21
-
#define RET_BCO 22
#define RET_SMALL 23
#define RET_VEC_SMALL 24
#define RET_BIG 25
#define RET_VEC_BIG 26
#define RET_DYN 27
#define UPDATE_FRAME 28
-#define CATCH_FRAME 29
-#define STOP_FRAME 30
-#define SEQ_FRAME 31
-
-#define BLACKHOLE 32
-#define MVAR 33
-
-#define ARR_WORDS 34
-#define ARR_PTRS 35
-
-#define MUT_ARR_WORDS 36
-#define MUT_ARR_PTRS 37
-#define MUT_ARR_PTRS_FROZEN 38
-#define MUT_VAR 39
-
-#define WEAK 40
-#define FOREIGN 41
-
-#define TSO 42
-#define BLOCKED_FETCH 43
-#define FETCH_ME 44
-
-#define EVACUATED 45
+#define UPDATE_STATIC_FRAME 29
+#define CATCH_FRAME 30
+#define STOP_FRAME 31
+#define SEQ_FRAME 32
+#define BLACKHOLE 33
+#define BLACKHOLE_STATIC 34
+#define MVAR 35
+#define ARR_WORDS 36
+#define MUT_ARR_WORDS 37
+#define MUT_ARR_PTRS 38
+#define MUT_ARR_PTRS_FROZEN 39
+#define MUT_VAR 40
+#define WEAK 41
+#define FOREIGN 42
+#define TSO 43
+#define BLOCKED_FETCH 44
+#define FETCH_ME 45
+#define EVACUATED 46
#endif CLOSURETYPES_H
View
@@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
- * $Id: Closures.h,v 1.2 1998/12/02 13:20:59 simonm Exp $
+ * $Id: Closures.h,v 1.3 1999/01/13 17:25:53 simonm Exp $
*
* Closures
*
@@ -113,6 +113,19 @@ typedef struct StgClosure_ {
struct StgClosure_ *payload[0];
} StgClosure;
+/* What a stroke of luck - all our mutable closures follow the same
+ * basic layout, with the mutable link field as the second field after
+ * the header. This means the following structure is the supertype of
+ * mutable closures.
+ */
+
+typedef struct StgMutClosure_ {
+ StgHeader header;
+ StgPtr *padding;
+ struct StgMutClosure_ *mut_link;
+ struct StgClosure_ *payload[0];
+} StgMutClosure;
+
typedef struct {
StgHeader header;
StgClosure *selectee;
@@ -147,8 +160,8 @@ typedef struct {
typedef struct {
StgHeader header;
- StgClosure *mut_link;
StgClosure *indirectee;
+ StgMutClosure *mut_link;
} StgIndOldGen;
typedef struct {
@@ -178,12 +191,14 @@ typedef struct {
typedef struct {
StgHeader header;
StgWord ptrs;
+ StgMutClosure *mut_link; /* mutable list */
StgClosure *payload[0];
-} StgArrPtrs;
+} StgMutArrPtrs;
typedef struct {
StgHeader header;
StgClosure *var;
+ StgMutClosure *mut_link;
} StgMutVar;
typedef struct _StgUpdateFrame {
@@ -251,8 +266,9 @@ typedef struct {
typedef struct {
StgHeader header;
- struct StgTSO_* head;
- struct StgTSO_* tail;
+ struct StgTSO_ *head;
+ StgMutClosure *mut_link;
+ struct StgTSO_ *tail;
StgClosure* value;
} StgMVar;
Oops, something went wrong.

0 comments on commit 4391e44

Please sign in to comment.