Skip site navigation (1) Skip section navigation (2)

Re: inline newNode()

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>,Neil Conway <neilc(at)samurai(dot)com>,PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: inline newNode()
Date: 2002-10-09 04:21:41
Message-ID: 200210090421.g994Lfc05927@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2002-10-09 04:28:32
Subject: Re: inline newNode()
Previous:From: Tom LaneDate: 2002-10-09 04:12:12
Subject: Re: inline newNode()

pgsql-patches by date

Next:From: Tom LaneDate: 2002-10-09 04:28:32
Subject: Re: inline newNode()
Previous:From: Tom LaneDate: 2002-10-09 04:12:12
Subject: Re: inline newNode()

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group