Re: WAL Insertion Lock Improvements

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: WAL Insertion Lock Improvements
Дата
Msg-id ZYPPb5VJcvm9a-kh@paquier.xyz
обсуждение исходный текст
Ответ на Re: WAL Insertion Lock Improvements  (Nathan Bossart <nathandbossart@gmail.com>)
Список pgsql-hackers
On Mon, Dec 18, 2023 at 10:00:29PM -0600, Nathan Bossart wrote:
> I found this code when searching for callers that use atomic exchanges as
> atomic writes with barriers (for a separate thread [0]).  Can't we use
> pg_atomic_write_u64() here since the locking functions that follow should
> serve as barriers?

The full barrier guaranteed by pg_atomic_exchange_u64() in
LWLockUpdateVar() was also necessary for the shortcut based on
read_u32() to see if there are no waiters, but it has been discarded
in the later versions of the patch because it did not influence
performance under heavy WAL inserts.

So you mean to rely on the full barriers taken by the fetches in
LWLockRelease() and LWLockWaitListLock()?  Hmm, I got the impression
that pg_atomic_exchange_u64() with its full barrier was necessary in
these two paths so as all the loads and stores are completed *before*
updating these variables.  So I am not sure to get why it would be
safe to switch to a write with no barrier.

> I've attached a patch to demonstrate what I'm thinking.  This might be more
> performant, although maybe less so after commit 64b1fb5.  Am I missing
> something obvious here?  If not, I might rerun the benchmarks to see
> whether it makes any difference.

I was wondering as well if the numbers we got upthread would go up
after what you have committed to improve the exchanges.  :)
Any change in this area should be strictly benchmarked.
--
Michael

Вложения

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

Предыдущее
От: Peter Smith
Дата:
Сообщение: Re: Synchronizing slots from primary to standby
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Function to get invalidation cause of a replication slot.