GC improvement
Henry Cejtin
henry@sourcelight.com
Wed, 27 Jun 2001 03:08:48 -0500
I did a quick hack changing gc.h to use my wordAlign() definition and
changing forward() in gc.c to actually test to make sure that all the
alignments were satisfied and to then just loop moving words instead of
calling memmove(). The result in a self compile was that GC time decreased
by 27% on a Red Hat 6.2 machine. Not huge, but definitely not bad. The most
extreme case is going to be when the live data consists of many small
objects. I don't know if this is the case with the self compile or not.
Any way, here are the changes to the two files. I will probably do some more
serious hacking on the gc, but if you agree that the relevant alignments are
all true in the copy loop, then you should replace the check with assert's
and put it in the official source. Also, if the memmove() in copyStack is
for non-overlapping regions, you should change it to a memcpy().
*** gc.orig.h Thu Apr 19 17:37:11 2001
--- gc.h Wed Jun 27 02:01:24 2001
***************
*** 85,91 ****
--- 85,95 ----
}
static inline uint wordAlign(uint p) {
+ #if 1 /* HCC */
+ return ((p + 3) & ~ 3);
+ #else
return ((1 + ((p - 1) >> 2)) << 2);
+ #endif
}
/* ------------------------------------------------- */
diff -c gc.orig.c gc.c
*** gc.orig.c Fri Jun 22 11:45:56 2001
--- gc.c Wed Jun 27 02:11:49 2001
***************
*** 965,971 ****
--- 965,989 ----
if (s->back + size + skip > s->toLimit)
die("Out of memory.");
/* Copy the object. */
+ #if 1 /* HCC */
+ {
+ uint *to,
+ *from,
+ *limit;
+
+ to = (uint *)s->back;
+ from = (uint *)(p - headerBytes);
+ if ((size & 3)
+ or ((uint)to & 3)
+ or ((uint)from & 3))
+ die("Henry: you blew it");
+ limit = (uint *)((char *)from + size);
+ until (from == limit)
+ *to++ = *from++;
+ }
+ #else
memmove(s->back, p - headerBytes, size);
+ #endif
/* Store the forwarding pointer in the old object. */
*(word*)(p - WORD_SIZE) = FORWARDED;
*(pointer*)p = s->back + headerBytes;