From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Jeremy Kerr <jk(at)ozlabs(dot)org> |
Cc: | "<pgsql-hackers(at)postgresql(dot)org>" <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> |
Subject: | Re: [PATCH] backend: compare word-at-a-time in bcTruelen |
Date: | 2009-06-16 04:24:46 |
Message-ID: | 603c8f070906152124u2b14fc10gec2f3a56a31710d4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jun 15, 2009 at 9:51 PM, Jeremy Kerr<jk(at)ozlabs(dot)org> wrote:
> I was considering something like:
>
> unsigned int spaces;
> const unsigned int wordsize = sizeof(unsigned int);
>
> memset(&spaces, ' ', wordsize);
>
> In most cases, the compiler should be able to optimise the memset out,
> but it may introduce overhead where this is not possible.
What about just:
static char spaces[4] = { ' ', ' ', ' ', ' ' };
and then ... * (uint32 *) spaces?
There's not much point taking the length of the word when you've
initialized it to contain exactly 4 bytes. What you want to do is
pick the flavor of integer that will be the same length as what you've
initialized, and it turns out we already have that (see
src/include/c.h).
As I look at this, another problem is that it seems to me that you're
assuming that VARDATA_ANY() will return an aligned pointer, which
isn't necessarily the case (see src/include/postgres.h).
The advice in Stephen's email is also very good - in particular,
whatever you come up with, you should submit performance results.
Note that while --enable-profiling is very useful and profiling
numbers are good to submit, you'll also want to make sure you do a
build that is optimized for speed (i.e. no profiling, no casserts, no
debug) and do timings on that.
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2009-06-16 04:29:52 | Re: question about meaning of character varying without length |
Previous Message | Konstantin Izmailov | 2009-06-16 04:24:22 | question about meaning of character varying without length |