Re: [PATCH v4] Avoid manual shift-and-test logic in AllocSetFreeIndex

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [PATCH v4] Avoid manual shift-and-test logic in AllocSetFreeIndex
Дата
Msg-id 26046.1248118662@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [PATCH v4] Avoid manual shift-and-test logic in AllocSetFreeIndex  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH v4] Avoid manual shift-and-test logic in AllocSetFreeIndex  (Greg Stark <gsstark@mit.edu>)
Список pgsql-hackers
I wrote:
> I'm still interested in the idea of doing a manual unroll instead of
> relying on a compiler-specific feature.  However, some quick testing
> didn't find an unrolling that helps much.

Hmm, actually this seems to work ok:
       idx++;       size >>= 1;       if (size != 0)       {           idx++;           size >>= 1;           if (size
!=0)           {               idx++;               size >>= 1;               if (size != 0)               {
      idx++;                   size >>= 1;                   while (size != 0)                   {
idx++;                       size >>= 1;                   }               }           }       }
 

(this is with the initial "if (size > (1 << ALLOC_MINBITS))" so that
we know the starting value is nonzero)

This seems to be about a wash or a small gain on x86_64, but on my
PPC Mac laptop it's very nearly identical in speed to the __builtin_clz
code.  I also see a speedup on HPPA, for which my gcc is too old to
know about __builtin_clz.

Anyone want to see if they can beat that?  Some testing on other
architectures would help too.
        regards, tom lane


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

Предыдущее
От: Ron Mayer
Дата:
Сообщение: Re: [PATCH] SE-PgSQL/tiny rev.2193
Следующее
От: Joshua Brindle
Дата:
Сообщение: Re: [PATCH] SE-PgSQL/tiny rev.2193