Re: spinlocks: generalizing "non-locking test"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: spinlocks: generalizing "non-locking test"
Date: 2004-10-19 16:01:52
Message-ID: 16451.1098201712@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neil Conway <neilc(at)samurai(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2004-10-19 16:11:19 Re: Time off
Previous Message Andrew Dunstan 2004-10-19 15:44:05 Re: [HACKERS] strange result from contrib/seg regression on windows