Re: [PATCH] backend: compare word-at-a-time in bcTruelen

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: [PATCH] backend: compare word-at-a-time in bcTruelen
Дата
Msg-id 603c8f070906152124u2b14fc10gec2f3a56a31710d4@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] backend: compare word-at-a-time in bcTruelen  (Jeremy Kerr <jk@ozlabs.org>)
Ответы Re: [PATCH] backend: compare word-at-a-time in bcTruelen  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Re: [PATCH] backend: compare word-at-a-time in bcTruelen  (Stephen Frost <sfrost@snowman.net>)
Re: [PATCH] backend: compare word-at-a-time in bcTruelen  (Simon Riggs <simon@2ndQuadrant.com>)
Список pgsql-hackers
On Mon, Jun 15, 2009 at 9:51 PM, Jeremy Kerr<jk@ozlabs.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Konstantin Izmailov
Дата:
Сообщение: question about meaning of character varying without length
Следующее
От: Robert Haas
Дата:
Сообщение: Re: question about meaning of character varying without length