diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-14 20:29:13 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-05-14 20:29:13 +0000 |
commit | 05b4293bd82035b22d673da90e64eae38beb4ceb (patch) | |
tree | 908b6f1f1bd1b7f82e0184051920becede4f17f5 /src | |
parent | 0ff7a2c2ad04404aeb1f45e1ae5d67dc91b575ee (diff) | |
download | postgresql-05b4293bd82035b22d673da90e64eae38beb4ceb.tar.gz postgresql-05b4293bd82035b22d673da90e64eae38beb4ceb.zip |
Minor speed hacks in AllocSetReset: avoid clearing the freelist headers
when the blocks list is empty (there can surely be no freelist items if
the context contains no memory), and use MemSetAligned not MemSet to
clear the headers (we assume alignof(pointer) >= alignof(int32)).
Per discussion with Atsushi Ogawa. He proposes some further hacking
that I'm not yet sold on, but these two changes are unconditional wins
since there is no case in which they make things slower.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/mmgr/aset.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 386d4508b37..4f60b186c27 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.59 2004/12/31 22:02:48 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.60 2005/05/14 20:29:13 tgl Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -395,12 +395,17 @@ AllocSetReset(MemoryContext context) AllocSetCheck(context); #endif + /* Nothing to do if context has never contained any data */ + if (block == NULL) + return; + /* Clear chunk freelists */ - MemSet(set->freelist, 0, sizeof(set->freelist)); + MemSetAligned(set->freelist, 0, sizeof(set->freelist)); + /* New blocks list is either empty or just the keeper block */ set->blocks = set->keeper; - while (block != NULL) + do { AllocBlock next = block->next; @@ -427,6 +432,7 @@ AllocSetReset(MemoryContext context) } block = next; } + while (block != NULL); } /* @@ -451,7 +457,7 @@ AllocSetDelete(MemoryContext context) #endif /* Make it look empty, just in case... */ - MemSet(set->freelist, 0, sizeof(set->freelist)); + MemSetAligned(set->freelist, 0, sizeof(set->freelist)); set->blocks = NULL; set->keeper = NULL; |