Re: Some interesting results from tweaking spinlocks

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Some interesting results from tweaking spinlocks
Дата
Msg-id 9904.1010206848@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Some interesting results from tweaking spinlocks  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Some interesting results from tweaking spinlocks
Список pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> OK, I am a little confused now.  I thought the spinlock was only done a
> few times if we couldn't get a lock, and if we don't we go to sleep, and
> the count determines how many times we try.  Isn't that expected to
> affect SMP machines?

Yeah, but if the spinlock is only held for a few dozen instructions,
one would think that the max useful delay is also a few dozen
instructions (or maybe a few times that, allowing for the possibility
that other processors might claim the lock before we can get it).
If we spin for longer than that, the obvious conclusion is that the
spinlock is held by a process that's lost the CPU, and we should
ourselves yield the CPU so that it can run again.  Further spinning
just wastes CPU time that might be used elsewhere.

These measurements seem to say there's a flaw in that reasoning.
What is the flaw?
        regards, tom lane


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Some interesting results from tweaking spinlocks
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Some interesting results from tweaking spinlocks