Dan Ports <d...@csail.mit.edu> wrote: > On Thu, Mar 31, 2011 at 11:06:30AM -0500, Kevin Grittner wrote: >> The only thing I've been on the fence about is whether it >> makes more sense to allocate it all up front or to continue to allow >> incremental allocation but set a hard limit on the number of entries >> allocated for each shared memory HTAB. Is there a performance- >> related reason to choose one path or the other? > > Seems like it would be marginally better to allocate it up front -- then > you don't have the cost of having to split buckets later as it grows. The attached patch should cover that. -Kevin
*** a/src/backend/storage/lmgr/lock.c --- b/src/backend/storage/lmgr/lock.c *************** *** 281,295 **** InitLocks(void) { HASHCTL info; int hash_flags; ! long init_table_size, ! max_table_size; /* * Compute init/max size to request for lock hashtables. Note these * calculations must agree with LockShmemSize! */ max_table_size = NLOCKENTS(); - init_table_size = max_table_size / 2; /* * Allocate hash table for LOCK structs. This stores per-locked-object --- 281,293 ---- { HASHCTL info; int hash_flags; ! long max_table_size; /* * Compute init/max size to request for lock hashtables. Note these * calculations must agree with LockShmemSize! */ max_table_size = NLOCKENTS(); /* * Allocate hash table for LOCK structs. This stores per-locked-object *************** *** 303,316 **** InitLocks(void) hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); LockMethodLockHash = ShmemInitHash("LOCK hash", ! init_table_size, max_table_size, &info, hash_flags); /* Assume an average of 2 holders per lock */ max_table_size *= 2; - init_table_size *= 2; /* * Allocate hash table for PROCLOCK structs. This stores --- 301,313 ---- hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); LockMethodLockHash = ShmemInitHash("LOCK hash", ! max_table_size, max_table_size, &info, hash_flags); /* Assume an average of 2 holders per lock */ max_table_size *= 2; /* * Allocate hash table for PROCLOCK structs. This stores *************** *** 323,329 **** InitLocks(void) hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); LockMethodProcLockHash = ShmemInitHash("PROCLOCK hash", ! init_table_size, max_table_size, &info, hash_flags); --- 320,326 ---- hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); LockMethodProcLockHash = ShmemInitHash("PROCLOCK hash", ! max_table_size, max_table_size, &info, hash_flags); *** a/src/backend/storage/lmgr/predicate.c --- b/src/backend/storage/lmgr/predicate.c *************** *** 959,966 **** InitPredicateLocks(void) { HASHCTL info; int hash_flags; ! long init_table_size, ! max_table_size; Size requestSize; bool found; --- 959,965 ---- { HASHCTL info; int hash_flags; ! long max_table_size; Size requestSize; bool found; *************** *** 969,975 **** InitPredicateLocks(void) * Note these calculations must agree with PredicateLockShmemSize! */ max_table_size = NPREDICATELOCKTARGETENTS(); - init_table_size = max_table_size / 2; /* * Allocate hash table for PREDICATELOCKTARGET structs. This stores --- 968,973 ---- *************** *** 983,996 **** InitPredicateLocks(void) hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); PredicateLockTargetHash = ShmemInitHash("PREDICATELOCKTARGET hash", ! init_table_size, max_table_size, &info, hash_flags); /* Assume an average of 2 xacts per target */ max_table_size *= 2; - init_table_size *= 2; /* * Reserve an entry in the hash table; we use it to make sure there's --- 981,993 ---- hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); PredicateLockTargetHash = ShmemInitHash("PREDICATELOCKTARGET hash", ! max_table_size, max_table_size, &info, hash_flags); /* Assume an average of 2 xacts per target */ max_table_size *= 2; /* * Reserve an entry in the hash table; we use it to make sure there's *************** *** 1014,1020 **** InitPredicateLocks(void) hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); PredicateLockHash = ShmemInitHash("PREDICATELOCK hash", ! init_table_size, max_table_size, &info, hash_flags); --- 1011,1017 ---- hash_flags = (HASH_ELEM | HASH_FUNCTION | HASH_PARTITION); PredicateLockHash = ShmemInitHash("PREDICATELOCK hash", ! max_table_size, max_table_size, &info, hash_flags);
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers