pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Gustafsson <dgustafsson@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Refresh cost-based delay params more frequently in autovacuum
Date: Thu, 06 Apr 2023 23:03:23 +0000
Message-ID: <E1pkYdW-001kmr-3f@gemulon.postgresql.org> (raw)

Refresh cost-based delay params more frequently in autovacuum

Allow autovacuum to reload the config file more often so that cost-based
delay parameters can take effect while VACUUMing a relation. Previously,
autovacuum workers only reloaded the config file once per relation
vacuumed, so config changes could not take effect until beginning to
vacuum the next table.

Now, check if a reload is pending roughly once per block, when checking
if we need to delay.

In order for autovacuum workers to safely update their own cost delay
and cost limit parameters without impacting performance, we had to
rethink when and how these values were accessed.

Previously, an autovacuum worker's wi_cost_limit was set only at the
beginning of vacuuming a table, after reloading the config file.
Therefore, at the time that autovac_balance_cost() was called, workers
vacuuming tables with no cost-related storage parameters could still
have different values for their wi_cost_limit_base and wi_cost_delay.

Now that the cost parameters can be updated while vacuuming a table,
workers will (within some margin of error) have no reason to have
different values for cost limit and cost delay (in the absence of
cost-related storage parameters). This removes the rationale for keeping
cost limit and cost delay in shared memory. Balancing the cost limit
requires only the number of active autovacuum workers vacuuming a table
with no cost-based storage parameters.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAAKRu_ZngzqnEODc7LmS1NH04Kt6Y9huSjz5pp7%2BDXhrjDA0gw%40m...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7d71d3dd080b9b147402db3365fe498f74704231

Modified Files
--------------
src/backend/access/heap/vacuumlazy.c  |   2 +-
src/backend/commands/vacuum.c         |  46 +++++-
src/backend/commands/vacuumparallel.c |   1 -
src/backend/postmaster/autovacuum.c   | 291 ++++++++++++++++++++--------------
src/include/commands/vacuum.h         |   1 +
5 files changed, 219 insertions(+), 122 deletions(-)



Message-ID: <E1pkYdW-001kmr-3f@gemulon.postgresql.org>
Permalink:  ../E1pkYdW-001kmr-3f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pkYdW-001kmr-3f@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: dgustafsson@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Refresh cost-based delay params more frequently in autovacuum
  In-Reply-To: <E1pkYdW-001kmr-3f@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox