Re: better atomics - v0.6

Andres Freund <andres@anarazel.de>

From: andres@anarazel.de (Andres Freund)
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Heikki Linnakangas <hlinnakangas@vmware.com>, Robert Haas <robertmhaas@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>, Peter Geoghegan <pg@heroku.com>, Pg Hackers <pgsql-hackers@postgresql.org>, Ants Aasma <ants@cybertec.at>
Date: 2014-09-24T16:57:56Z
Lists: pgsql-hackers
On 2014-09-24 12:44:09 -0400, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > On 2014-09-24 18:55:51 +0300, Heikki Linnakangas wrote:
> >> There doesn't seem to be any hardware implementations of that in the patch.
> >> Is there any architecture that has an instruction or compiler intrinsic for
> >> that?
> 
> > You can implement it rather efficiently on ll/sc architectures. But I
> > don't really think it matters. I prefer add_until (I've seen it named
> > saturated add before as well) to live in the atomics code, rather than
> > reimplement it in atomics employing code. I guess you see that
> > differently?
> 
> I think the question is more like "what in the world happened to confining
> ourselves to a small set of atomics". 

I fail to see why the existance of a wrapper around compare-exchange
(which is one of the primitives we'd agreed upon) runs counter to
the agreement that we'll only rely on a limited number of atomics on the
hardware level?

> I doubt either that this exists
> natively anywhere, or ethat it's so useful that we should expect platforms
> to have efficient implementations.

It's useful for my work to get rid of most LockBufHdr() calls (to
manipulate usagecount locklessly). That's why I added it. We can delay
it till that patch is ready, but I don't really see the benefit.

Greetings,

Andres Freund

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


Commits

  1. Avoid the use of a separate spinlock to protect a LWLock's wait queue.

  2. Improve LWLock scalability.

  3. Reduce the number of semaphores used under --disable-spinlocks.

  4. Alter the configure script to fail immediately if the C compiler does not