Re: Suboptimal spinlock code due to volatile

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Suboptimal spinlock code due to volatile
Дата
Msg-id CA+TgmoZ78ieZYsrxzB=D1YjjnV1FHFS97nxC+E+mZkouqBWuCg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Suboptimal spinlock code due to volatile  (Heikki Linnakangas <hlinnaka@iki.fi>)
Список pgsql-hackers
On Tue, Jul 30, 2024 at 3:46 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> Aside from performance, I find "volatile" difficult to reason about. I
> feel more comfortable with atomics and memory barriers.

I think nearly everyone feels more comfortable with atomics and memory
barriers. The semantics of volatile are terrible. It almost does more
or less than what you actually wanted, sometimes both.

Reading Andres's original message, I couldn't help wondering if this
is an argument against rolling our own spinlock implementations.
Presumably a compiler intrinsic wouldn't cause this kind of
unfortunate artifact. Our position in the past has essentially been
"we know better," but this seems like a counterexample.

--
Robert Haas
EDB: http://www.enterprisedb.com



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