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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Reduce the number of GetFlushRecPtr() calls done by walsenders.
Дата
Msg-id E1ioa8t-0003ZR-6i@gemulon.postgresql.org
обсуждение исходный текст
Список 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
------
master

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

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


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pgsql: Remove support for OpenSSL 0.9.8 and 1.0.0
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: pgsql: Update copyrights for 2020