* Re: Disabling CSE passes and GC? [+ a little bookkeeping patch]
2002-12-10 12:05 ` Geoff Keating
@ 2002-12-21 10:39 ` Segher Boessenkool
0 siblings, 0 replies; 4+ messages in thread
From: Segher Boessenkool @ 2002-12-21 10:39 UTC (permalink / raw)
To: gcc-patches; +Cc: gcc
Geoff Keating wrote:
>
> You can effectively disable GC in GCC 3.3 by using
> --param ggc-min-heapsize=<size in K>
> and letting GCC grow the heap to a very large size before collecting.
> The default is 4096, which means GCC won't run collection until the
> heap is 4Mb or larger; you might want to pick a number like 128000, if
> your machine has 256Mb of memory.
I use minimum 16MB and minimum "grow factor" of 4, before doing GC;
works fine, and saves about 30% wall clock time. This is probably
too big to have as default for GCC on all systems, though; but
setting the grow factor to 2 helps a lot, already. The current
default of 1.2 isn't very well tuned, it seems.
Before I forget: maybe someone tuning GC will find the attached
old patch useful: it reports which pass allocated how much GC-able
memory (but it doesn't report when it is freed).
No Changelog, I'm lazy, this is just some boring code that someone
might find useful while investigating GC speedup. And the FSF didn't
process my papers yet anyway. Oh, and it's for ggc-page only, btw.
Segher
--- /home/segher/gcc/gcc-20020805/gcc/timevar.c Fri Nov 16 03:36:39 2001
+++ ./timevar.c Mon Aug 19 18:20:56 2002
@@ -24,6 +24,8 @@
#include "intl.h"
#include "rtl.h"
+extern HOST_WIDE_INT ggc_total_allocated;
+
#ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
@@ -186,6 +188,8 @@
now->sys = 0;
now->wall = 0;
+ now->alloc = 0;
+
if (!TIMEVAR_ENABLE)
return;
@@ -206,6 +210,8 @@
now->user = clock () * clocks_to_msec;
#endif
}
+
+ now->alloc = ggc_total_allocated;
}
/* Add the difference between STOP_TIME and START_TIME to TIMER. */
@@ -219,6 +225,8 @@
timer->user += stop_time->user - start_time->user;
timer->sys += stop_time->sys - start_time->sys;
timer->wall += stop_time->wall - start_time->wall;
+
+ timer->alloc += stop_time->alloc - start_time->alloc;
}
/* Initialize timing variables. */
@@ -464,7 +472,8 @@
zeroes. */
if (tv->elapsed.user < tiny
&& tv->elapsed.sys < tiny
- && tv->elapsed.wall < tiny)
+ && tv->elapsed.wall < tiny
+ && tv->elapsed.alloc < tiny * 1048576)
continue;
/* The timing variable name. */
@@ -491,6 +500,11 @@
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
#endif /* HAVE_WALL_TIME */
+ /* Print Megabytes allocated in GC memory. */
+ fprintf(fp, "%7.2f (%2.0f%%) alloc",
+ tv->elapsed.alloc / 1048576.,
+ (total->alloc == 0 ? 0 : (double)tv->elapsed.alloc / total->alloc) * 100);
+
putc ('\n', fp);
}
@@ -503,9 +517,10 @@
fprintf (fp, "%7.2f ", total->sys);
#endif
#ifdef HAVE_WALL_TIME
- fprintf (fp, "%7.2f\n", total->wall);
+ fprintf (fp, "%7.2f ", total->wall);
#endif
-
+ fprintf (fp, "%7.2f\n", total->alloc / 1048576.);
+
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|| defined (HAVE_WALL_TIME) */
}
--- /home/segher/gcc/gcc-20020805/gcc/timevar.h Tue Oct 30 00:01:45 2001
+++ ./timevar.h Mon Aug 19 16:49:12 2002
@@ -61,6 +61,9 @@
/* Wall clock time. */
float wall;
+
+ /* GC allocated bytes. */
+ HOST_WIDE_INT alloc;
};
/* An enumeration of timing variable identifiers. Constructed from
--- /home/segher/gcc/gcc-20020805/gcc/ggc-page.c Sat Jan 5 23:11:21 2002
+++ ./ggc-page.c Mon Aug 19 20:59:59 2002
@@ -335,6 +335,8 @@
FILE *debug_file;
} G;
+HOST_WIDE_INT ggc_total_allocated;
+
/* The size in bytes required to maintain a bitmap for the objects
on a page-entry. */
#define BITMAP_SIZE(Num_objects) \
@@ -952,6 +954,7 @@
/* Keep track of how many bytes are being allocated. This
information is used in deciding when to collect. */
G.allocated += OBJECT_SIZE (order);
+ ggc_total_allocated += size;
if (GGC_DEBUG_LEVEL >= 3)
fprintf (G.debug_file,
@@ -1046,6 +1049,8 @@
init_ggc ()
{
unsigned order;
+
+ ggc_total_allocated = 0;
G.pagesize = getpagesize();
G.lg_pagesize = exact_log2 (G.pagesize);
^ permalink raw reply [flat|nested] 4+ messages in thread