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

Commit8fba928

Browse files
committed
Improve the naming of Parallel Hash Join phases.
* Commit3048898 dropped -ING from PHJ wait event names. Update the corresponding barrier phases names to match.* Rename the "DONE" phases to "FREE". That's symmetrical with "ALLOCATE", and names the activity that actually happens in that phase (as we do for the other phases) rather than a state. The bug fixed by commit8d578b9 might have been more obvious with this name.* Rename the batch/bucket growth barriers' "ALLOCATE" phases to "REALLOCATE", a better description of what they do.* Update the high level comments about phases to highlight phases are executed by a single process with an asterisk (mostly memory management phases).No behavior change, as this is just improving internal identifiers. Theonly user-visible sign of this is that a couple of wait events' displaynames change from "...Allocate" to "...Reallocate" in pg_stat_activity,to stay in sync with the internal names.Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>Discussion:https://postgr.es/m/CA%2BhUKG%2BMDpwF2Eo2LAvzd%3DpOh81wUTsrwU1uAwR-v6OGBB6%2B7g%40mail.gmail.com
1 parent11470f5 commit8fba928

File tree

6 files changed

+119
-118
lines changed

6 files changed

+119
-118
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,11 +1700,6 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
17001700
<entry>Waiting for other Parallel Hash participants to finish partitioning
17011701
the outer relation.</entry>
17021702
</row>
1703-
<row>
1704-
<entry><literal>HashGrowBatchesAllocate</literal></entry>
1705-
<entry>Waiting for an elected Parallel Hash participant to allocate more
1706-
batches.</entry>
1707-
</row>
17081703
<row>
17091704
<entry><literal>HashGrowBatchesDecide</literal></entry>
17101705
<entry>Waiting to elect a Parallel Hash participant to decide on future
@@ -1720,21 +1715,26 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
17201715
<entry>Waiting for an elected Parallel Hash participant to decide on
17211716
future batch growth.</entry>
17221717
</row>
1718+
<row>
1719+
<entry><literal>HashGrowBatchesReallocate</literal></entry>
1720+
<entry>Waiting for an elected Parallel Hash participant to allocate more
1721+
batches.</entry>
1722+
</row>
17231723
<row>
17241724
<entry><literal>HashGrowBatchesRepartition</literal></entry>
17251725
<entry>Waiting for other Parallel Hash participants to finish
17261726
repartitioning.</entry>
17271727
</row>
1728-
<row>
1729-
<entry><literal>HashGrowBucketsAllocate</literal></entry>
1730-
<entry>Waiting for an elected Parallel Hash participant to finish
1731-
allocating more buckets.</entry>
1732-
</row>
17331728
<row>
17341729
<entry><literal>HashGrowBucketsElect</literal></entry>
17351730
<entry>Waiting to elect a Parallel Hash participant to allocate more
17361731
buckets.</entry>
17371732
</row>
1733+
<row>
1734+
<entry><literal>HashGrowBucketsReallocate</literal></entry>
1735+
<entry>Waiting for an elected Parallel Hash participant to finish
1736+
allocating more buckets.</entry>
1737+
</row>
17381738
<row>
17391739
<entry><literal>HashGrowBucketsReinsert</literal></entry>
17401740
<entry>Waiting for other Parallel Hash participants to finish inserting

