Re: MemSet inline for newNode - Mailing list pgsql-patches

From Tom Lane
Subject Re: MemSet inline for newNode
Date
Msg-id 23217.1036983003@sss.pgh.pa.us
Whole thread Raw
In response to Re: MemSet inline for newNode  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: MemSet inline for newNode
List pgsql-patches
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I thought someone had tested that there was little/no performance
> difference between these two statements:
>     MemSet(ptr, 0, 256)
> vs.
>     i = 256;
>     MemSet(ptr, 0, i)

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.

> I can back out my changes, but it would be easier to see if there is a
> benefit before doing that.  Personally, I am going to be surprised if a
> single conditional tests in MemSet (which is not in the assignment loop)
> will make any measurable difference.

Then why were we bothering?  IIRC, this was being sold as a performance
improvement.

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: more SGML fixes
Next
From: Bruce Momjian
Date:
Subject: Re: MemSet inline for newNode