From 47d1bdd34de5f3d5f70ab33f29f31000d9eed344 Mon Sep 17 00:00:00 2001 From: Zhang Mingli Date: Thu, 26 Oct 2023 18:37:03 +0800 Subject: [PATCH] Rename 'Parallel Broadcast Motion' to 'Broadcast Workers Motion' A Parallel node in plan means it's a parallel aware node. Parallel Seq Scan: workers work together to scan a table, Parallel Hash Join: workers work together to make a join. And in the internal implementation, a Parallel node usually has a technique(shared memory) to sync between workers. It's confused for Parallel Broadcast Motion, the workers of this node doesn't use such a technique to sync. The node is not parallel aware, and the real meaning is to send tuples across target slice's workers for each segment. Let's rename it to Broadcast Workers Motion representing for broadcasting tuples across workers of segments. Authored-by: Zhang Mingli avamingli@gmail.com --- src/backend/cdb/cdbmutate.c | 2 +- src/backend/commands/explain.c | 4 ++-- src/backend/executor/nodeMotion.c | 6 +++--- src/backend/nodes/readfast.c | 2 +- src/include/nodes/plannodes.h | 2 +- src/test/regress/expected/gp_parallel.out | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/cdb/cdbmutate.c b/src/backend/cdb/cdbmutate.c index 525668b7ff2..b7d777c7f63 100644 --- a/src/backend/cdb/cdbmutate.c +++ b/src/backend/cdb/cdbmutate.c @@ -153,7 +153,7 @@ make_parallel_broadcast_motion(Plan *lefttree) motion = make_motion(NULL, lefttree, 0, NULL, NULL, NULL, NULL); - motion->motionType = MOTIONTYPE_PARALLEL_BROADCAST; + motion->motionType = MOTIONTYPE_BROADCAST_WORKERS; motion->hashExprs = NIL; motion->hashFuncs = NULL; diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index cb968ec23d4..14f1bf596bc 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -1789,8 +1789,8 @@ ExplainNode(PlanState *planstate, List *ancestors, case MOTIONTYPE_BROADCAST: sname = "Broadcast Motion"; break; - case MOTIONTYPE_PARALLEL_BROADCAST: - sname = "Parallel Broadcast Motion"; + case MOTIONTYPE_BROADCAST_WORKERS: + sname = "Broadcast Workers Motion"; break; case MOTIONTYPE_EXPLICIT: sname = "Explicit Redistribute Motion"; diff --git a/src/backend/executor/nodeMotion.c b/src/backend/executor/nodeMotion.c index 9c8e9d1ec88..f2e78d2af47 100644 --- a/src/backend/executor/nodeMotion.c +++ b/src/backend/executor/nodeMotion.c @@ -220,7 +220,7 @@ execMotionSender(MotionState *node) motion->motionType == MOTIONTYPE_GATHER_SINGLE || motion->motionType == MOTIONTYPE_HASH || motion->motionType == MOTIONTYPE_BROADCAST || - motion->motionType == MOTIONTYPE_PARALLEL_BROADCAST || + motion->motionType == MOTIONTYPE_BROADCAST_WORKERS || (motion->motionType == MOTIONTYPE_EXPLICIT && motion->segidColIdx > 0)); Assert(node->ps.state->interconnect_context); @@ -316,7 +316,7 @@ execMotionUnsortedReceiver(MotionState *node) motion->motionType == MOTIONTYPE_GATHER_SINGLE || motion->motionType == MOTIONTYPE_HASH || motion->motionType == MOTIONTYPE_BROADCAST || - motion->motionType == MOTIONTYPE_PARALLEL_BROADCAST || + motion->motionType == MOTIONTYPE_BROADCAST_WORKERS || (motion->motionType == MOTIONTYPE_EXPLICIT && motion->segidColIdx > 0)); Assert(node->ps.state->motionlayer_context); @@ -1210,7 +1210,7 @@ doSendTuple(Motion *motion, MotionState *node, TupleTableSlot *outerTupleSlot) { targetRoute = BROADCAST_SEGIDX; } - else if (motion->motionType == MOTIONTYPE_PARALLEL_BROADCAST) + else if (motion->motionType == MOTIONTYPE_BROADCAST_WORKERS) { int numSegments = recvSlice->planNumSegments; diff --git a/src/backend/nodes/readfast.c b/src/backend/nodes/readfast.c index d1efd231c53..4013350ac05 100644 --- a/src/backend/nodes/readfast.c +++ b/src/backend/nodes/readfast.c @@ -980,7 +980,7 @@ _readMotion(void) local_node->motionType == MOTIONTYPE_GATHER_SINGLE || local_node->motionType == MOTIONTYPE_HASH || local_node->motionType == MOTIONTYPE_BROADCAST || - local_node->motionType == MOTIONTYPE_PARALLEL_BROADCAST || + local_node->motionType == MOTIONTYPE_BROADCAST_WORKERS || local_node->motionType == MOTIONTYPE_EXPLICIT); READ_BOOL_FIELD(sendSorted); diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index b56a16df321..58189fc74fc 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -1452,7 +1452,7 @@ typedef enum MotionType MOTIONTYPE_GATHER_SINGLE, /* Execute subplan on N nodes, but only send the tuples from one */ MOTIONTYPE_HASH, /* Use hashing to select a segindex destination */ MOTIONTYPE_BROADCAST, /* Send tuples from one sender to a fixed set of segindexes */ - MOTIONTYPE_PARALLEL_BROADCAST, /* */ + MOTIONTYPE_BROADCAST_WORKERS, /* CBDB_PARALLEL: Send tuples across worker processes of a fixed set of segindexes */ MOTIONTYPE_EXPLICIT, /* Send tuples to the segment explicitly specified in their segid column */ MOTIONTYPE_OUTER_QUERY /* Gather or Broadcast to outer query's slice, don't know which one yet */ } MotionType; diff --git a/src/test/regress/expected/gp_parallel.out b/src/test/regress/expected/gp_parallel.out index b9c6db2e4a4..78733003134 100644 --- a/src/test/regress/expected/gp_parallel.out +++ b/src/test/regress/expected/gp_parallel.out @@ -1827,7 +1827,7 @@ explain(costs off) select sum(t1.c1) from t1 where c1 not in (select c2 from t2) Hash Cond: (t1.c1 = t2.c2) -> Parallel Seq Scan on t1 -> Parallel Hash - -> Parallel Broadcast Motion 6:6 (slice2; segments: 6) + -> Broadcast Workers Motion 6:6 (slice2; segments: 6) -> Parallel Seq Scan on t2 Optimizer: Postgres query optimizer (10 rows) @@ -1846,7 +1846,7 @@ explain(costs off) select * from t1 where c1 not in (select c2 from t3_null); Hash Cond: (t1.c1 = t3_null.c2) -> Parallel Seq Scan on t1 -> Parallel Hash - -> Parallel Broadcast Motion 6:6 (slice2; segments: 6) + -> Broadcast Workers Motion 6:6 (slice2; segments: 6) -> Parallel Seq Scan on t3_null Optimizer: Postgres query optimizer (8 rows)