Re: Atomics hardware support table & supported architectures

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Atomics hardware support table & supported architectures
Date: 2014-06-23 16:38:17
Message-ID: 20140623163817.GW16260@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-06-23 09:28:19 -0700, Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > On Mon, Jun 23, 2014 at 11:16 AM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> >> Since fetch-and-add is trivially implemented using CAS, there's not much
> >> need to distinguish between CAS and CAS + fetch_and_add. From my POV the
> >> restriction to just CAS/fetch_and_add isn't actually buying much. Pretty
> >> much all platforms but older gcc ones have atomic intrinsics since
> >> forever. Once you've dug up the documentation for one operation not
> >> adding two more or so doesn't save much.
>
> > Again, the concern that was expressed at the developer's meeting was
> > that the performance characteristics of the CAS loop might be
> > significantly different from a native atomic op as to cause us
> > heartburn. I think that's a valid concern... but if everything in
> > common use has both CAS and fetch-and-add, then I think there's
> > probably no issue here.
>
> What I want to know is whether we are going to agree that the set of
> atomics is going to be CAS plus fetch_and_add plus *nothing else*.

It's going to be TAS, CAS, fetch_and_add, right? Since TAS is the only
thing supported on some platforms?

The only op I'm currently wondering about adding is a atomic exchange,
without compare to that set. All platforms that support CAS also have a
non-comparing version of it.

Right now the patch also uses __sync_fetch_and_sub() in the generic gcc
implementation instead of doing the negation itself, but that's easily
"fixable".

> Andres seems to envision that those will be a minimal set and then
> we'll freely use any other atomic op that seems handy as long as we can
> provide a fallback implementation of it.

Well, I *do* also want pg_atomic_fetch_and/or_u32() - but I'm totally
fine with those two only being implemented with CAS. On all
platforms. Otherwise the next scalability patch I'm going to submit will
just have to open code a CAS loop for it which doesn't seem to help.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2014-06-23 16:39:50 Re: SQL access to database attributes
Previous Message Heikki Linnakangas 2014-06-23 16:37:50 Re: releaseOk and LWLockWaitForVar