‎src/backend/executor/nodeHash.c

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ MultiExecParallelHash(HashState *node)
246246
*/
247247
pstate=hashtable->parallel_state;
248248
build_barrier=&pstate->build_barrier;
249-
Assert(BarrierPhase(build_barrier) >=PHJ_BUILD_ALLOCATING);
249+
Assert(BarrierPhase(build_barrier) >=PHJ_BUILD_ALLOCATE);
250250
switch (BarrierPhase(build_barrier))
251251
{
252-
casePHJ_BUILD_ALLOCATING:
252+
casePHJ_BUILD_ALLOCATE:
253253

254254
/*
255255
* Either I just allocated the initial hash table in
@@ -259,7 +259,7 @@ MultiExecParallelHash(HashState *node)
259259
BarrierArriveAndWait(build_barrier,WAIT_EVENT_HASH_BUILD_ALLOCATE);
260260
/* Fall through. */
261261

262-
casePHJ_BUILD_HASHING_INNER:
262+
casePHJ_BUILD_HASH_INNER:
263263

264264
/*
265265
* It's time to begin hashing, or if we just arrived here then
@@ -271,10 +271,10 @@ MultiExecParallelHash(HashState *node)
271271
* below.
272272
*/
273273
if (PHJ_GROW_BATCHES_PHASE(BarrierAttach(&pstate->grow_batches_barrier))!=
274-
PHJ_GROW_BATCHES_ELECTING)
274+
PHJ_GROW_BATCHES_ELECT)
275275
ExecParallelHashIncreaseNumBatches(hashtable);
276276
if (PHJ_GROW_BUCKETS_PHASE(BarrierAttach(&pstate->grow_buckets_barrier))!=
277-
PHJ_GROW_BUCKETS_ELECTING)
277+
PHJ_GROW_BUCKETS_ELECT)
278278
ExecParallelHashIncreaseNumBuckets(hashtable);
279279
ExecParallelHashEnsureBatchAccessors(hashtable);
280280
ExecParallelHashTableSetCurrentBatch(hashtable,0);
@@ -338,17 +338,17 @@ MultiExecParallelHash(HashState *node)
338338
* Unless we're completely done and the batch state has been freed, make
339339
* sure we have accessors.
340340
*/
341-
if (BarrierPhase(build_barrier)<PHJ_BUILD_DONE)
341+
if (BarrierPhase(build_barrier)<PHJ_BUILD_FREE)
342342
ExecParallelHashEnsureBatchAccessors(hashtable);
343343

344344
/*
345345
* The next synchronization point is in ExecHashJoin's HJ_BUILD_HASHTABLE
346-
* case, which will bring the build phase toPHJ_BUILD_RUNNING (if it
347-
*isn'tthere already).
346+
* case, which will bring the build phase toPHJ_BUILD_RUN (if it isn't
347+
* there already).
348348
*/
349-
Assert(BarrierPhase(build_barrier)==PHJ_BUILD_HASHING_OUTER||
350-
BarrierPhase(build_barrier)==PHJ_BUILD_RUNNING||
351-
BarrierPhase(build_barrier)==PHJ_BUILD_DONE);
349+
Assert(BarrierPhase(build_barrier)==PHJ_BUILD_HASH_OUTER||
350+
BarrierPhase(build_barrier)==PHJ_BUILD_RUN||
351+
BarrierPhase(build_barrier)==PHJ_BUILD_FREE);
352352
}
353353

354354
/* ----------------------------------------------------------------
@@ -592,8 +592,8 @@ ExecHashTableCreate(HashState *state, List *hashOperators, List *hashCollations,
592592
* Attach to the build barrier. The corresponding detach operation is
593593
* in ExecHashTableDetach. Note that we won't attach to the
594594
* batch_barrier for batch 0 yet. We'll attach later and start it out
595-
* inPHJ_BATCH_PROBING phase, because batch 0 is allocated up front
596-
*andthen loaded while hashing (the standard hybrid hash join
595+
* inPHJ_BATCH_PROBE phase, because batch 0 is allocated up front and
596+
* then loaded while hashing (the standard hybrid hash join
597597
* algorithm), and we'll coordinate that using build_barrier.
598598
*/
599599
build_barrier=&pstate->build_barrier;
@@ -606,7 +606,7 @@ ExecHashTableCreate(HashState *state, List *hashOperators, List *hashCollations,
606606
* SharedHashJoinBatch objects and the hash table for batch 0. One
607607
* backend will be elected to do that now if necessary.
608608
*/
609-
if (BarrierPhase(build_barrier)==PHJ_BUILD_ELECTING&&
609+
if (BarrierPhase(build_barrier)==PHJ_BUILD_ELECT&&
610610
BarrierArriveAndWait(build_barrier,WAIT_EVENT_HASH_BUILD_ELECT))
611611
{
612612
pstate->nbatch=nbatch;
@@ -627,7 +627,7 @@ ExecHashTableCreate(HashState *state, List *hashOperators, List *hashCollations,
627627
/*
628628
* The next Parallel Hash synchronization point is in
629629
* MultiExecParallelHash(), which will progress it all the way to
630-
*PHJ_BUILD_RUNNING. The caller must not return control from this
630+
*PHJ_BUILD_RUN. The caller must not return control from this
631631
* executor node between now and then.
632632
*/
633633
}
@@ -1075,7 +1075,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable)
10751075
{
10761076
ParallelHashJoinState*pstate=hashtable->parallel_state;
10771077

1078-
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_HASHING_INNER);
1078+
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_HASH_INNER);
10791079

10801080
/*
10811081
* It's unlikely, but we need to be prepared for new participants to show
@@ -1084,7 +1084,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable)
10841084
*/
10851085
switch (PHJ_GROW_BATCHES_PHASE(BarrierPhase(&pstate->grow_batches_barrier)))
10861086
{
1087-
casePHJ_GROW_BATCHES_ELECTING:
1087+
casePHJ_GROW_BATCHES_ELECT:
10881088

10891089
/*
10901090
* Elect one participant to prepare to grow the number of batches.
@@ -1200,13 +1200,13 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable)
12001200
}
12011201
/* Fall through. */
12021202

1203-
casePHJ_GROW_BATCHES_ALLOCATING:
1203+
casePHJ_GROW_BATCHES_REALLOCATE:
12041204
/* Wait for the above to be finished. */
12051205
BarrierArriveAndWait(&pstate->grow_batches_barrier,
1206-
WAIT_EVENT_HASH_GROW_BATCHES_ALLOCATE);
1206+
WAIT_EVENT_HASH_GROW_BATCHES_REALLOCATE);
12071207
/* Fall through. */
12081208

1209-
casePHJ_GROW_BATCHES_REPARTITIONING:
1209+
casePHJ_GROW_BATCHES_REPARTITION:
12101210
/* Make sure that we have the current dimensions and buckets. */
12111211
ExecParallelHashEnsureBatchAccessors(hashtable);
12121212
ExecParallelHashTableSetCurrentBatch(hashtable,0);
@@ -1219,7 +1219,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable)
12191219
WAIT_EVENT_HASH_GROW_BATCHES_REPARTITION);
12201220
/* Fall through. */
12211221

