Re: dynamic shared memory and locks

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: dynamic shared memory and locks
Дата
Msg-id 52CA6AEF.8080901@vmware.com
обсуждение исходный текст
Ответ на dynamic shared memory and locks  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: dynamic shared memory and locks  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-hackers
On 01/05/2014 07:56 PM, Robert Haas wrote:
> Right now, storing spinlocks in dynamic shared memory *almost* works,
> but there are problems with --disable-spinlocks.  In that
> configuration, we use semaphores to simulate spinlocks.  Every time
> someone calls SpinLockInit(), it's going to allocate a new semaphore
> which will never be returned to the operating system, so you're pretty
> quickly going to run out.  There are a couple of things we could do
> about this:

5. Allocate a fixed number of semaphores, and multiplex them to emulate 
any number of spinlocks. For example, allocate 100 semaphores, and use 
the address of the spinlock modulo 100 to calculate which semaphore to 
use to emulate that spinlock.

That assumes that you never hold more than one spinlock at a time, 
otherwise you can get deadlocks. I think that assumptions holds 
currently, because acquiring two spinlocks at a time would be bad on 
performance grounds anyway.

- Heikki



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

Предыдущее
От: Amit Langote
Дата:
Сообщение: Re: GIN improvements part 1: additional information
Следующее
От: Gabriele Bartolini
Дата:
Сообщение: Re: [PATCH] Support for pg_stat_archiver view