From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Optimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64.
Date: Mon, 18 Dec 2023 16:53:49 +0000
Message-ID: <E1rFGsH-00AnIH-01@gemulon.postgresql.org> (raw)
Optimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64.
Presently, all platforms implement atomic exchanges by performing
an atomic compare-and-swap in a loop until it succeeds. This can
be especially expensive when there is contention on the atomic
variable. This commit optimizes atomic exchanges on many platforms
by using compiler intrinsics, which should compile into something
much less expensive than a compare-and-swap loop. Since these
intrinsics have been available for some time, the inline assembly
implementations are omitted.
Suggested-by: Andres Freund
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/20231129212905.GA1258737%40nathanxps13
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/64b1fb5f03266f0ef4eef3ad2b7d97170bb05b78
Modified Files
--------------
src/include/port/atomics/generic-gcc.h | 34 +++++++++++++++++++++++++++++++
src/include/port/atomics/generic-msvc.h | 18 ++++++++++++++++
src/include/port/atomics/generic-sunpro.h | 14 +++++++++++++
3 files changed, 66 insertions(+)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Optimize pg_atomic_exchange_u32 and pg_atomic_exchange_u64.
In-Reply-To: <E1rFGsH-00AnIH-01@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox