mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Major patch to speed up backend startup after profiling analysis.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user