Re: spinlocks on powerpc

From: Jeremy Harris <jgh(at)wizmail(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: spinlocks on powerpc
Date: 2012-01-03 20:05:33
Message-ID: 4F035F8D.6050709@wizmail.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2012-01-03 20:09:16 Re: Collect frequency statistics for arrays
Previous Message Pavel Stehule 2012-01-03 19:49:12 Re: patch: ALTER TABLE IF EXISTS