From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
Cc: | Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: Suboptimal spinlock code due to volatile |
Date: | 2024-07-30 16:38:40 |
Message-ID: | CA+TgmoZ78ieZYsrxzB=D1YjjnV1FHFS97nxC+E+mZkouqBWuCg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 30, 2024 at 3:46 AM Heikki Linnakangas <hlinnaka(at)iki(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Ranier Vilela | 2024-07-30 16:56:16 | Re: New compiler warnings in buildfarm |
Previous Message | Tom Lane | 2024-07-30 16:19:09 | New compiler warnings in buildfarm |