Re: spinlocks on powerpc

Jeremy Harris <jgh@wizmail.org>

From: Jeremy Harris <jgh@wizmail.org>
To: pgsql-hackers@postgresql.org
Date: 2012-01-03T20:05:33Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Use LWSYNC in place of SYNC/ISYNC in PPC spinlocks, where possible.

  2. Reduce sinval synchronization overhead.

On 2012-01-03 04:44, Robert Haas wrote:
> On read-only workloads, you get spinlock contention, because everyone
> who wants a snapshot has to take the LWLock mutex to increment the
> shared lock count and again (just a moment later) to decrement it.

Does the LWLock protect anything but the shared lock count?  If not
then the usually quickest manipulation is along the lines of:

loop: lwarx r5,0,r3  #load and reserve
         add     r0,r4,r5 #increment word
         stwcx. r0,0,r3  #store new value if still reserved
         bne-    loop      #loop if lost reservation

(per IBM's software ref manual,
  https://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF778525699600719DF2
)

The same sort of thing generally holds on other instruction-sets also.

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).
-- 
Jeremy