* 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: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63268
138bc75d-0d04-0410-961f-
82ee72b054a4
+2003-02-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * 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.
+
Sat Feb 22 02:35:07 CET 2003 Jan Hubicka <jh@suse.cz>
* i386.c (def_builtin): Special case 64bit builtins.
ssa.h cselib.h insn-addr.h
ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GGC_H) \
- $(HASHTAB_H) toplev.h
+ $(HASHTAB_H) toplev.h $(PARAMS_H)
ggc-simple.o: ggc-simple.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
flags.h $(GGC_H) varray.h $(TIMEVAR_H) $(TM_P_H) $(PARAMS_H)
Tuning this may improve compilation speed; it has no effect on code
generation.
-The default is 30%. Setting this parameter and
+The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
+RAM >= 1GB. If GCC is not able to calculate RAM on a particular
+platform, the lower bound of 30% is used. Setting this parameter and
@option{ggc-min-heapsize} to zero causes a full collection to occur at
every opportunity. This is extremely slow, but can be useful for
debugging.
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. Setting this parameter and
-@option{ggc-min-expand} to zero causes a full collection to occur at
-every opportunity.
+The default is RAM/8, with a lower bound of 4096 (four megabytes) and an
+upper bound of 131072 (128 megabytes). If GCC is not able to calculate
+RAM on a particular platform, the lower bound is used. Setting this
+parameter very large effectively disables garbage collection. Setting
+this parameter and @option{ggc-min-expand} to zero causes a full
+collection to occur at every opportunity.
@end table
@end table
#include "hashtab.h"
#include "ggc.h"
#include "toplev.h"
+#include "params.h"
#ifdef HAVE_MMAP_FILE
# include <sys/mman.h>
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
+}
/* Print allocation statistics. */
extern void ggc_print_statistics PARAMS ((void));
extern void stringpool_statistics PARAMS ((void));
+
+/* Heuristics. */
+extern int ggc_min_expand_heuristic PARAMS ((void));
+extern int ggc_min_heapsize_heuristic PARAMS ((void));
+extern void init_ggc_heuristics PARAMS ((void));
FILE *file;
const char *indent;
{
+ fnotice (file, "GGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n",
+ PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
#ifndef __VERSION__
#define __VERSION__ "[?]"
#endif
/* Register the language-independent parameters. */
add_params (lang_independent_params, LAST_PARAM);
+ /* This must be done after add_params but before argument processing. */
+ init_ggc_heuristics();
+
/* Perform language-specific options initialization. */
(*lang_hooks.init_options) ();