Re: spinlocks: generalizing "non-locking test"

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: spinlocks: generalizing "non-locking test"
Дата
Msg-id 1098160995.1113.147.camel@localhost.localdomain
обсуждение исходный текст
Ответ на Re: spinlocks: generalizing "non-locking test"  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: spinlocks: generalizing "non-locking test"  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Mon, 2004-10-18 at 11:53, Tom Lane wrote:
> Only once we've begun to spin.  The first time through, it's not at all
> clear whether the extra test is worthwhile --- it's certainly a win if
> the lock is always already held, and certainly a loss if the lock is
> always free

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). Therefore we have two cases: "initial TAS"
and "TAS inside loop", so so the logical implementation is two distinct
macros. Of course, there may well be platforms on which TAS() is defined
to TAS_INNER_LOOP() or vice versa, but this decision will vary by
platform.

> you have to do some benchmarking to decide if you want it or not. 

I agree that benchmarking is worth doing before making changes.

> We have the ASM-level test on those platforms
> where people seem to think that it is worthwhile, but not everywhere.

That is certainly an optimistic interpretation :-) I would say an
equally likely theory is that there is only one platform on which people
have bothered to try a non-blocking test and see if it improves
performance, and accordingly we only have one platform on which a
non-locking test is used.

(If anyone out there _has_ modified the spinlock implementation for
PostgreSQL on a particular platform to use a non-locking initial test
and found it hasn't improved performance, please speak up.)

-Neil




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Davie
Дата:
Сообщение: Re: [BUGS] BUG #1270: stack overflow in thread in fe_getauthname
Следующее
От: Satoshi Nagayasu
Дата:
Сообщение: smgr.c and smgrtype.c