Re: dynamic shared memory and locks

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: dynamic shared memory and locks
Дата
Msg-id 8369.1389034544@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: dynamic shared memory and locks  (Andres Freund <andres@2ndquadrant.com>)
Ответы Re: dynamic shared memory and locks  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Andres Freund <andres@2ndquadrant.com> writes:
> On 2014-01-05 14:06:52 -0500, Tom Lane wrote:
>> I seem to recall that there was some good reason for keeping all the
>> LWLocks in an array, back when the facility was first designed.
>> I'm too lazy to research the point right now, but you might want to
>> go back and look at the archives around when lwlock.c was written.

> Your proposal is at
> http://www.postgresql.org/message-id/1054.1001520600@sss.pgh.pa.us -
> afaics there hasn't been much discussion about implementation details at
> that level.

Yeah, there wasn't :-(.  On reflection I believe that my reason for
building it like this was partially to reduce the number of pointer
variables needed, and partially to avoid exposing the contents of the
LWLock struct type to the rest of the backend.

Robert's idea of continuing to keep the "fixed" LWLocks in an array
would solve the first problem, but I don't think there's any way to
avoid exposing the struct type if we want to embed the things into
other structs, or even just rely on array indexing.

OTOH, the LWLock mechanism has been stable for long enough now that
we can probably suppose this struct is no more subject to churn than
any other widely-known one, so maybe that consideration is no longer
significant.

Another nice benefit of switching to separate allocations that we could
get rid of the horrid kluge that lwlock.h is the place that defines
NUM_BUFFER_PARTITIONS and some other constants that don't belong there.

So on the whole I'm in favor of this, as long as we can avoid any
notational churn at most call sites.

Should we get rid of RequestAddinLWLocks() and LWLockAssign(), in
favor of telling extensions to just allocate some space and do
LWLockInit() on it?

BTW, NumLWLocks() also becomes a big problem if lwlock creation
gets decentralized.  This is only used by SpinlockSemas() ...
so maybe we need to use Heikki's modulo idea to get rid of the
need for that to know the number of LWLocks, independently of DSM.
        regards, tom lane



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: dynamic shared memory and locks
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Add CREATE support to event triggers