Re: [RFC,PATCH] Avoid manual shift-and-test logic in AllocSetFreeIndex
| От | Jeremy Kerr |
|---|---|
| Тема | Re: [RFC,PATCH] Avoid manual shift-and-test logic in AllocSetFreeIndex |
| Дата | |
| Msg-id | 200906050918.25358.jk@ozlabs.org обсуждение исходный текст |
| Ответ на | Re: [RFC,PATCH] Avoid manual shift-and-test logic in AllocSetFreeIndex (Atsushi Ogawa <a_ogawa@hi-ho.ne.jp>) |
| Ответы |
[PATCH v2] Avoid manual shift-and-test logic in AllocSetFreeIndex
Re: [RFC,PATCH] Avoid manual shift-and-test logic in AllocSetFreeIndex |
| Список | pgsql-hackers |
Hi Atsushi,
> If size <= 8, fls((size - 1) >> ALLOC_MINBITS) is fls(0).
> The result of fls(0) is undefined.
Yep, got caught out by this because my previous fls() supported zero.
> I think we have to never call fls(0) from AllocSetFreeIndex().
> My proposal code:
>
> if (size > (1 << ALLOC_MINBITS))
> {
> idx = fls((size - 1) >> ALLOC_MINBITS);
> Assert(idx < ALLOCSET_NUM_FREELISTS);
> }
Looks good, I'll send an updated patch.
Also, are you still seeing the same improvement with the __builtin_clz
as your inline asm implementation?
Cheers,
Jeremy
В списке pgsql-hackers по дате отправления: