Re: C11 / VS 2019

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru>, Michael Paquier <michael(at)paquier(dot)xyz>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: C11 / VS 2019
Date: 2025-06-03 20:46:31
Message-ID: CA+hUKGKVMuTYtzFFTrsd7TfZu08boLDzg6DJOkhBaaReij__Gg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 4, 2025 at 2:02 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru> writes:
> > Will it mean we can implement atomics in term of C11 atomics?
>
> Any such change would have to be supported by extensive performance
> testing to verify that there's not a regression on any supported
> platform. Yeah, it'd be cool if we could rip out a lot of that
> code, but we aren't going to just rip on faith.

FWIW I posted an experimental patch like that at:

https://www.postgresql.org/message-id/flat/CA%2BhUKG%2Bw-2RyyYUte_mSAunoRE00bQUCG44%3DFiOuyMaN-6uoOw%40mail.gmail.com#60354fbd9784c58d3eeaf9a4193a7414

To make progress down this path, yeah, we'd definitely want to do a
bunch of cross-platform evaluation work, ie performance valuation and
probably reading assembler. Note that in that experiment I just
mapped to the non-_explicit() variants (in other words all the
operations are defaulting to memory_order_seq_cst, which is too strong
in many cases), so we'd also what to think hard about which of the
pg_atomics operations should use _explicit() with a weaker
memory_order. Nearby there are also patches to change our spinlocks
to use pg_atomics, so then that just becomes standard C11 code too.
Assuming all that can be ironed out, AFAIK there is only one piece
that we'll still need to hand-roll, because C11 doesn't provide
anything like it: pg_spin_delay_impl(). (I haven't looked into
whether there is anything standard proposed to deal with that in some
future C.)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Koval 2025-06-03 20:53:13 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message Mihail Nikalayeu 2025-06-03 20:26:09 Re: bt_index_parent_check and concurrently build indexes