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-development <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | Re: [PATCHES] MemSet inline for newNode |
Date: | 2002-11-10 21:06:44 |
Message-ID: | 200211102106.gAAL6ir09610@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
OK, my compiler, gcc 2.95 does the optimization at -O2, so I ran the
tests here with the attached program, testing a constant of 256 and a
variable 'j' equal to 256.
I found a 1.7% slowdown with the variable compared to the constant.
The 256 value is rather large. For a length of 32, the difference was
14%!
So, seems I should back out the palloc0 usage and let the MemSet inline
at each location. Does that seems like the direction to head?
---------------------------------------------------------------------------
Bruce Momjian wrote:
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
--
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
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/plain | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | a person | 2002-11-10 22:06:25 | Locking Question |
Previous Message | Bruce Momjian | 2002-11-10 20:04:23 | Re: MemSet inline for newNode |
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2002-11-10 21:16:25 | minor SGML fix |
Previous Message | Bruce Momjian | 2002-11-10 20:04:23 | Re: MemSet inline for newNode |