pgsql: Reduce rate of walwriter wakeups due to async commits.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Reduce rate of walwriter wakeups due to async commits.
Date: 2023-11-27 15:52:29
Message-ID: E1r7duP-007WNv-5r@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Reduce rate of walwriter wakeups due to async commits.

XLogSetAsyncXactLSN(), called at asynchronous commit, would wake up
walwriter every time the LSN advances, but walwriter doesn't actually
do anything unless it has at least 'wal_writer_flush_after' full
blocks of WAL to write. Repeatedly waking up walwriter to do nothing
is a waste of CPU cycles in both walwriter and the backends doing the
wakeups. To fix, apply the same logic in XLogSetAsyncXactLSN() to
decide whether to wake up walwriter, as walwriter uses to determine if
it has any work to do.

In the passing, rename misleadingly named 'flushbytes' local variable
to 'flushblocks'.

Author: Andres Freund, Heikki Linnakangas
Discussion: https://www.postgresql.org/message-id/20231024230929.vsc342baqs7kmbte@awork3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1f395354d8742d57c166104874114b6e0d01e104

Modified Files
--------------
src/backend/access/transam/xlog.c | 49 +++++++++++++++++++++++++--------------
1 file changed, 31 insertions(+), 18 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2023-11-27 15:53:24 pgsql: Check if ii_AmCache is NULL in aminsertcleanup
Previous Message Amit Kapila 2023-11-27 03:49:56 pgsql: Avoid unconditionally filling in missing values with NULL in pgo