Major patch to speed up backend startup after profiling analysis.

This commit is contained in:
Bruce Momjian 1997-08-24 23:08:01 +00:00
parent 281ba3f40d
commit c4cb617504
9 changed files with 122 additions and 198 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.19 1997/08/19 21:28:49 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.20 1997/08/24 23:07:26 momjian Exp $
*
* NOTES
* The old interface functions have been converted to macros
@ -695,26 +695,20 @@ heap_getattr(HeapTuple tup,
if (attnum > (int) tup->t_natts) {
*isnull = true;
return ((char *) NULL);
} else if (attnum > 0) {
/* ----------------
* take care of user defined attributes
* ----------------
*/
return fastgetattr(tup, attnum, tupleDesc, isnull);
} else {
/* ----------------
* take care of system attributes
* ----------------
*/
*isnull = false;
return heap_getsysattr(tup, b, attnum);
}
/* ----------------
* take care of user defined attributes
* ----------------
*/
if (attnum > 0) {
char *datum;
datum = fastgetattr(tup, attnum, tupleDesc, isnull);
return (datum);
}
/* ----------------
* take care of system attributes
* ----------------
*/
*isnull = false;
return
heap_getsysattr(tup, b, attnum);
}
/* ----------------

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.13 1997/03/28 07:03:53 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.14 1997/08/24 23:07:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -22,6 +22,7 @@
#include <utils/rel.h>
#include <utils/tqual.h>
#include <storage/bufmgr.h>
#include <utils/builtins.h>
/* ----------------
* heap_keytest
@ -53,7 +54,9 @@ heap_keytest(HeapTuple t,
return (false);
}
if (keys->sk_flags & SK_COMMUTE)
if (keys->sk_func == (func_ptr)oideq) /* optimization */
test = (keys->sk_argument == atp);
else if (keys->sk_flags & SK_COMMUTE)
test = (long) FMGR_PTR2(keys->sk_func, keys->sk_procedure,
keys->sk_argument, atp);
else

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.19 1997/08/20 00:50:11 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.20 1997/08/24 23:07:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -44,12 +44,6 @@
#if defined(HAS_TEST_AND_SET)
# if defined(__alpha__) && defined(linux)
static long int tas(slock_t *lock);
# else
static int tas(slock_t *lock);
#endif
#if defined (nextstep)
/*
* NEXTSTEP (mach)
@ -167,6 +161,8 @@ S_LOCK_FREE(slock_t *lock)
defined(sparc_solaris)
/* for xxxxx_solaris, this is defined in port/.../tas.s */
static int tas(slock_t *lock);
void
S_LOCK(slock_t *lock)
{
@ -233,6 +229,8 @@ S_INIT_LOCK(slock_t *lock)
*/
static slock_t clear_lock = { -1, -1, -1, -1 };
static int tas(slock_t *lock);
void
S_LOCK(slock_t *lock)
{
@ -268,6 +266,8 @@ S_LOCK_FREE(slock_t *lock)
#if defined(sun3)
static int tas(slock_t *lock);
void
S_LOCK(slock_t *lock)
{
@ -320,6 +320,8 @@ tas_dummy()
#define asm(x) __asm__(x)
#endif
static int tas(slock_t *lock);
static int
tas_dummy()
{
@ -383,19 +385,14 @@ S_INIT_LOCK(unsigned char *addr)
#if defined(NEED_I386_TAS_ASM)
static int
tas(slock_t *m)
{
slock_t res;
__asm__("xchgb %0,%1":"=q" (res),"=m" (*m):"0" (0x1));
return(res);
}
void
S_LOCK(slock_t *lock)
{
while (tas(lock))
;
slock_t res;
do{
__asm__("xchgb %0,%1":"=q" (res),"=m" (*lock):"0" (0x1));
}while(res != 0);
}
void
@ -415,31 +412,26 @@ S_INIT_LOCK(slock_t *lock)
#if defined(__alpha__) && defined(linux)
static long int
tas(slock_t *m)
{
slock_t res;
__asm__(" ldq $0, %0 \n\
bne $0, already_set \n\
ldq_l $0, %0 \n\
bne $0, already_set \n\
or $31, 1, $0 \n\
stq_c $0, %0 \n\
beq $0, stqc_fail \n\
success: bis $31, $31, %1 \n\
mb \n\
jmp $31, end \n\
stqc_fail: or $31, 1, $0 \n\
already_set: bis $0, $0, %1 \n\
end: nop " : "=m" (*m), "=r" (res) :: "0" );
return(res);
}
void
S_LOCK(slock_t *lock)
{
while (tas(lock))
;
slock_t res;
do{
__asm__(" ldq $0, %0 \n\
bne $0, already_set \n\
ldq_l $0, %0 \n\
bne $0, already_set \n\
or $31, 1, $0 \n\
stq_c $0, %0 \n\
beq $0, stqc_fail \n\
success: bis $31, $31, %1 \n\
mb \n\
jmp $31, end \n\
stqc_fail: or $31, 1, $0 \n\
already_set: bis $0, $0, %1 \n\
end: nop " : "=m" (*lock), "=r" (res) :: "0" );
}while(res != 0);
}
void
@ -459,21 +451,16 @@ S_INIT_LOCK(slock_t *lock)
#if defined(linux) && defined(sparc)
static int
tas(slock_t *m)
{
slock_t res;
__asm__("ldstub [%1], %0"
: "=&r" (res)
: "r" (m));
return (res != 0);
}
void
S_LOCK(slock_t *lock)
{
while (tas(lock))
;
slock_t res;
do{
__asm__("ldstub [%1], %0"
: "=&r" (res)
: "r" (lock));
}while(!res != 0);
}
void
@ -490,41 +477,6 @@ S_INIT_LOCK(slock_t *lock)
#endif /* defined(linux) && defined(sparc) */
#if defined(NEED_NS32K_TAS_ASM)
static int
tas(slock_t *m)
{
slock_t res = 0;
__asm__("movd 8(fp), r1");
__asm__("movqd 0, r0");
__asm__("sbitd r0, 0(r1)");
__asm__("sprb us, %0" : "=r" (res));
res = (res >> 5) & 1;
return res;
}
void
S_LOCK(slock_t *lock)
{
while (tas(lock))
;
}
void
S_UNLOCK(slock_t *lock)
{
*lock = 0;
}
void
S_INIT_LOCK(slock_t *lock)
{
S_UNLOCK(lock);
}
#endif /* NEED_NS32K_TAS_ASM */
#if defined(linux) && defined(PPC)
static int tas_dummy()

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.7 1997/08/19 21:33:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.8 1997/08/24 23:07:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -31,43 +31,6 @@ static void PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr,
static bool PageManagerShuffle = true; /* default is shuffle mode */
/* ----------------------------------------------------------------
* Buffer support functions
* ----------------------------------------------------------------
*/
/*
* BufferGetPageSize --
* Returns the page size within a buffer.
*
* Notes:
* Assumes buffer is valid.
*
* The buffer can be a raw disk block and need not contain a valid
* (formatted) disk page.
*/
Size
BufferGetPageSize(Buffer buffer)
{
Size pageSize;
Assert(BufferIsValid(buffer));
pageSize = BLCKSZ; /* XXX dig out of buffer descriptor */
Assert(PageSizeIsValid(pageSize));
return (pageSize);
}
/*
* BufferGetPage --
* Returns the page associated with a buffer.
*/
Page
BufferGetPage(Buffer buffer)
{
return (Page) BufferGetBlock(buffer);
}
/* ----------------------------------------------------------------
* Page support functions
* ----------------------------------------------------------------
@ -94,31 +57,6 @@ PageInit(Page page, Size pageSize, Size specialSize)
PageSetPageSize(page, pageSize);
}
/*
* PageGetItem --
* Retrieves an item on the given page.
*
* Note:
* This does change the status of any of the resources passed.
* The semantics may change in the future.
*/
Item
PageGetItem(Page page, ItemId itemId)
{
Item item;
Assert(PageIsValid(page));
/* Assert(itemId->lp_flags & LP_USED); */
if(!(itemId->lp_flags & LP_USED)) {
elog(NOTICE, "LP_USED assertion failed. dumping core.");
abort();
}
item = (Item)(((char *)page) + itemId->lp_off);
return (item);
}
/*
* PageAddItem --
* Adds item to the given page.

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.7 1997/07/24 20:16:17 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.8 1997/08/24 23:07:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -96,6 +96,10 @@ char *oidout(Oid o)
* PUBLIC ROUTINES *
*****************************************************************************/
/*
* If you change this function, change heap_keytest()
* because we have hardcoded this in there as an optimization
*/
bool oideq(Oid arg1, Oid arg2)
{
return(arg1 == arg2);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.7 1997/08/19 21:34:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.8 1997/08/24 23:07:42 momjian Exp $
*
* Notes:
* XXX This needs to use exception.h to handle recovery when
@ -656,8 +656,19 @@ InitSysCache(char *relname,
* and the LRU tuple list
* ----------------
*/
for (i = 0; i <= NCCBUCK; ++i) {
cp->cc_cache[i] = DLNewList();
{
/*
* We can only do this optimization because the number of hash
* buckets never changes. Without it, we call malloc() too much.
* We could move this to dllist.c, but the way we do this is not
* dynamic/portabl, so why allow other routines to use it.
*/
void *cache_begin = malloc((NCCBUCK+1)*sizeof(Dllist));
for (i = 0; i <= NCCBUCK; ++i) {
cp->cc_cache[i] = cache_begin + i * sizeof(Dllist);
cp->cc_cache[i]->dll_head = 0;
cp->cc_cache[i]->dll_tail = 0;
}
}
cp->cc_lrulist = DLNewList();

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.2 1997/08/19 21:35:59 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.3 1997/08/24 23:07:50 momjian Exp $
*
* NOTE
* XXX This is a preliminary implementation which lacks fail-fast
@ -20,7 +20,6 @@
#include "utils/memutils.h" /* where declarations of this file goes */
static Pointer OrderedElemGetBase(OrderedElem elem);
static void OrderedElemInit(OrderedElem elem, OrderedSet set);
static void OrderedElemPush(OrderedElem elem);
static void OrderedElemPushHead(OrderedElem elem);
@ -49,18 +48,6 @@ OrderedSetInit(OrderedSet set, Offset offset)
set->offset = offset;
}
/*
* OrderedElemInit --
*/
static void
OrderedElemInit(OrderedElem elem, OrderedSet set)
{
elem->set = set;
/* mark as unattached */
elem->next = NULL;
elem->prev = NULL;
}
/*
* OrderedSetContains --
* True iff ordered set contains given element.
@ -148,7 +135,10 @@ OrderedElemPop(OrderedElem elem)
void
OrderedElemPushInto(OrderedElem elem, OrderedSet set)
{
OrderedElemInit(elem, set);
elem->set = set;
/* mark as unattached */
elem->next = NULL;
elem->prev = NULL;
OrderedElemPush(elem);
}

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: c.h,v 1.14 1997/08/12 20:16:17 momjian Exp $
* $Id: c.h,v 1.15 1997/08/24 23:07:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -686,8 +686,7 @@ typedef struct Exception {
* Does string copy, and forces terminating NULL
*/
/* we do this so if the macro is used in an if action, it will work */
#define strNcpy(dest,src,len) do \
{strncpy((dest),(src),(len));*((dest) + (len)) = '\0';} while (0)
#define strNcpy(dst,src,len) (strncpy((dst),(src),(len)),*((dst)+(len))='\0',dst)
/* ----------------------------------------------------------------
* Section 9: externs

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: bufpage.h,v 1.8 1997/08/19 21:39:47 momjian Exp $
* $Id: bufpage.h,v 1.9 1997/08/24 23:08:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -233,17 +233,50 @@ typedef enum {
#define PageGetSpecialPointer(page) \
(AssertMacro(PageIsValid(page)) ? \
(char *) ((char *) (page) + ((PageHeader) (page))->pd_special) \
: (char *) 0)
: (char *)0 )
/*
* PageGetItem --
* Retrieves an item on the given page.
*
* Note:
* This does change the status of any of the resources passed.
* The semantics may change in the future.
*/
#define PageGetItem(page, itemId) \
(AssertMacro(PageIsValid(page)) ? \
AssertMacro(itemId->lp_flags & LP_USED) ? \
(Item)(((char *)page) + itemId->lp_off) : false : false)
/*
* BufferGetPageSize --
* Returns the page size within a buffer.
*
* Notes:
* Assumes buffer is valid.
*
* The buffer can be a raw disk block and need not contain a valid
* (formatted) disk page.
*/
/* XXX dig out of buffer descriptor */
#define BufferGetPageSize(buffer) \
(AssertMacro(BufferIsValid(buffer)) ? \
AssertMacro(PageSizeIsValid(pageSize)) ? \
((Size)BLCKSZ) : false : false)
/*
* BufferGetPage --
* Returns the page associated with a buffer.
*/
#define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer))
/* ----------------------------------------------------------------
* extern declarations
* ----------------------------------------------------------------
*/
extern Size BufferGetPageSize(Buffer buffer);
extern Page BufferGetPage(Buffer buffer);
extern void PageInit(Page page, Size pageSize, Size specialSize);
extern Item PageGetItem(Page page, ItemId itemId);
extern OffsetNumber PageAddItem(Page page, Item item, Size size,
OffsetNumber offsetNumber, ItemIdFlags flags);
extern Page PageGetTempPage(Page page, Size specialSize);