Re: spinlocks on HP-UX

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: spinlocks on HP-UX
Дата
Msg-id CA+TgmoaAdQPZkOMi0GFBrChAe+gJdtav5bg1tF11RB_R9QaDow@mail.gmail.com
обсуждение исходный текст
Ответ на Re: spinlocks on HP-UX  (Pavan Deolasee <pavan.deolasee@gmail.com>)
Список pgsql-hackers
On Tue, Oct 18, 2011 at 2:20 AM, Pavan Deolasee
<pavan.deolasee@gmail.com> wrote:
> On Tue, Oct 18, 2011 at 10:04 AM, Robert Haas <robertmhaas@gmail.com> wrote:
>> Hmm, so you added the non-locked test in TAS()?  Did you try adding it
>> just to TAS_SPIN()?  On Itanium, I found that it was slightly better
>> to do it only in TAS_SPIN() - i.e. in the contended case.
>
> Would it be a good change for S_LOCK() to use TAS_SPIN()  as well ?

Well, that would be sort of missing the point of why we invented
TAS_SPIN() in the first place.  What we found on Itanium is that using
the unlocked test always was better than never doing it, but what was
even slightly better was to use the unlocked first test *only when
spinning*.  In other words, on the very first go-around, we use the
atomic instruction right away.  Only if that fails do we switch to
using the unlocked test first.

Now it's possible that on some other architecture it's better to do
the unlocked test first every time.  But it seems somewhat unlikely,
because in the hopefully-common case where the spinlock is
uncontended, it's just a waste.  If you're having enough spinlock
contention that the first TAS() is failing frequently, you need to fix
the underlying cause of the spinlock contention...

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: new compiler warnings
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: new compiler warnings