diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-03-07 02:01:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-03-07 02:01:09 +0000 |
commit | 2ecbf94430265822e08758df375ffea9d041a86a (patch) | |
tree | fbbdbe291eeec725547069f0b15536697eff69c3 /src/backend/storage/buffer/buf_init.c | |
parent | 0fda84bfcd7e3ab1a8bcca7282e2b319930f7070 (diff) | |
download | postgresql-REL6_4.tar.gz |
Retrofit hashtable and shared-mem-size-estimation bug fixesREL6_4
into REL6_4.
Diffstat (limited to 'src/backend/storage/buffer/buf_init.c')
-rw-r--r-- | src/backend/storage/buffer/buf_init.c | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index 975e999ec2..ff836506b8 100644 --- a/src/backend/storage/buffer/buf_init.c +++ b/src/backend/storage/buffer/buf_init.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.19 1998/09/01 04:31:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.19.2.1 1999/03/07 02:01:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,6 @@ #include "storage/lmgr.h" #include "miscadmin.h" #include "utils/builtins.h" -#include "utils/dynahash.h" #include "utils/hsearch.h" #include "utils/memutils.h" #include "executor/execdebug.h" /* for NDirectFileRead */ @@ -270,21 +269,11 @@ int BufferShmemSize() { int size = 0; - int nbuckets; - int nsegs; - int tmp; - - nbuckets = 1 << (int) my_log2((NBuffers - 1) / DEF_FFACTOR + 1); - nsegs = 1 << (int) my_log2((nbuckets - 1) / DEF_SEGSIZE + 1); - - /* size of shmem index table */ - size += MAXALIGN(my_log2(SHMEM_INDEX_SIZE) * sizeof(void *)); /* HTAB->dir */ - size += MAXALIGN(sizeof(HHDR)); /* HTAB->hctl */ - size += MAXALIGN(DEF_SEGSIZE * sizeof(SEGMENT)); - size += BUCKET_ALLOC_INCR * - (MAXALIGN(sizeof(BUCKET_INDEX)) + - MAXALIGN(SHMEM_INDEX_KEYSIZE) + - MAXALIGN(SHMEM_INDEX_DATASIZE)); + + /* size of shmem index hash table */ + size += hash_estimate_size(SHMEM_INDEX_SIZE, + SHMEM_INDEX_KEYSIZE, + SHMEM_INDEX_DATASIZE); /* size of buffer descriptors */ size += MAXALIGN((NBuffers + 1) * sizeof(BufferDesc)); @@ -293,17 +282,13 @@ BufferShmemSize() size += NBuffers * MAXALIGN(BLCKSZ); /* size of buffer hash table */ - size += MAXALIGN(my_log2(NBuffers) * sizeof(void *)); /* HTAB->dir */ - size += MAXALIGN(sizeof(HHDR)); /* HTAB->hctl */ - size += nsegs * MAXALIGN(DEF_SEGSIZE * sizeof(SEGMENT)); - tmp = (int) ceil((double) NBuffers / BUCKET_ALLOC_INCR); - size += tmp * BUCKET_ALLOC_INCR * - (MAXALIGN(sizeof(BUCKET_INDEX)) + - MAXALIGN(sizeof(BufferTag)) + - MAXALIGN(sizeof(Buffer))); + size += hash_estimate_size(NBuffers, + sizeof(BufferTag), + sizeof(Buffer)); #ifdef BMTRACE size += (BMT_LIMIT * sizeof(bmtrace)) + sizeof(long); #endif + return size; } |