Re: MemSet inline for newNode

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: MemSet inline for newNode
Date: 2002-11-11 03:10:32
Message-ID: 23463.1036984232@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Tom Lane wrote:
>> But with any reasonably smart compiler, those *will* be the same because
>> the compiler can do constant-folding (ie, it knows i is 256 when control
>> reaches the MemSet). Pushing the MemSet into MemoryContextAlloc
>> eliminates the possibility of knowing the size argument's value.

> Yes, however, I am not seeing that getting optimized with gcc 2.95 -O2.

You aren't? I just checked gcc 2.95.3 on HPPA; it definitely propagates
the constant at -O2.

> Well, the palloc0 use by newNode was a performance boost, as tested by
> Neil Conway. Without palloc0, there was no way to inline newNode.

But your patch as committed does NOT inline newNode, in fact it does the
exact opposite: the MemSet macro is removed from the callsite.

> I made a new version that did the alignment test of start and len in one
> pass:

I thought the point of this exercise was to eliminate the alignment test
altogether, by making it doable at compile time. IIRC, the upshot of
the prior discussion was to keep the MemSet calls at the call site and
to eliminate the alignment test on the pointer by special-casing palloc0
(essentially, wiring into the macro the assumption that palloc's
returned pointer will be suitably aligned).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-11-11 03:12:05 Beta 5 build report
Previous Message Bruce Momjian 2002-11-11 02:58:07 Re: MemSet inline for newNode

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2002-11-11 03:36:13 Re: MemSet inline for newNode
Previous Message Bruce Momjian 2002-11-11 02:58:07 Re: MemSet inline for newNode