Re: s_lock() seems too aggressive for machines with many sockets

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: s_lock() seems too aggressive for machines with many sockets
Дата
Msg-id 20150610142041.GD5067@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: s_lock() seems too aggressive for machines with many sockets  (Nils Goroll <slink@schokola.de>)
Ответы Re: s_lock() seems too aggressive for machines with many sockets
Re: s_lock() seems too aggressive for machines with many sockets
Список pgsql-hackers
On 2015-06-10 16:12:05 +0200, Nils Goroll wrote:
>
> On 10/06/15 16:05, Andres Freund wrote:
> > it'll nearly always be beneficial to spin
>
> Trouble is that postgres cannot know if the process holding the lock actually
> does run, so if it doesn't, all we're doing is burn cycles and make the problem
> worse.

That's precisely what I referred to in the bit you cut away...

> Contrary to that, the kernel does know, so for a (f|m)utex which fails to
> acquire immediately and thus needs to syscall, the kernel has the option to spin
> only if the lock holder is running (the "adaptive" mutex).

Unfortunately there's no portable futex support. That's what stopped us
from adopting them so far.  And even futexes can be significantly more
heavyweight under moderate contention than our spinlocks - It's rather
easy to reproduce scenarios where futexes cause significant slowdown in
comparison to spinning in userspace (just reproduce contention on a
spinlock where the protected area will be *very* short - i.e. no cache
misses, no branches or such).

I think we should eventually work on replacing most of the currently
spinlock using code to either use lwlocks (which will enter the kernel
under contention, but not otherwise) or use lockless programming
techniques. I think there's relatively few relevant places left. Most
prominetly the buffer header spinlocks...



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: s_lock() seems too aggressive for machines with many sockets
Следующее
От: Tom Lane
Дата:
Сообщение: Re: s_lock() seems too aggressive for machines with many sockets