1222-
casePHJ_GROW_BATCHES_DECIDING:
1222+
casePHJ_GROW_BATCHES_DECIDE:
12231223

12241224
/*
12251225
* Elect one participant to clean up and decide whether further
@@ -1274,7 +1274,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable)
12741274
}
12751275
/* Fall through. */
12761276

1277-
casePHJ_GROW_BATCHES_FINISHING:
1277+
casePHJ_GROW_BATCHES_FINISH:
12781278
/* Wait for the above to complete. */
12791279
BarrierArriveAndWait(&pstate->grow_batches_barrier,
12801280
WAIT_EVENT_HASH_GROW_BATCHES_FINISH);
@@ -1514,7 +1514,7 @@ ExecParallelHashIncreaseNumBuckets(HashJoinTable hashtable)
15141514
HashMemoryChunkchunk;
15151515
dsa_pointerchunk_s;
15161516

1517-
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_HASHING_INNER);
1517+
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_HASH_INNER);
15181518

15191519
/*
15201520
* It's unlikely, but we need to be prepared for new participants to show
@@ -1523,7 +1523,7 @@ ExecParallelHashIncreaseNumBuckets(HashJoinTable hashtable)
15231523
*/
15241524
switch (PHJ_GROW_BUCKETS_PHASE(BarrierPhase(&pstate->grow_buckets_barrier)))
15251525
{
1526-
casePHJ_GROW_BUCKETS_ELECTING:
1526+
casePHJ_GROW_BUCKETS_ELECT:
15271527
/* Elect one participant to prepare to increase nbuckets. */
15281528
if (BarrierArriveAndWait(&pstate->grow_buckets_barrier,
15291529
WAIT_EVENT_HASH_GROW_BUCKETS_ELECT))
@@ -1552,13 +1552,13 @@ ExecParallelHashIncreaseNumBuckets(HashJoinTable hashtable)
15521552
}
15531553
/* Fall through. */
15541554

1555-
casePHJ_GROW_BUCKETS_ALLOCATING:
1555+
casePHJ_GROW_BUCKETS_REALLOCATE:
15561556
/* Wait for the above to complete. */
15571557
BarrierArriveAndWait(&pstate->grow_buckets_barrier,
1558-
WAIT_EVENT_HASH_GROW_BUCKETS_ALLOCATE);
1558+
WAIT_EVENT_HASH_GROW_BUCKETS_REALLOCATE);
15591559
/* Fall through. */
15601560

