This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Avoid over-frequent GC on large working sets


On a 32-bit machine, the calculation of min_expand will overflow
at the default value (30) of GGC_MIN_EXPAND when GCed memory is about
136M, and from then on GC will occur every time ggc_collect is called,
which is certainly not what you want.  If GGC_MIN_EXPAND is set
higher, like Darwin's default of 100, this happens more often, like
40Mb on Darwin.  Ouch!

Bootstrapped & tested on powerpc-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-gcoverflow.patch======================
2003-01-10  Geoffrey Keating  <geoffk@apple.com>

	* ggc-page.c (ggc_collect): Avoid overflow computing
	min_expand.

Index: ggc-page.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-page.c,v
retrieving revision 1.59
diff -u -p -u -p -r1.59 ggc-page.c
--- ggc-page.c	10 Jan 2003 02:22:03 -0000	1.59
+++ ggc-page.c	10 Jan 2003 22:27:39 -0000
@@ -1509,10 +1509,10 @@ ggc_collect ()
   /* Avoid frequent unnecessary work by skipping collection if the
      total allocations haven't expanded much since the last
      collection.  */
-  size_t allocated_last_gc =
+  float 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;
+  float min_expand = allocated_last_gc * PARAM_VALUE (GGC_MIN_EXPAND) / 100;
 
   if (G.allocated < allocated_last_gc + min_expand)
     return;
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]