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

Re: inline newNode()

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>,Neil Conway <neilc(at)samurai(dot)com>
Subject: Re: inline newNode()
Date: 2002-10-09 05:21:56
Message-ID: 200210090521.g995Lur17063@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > > 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.
> > 
> > But if the MemSet is inside the called function then it cannot reduce
> > the if-tests to a compile-time decision to invoke the word-zeroing loop.
> > We want the MemSet to be expanded at the newNode call site, where the
> > size of the allocated memory is a compile-time constant.
> 
> I can easily do the tests in the MemSet macro, but I can't do a loop in
> a macro that has to return a value;  I need while().  Though a loop in a
> new fuction will not be as fast as a MemSet macro, I think it will be
> better than what we have now with newNode only because newNode will be a
> macro and not a function anymore, i.e. the MemSet will happen in the
> function called by pallocC and not in newNode anymore, and there will be
> zero code bloat.  I wish I saw another way.

OK, here's a patch for testing.  It needs cleanup because the final
version would remove the nodes/nodes.c file.  The net effect of the
patch is to make newNode a macro with little code bloat.

-- 
  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 05:24:10
Subject: Re: inline newNode()
Previous:From: Bruce MomjianDate: 2002-10-09 04:35:06
Subject: Re: inline newNode()

pgsql-patches by date

Next:From: Tom LaneDate: 2002-10-09 05:24:10
Subject: Re: inline newNode()
Previous:From: Bruce MomjianDate: 2002-10-09 04:58:47
Subject: Re: Allow SET to not start a transaction

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