pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reduce the number of GetFlushRecPtr() calls done by walsenders.
Date: Mon, 06 Jan 2020 21:42:31 +0000
Message-ID: <E1ioa8t-0003ZS-78@gemulon.postgresql.org> (raw)

Reduce the number of GetFlushRecPtr() calls done by walsenders.

Since the WAL flush position only moves forward, it's safe to cache
its previous value within each walsender process, and update from
shared memory only once we've caught up to the previously-seen value.
When there are many active walsenders, this makes for a very significant
reduction in the amount of contention on the XLogCtl->info_lck spinlock.

This patch also adjusts the logic so that we update our idea of the
flush position after processing a WAL record, rather than beforehand.
This may cause us to realize we're not caught up when the preceding
coding would've thought that we were, but that seems all to the good;
it may avoid a useless sleep-and-wakeup cycle.

Back-patch to v12.  The contention problem exists in prior branches,
but it's much less severe (due to inefficiencies elsewhere) so there
seems no need to take any risk of back-patching further.

Pierre Ducroquet, reviewed by Julien Rouhaud

Discussion: https://postgr.es/m/2931018.Vxl9zapr77@pierred-pdoc

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b89845267a6b0197e86b5a189d26f90f6a45c05f

Modified Files
--------------
src/backend/replication/walsender.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)



view thread (2+ messages)

Message-ID: <E1ioa8t-0003ZS-78@gemulon.postgresql.org>
Permalink:  ../E1ioa8t-0003ZS-78@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ioa8t-0003ZS-78@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Reduce the number of GetFlushRecPtr() calls done by walsenders.
  In-Reply-To: <E1ioa8t-0003ZS-78@gemulon.postgresql.org>
  References: <E1ioa8t-0003ZS-78@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