1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Minor adjustments to improve the accuracy of our computation of required

shared memory size.
This commit is contained in:
Tom Lane
2004-09-29 15:15:56 +00:00
parent 1bb38bb4e5
commit 0fb3152ea9
5 changed files with 44 additions and 22 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.141 2004/09/28 20:46:32 tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.142 2004/09/29 15:15:55 tgl Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@@ -1689,15 +1689,17 @@ LockReassignCurrentOwner(void)
}
/*
* Estimate shared-memory space used for lock tables
*/
int
LockShmemSize(int maxBackends)
{
int size = 0;
long max_table_size = NLOCKENTS(maxBackends);
size += MAXALIGN(sizeof(PROC_HDR)); /* ProcGlobal */
size += maxBackends * MAXALIGN(sizeof(PGPROC)); /* each MyProc */
size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LockMethodData)); /* each lock method */
/* lock method headers */
size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LockMethodData));
/* lockHash table */
size += hash_estimate_size(max_table_size, sizeof(LOCK));
@@ -1706,6 +1708,9 @@ LockShmemSize(int maxBackends)
size += hash_estimate_size(max_table_size, sizeof(PROCLOCK));
/*
* Note we count only one pair of hash tables, since the userlocks
* table actually overlays the main one.
*
* Since the lockHash entry count above is only an estimate, add 10%
* safety margin.
*/