Re: [HACKERS] Postgres Speed or lack thereof

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Postgres Speed or lack thereof
Дата
Msg-id 23893.917552355@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Postgres Speed or lack thereof  (Massimo Dal Zotto <dz@cs.unitn.it>)
Ответы Re: [HACKERS] Postgres Speed or lack thereof
Список pgsql-hackers
Massimo Dal Zotto <dz@cs.unitn.it> writes:
> We could use 4 methods for dynamic allocation:

This sounds pretty close to what I was thinking, too.  We already have
the notion of "memory contexts" which can have different alloc/free
implementations, so there's already a structure to put these different
alloc methods into.

However, we probably don't really want to touch each individual palloc()
call in the system to change it to a MemoryContextAlloc(some-context, size)
call.  Not only would that be horribly tedious, but an awful lot of
these calls are made for the purpose of creating an object that the
requesting routine intends to pass back to its caller.  In that
situation, the requesting routine doesn't really *know* what the
lifetime of the storage needs to be --- it's the caller that determines
what's going to happen.

I think what we want is to define palloc() as allocating
not-individually-freeable storage from the current context, which is set
by the most closely nested main control routine (parser, planner,
executor, etc).  That should handle the majority of the existing code
and thus minimize the number of places that have to be touched.
pfree() goes away, eventually, and can be made a no-op meanwhile.

This assumes that the number of places that really *want* to free
storage earlier than end of context is much smaller than the number
of places that don't want to be bothered --- therefore, it makes more
sense to redefine palloc() as the not-separately-freeable kind and
change the places that do want to control their storage lifetime,
instead of changing all the other places.

> 4)    fast_talloc - we could introduce a `tuple' context handled like
>     fast_palloc for storage used only while processing one tuple.

Right, that could be the most closely nested context for operations that
iterate over tuples.  A further idea I had is to define allocations
from that context as being only good for one tuple, but to not bother to
physically clear the context after every single tuple --- do it every
ten or hundred or so tuples, instead.  The amount of storage wasted
won't be very large, and it cuts the per-tuple time cost even more.
(Of course, if resetting a context to empty only takes a few
instructions, you might as well just do it every time.  I'm not sure
offhand if that will be true or not.)
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] new heap manager mmalloc
Следующее
От: "Jackson, DeJuan"
Дата:
Сообщение: RE: [HACKERS] Problem with multiple SUMs