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: "Alex Hunsaker"
Date: Fri, 29 Aug 2008 16:46:58 -0600
Newsgroups: pgsql.hackers

On Fri, Aug 29, 2008 at 1:16 PM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
> In theory the above implementation of newNode should be a clear win,
> so I'm thinking this result must be an artifact of some kind.  I'm
> going to go try it on PPC and HPPA machines next; does anyone want to
> try it on something else?

Hrm, I tried it on my x86_64 (quad core 2.66ghz, sorry no exotic
machines here :)) and did not see any real noticeable difference
between the two...

Here is what I tried:
(all with ./configure --enable-debug and make clean in between)

CVS HEAD:
tps = 30.375794
tps = 31.138078
tps = 30.928565

#define newNode(size, tag) \
({  Node *newNodeMacroHolder; \
   AssertMacro((size) >= sizeof(Node));        /* need the tag, at least */ \
   newNodeMacroHolder = (Node *) palloc0fast(size); \
   newNodeMacroHolder->type = (tag); \
   newNodeMacroHolder; \
})

tps = 30.814628
tps = 30.706080
tps = 31.10788

static inline Node *newNode(Size size, NodeTag tag)
{
        Node *newNode;
        Assert(size >= sizeof(Node));
        newNode = (Node *) palloc0(size);
        newNode->type = tag;
        return newNode;
}

tps = 30.317978
tps = 30.786187
tps = 30.747112

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


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