diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-02-03 23:29:19 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-02-03 23:29:19 +0000 |
commit | cc4f58f4cdf7c3534c3e08b5dcc0e545fe192be8 (patch) | |
tree | e85e3131fc0497f44fd5bc631113a366de7d9ee2 /src/backend/storage/buffer/buf_init.c | |
parent | ad893a361da303226f91e0f79cc7afe11087c8ef (diff) | |
download | postgresql-cc4f58f4cdf7c3534c3e08b5dcc0e545fe192be8.tar.gz postgresql-cc4f58f4cdf7c3534c3e08b5dcc0e545fe192be8.zip |
Ensure that all details of the ARC algorithm are hidden within freelist.c.
This refactoring does not change any algorithms or data structures, just
remove visibility of the ARC datastructures from other source files.
Diffstat (limited to 'src/backend/storage/buffer/buf_init.c')
-rw-r--r-- | src/backend/storage/buffer/buf_init.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index 6b6a8289ad8..f6500fec89e 100644 --- a/src/backend/storage/buffer/buf_init.c +++ b/src/backend/storage/buffer/buf_init.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.70 2004/12/31 22:00:49 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.71 2005/02/03 23:29:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -73,7 +73,6 @@ long int LocalBufferFlushCount; * aborts, it should only unpin the buffers exactly the number of times it * has pinned them, so that it will not blow away buffers of another * backend. - * */ @@ -120,14 +119,17 @@ InitBufferPool(void) block = BufferBlocks; /* - * link the buffers into a single linked list. This will become - * the LIFO list of unused buffers returned by - * StrategyGetBuffer(). + * Initialize all the buffer headers. */ for (i = 0; i < NBuffers; block += BLCKSZ, buf++, i++) { Assert(ShmemIsValid((unsigned long) block)); + /* + * The bufNext fields link together all totally-unused buffers. + * Subsequent management of this list is done by + * StrategyGetBuffer(). + */ buf->bufNext = i + 1; CLEAR_BUFFERTAG(buf->tag); @@ -142,7 +144,7 @@ InitBufferPool(void) buf->wait_backend_id = 0; } - /* Correct last entry */ + /* Correct last entry of linked list */ BufferDescriptors[NBuffers - 1].bufNext = -1; LWLockRelease(BufMgrLock); @@ -178,7 +180,8 @@ InitBufferPoolAccess(void) /* * Convert shmem offsets into addresses as seen by this process. This - * is just to speed up the BufferGetBlock() macro. + * is just to speed up the BufferGetBlock() macro. It is OK to do this + * without any lock since the data pointers never change. */ for (i = 0; i < NBuffers; i++) BufferBlockPointers[i] = (Block) MAKE_PTR(BufferDescriptors[i].data); @@ -201,14 +204,8 @@ BufferShmemSize(void) /* size of data pages */ size += NBuffers * MAXALIGN(BLCKSZ); - /* size of buffer hash table */ - size += hash_estimate_size(NBuffers * 2, sizeof(BufferLookupEnt)); - - /* size of the shared replacement strategy control block */ - size += MAXALIGN(sizeof(BufferStrategyControl)); - - /* size of the ARC directory blocks */ - size += MAXALIGN(NBuffers * 2 * sizeof(BufferStrategyCDB)); + /* size of stuff controlled by freelist.c */ + size += StrategyShmemSize(); return size; } |