Re: MemSet inline for newNode

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

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > I have applied this patch to inline MemSet for newNode.
> > I will make another commit to make more general use of palloc0.
>
> Refresh my memory on why either of these was a good idea?

You are talking about the use of palloc0 in place of palloc/MemSet(0),
not the use of palloc0 in newNode, right?

> > This was already discussed on hackers.
>
> And this was not the approach agreed to, IIRC. What you've done has
> eliminated the possibility of optimizing away the controlling tests
> in MemSet.

I see now:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=200210120006.g9C06i502964%40candle.pha.pa.us

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)

However, seeing no email reply, I now assume no test was done.

Neil, can you run such a test and let us know. It has to be with a
compiler that optimizes out the MemSet length test when the len is a
constant. I can't remember what compiler version/settings that was, but
it may have been -O3 gcc 3.20.

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.

--
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

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-11-10 21:06:44 Re: [PATCHES] MemSet inline for newNode
Previous Message Tom Lane 2002-11-10 18:58:57 Implicit coercions, choosing types for constants, etc (yet again)

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2002-11-10 21:06:44 Re: [PATCHES] MemSet inline for newNode
Previous Message Bruce Momjian 2002-11-10 19:49:24 Re: pgsql-server/src Makefile.global.in makefiles/ ...