pgsql.hackers
[Top] [All Lists]

Re: Is it really such a good thing for newNode() to be a macro?

Subject: Re: Is it really such a good thing for newNode() to be a macro?
From: "Heikki Linnakangas"
Date: Wed, 27 Aug 2008 17:32:13 +0300
Newsgroups: pgsql.hackers


Tom Lane wrote:
"Heikki Linnakangas" <heikki@xxxxxxxxxxxxxxxx> writes:
Note that the MemSetLoop macro used in palloc0fast is supposed to be evaluated at compile time,

Oooh, good point, I had forgotten about that little detail.  Yeah,
we'll lose that optimization if we move the code out-of-line.

Well, we could still have the MemSetTest outside the function, and evaluated at compile-time, if we provided an aligned and unaligned version of newNode:

#define newNode(size, tag) \
( \
        AssertMacro((size) >= sizeof(Node)),         /* need the tag, at least 
*/ \
        ( MemSetTest(0, sz) ? \
                newNodeAligned(CurrentMemoryContext, sz, tag) : \
                newNodeNotAligned(CurrentMemoryContext, sz, tag))

And if you're worried about the function call overhead, newNode(Not)Aligned could have the contents of MemoryContextAllocZero inlined into it. Not sure how much optimization is worthwhile here..

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@xxxxxxxxxxxxxx)
To make changes to your subscription:
                                www.postgresql.org/mailpref/pgsql-hackers">http://www.postgresql.org/mailpref/pgsql-hackers


<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy