Skip to content

Unify parallel worker handling for index builds and instrumentation#77

Open
lfittl wants to merge 4 commits into
masterfrom
refactor-parallel-workers
Open

Unify parallel worker handling for index builds and instrumentation#77
lfittl wants to merge 4 commits into
masterfrom
refactor-parallel-workers

Conversation

@lfittl
Copy link
Copy Markdown
Owner

@lfittl lfittl commented May 31, 2026

No description provided.

lfittl added 4 commits May 31, 2026 11:34
This simplifies the DSM allocations a bit since we don't need to
separately allocate WAL and buffer usage, and allows the easier future
addition of a third stack-based struct being discussed.

In passing, adjust InstrAccumParallelQuery to handle multiple workers:
All callers currently have a loop to call the accumulation for each
worker and a local loop variable defined. To slightly simplify the
callers, move the loop into the InstrAccumParallelQuery function and
add a new "nworkers" argument to it.

Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by:
Discussion:
Similar to query text, introduce helpers to estimate the shared
memory required for instrumentation, and for allocating and storing it
in shared memory.

Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by:
Discussion:
Multiple callers (parallel index builds, parallel vacuum, parallel query)
all had the same implementation for passing query text to the parallel
workers.

To reduce duplicated code, introduce new helper functions to: (1) estimate
the needed shared memory space for the query text, (2) store the query
text in shared memory, and (3) restore the query text in the worker.

Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by:
Discussion:
The three in-tree index AMs that currently support parallel index builds
(nbtree, gin and brin) each share very similar code for initializing
parallel workers, allocating shared memory and communicating between the
leader and the workers.

To reduce duplication, introduce shared helpers for parallel index
builds, unifiying the existing code.

This also fixes an oversight in parallel GIN index builds that forgot
to pass the queryid to the parallel workers, like other AMs do.

Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by:
Discussion:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant