aboutsummaryrefslogtreecommitdiff
path: root/gcc/ggc-common.c
diff options
context:
space:
mode:
authorKaveh Ghazi <ghazi@caip.rutgers.edu>2003-02-22 03:08:47 +0000
committerKaveh Ghazi <ghazi@caip.rutgers.edu>2003-02-22 03:08:47 +0000
commit1d762f98b251a3b28d899c77771d8962be5dbb31 (patch)
treea4fedfbc4cbd08463a6d674fcb9176179935dd4d /gcc/ggc-common.c
parentde3b0ffb9341e72dc6c3ed8a5af27bb569e82620 (diff)
* Makefile.in (ggc-common.o): Depend on $(PARAMS_H)
* doc/invoke.texi (ggc-min-expand, ggc-min-heapsize): Update documentation. * ggc-common.c: Include params.h (ggc_min_expand_heuristic, ggc_min_heapsize_heuristic, init_ggc_heuristics): New functions. * ggc.h (ggc_min_expand_heuristic, ggc_min_heapsize_heuristic, init_ggc_heuristics): Prototype. * toplev.c (print_version): Output GGC heuristics. (parse_options_and_default_flags): Call init_ggc_heuristics. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@63268 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-common.c')
-rw-r--r--gcc/ggc-common.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index e9c2f020668..8a8f7ecd313 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -27,6 +27,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "hashtab.h"
#include "ggc.h"
#include "toplev.h"
+#include "params.h"
#ifdef HAVE_MMAP_FILE
# include <sys/mman.h>
@@ -624,3 +625,43 @@ gt_pch_restore (f)
gt_pch_restore_stringpool ();
}
+
+/* Heuristic to set a default for GGC_MIN_EXPAND. */
+int
+ggc_min_expand_heuristic()
+{
+ double min_expand = physmem_total();
+
+ /* The heuristic is a percentage equal to 30% + 70%*(RAM/1GB), yielding
+ a lower bound of 30% and an upper bound of 100% (when RAM >= 1GB). */
+ min_expand /= 1024*1024*1024;
+ min_expand *= 70;
+ min_expand = MIN (min_expand, 70);
+ min_expand += 30;
+
+ return min_expand;
+}
+
+/* Heuristic to set a default for GGC_MIN_HEAPSIZE. */
+int
+ggc_min_heapsize_heuristic()
+{
+ double min_heap_kbytes = physmem_total() / 1024;
+
+ /* The heuristic is RAM/8, with a lower bound of 4M and an upper
+ bound of 128M (when RAM >= 1GB). */
+ min_heap_kbytes /= 8;
+ min_heap_kbytes = MAX (min_heap_kbytes, 4 * 1024);
+ min_heap_kbytes = MIN (min_heap_kbytes, 128 * 1024);
+
+ return min_heap_kbytes;
+}
+
+void
+init_ggc_heuristics ()
+{
+#ifndef ENABLE_GC_ALWAYS_COLLECT
+ set_param_value ("ggc-min-expand", ggc_min_expand_heuristic());
+ set_param_value ("ggc-min-heapsize", ggc_min_heapsize_heuristic());
+#endif
+}