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

Commit51ee9fa

Browse files
committed
Add support to dynahash.c for partitioning shared hashtables according
to the low-order bits of the entry hash value. Also make some incidentalcleanups in the dynahash API, such as not exporting the hash headerstructs to the world.
1 parentc0e9b31 commit51ee9fa

File tree

4 files changed

+387
-180
lines changed

4 files changed

+387
-180
lines changed

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

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.93 2006/07/14 14:52:22 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.94 2006/07/22 23:04:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -211,9 +211,6 @@ InitShmemIndex(void)
211211
{
212212
HASHCTLinfo;
213213
inthash_flags;
214-
ShmemIndexEnt*result,
215-
item;
216-
boolfound;
217214

218215
/*
219216
* Since ShmemInitHash calls ShmemInitStruct, which expects the ShmemIndex
@@ -227,32 +224,11 @@ InitShmemIndex(void)
227224
info.entrysize=sizeof(ShmemIndexEnt);
228225
hash_flags=HASH_ELEM;
229226

230-
/* This will acquire the shmem index lock, but not release it. */
231227
ShmemIndex=ShmemInitHash("ShmemIndex",
232228
SHMEM_INDEX_SIZE,SHMEM_INDEX_SIZE,
233229
&info,hash_flags);
234230
if (!ShmemIndex)
235231
elog(FATAL,"could not initialize Shmem Index");
236-
237-
/*
238-
* Now, create an entry in the hashtable for the index itself.
239-
*/
240-
if (!IsUnderPostmaster)
241-
{
242-
MemSet(item.key,0,SHMEM_INDEX_KEYSIZE);
243-
strncpy(item.key,"ShmemIndex",SHMEM_INDEX_KEYSIZE);
244-
245-
result= (ShmemIndexEnt*)
246-
hash_search(ShmemIndex, (void*)&item,HASH_ENTER,&found);
247-
248-
Assert(!found);
249-
250-
result->location=MAKE_OFFSET(ShmemIndex->hctl);
251-
result->size=SHMEM_INDEX_SIZE;
252-
}
253-
254-
/* now release the lock acquired in ShmemInitStruct */
255-
LWLockRelease(ShmemIndexLock);
256232
}
257233

258234
/*
@@ -295,7 +271,7 @@ ShmemInitHash(const char *name, /* table string name for shmem index */
295271

296272
/* look it up in the shmem index */
297273
location=ShmemInitStruct(name,
298-
sizeof(HASHHDR)+infoP->dsize*sizeof(HASHSEGMENT),
274+
hash_get_shared_size(infoP,hash_flags),
299275
&found);
300276

301277
/*
@@ -312,9 +288,8 @@ ShmemInitHash(const char *name, /* table string name for shmem index */
312288
if (found)
313289
hash_flags |=HASH_ATTACH;
314290

315-
/*Now provide theheaderand directory pointers */
291+
/*Pass location of hashtableheaderto hash_create */
316292
infoP->hctl= (HASHHDR*)location;
317-
infoP->dir= (HASHSEGMENT*) (((char*)location)+sizeof(HASHHDR));
318293

319294
returnhash_create(name,init_size,infoP,hash_flags);
320295
}
@@ -363,14 +338,16 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
363338
* If the shmem index doesn't exist, we are bootstrapping: we must
364339
* be trying to init the shmem index itself.
365340
*
366-
* Notice that the ShmemIndexLock is held until the shmem index
367-
* has been completely initialized.
341+
* Notice that the ShmemIndexLock is released before the shmem
342+
* index has been initialized. This should be OK because no
343+
* other process can be accessing shared memory yet.
368344
*/
369345
Assert(shmemseghdr->indexoffset==0);
370346
structPtr=ShmemAlloc(size);
371347
shmemseghdr->indexoffset=MAKE_OFFSET(structPtr);
372348
*foundPtr= FALSE;
373349
}
350+
LWLockRelease(ShmemIndexLock);
374351
returnstructPtr;
375352
}
376353

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.166 2006/07/14 14:52:23 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.167 2006/07/22 23:04:39 tgl Exp $
1212
*
1313
* NOTES
1414
* A lock table is a shared memory hash table. When
@@ -1958,7 +1958,7 @@ GetLockStatusData(void)
19581958
{
19591959
LWLockAcquire(FirstLockMgrLock+i,LW_SHARED);
19601960
proclockTable=LockMethodProcLockHash[i];
1961-
els+=proclockTable->hctl->nentries;
1961+
els+=hash_get_num_entries(proclockTable);
19621962
}
19631963

19641964
data->nelements=els;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp