Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5326~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5326
Choose a head ref
  • 5 commits
  • 11 files changed
  • 2 contributors

Commits on Apr 30, 2025

  1. Introduces table AM APIs for parallel table vacuuming.

    This commit introduces the following new table AM APIs for parallel
    table vacuuming:
    
    - parallel_vacuum_compute_workers
    - parallel_vacuum_estimate
    - parallel_vacuum_initialize
    - parallel_vacuum_initialize_worker
    - parallel_vacuum_collect_dead_items
    
    While parallel_vacuum_compute_workers is required, other new callbacks
    are optional.
    
    There is no code using these new APIs for now. Upcoming parallel
    vacuum patches utilize these APIs.
    
    Reviewed-by: Amit Kapila <[email protected]>
    Reviewed-by: Hayato Kuroda <[email protected]>
    Reviewed-by: Peter Smith <[email protected]>
    Reviewed-by: Tomas Vondra <[email protected]>
    Reviewed-by: Dilip Kumar <[email protected]>
    Reviewed-by: Melanie Plageman <[email protected]>
    Discussion: https://postgr.es/m/CAD21AoAEfCNv-GgaDheDJ+s-p_Lv1H24AiJeNoPGCmZNSwL1YA@mail.gmail.com
    MasahikoSawada authored and Commitfest Bot committed Apr 30, 2025
    Configuration menu
    Copy the full SHA
    fd2b00b View commit details
    Browse the repository at this point in the history
  2. vacuumparallel.c: Support parallel vacuuming for tables to collect de…

    …ad items.
    
    Previously, parallel vacuum was available only for index vacuuming and
    index cleanup, ParallelVacuumState was initialized only when the table
    has at least two indexes that are eligible for parallel index
    vacuuming and cleanup.
    
    This commit extends vacuumparallel.c to support parallel table
    vacuuming. parallel_vacuum_init() now initializes ParallelVacuumState
    to perform parallel heap scan to collect dead items, or paralel index
    vacuuming/cleanup, or both. During the initialization, it asks the
    table AM for the number of parallel workers required for parallel
    table vacuuming. If >0, it enables parallel table vacuuming and calls
    further table AM APIs such as parallel_vacuum_estimate.
    
    For parallel table vacuuming, this commit introduces
    parallel_vacuum_collect_dead_items_begin() function, which can be used
    to collect dead items in the table (for example, the first pass over
    heap table in lazy vacuum for heap tables).
    
    Heap table AM disables the parallel heap vacuuming for now, but an
    upcoming patch uses it.
    
    Reviewed-by: Amit Kapila <[email protected]>
    Reviewed-by: Hayato Kuroda <[email protected]>
    Reviewed-by: Peter Smith <[email protected]>
    Reviewed-by: Tomas Vondra <[email protected]>
    Reviewed-by: Dilip Kumar <[email protected]>
    Reviewed-by: Melanie Plageman <[email protected]>
    Discussion: https://postgr.es/m/CAD21AoAEfCNv-GgaDheDJ+s-p_Lv1H24AiJeNoPGCmZNSwL1YA@mail.gmail.com
    MasahikoSawada authored and Commitfest Bot committed Apr 30, 2025
    Configuration menu
    Copy the full SHA
    6179c4f View commit details
    Browse the repository at this point in the history
  3. Move lazy heap scan related variables to new struct LVScanData.

    This is a pure refactoring for upcoming parallel heap scan, which
    requires storing relation statistics and relation data such as extant
    oldest XID/MXID collected during lazy heap scan to a shared memory
    area.
    
    Reviewed-by: Amit Kapila <[email protected]>
    Reviewed-by: Hayato Kuroda <[email protected]>
    Reviewed-by: Peter Smith <[email protected]>
    Reviewed-by: Tomas Vondra <[email protected]>
    Reviewed-by: Dilip Kumar <[email protected]>
    Reviewed-by: Melanie Plageman <[email protected]>
    Discussion: https://postgr.es/m/CAD21AoAEfCNv-GgaDheDJ+s-p_Lv1H24AiJeNoPGCmZNSwL1YA@mail.gmail.com
    MasahikoSawada authored and Commitfest Bot committed Apr 30, 2025
    Configuration menu
    Copy the full SHA
    6f87345 View commit details
    Browse the repository at this point in the history
  4. Support parallelism for collecting dead items during lazy vacuum.

    This feature allows the vacuum to leverage multiple CPUs in order to
    collect dead items (i.e. the first pass over heap table) with parallel
    workers. The parallel degree for parallel heap vacuuming is determined
    based on the number of blocks to vacuum unless PARALLEL option of
    VACUUM command is specified, and further limited by
    max_parallel_maintenance_workers.
    
    For the parallel heap scan to collect dead items, we utilize a
    parallel block table scan, controlled by ParallelBlockTableScanDesc,
    in conjunction with the read stream. The workers' parallel scan
    descriptions are stored in the DSM space, enabling different parallel
    workers to resume the heap scan (phase 1) after a cycle of heap
    vacuuming and index vacuuming (phase 2 and 3) from their previous
    state. However, due to the potential presence of pinned buffers loaded
    by the read stream's look-ahead mechanism, we cannot abruptly stop
    phase 1 even when the space of dead_items TIDs exceeds the
    limit. Therefore, once the space of dead_items TIDs exceeds the limit,
    we begin processing pages without attempting to retrieve additional
    blocks by look-ahead mechanism until the read stream is exhausted,
    even if the the memory limit is surpassed. While this approach may
    increase the memory usage, it typically doesn't pose a significant
    problem, as processing a few 10s-100s buffers doesn't substantially
    increase the size of dead_items TIDs.
    
    When the parallel heap scan to collect dead items is enabled, we
    disable eager scanning. This is because parallel vacuum is available
    only in the VACUUM command and would not occur frequently, which
    doesn't align with the purpose of eager scanning.
    
    Reviewed-by: Amit Kapila <[email protected]>
    Reviewed-by: Hayato Kuroda <[email protected]>
    Reviewed-by: Peter Smith <[email protected]>
    Reviewed-by: Tomas Vondra <[email protected]>
    Reviewed-by: Dilip Kumar <[email protected]>
    Reviewed-by: Melanie Plageman <[email protected]>
    Reviewed-by: Andres Freund <[email protected]>
    Discussion: https://postgr.es/m/CAD21AoAEfCNv-GgaDheDJ+s-p_Lv1H24AiJeNoPGCmZNSwL1YA@mail.gmail.com
    MasahikoSawada authored and Commitfest Bot committed Apr 30, 2025
    Configuration menu
    Copy the full SHA
    607b276 View commit details
    Browse the repository at this point in the history
  5. [CF 5326] v16 - Parallel heap vacuum

    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/5326
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/CAD21AoCdxc6jLfk5fc1a5-2DgxFikrjFPa6-A5b8pn27i4yKRg@mail.gmail.com
    Author(s): Masahiko Sawada
    Commitfest Bot committed Apr 30, 2025
    Configuration menu
    Copy the full SHA
    0d70fb5 View commit details
    Browse the repository at this point in the history
Loading