1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-27 07:42:10 +03:00

A few further tweaks to shared memory space estimation.

This change brings the default size of the main shmem block back under 1MB,
which is a fairly popular value for the kernel's SHMMAX parameter.
This commit is contained in:
Tom Lane
1999-03-06 21:17:56 +00:00
parent 03842eb03b
commit 731603a92b
5 changed files with 42 additions and 27 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.22 1999/02/22 06:16:49 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.23 1999/03/06 21:17:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,14 +77,12 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends)
* Size of the primary shared-memory block is estimated via
* moderately-accurate estimates for the big hogs, plus 100K for
* the stuff that's too small to bother with estimating.
* Then we add 10% for a safety margin.
*/
size = BufferShmemSize() + LockShmemSize(maxBackends);
#ifdef STABLE_MEMORY_STORAGE
size += MMShmemSize();
#endif
size += 100000;
size += size / 10;
if (DebugLvl > 1)
{

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.45 1999/02/22 06:16:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.46 1999/03/06 21:17:44 tgl Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@@ -339,8 +339,8 @@ LockMethodTableInit(char *tabName,
* to find the different locks.
* ----------------------
*/
info.keysize = sizeof(LOCKTAG);
info.datasize = sizeof(LOCK);
info.keysize = SHMEM_LOCKTAB_KEYSIZE;
info.datasize = SHMEM_LOCKTAB_DATASIZE;
info.hash = tag_hash;
hash_flags = (HASH_ELEM | HASH_FUNCTION);
@@ -361,8 +361,8 @@ LockMethodTableInit(char *tabName,
* the same lock, additional information must be saved (locks per tx).
* -------------------------
*/
info.keysize = XID_TAGSIZE;
info.datasize = sizeof(XIDLookupEnt);
info.keysize = SHMEM_XIDTAB_KEYSIZE;
info.datasize = SHMEM_XIDTAB_DATASIZE;
info.hash = tag_hash;
hash_flags = (HASH_ELEM | HASH_FUNCTION);
@@ -1488,13 +1488,18 @@ LockShmemSize(int maxBackends)
/* lockHash table */
size += hash_estimate_size(NLOCKENTS(maxBackends),
sizeof(LOCKTAG),
sizeof(LOCK));
SHMEM_LOCKTAB_KEYSIZE,
SHMEM_LOCKTAB_DATASIZE);
/* xidHash table */
size += hash_estimate_size(maxBackends,
XID_TAGSIZE,
sizeof(XIDLookupEnt));
SHMEM_XIDTAB_KEYSIZE,
SHMEM_XIDTAB_DATASIZE);
/* Since the lockHash entry count above is only an estimate,
* add 10% safety margin.
*/
size += size / 10;
return size;
}

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.14 1999/02/22 06:16:57 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.15 1999/03/06 21:17:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -110,7 +110,7 @@ mminit()
}
info.keysize = sizeof(MMCacheTag);
info.datasize = sizeof(int);
info.datasize = sizeof(MMHashEntry) - sizeof(MMCacheTag);
info.hash = tag_hash;
MMCacheHT = (HTAB *) ShmemInitHash("Main memory store HT",
@@ -124,7 +124,7 @@ mminit()
}
info.keysize = sizeof(MMRelTag);
info.datasize = sizeof(int);
info.datasize = sizeof(MMRelHashEntry) - sizeof(MMRelTag);
info.hash = tag_hash;
MMRelCacheHT = (HTAB *) ShmemInitHash("Main memory rel HT",