aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zack@codesourcery.com>2002-11-16 03:44:20 +0000
committerGeoffrey Keating <geoffk@apple.com>2002-11-16 03:44:20 +0000
commitf0086fa6bf605239619bb9d3fa9bcf3c594a128c (patch)
tree118b1f8b626283b5878b7812c2eeff784a82688f
parent1928c7a082ad06e5a41c6afad6f3a45a5d55d03e (diff)
Merge:
2002-11-11 Zack Weinberg <zack@codesourcery.com> * params.def (ggc-min-expand, ggc-min-heapsize): New parameters. * doc/invoke.texi: Document them. * ggc-page.c: Include params.h. Remove definitions of GGC_MIN_EXPAND_FOR_GC, GGC_MIN_LAST_ALLOCATED. Replace GGC_POISON with ENABLE_GC_CHECKING in ifdefs, delete #define. (init_gcc): Don't set G.allocated_last_gc here. (ggc_collect): Use PARAM_VALUE (GGC_MIN_HEAPSIZE) and PARAM_VALUE (GGC_MIN_EXPAND) to decide whether or not to perform collection. * ggc-simple.c: Similarly. * Makefile.in (ggc-common.o, ggc-simple.o): Add $(PARAMS_H) to dependencies. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/pch-branch@59150 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog18
-rw-r--r--gcc/Makefile.in4
-rw-r--r--gcc/doc/invoke.texi23
-rw-r--r--gcc/ggc-page.c50
-rw-r--r--gcc/ggc-simple.c36
-rw-r--r--gcc/params.def25
6 files changed, 89 insertions, 67 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2f8d3dd5714..e7cb3779153 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,7 @@
2002-11-15 Geoffrey Keating <geoffk@apple.com>
+ * ggc-page.c (ggc_pch_read): Remove unused 'bmap_size'.
+
* cpppch.c (cpp_read_state): Correct size reallocated for 'defn'.
2002-11-14 Geoffrey Keating <geoffk@apple.com>
@@ -413,6 +415,22 @@
(dwarf2out_init): Don't call ggc_add_root.
*** End of unmerged pch-branch ChangeLog ***
+2002-11-11 Zack Weinberg <zack@codesourcery.com>
+
+ * params.def (ggc-min-expand, ggc-min-heapsize): New parameters.
+ * doc/invoke.texi: Document them.
+
+ * ggc-page.c: Include params.h. Remove definitions of
+ GGC_MIN_EXPAND_FOR_GC, GGC_MIN_LAST_ALLOCATED. Replace
+ GGC_POISON with ENABLE_GC_CHECKING in ifdefs, delete #define.
+ (init_gcc): Don't set G.allocated_last_gc here.
+ (ggc_collect): Use PARAM_VALUE (GGC_MIN_HEAPSIZE) and
+ PARAM_VALUE (GGC_MIN_EXPAND) to decide whether or not to
+ perform collection.
+ * ggc-simple.c: Similarly.
+ * Makefile.in (ggc-common.o, ggc-simple.o): Add $(PARAMS_H) to
+ dependencies.
+
2002-11-08 Dale Johannesen <dalej@apple.com>
* dbxout.c (dbxout_type): Fix stabs info for vector types.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index d76b20a8e98..881bab2eca5 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1336,10 +1336,10 @@ ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) $(GGC_H) $(HASHTAB_H) \
toplev.h
ggc-simple.o: ggc-simple.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
- $(GGC_H) varray.h $(TIMEVAR_H) $(TM_P_H)
+ $(GGC_H) varray.h $(TIMEVAR_H) $(TM_P_H) $(PARAMS_H)
ggc-page.o: ggc-page.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
- toplev.h $(GGC_H) varray.h $(TIMEVAR_H) $(TM_P_H)
+ toplev.h $(GGC_H) varray.h $(TIMEVAR_H) $(TM_P_H) $(PARAMS_H)
stringpool.o: stringpool.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(OBSTACK_H) \
$(GGC_H) gt-stringpool.h
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 09be09927ab..d58bc6982ea 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4244,6 +4244,29 @@ compilation for profile feedback and one for compilation without. The value
for compilation with profile feedback needs to be more conservative (higher) in
order to make tracer effective.
+@item ggc-min-expand
+
+GCC uses a garbage collector to manage its own memory allocation. This
+parameter specifies the minimum percentage by which the garbage
+collector's heap should be allowed to expand between collections.
+Tuning this may improve compilation speed; it has no effect on code
+generation.
+
+The default is 30%. Setting this parameter to zero causes a full
+collection to occur at every opportunity. This is extremely slow, but
+can be useful for debugging.
+
+@item ggc-min-heapsize
+
+Minimum size of the garbage collector's heap before it begins bothering
+to collect garbage. The first collection occurs after the heap expands
+by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
+tuning this may improve compilation speed, and has no effect on code
+generation.
+
+The default is 4096 (four megabytes). Setting this parameter very large
+effectively disables garbage collection.
+
@end table
@end table
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 9df18744430..188b19639f2 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -28,6 +28,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "flags.h"
#include "ggc.h"
#include "timevar.h"
+#include "params.h"
/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
file open. Prefer either to valloc. */
@@ -88,23 +89,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
deallocated at the start of the next collection if they haven't
been recycled by then. */
-
-/* Define GGC_POISON to poison memory marked unused by the collector. */
-#undef GGC_POISON
-
-/* Define GGC_ALWAYS_COLLECT to perform collection every time
- ggc_collect is invoked. Otherwise, collection is performed only
- when a significant amount of memory has been allocated since the
- last collection. */
-#undef GGC_ALWAYS_COLLECT
-
-#ifdef ENABLE_GC_CHECKING
-#define GGC_POISON
-#endif
-#ifdef ENABLE_GC_ALWAYS_COLLECT
-#define GGC_ALWAYS_COLLECT
-#endif
-
/* Define GGC_DEBUG_LEVEL to print debugging information.
0: No debugging output.
1: GC statistics only.
@@ -376,16 +360,6 @@ static struct globals
#define BITMAP_SIZE(Num_objects) \
(CEIL ((Num_objects), HOST_BITS_PER_LONG) * sizeof(long))
-/* Skip garbage collection if the current allocation is not at least
- this factor times the allocation at the end of the last collection.
- In other words, total allocation must expand by (this factor minus
- one) before collection is performed. */
-#define GGC_MIN_EXPAND_FOR_GC (1.3)
-
-/* Bound `allocated_last_gc' to 4MB, to prevent the memory expansion
- test from triggering too often when the heap is small. */
-#define GGC_MIN_LAST_ALLOCATED (4 * 1024 * 1024)
-
/* Allocate pages in chunks of this size, to throttle calls to memory
allocation routines. The first page is used, the rest go onto the
free list. This cannot be larger than HOST_BITS_PER_INT for the
@@ -411,7 +385,7 @@ static void sweep_pages PARAMS ((void));
static void ggc_recalculate_in_use_p PARAMS ((page_entry *));
static void compute_inverse PARAMS ((unsigned));
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
static void poison_pages PARAMS ((void));
#endif
@@ -980,7 +954,7 @@ ggc_alloc (size)
/* Calculate the object's address. */
result = entry->page + object_offset;
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
/* `Poison' the entire allocated object, including any padding at
the end. */
memset (result, 0xaf, OBJECT_SIZE (order));
@@ -1141,8 +1115,6 @@ init_ggc ()
G.debug_file = stdout;
#endif
- G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
-
#ifdef USING_MMAP
/* StunOS has an amazing off-by-one error for the first mmap allocation
after fiddling with RLIMIT_STACK. The result, as hard as it is to
@@ -1445,7 +1417,7 @@ sweep_pages ()
}
}
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
/* Clobber all free objects. */
static inline void
@@ -1492,10 +1464,13 @@ ggc_collect ()
/* Avoid frequent unnecessary work by skipping collection if the
total allocations haven't expanded much since the last
collection. */
-#ifndef GGC_ALWAYS_COLLECT
- if (G.allocated < GGC_MIN_EXPAND_FOR_GC * G.allocated_last_gc)
+ size_t allocated_last_gc =
+ MAX (G.allocated_last_gc, (size_t)PARAM_VALUE (GGC_MIN_HEAPSIZE) * 1024);
+
+ size_t min_expand = allocated_last_gc * PARAM_VALUE (GGC_MIN_EXPAND) / 100;
+
+ if (G.allocated < allocated_last_gc + min_expand)
return;
-#endif
timevar_push (TV_GC);
if (!quiet_flag)
@@ -1512,15 +1487,13 @@ ggc_collect ()
clear_marks ();
ggc_mark_roots ();
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
poison_pages ();
#endif
sweep_pages ();
G.allocated_last_gc = G.allocated;
- if (G.allocated_last_gc < GGC_MIN_LAST_ALLOCATED)
- G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
timevar_pop (TV_GC);
@@ -1778,7 +1751,6 @@ ggc_pch_read (f, addr)
struct page_entry *entry;
char *pte;
size_t bytes;
- size_t bmap_size;
size_t num_objs;
size_t j;
diff --git a/gcc/ggc-simple.c b/gcc/ggc-simple.c
index 6479291aeec..f9a0029e130 100644
--- a/gcc/ggc-simple.c
+++ b/gcc/ggc-simple.c
@@ -28,20 +28,16 @@
#include "ggc.h"
#include "toplev.h"
#include "timevar.h"
+#include "params.h"
/* Debugging flags. */
/* Zap memory before freeing to catch dangling pointers. */
-#define GGC_POISON
+#undef GGC_POISON
/* Collect statistics on how bushy the search tree is. */
#undef GGC_BALANCE
-/* Perform collection every time ggc_collect is invoked. Otherwise,
- collection is performed only when a significant amount of memory
- has been allocated since the last collection. */
-#undef GGC_ALWAYS_COLLECT
-
/* Always verify that the to-be-marked memory is collectable. */
#undef GGC_ALWAYS_VERIFY
@@ -49,9 +45,6 @@
#define GGC_POISON
#define GGC_ALWAYS_VERIFY
#endif
-#ifdef ENABLE_GC_ALWAYS_COLLECT
-#define GGC_ALWAYS_COLLECT
-#endif
#ifndef HOST_BITS_PER_PTR
#define HOST_BITS_PER_PTR HOST_BITS_PER_LONG
@@ -116,16 +109,6 @@ static struct globals
int context;
} G;
-/* Skip garbage collection if the current allocation is not at least
- this factor times the allocation at the end of the last collection.
- In other words, total allocation must expand by (this factor minus
- one) before collection is performed. */
-#define GGC_MIN_EXPAND_FOR_GC (1.3)
-
-/* Bound `allocated_last_gc' to 4MB, to prevent the memory expansion
- test from triggering too often when the heap is small. */
-#define GGC_MIN_LAST_ALLOCATED (4 * 1024 * 1024)
-
/* Local function prototypes. */
static void tree_insert PARAMS ((struct ggc_mem *));
@@ -325,10 +308,16 @@ sweep_objs (root)
void
ggc_collect ()
{
-#ifndef GGC_ALWAYS_COLLECT
- if (G.allocated < GGC_MIN_EXPAND_FOR_GC * G.allocated_last_gc)
+ /* Avoid frequent unnecessary work by skipping collection if the
+ total allocations haven't expanded much since the last
+ collection. */
+ size_t allocated_last_gc =
+ MAX (G.allocated_last_gc, (size_t)PARAM_VALUE (GGC_MIN_HEAPSIZE) * 1024);
+
+ size_t min_expand = allocated_last_gc * PARAM_VALUE (GGC_MIN_EXPAND) / 100;
+
+ if (G.allocated < allocated_last_gc + min_expand)
return;
-#endif
#ifdef GGC_BALANCE
debug_ggc_balance ();
@@ -346,8 +335,6 @@ ggc_collect ()
sweep_objs (&G.root);
G.allocated_last_gc = G.allocated;
- if (G.allocated_last_gc < GGC_MIN_LAST_ALLOCATED)
- G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
timevar_pop (TV_GC);
@@ -364,7 +351,6 @@ ggc_collect ()
void
init_ggc ()
{
- G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
}
/* Start a new GGC context. Memory allocated in previous contexts
diff --git a/gcc/params.def b/gcc/params.def
index 1427819d2b8..d961189b3a5 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -1,5 +1,5 @@
/* params.def - Run-time parameters.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
This file is part of GCC.
@@ -190,6 +190,29 @@ DEFPARAM(TRACER_MIN_BRANCH_PROBABILITY,
"Stop forward growth if the probability of best edge is less than \
this threshold (in percents). Used when profile feedback is not available",
50)
+
+#ifdef ENABLE_GC_ALWAYS_COLLECT
+# define GGC_MIN_EXPAND_DEFAULT 0
+# define GGC_MIN_HEAPSIZE_DEFAULT 0
+#else
+# define GGC_MIN_EXPAND_DEFAULT 30
+# define GGC_MIN_HEAPSIZE_DEFAULT 4096
+#endif
+
+DEFPARAM(GGC_MIN_EXPAND,
+ "ggc-min-expand",
+ "Minimum heap expansion to trigger garbage collection, as \
+a percentage of the total size of the heap.",
+ GGC_MIN_EXPAND_DEFAULT)
+
+DEFPARAM(GGC_MIN_HEAPSIZE,
+ "ggc-min-heapsize",
+ "Minimum heap size before we start collecting garbage, in kilobytes.",
+ GGC_MIN_HEAPSIZE_DEFAULT)
+
+#undef GGC_MIN_EXPAND_DEFAULT
+#undef GGC_MIN_HEAPSIZE_DEFAULT
+
/*
Local variables:
mode:c