1561-
casePHJ_GROW_BUCKETS_REINSERTING:
1561+
casePHJ_GROW_BUCKETS_REINSERT:
15621562
/* Reinsert all tuples into the hash table. */
15631563
ExecParallelHashEnsureBatchAccessors(hashtable);
15641564
ExecParallelHashTableSetCurrentBatch(hashtable,0);
@@ -1714,7 +1714,7 @@ ExecParallelHashTableInsert(HashJoinTable hashtable,
17141714

17151715
/* Try to load it into memory. */
17161716
Assert(BarrierPhase(&hashtable->parallel_state->build_barrier)==
1717-
PHJ_BUILD_HASHING_INNER);
1717+
PHJ_BUILD_HASH_INNER);
17181718
hashTuple=ExecParallelHashTupleAlloc(hashtable,
17191719
HJTUPLE_OVERHEAD+tuple->t_len,
17201720
&shared);
@@ -2868,7 +2868,7 @@ ExecParallelHashTupleAlloc(HashJoinTable hashtable, size_t size,
28682868
if (pstate->growth!=PHJ_GROWTH_DISABLED)
28692869
{
28702870
Assert(curbatch==0);
2871-
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_HASHING_INNER);
2871+
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_HASH_INNER);
28722872

28732873
/*
28742874
* Check if our space limit would be exceeded. To avoid choking on
@@ -2988,7 +2988,7 @@ ExecParallelHashJoinSetUpBatches(HashJoinTable hashtable, int nbatch)
29882988
{
29892989
/* Batch 0 doesn't need to be loaded. */
29902990
BarrierAttach(&shared->batch_barrier);
2991-
while (BarrierPhase(&shared->batch_barrier)<PHJ_BATCH_PROBING)
2991+
while (BarrierPhase(&shared->batch_barrier)<PHJ_BATCH_PROBE)
29922992
BarrierArriveAndWait(&shared->batch_barrier,0);
29932993
BarrierDetach(&shared->batch_barrier);
29942994
}
@@ -3063,7 +3063,7 @@ ExecParallelHashEnsureBatchAccessors(HashJoinTable hashtable)
30633063
/*
30643064
* We should never see a state where the batch-tracking array is freed,
30653065
* because we should have given up sooner if we join when the build
3066-
* barrier has reached thePHJ_BUILD_DONE phase.
3066+
* barrier has reached thePHJ_BUILD_FREE phase.
30673067
*/
30683068
Assert(DsaPointerIsValid(pstate->batches));
30693069

@@ -3146,7 +3146,7 @@ ExecHashTableDetachBatch(HashJoinTable hashtable)
31463146
* longer attached, but since there is no way it's moving after
31473147
* this point it seems safe to make the following assertion.
31483148
*/
3149-
Assert(BarrierPhase(&batch->batch_barrier)==PHJ_BATCH_DONE);
3149+
Assert(BarrierPhase(&batch->batch_barrier)==PHJ_BATCH_FREE);
31503150

31513151
/* Free shared chunks and buckets. */
31523152
while (DsaPointerIsValid(batch->chunks))
@@ -3189,13 +3189,12 @@ ExecHashTableDetach(HashJoinTable hashtable)
31893189

31903190
/*
31913191
* If we're involved in a parallel query, we must either have gotten all
3192-
* the way to PHJ_BUILD_RUNNING, or joined too late and be in
3193-
* PHJ_BUILD_DONE.
3192+
* the way to PHJ_BUILD_RUN, or joined too late and be in PHJ_BUILD_FREE.
31943193
*/
31953194
Assert(!pstate||
3196-
BarrierPhase(&pstate->build_barrier) >=PHJ_BUILD_RUNNING);
3195+
BarrierPhase(&pstate->build_barrier) >=PHJ_BUILD_RUN);
31973196

3198-
if (pstate&&BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_RUNNING)
3197+
if (pstate&&BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_RUN)
31993198
{
32003199
inti;
32013200

@@ -3218,7 +3217,7 @@ ExecHashTableDetach(HashJoinTable hashtable)
32183217
* Late joining processes will see this state and give up
32193218
* immediately.
32203219
*/
3221-
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_DONE);
3220+
Assert(BarrierPhase(&pstate->build_barrier)==PHJ_BUILD_FREE);
32223221

32233222
if (DsaPointerIsValid(pstate->batches))
32243223
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp