Re: inline newNode()

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: inline newNode()
Дата
Msg-id 200210090421.g994Lfc05927@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: inline newNode()  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: inline newNode()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-patches
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > OK, here is a version of newNode that is a macro.
>
> If you use memset() instead of MemSet(), I'm afraid you're going to blow
> off most of the performance gain this was supposed to achieve.

Yep.

> > Does anyone have additional suggestions?  The only thing I can suggest
> > is to make a clear-memory version of palloc because palloc always calls
> > MemoryContextAlloc() so I can put it in there.  How does that sound?
>
> I do not think palloc should auto-zero memory.  Hard to explain why,
> but it just feels like a bad decision.  One point is that the MemSet
> has to be inlined or it cannot compile-out the tests on _len.  palloc
> can't treat the length as a compile-time constant.

Right, palloc shouldn't.  I was thinking of having another version of
palloc that _does_ clear out memory, and calling that from a newNode()
macro.  We already know palloc is going to call MemoryContextAlloc, so
we could have a pallocC() that calls a new MemoryContextAllocC() that
would call the underlying memory allocation function, then do the loop
like MemSet to clear it.

It would allow newNode to be a macro and prevent the bloat of having
MemSet appear everywhere newNode appears;  it would all be in the new
function MemoryContextAllocC().

> > The regression tests do pass with this patch, so functionally it works
> > fine.
>
> Speed is the issue here, not functionality...

I was just proving it works, that's all.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: inline newNode()
Следующее
От: Tom Lane
Дата:
Сообщение: Re: inline newNode()