Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite7fa73d

Browse files
committed
Integrate dynahash patch by Alexander Alexeev. This fix lock contension for shared memory
1 parent18a94a2 commite7fa73d

File tree

9 files changed

+140
-87
lines changed

9 files changed

+140
-87
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ pgss_shmem_startup(void)
495495
info.hash=pgss_hash_fn;
496496
info.match=pgss_match_fn;
497497
pgss_hash=ShmemInitHash("pg_stat_statements hash",
498-
pgss_max,pgss_max,
498+
pgss_max,
499499
&info,
500500
HASH_ELEM |HASH_FUNCTION |HASH_COMPARE);
501501

‎doc/src/sgml/release-pro-9.5.sgml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,17 @@
103103
and queries which use large number of resoures
104104
-->
105105
<para>Resource owner optimisation for complicated queries: now
106-
107106
resource lists has constant access time, which improves performance
108107
for heavily partitioned tables and queries which use hundreds of
109108
tables.
110109
</para>
110+
</listitem>
111+
<listitem>
112+
<para>
113+
Fix lock contention for HASHHDR.mutex. (Alexander Alexeev). This
114+
prevents Postgres from waiting for lock up to several milliseconds
115+
when modifying state, shared between processes.
116+
</para>
111117
</listitem>
112118
</itemizedlist>
113119
</listitem>

‎src/backend/storage/buffer/buf_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ InitBufTable(int size)
6262
info.num_partitions=NUM_BUFFER_PARTITIONS;
6363

6464
SharedBufHash=ShmemInitHash("Shared Buffer Lookup Table",
65-
size,size,
65+
size,
6666
&info,
6767
HASH_ELEM |HASH_BLOBS |HASH_PARTITION);
6868
}

‎src/backend/storage/ipc/shmem.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ InitShmemIndex(void)
240240
hash_flags=HASH_ELEM;
241241

242242
ShmemIndex=ShmemInitHash("ShmemIndex",
243-
SHMEM_INDEX_SIZE,SHMEM_INDEX_SIZE,
243+
SHMEM_INDEX_SIZE,
244244
&info,hash_flags);
245245
}
246246

@@ -258,17 +258,12 @@ InitShmemIndex(void)
258258
* exceeded substantially (since it's used to compute directory size and
259259
* the hash table buckets will get overfull).
260260
*
261-
* init_size is the number of hashtable entries to preallocate. For a table
262-
* whose maximum size is certain, this should be equal to max_size; that
263-
* ensures that no run-time out-of-shared-memory failures can occur.
264-
*
265261
* Note: before Postgres 9.0, this function returned NULL for some failure
266262
* cases. Now, it always throws error instead, so callers need not check
267263
* for NULL.
268264
*/
269265
HTAB*
270266
ShmemInitHash(constchar*name,/* table string name for shmem index */
271-
longinit_size,/* initial table size */
272267
longmax_size,/* max size of the table */
273268
HASHCTL*infoP,/* info about key and bucket size */
274269
inthash_flags)/* info about infoP */
@@ -302,7 +297,7 @@ ShmemInitHash(const char *name, /* table string name for shmem index */
302297
/* Pass location of hashtable header to hash_create */
303298
infoP->hctl= (HASHHDR*)location;
304299

305-
returnhash_create(name,init_size,infoP,hash_flags);
300+
returnhash_create(name,max_size,infoP,hash_flags);
306301
}
307302

308303
/*

‎src/backend/storage/lmgr/lock.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,14 @@ void
373373
InitLocks(void)
374374
{
375375
HASHCTLinfo;
376-
longinit_table_size,
377-
max_table_size;
376+
longmax_table_size;
378377
boolfound;
379378

380379
/*
381380
* Compute init/max size to request for lock hashtables. Note these
382381
* calculations must agree with LockShmemSize!
383382
*/
384383
max_table_size=NLOCKENTS();
385-
init_table_size=max_table_size /2;
386384

387385
/*
388386
* Allocate hash table for LOCK structs. This stores per-locked-object
@@ -394,14 +392,12 @@ InitLocks(void)
394392
info.num_partitions=NUM_LOCK_PARTITIONS;
395393

396394
LockMethodLockHash=ShmemInitHash("LOCK hash",
397-
init_table_size,
398395
max_table_size,
399396
&info,
400397
HASH_ELEM |HASH_BLOBS |HASH_PARTITION);
401398

402399
/* Assume an average of 2 holders per lock */
403400
max_table_size *=2;
404-
init_table_size *=2;
405401

406402
/*
407403
* Allocate hash table for PROCLOCK structs. This stores
@@ -413,7 +409,6 @@ InitLocks(void)
413409
info.num_partitions=NUM_LOCK_PARTITIONS;
414410

415411
LockMethodProcLockHash=ShmemInitHash("PROCLOCK hash",
416-
init_table_size,
417412
max_table_size,
418413
&info,
419414
HASH_ELEM |HASH_FUNCTION |HASH_PARTITION);

‎src/backend/storage/lmgr/predicate.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,6 @@ InitPredicateLocks(void)
11151115
info.num_partitions=NUM_PREDICATELOCK_PARTITIONS;
11161116

11171117
PredicateLockTargetHash=ShmemInitHash("PREDICATELOCKTARGET hash",
1118-
max_table_size,
11191118
max_table_size,
11201119
&info,
11211120
HASH_ELEM |HASH_BLOBS |
@@ -1143,7 +1142,6 @@ InitPredicateLocks(void)
11431142
info.num_partitions=NUM_PREDICATELOCK_PARTITIONS;
11441143

11451144
PredicateLockHash=ShmemInitHash("PREDICATELOCK hash",
1146-
max_table_size,
11471145
max_table_size,
11481146
&info,
11491147
HASH_ELEM |HASH_FUNCTION |
@@ -1224,7 +1222,6 @@ InitPredicateLocks(void)
12241222
info.entrysize=sizeof(SERIALIZABLEXID);
12251223

12261224
SerializableXidHash=ShmemInitHash("SERIALIZABLEXID hash",
1227-
max_table_size,
12281225
max_table_size,
12291226
&info,
12301227
HASH_ELEM |HASH_BLOBS |

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp