pgsql: Reduce rate of walwriter wakeups due to async commits. - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Reduce rate of walwriter wakeups due to async commits.
Date
Msg-id E1r7duP-007WNv-5r@gemulon.postgresql.org
Whole thread Raw
List 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(-)


pgsql-committers by date:

Previous
From: Amit Kapila
Date:
Subject: pgsql: Avoid unconditionally filling in missing values with NULL in pgo
Next
From: Tomas Vondra
Date:
Subject: pgsql: Check if ii_AmCache is NULL in aminsertcleanup