aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1997-08-24 23:08:01 +0000
committerBruce Momjian <bruce@momjian.us>1997-08-24 23:08:01 +0000
commitc4cb617504a6e7990de0416b0d18d1dadf176d6c (patch)
treeb38bf26650cb9b6fb54a2a3df05624854f661a72 /src/backend/storage
parent281ba3f40d023dbe0b03f2d76f3c854c3232664f (diff)
downloadpostgresql-c4cb617504a6e7990de0416b0d18d1dadf176d6c.tar.gz
postgresql-c4cb617504a6e7990de0416b0d18d1dadf176d6c.zip
Major patch to speed up backend startup after profiling analysis.
Diffstat (limited to 'src/backend/storage')
-rw-r--r--src/backend/storage/ipc/s_lock.c124
-rw-r--r--src/backend/storage/page/bufpage.c64
2 files changed, 39 insertions, 149 deletions
diff --git a/src/backend/storage/ipc/s_lock.c b/src/backend/storage/ipc/s_lock.c
index 7a811851625..85477cce618 100644
--- a/src/backend/storage/ipc/s_lock.c
+++ b/src/backend/storage/ipc/s_lock.c
@@ -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,56 +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))
- ;
-}
-
-void
-S_UNLOCK(slock_t *lock)
-{
- *lock = 0;
-}
-
-void
-S_INIT_LOCK(slock_t *lock)
-{
- S_UNLOCK(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;
-}
+ slock_t res;
-void
-S_LOCK(slock_t *lock)
-{
- while (tas(lock))
- ;
+ do{
+ __asm__("ldstub [%1], %0"
+ : "=&r" (res)
+ : "r" (lock));
+ }while(!res != 0);
}
void
@@ -523,7 +475,7 @@ S_INIT_LOCK(slock_t *lock)
S_UNLOCK(lock);
}
-#endif /* NEED_NS32K_TAS_ASM */
+#endif /* defined(linux) && defined(sparc) */
#if defined(linux) && defined(PPC)
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index ac142825741..98d1c59d5f0 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -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 $
*
*-------------------------------------------------------------------------
*/
@@ -32,43 +32,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
* ----------------------------------------------------------------
*/
@@ -95,31 +58,6 @@ PageInit(Page page, Size pageSize, Size specialSize)
}
/*
- * 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.
*