From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Reduce the number of GetFlushRecPtr() calls done by walsenders. |
Date: | 2020-01-06 21:42:31 |
Message-ID: | E1ioa8t-0003ZS-78@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2020-01-06 22:00:34 | Re: pgsql: Update copyrights for 2020 |
Previous Message | Tom Lane | 2020-01-06 20:08:25 | Re: pgsql: Remove support for OpenSSL 0.9.8 and 1.0.0 |