v4-0001-Introduce-two-new-counters-in-EState-for-parallel.patch
text/x-diff
Filename: v4-0001-Introduce-two-new-counters-in-EState-for-parallel.patch
Type: text/x-diff
Part: 0
Patch
Format: format-patch
Series: patch v4-0001
Subject: Introduce two new counters in EState for parallel workers
| File | + | − |
|---|---|---|
| src/backend/executor/execUtils.c | 2 | 0 |
| src/backend/executor/nodeGather.c | 7 | 0 |
| src/backend/executor/nodeGatherMerge.c | 7 | 0 |
| src/include/nodes/execnodes.h | 5 | 0 |
From 5dc567cda5ad9e0c41532ef6ce5cc5f1808e974e Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Tue, 8 Oct 2024 15:52:38 +0900
Subject: [PATCH v4 1/3] Introduce two new counters in EState for parallel
workers
They will be used by some follow-up patches to populate other parts of
the system with this data extracted from the executor.
---
src/include/nodes/execnodes.h | 5 +++++
src/backend/executor/execUtils.c | 2 ++
src/backend/executor/nodeGather.c | 7 +++++++
src/backend/executor/nodeGatherMerge.c | 7 +++++++
4 files changed, 21 insertions(+)
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index aab59d681c..e4698a28c4 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -708,6 +708,11 @@ typedef struct EState
bool es_use_parallel_mode; /* can we use parallel workers? */
+ int es_parallel_workers_to_launch; /* number of workers to
+ * launch. */
+ int es_parallel_workers_launched; /* number of workers actually
+ * launched. */
+
/* The per-query shared memory area to use for parallel execution. */
struct dsa_area *es_query_dsa;
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 5737f9f4eb..6712302ec8 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -158,6 +158,8 @@ CreateExecutorState(void)
estate->es_sourceText = NULL;
estate->es_use_parallel_mode = false;
+ estate->es_parallel_workers_to_launch = 0;
+ estate->es_parallel_workers_launched = 0;
estate->es_jit_flags = 0;
estate->es_jit = NULL;
diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c
index 5d4ffe989c..7f7edc7f9f 100644
--- a/src/backend/executor/nodeGather.c
+++ b/src/backend/executor/nodeGather.c
@@ -182,6 +182,13 @@ ExecGather(PlanState *pstate)
/* We save # workers launched for the benefit of EXPLAIN */
node->nworkers_launched = pcxt->nworkers_launched;
+ /*
+ * Count number of workers originally wanted and actually
+ * launched.
+ */
+ estate->es_parallel_workers_to_launch += pcxt->nworkers_to_launch;
+ estate->es_parallel_workers_launched += pcxt->nworkers_launched;
+
/* Set up tuple queue readers to read the results. */
if (pcxt->nworkers_launched > 0)
{
diff --git a/src/backend/executor/nodeGatherMerge.c b/src/backend/executor/nodeGatherMerge.c
index 45f6017c29..bc99c0b448 100644
--- a/src/backend/executor/nodeGatherMerge.c
+++ b/src/backend/executor/nodeGatherMerge.c
@@ -223,6 +223,13 @@ ExecGatherMerge(PlanState *pstate)
/* We save # workers launched for the benefit of EXPLAIN */
node->nworkers_launched = pcxt->nworkers_launched;
+ /*
+ * Count number of workers originally wanted and actually
+ * launched.
+ */
+ estate->es_parallel_workers_to_launch += pcxt->nworkers_to_launch;
+ estate->es_parallel_workers_launched += pcxt->nworkers_launched;
+
/* Set up tuple queue readers to read the results. */
if (pcxt->nworkers_launched > 0)
{
--
2.45.2