diff options
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 14 | ||||
-rw-r--r-- | gcc/ggc-common.c | 41 | ||||
-rw-r--r-- | gcc/ggc.h | 5 | ||||
-rw-r--r-- | gcc/toplev.c | 5 |
6 files changed, 74 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 746458b..17655e6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +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. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index b0920e0..e00b288 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1375,7 +1375,7 @@ gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) varray.h 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) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f47c51e..69aef14 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4473,7 +4473,9 @@ 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 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. @@ -4486,10 +4488,12 @@ 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. 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 diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index e9c2f02..8a8f7ecd 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 +} @@ -262,3 +262,8 @@ extern void ggc_print_common_statistics PARAMS ((FILE *, ggc_statistics *)); /* 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)); diff --git a/gcc/toplev.c b/gcc/toplev.c index 92bc8ad..4489852 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -4638,6 +4638,8 @@ print_version (file, indent) 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 @@ -4893,6 +4895,9 @@ parse_options_and_default_flags (argc, argv) /* 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) (); |