Re: spinlocks: generalizing "non-locking test" - Mailing list pgsql-hackers

From Tom Lane
Subject Re: spinlocks: generalizing "non-locking test"
Date
Msg-id 16451.1098201712@sss.pgh.pa.us
Whole thread Raw
In response to Re: spinlocks: generalizing "non-locking test"  (Neil Conway <neilc@samurai.com>)
List pgsql-hackers
Neil Conway <neilc@samurai.com> writes:
> Granted, but I think you've mostly conceded my point: every _subsequent_
> time TAS() is invoked, the non-locking test is a clear win (with the
> possible exception of PPC).

I'm not real sure.  One point here is that the standard advice about
this stuff is generally thinking in terms of an *extremely* tight spin
loop, ie
while (TAS(lock))    ;

The loop in s_lock.c has a bit more overhead than that.  Also, because
we only use spinlocks to protect LWLocks, the expected hold time for a
spinlock is just a couple dozen instructions, which is probably less
than the expected time in most other uses of spinlocks.  So I think it's
less than clear that we should expect TAS to fail, even within the loop.

Basically I'd like to see some tests proving that there's actually any
value in it before we go complicating the assembly-code API ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re:
Next
From: Andreas Pflug
Date:
Subject: Re: Time off