Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 05b4293

Browse files
committed
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.
1 parent 0ff7a2c commit 05b4293

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/backend/utils/mmgr/aset.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.59 2004/12/31 22:02:48 pgsql Exp $
14+
* $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.60 2005/05/14 20:29:13 tgl Exp $
1515
*
1616
* NOTE:
1717
* This is a new (Feb. 05, 1999) implementation of the allocation set
@@ -395,12 +395,17 @@ AllocSetReset(MemoryContext context)
395395
AllocSetCheck(context);
396396
#endif
397397

398+
/* Nothing to do if context has never contained any data */
399+
if (block == NULL)
400+
return;
401+
398402
/* Clear chunk freelists */
399-
MemSet(set->freelist, 0, sizeof(set->freelist));
403+
MemSetAligned(set->freelist, 0, sizeof(set->freelist));
404+
400405
/* New blocks list is either empty or just the keeper block */
401406
set->blocks = set->keeper;
402407

403-
while (block != NULL)
408+
do
404409
{
405410
AllocBlock next = block->next;
406411

@@ -427,6 +432,7 @@ AllocSetReset(MemoryContext context)
427432
}
428433
block = next;
429434
}
435+
while (block != NULL);
430436
}
431437

432438
/*
@@ -451,7 +457,7 @@ AllocSetDelete(MemoryContext context)
451457
#endif
452458

453459
/* Make it look empty, just in case... */
454-
MemSet(set->freelist, 0, sizeof(set->freelist));
460+
MemSetAligned(set->freelist, 0, sizeof(set->freelist));
455461
set->blocks = NULL;
456462
set->keeper = NULL;
457463

0 commit comments

Comments
 (0)