Re: spinlocks on powerpc - Mailing list pgsql-hackers

From Tom Lane
Subject Re: spinlocks on powerpc
Date
Msg-id 25841.1325623738@sss.pgh.pa.us
Whole thread Raw
In response to Re: spinlocks on powerpc  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, Jan 3, 2012 at 3:05 PM, Jeremy Harris <jgh@wizmail.org> wrote:
>> Also, heavy-contention locks should be placed in cache lines away from other
>> data (to avoid thrashing the data cache lines when processors are fighting
>> over the lock cache lines).

> Yep.  This is possibly a problem, and has been discussed before, but I
> don't think we have any firm evidence that it's a problem, or how much
> padding helps.  The heavily contended LWLocks are mostly
> non-consecutive, except perhaps for the buffer mapping locks.

We are in fact already padding and aligning LWLocks on (if memory
serves) 16 or 32 byte boundaries depending on platform.  So there
might be 2 to 4 LWLocks in the same cache line, depending on platform.
It's been suggested before that we pad more to reduce this number,
but nobody's demonstrated any performance win from doing so.

> It's been suggested to me that we should replace our existing LWLock
> implementation with a CAS-based implementation that crams all the
> relevant details into a single 8-byte word.

I'm under the impression that the main costs are associated with trading
cache line ownership between CPUs, which makes me think that this'd be
essentially a waste of effort, quite aside from the portability problems
involved.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Collect frequency statistics for arrays
Next
From: Alexander Korotkov
Date:
Subject: Re: Collect frequency statistics for arrays