This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Improve zone allocator allocation performance
- From: Daniel Jacobowitz <drow at false dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dberlin at dberlin dot org
- Date: Mon, 23 Aug 2004 16:22:54 -0400
- Subject: Improve zone allocator allocation performance
This patch brings the zone allocator roughly to par with the page allocator.
A brief comparison, all boostrapped with --disable-checking:
Page collector, -O2:
Average: real 367.07633s user 357.19500s sys 9.57467s
StdDev: real 2.31361 user 1.86720 sys 0.09340
Patched zone collector, -O2:
Average: real 369.10167s user 358.33100s sys 10.77833s
StdDev: real 3.72507 user 3.62755 sys 0.10756
Page collector, -O0 -g:
Average: real 129.31100s user 122.74267s sys 6.58167s
StdDev: real 1.37410 user 0.99542 sys 0.40052
Patched zone collector, -O0 -g:
Average: real 132.18700s user 124.46667s sys 7.20700s
StdDev: real 0.80239 user 0.25871 sys 0.05546
Page collector bootstrap:
2307.99s user 412.17s system 179% cpu 25:18.15 total
Patched zone collector bootstrap:
2321.49s user 413.19s system 179% cpu 25:20.33 total
So we're still holding at from half a percentage point to two percentage
points slower. It used to be much worse, and I think there's still some
room to improve. I'm not sure how each of allocation, collection, and
general locality issues are currently affected; I'll run some more profiling
later to find out.
Patch OK?
--
Daniel Jacobowitz
2004-08-23 Daniel Jacobowitz <dan@debian.org>
* ggc-zone.c (struc alloc_chunk): Rearrange flag bits and SIZE.
Remove TYPECODE.
(ggc_alloc_zone_1): Mark TYPE as unused. Don't save it in the chunk.
Index: ggc-zone.c
===================================================================
RCS file: /home/drow/rsync/gcc-cvs/gcc/gcc/ggc-zone.c,v
retrieving revision 2.18
diff -u -p -r2.18 ggc-zone.c
--- ggc-zone.c 9 Aug 2004 23:11:08 -0000 2.18
+++ ggc-zone.c 23 Aug 2004 20:16:06 -0000
@@ -146,10 +146,13 @@ struct alloc_chunk {
unsigned int magic;
#endif
unsigned int type:1;
- unsigned int typecode:14;
- unsigned int large:1;
- unsigned int size:15;
unsigned int mark:1;
+ unsigned char large;
+ unsigned short size;
+ /* Right now, on 32-bit hosts we don't have enough room to save the
+ typecode unless we make the one remaining flag into a bitfield.
+ There's a performance cost to that, so we don't do it until we're
+ ready to use the type information for something. */
union {
struct alloc_chunk *next_free;
char data[1];
@@ -594,7 +597,8 @@ free_chunk (struct alloc_chunk *chunk, s
/* Allocate a chunk of memory of SIZE bytes. */
static void *
-ggc_alloc_zone_1 (size_t orig_size, struct alloc_zone *zone, short type
+ggc_alloc_zone_1 (size_t orig_size, struct alloc_zone *zone,
+ short type ATTRIBUTE_UNUSED
MEM_STAT_DECL)
{
size_t bin = 0;
@@ -696,7 +700,8 @@ ggc_alloc_zone_1 (size_t orig_size, stru
#endif
chunk->type = 1;
chunk->mark = 0;
- chunk->typecode = type;
+ /* We could save TYPE in the chunk, but we don't use that for
+ anything yet. */
result = chunk->u.data;
#ifdef ENABLE_GC_CHECKING