Skip to content

Commit de3a2ea

Browse files
committed
Introduce two fields in EState to track parallel worker activity
These fields can be set by executor nodes to record how many parallel workers were planned to be launched and how many of them have been actually launched within the number initially planned. This data is able to give an approximation of the parallel worker draught a system is facing, making easier the tuning of related configuration parameters. These fields will be used by some follow-up patches to populate other parts of the system with their data. Author: Guillaume Lelarge, Benoit Lobréau Discussion: https://postgr.es/m/783bc7f7-659a-42fa-99dd-ee0565644e25@dalibo.com Discussion: https://postgr.es/m/CAECtzeWtTGOK0UgKXdDGpfTVSa5bd_VbUt6K6xn8P7X+_dZqKw@mail.gmail.com
1 parent 01fce8d commit de3a2ea

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

src/backend/executor/execUtils.c

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ CreateExecutorState(void)
158158
estate->es_sourceText = NULL;
159159

160160
estate->es_use_parallel_mode = false;
161+
estate->es_parallel_workers_to_launch = 0;
162+
estate->es_parallel_workers_launched = 0;
161163

162164
estate->es_jit_flags = 0;
163165
estate->es_jit = NULL;

src/backend/executor/nodeGather.c

+7
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ ExecGather(PlanState *pstate)
182182
/* We save # workers launched for the benefit of EXPLAIN */
183183
node->nworkers_launched = pcxt->nworkers_launched;
184184

185+
/*
186+
* Count number of workers originally wanted and actually
187+
* launched.
188+
*/
189+
estate->es_parallel_workers_to_launch += pcxt->nworkers_to_launch;
190+
estate->es_parallel_workers_launched += pcxt->nworkers_launched;
191+
185192
/* Set up tuple queue readers to read the results. */
186193
if (pcxt->nworkers_launched > 0)
187194
{

src/backend/executor/nodeGatherMerge.c

+7
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ ExecGatherMerge(PlanState *pstate)
223223
/* We save # workers launched for the benefit of EXPLAIN */
224224
node->nworkers_launched = pcxt->nworkers_launched;
225225

226+
/*
227+
* Count number of workers originally wanted and actually
228+
* launched.
229+
*/
230+
estate->es_parallel_workers_to_launch += pcxt->nworkers_to_launch;
231+
estate->es_parallel_workers_launched += pcxt->nworkers_launched;
232+
226233
/* Set up tuple queue readers to read the results. */
227234
if (pcxt->nworkers_launched > 0)
228235
{

src/include/nodes/execnodes.h

+5
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,11 @@ typedef struct EState
708708

709709
bool es_use_parallel_mode; /* can we use parallel workers? */
710710

711+
int es_parallel_workers_to_launch; /* number of workers to
712+
* launch. */
713+
int es_parallel_workers_launched; /* number of workers actually
714+
* launched. */
715+
711716
/* The per-query shared memory area to use for parallel execution. */
712717
struct dsa_area *es_query_dsa;
713718

0 commit comments

Comments
 (0)