This is the mail archive of the 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]

Trying to understand ggc-page vs. ggc-simple

Hi there,

Could someone please explain to me the difference between ggc-page and
ggc-simple and the logic behind them? I've been completely ignorant to this
whole thing mostly, but I got a rude awakening around this New Year when
ggc-page, which configure picked by default, overflowed my 64 MB systemwide VM
space while compiling fold-const.c in stage 2. configuring --with-gc=simple,
which is what I have been doing since then, solves the problem and my peak
virtual memory usage during bootstrap is around 28 MB I think (which does
require a special kernel configuration to let a single process hog this much
VM, but is still OK with me, and even almost fits into my current physical
memory of 24 MB). This is on 4.3BSD VAX VMUNIX of course.

Now when I started looking into what ggc-page does and why is it necessary in
the first place, I got confused. First it tries to do something with mmap if
available. Berkeley VMUNIX doesn't have mmap and never will, it has and always
will have the traditional VAX VMUNIX model with text at the start of P0,
followed by the data space sizable with the break system call, and the stack
automatically growing downward from the top of P1. I don't know what mmap does
on "modern systems" and don't want to ever know, so I won't try to judge what
advantages might mmap and ggc-page bring on those systems. However, I have a
hard time understanding what is ggc-page trying to do *on traditional VMUNIX*.

I recall that there have been some recent changes in ggc-page, but I didn't
follow closely. Back in December when I was looking into this, ggc-page
required either mmap or valloc, otherwise ggc-simple was chosen. 4.3BSD does
have valloc, though, which is why ggc-page got chosen. What I cannot
understand, however, is what purpose are the valloc and ggc-page serving other
than wasting memory and running out of it like it did for me. On 4.3BSD
valloc is a libc function:

char *
	int i;
	int valsiz = getpagesize(), j;
	char *cp = malloc(i + (valsiz-1));

	j = ((int)cp + (valsiz-1)) &~ (valsiz-1);
	return ((char *)j);

All it does is waste memory, malloc'ing 1023 bytes more than it was asked for
and returning a 1024-byte page cluster-aligned block. This function is present
in Berkeley UNIX only for the benefit of very special VAX-specific system-level
programs that mess with the kernel's VM internals or directly access VAX
hardware and thus require their data structures to be aligned with the kernel
VM system's notion of page clusters. However, using valloc or caring about page
sizes and page alignment in ordinary user programs is completely useless and
does nothing except wasting memory, which ggc-page did very well (for a single
process to hog and overflow a 64 MB systemwide VM space is certainly the all-
time world record for Berkeley VMUNIX).

Now could some kind soul please explain to me just why does ggc-page do this
and just what advantages does it have over ggc-simple? TIA.

Michael Sokolov
Public Service Agent
International Engineering and Science Task Force

1351 VINE AVE APT 27		Phone: +1-714-738-5409
FULLERTON CA 92833-4291 USA	(home office)

E-mail: msokolov@ivan.Harhan.ORG (ARPA TCP/SMTP)

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