aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/buf_init.c
diff options
context:
space:
mode:
authorJan Wieck <JanWieck@Yahoo.com>2003-11-13 00:40:02 +0000
committerJan Wieck <JanWieck@Yahoo.com>2003-11-13 00:40:02 +0000
commit48adc0b34b3de911eccb2a80c78b137aa631f199 (patch)
tree49f62ee74ea9a3e86854bcab68f4ff4b061cda39 /src/backend/storage/buffer/buf_init.c
parent27e8ef05350ee9e681ed5d456526ac5abf5cd889 (diff)
downloadpostgresql-48adc0b34b3de911eccb2a80c78b137aa631f199.tar.gz
postgresql-48adc0b34b3de911eccb2a80c78b137aa631f199.zip
Replacement of the buffer replacement strategy with an ARC
algorithm adopted for PostgreSQL. Jan
Diffstat (limited to 'src/backend/storage/buffer/buf_init.c')
-rw-r--r--src/backend/storage/buffer/buf_init.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c
index 38cc332efd3..616338c60c6 100644
--- a/src/backend/storage/buffer/buf_init.c
+++ b/src/backend/storage/buffer/buf_init.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.54 2003/08/04 02:40:03 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.55 2003/11/13 00:40:01 wieck Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,9 +48,6 @@ long *CurTraceBuf;
int ShowPinTrace = 0;
int Data_Descriptors;
-int Free_List_Descriptor;
-int Lookup_List_Descriptor;
-int Num_Descriptors;
BufferDesc *BufferDescriptors;
Block *BufferBlockPointers;
@@ -133,9 +130,6 @@ InitBufferPool(void)
int i;
Data_Descriptors = NBuffers;
- Free_List_Descriptor = Data_Descriptors;
- Lookup_List_Descriptor = Data_Descriptors + 1;
- Num_Descriptors = Data_Descriptors + 1;
/*
* It's probably not really necessary to grab the lock --- if there's
@@ -156,7 +150,7 @@ InitBufferPool(void)
BufferDescriptors = (BufferDesc *)
ShmemInitStruct("Buffer Descriptors",
- Num_Descriptors * sizeof(BufferDesc), &foundDescs);
+ Data_Descriptors * sizeof(BufferDesc), &foundDescs);
BufferBlocks = (char *)
ShmemInitStruct("Buffer Blocks",
@@ -176,16 +170,14 @@ InitBufferPool(void)
block = BufferBlocks;
/*
- * link the buffers into a circular, doubly-linked list to
- * initialize free list, and initialize the buffer headers. Still
- * don't know anything about replacement strategy in this file.
+ * link the buffers into a single linked list. This will become the
+ * LiFo list of unused buffers returned by StragegyGetBuffer().
*/
for (i = 0; i < Data_Descriptors; block += BLCKSZ, buf++, i++)
{
Assert(ShmemIsValid((unsigned long) block));
- buf->freeNext = i + 1;
- buf->freePrev = i - 1;
+ buf->bufNext = i + 1;
CLEAR_BUFFERTAG(&(buf->tag));
buf->buf_id = i;
@@ -199,14 +191,12 @@ InitBufferPool(void)
buf->wait_backend_id = 0;
}
- /* close the circular queue */
- BufferDescriptors[0].freePrev = Data_Descriptors - 1;
- BufferDescriptors[Data_Descriptors - 1].freeNext = 0;
+ /* Correct last entry */
+ BufferDescriptors[Data_Descriptors - 1].bufNext = -1;
}
/* Init other shared buffer-management stuff */
- InitBufTable();
- InitFreeList(!foundDescs);
+ StrategyInitialize(!foundDescs);
LWLockRelease(BufMgrLock);
}