Re: use CLZ instruction in AllocSetFreeIndex() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: use CLZ instruction in AllocSetFreeIndex()
Date
Msg-id 6478.1577462722@sss.pgh.pa.us
Whole thread Raw
In response to Re: use CLZ instruction in AllocSetFreeIndex()  (John Naylor <john.naylor@2ndquadrant.com>)
Responses Re: use CLZ instruction in AllocSetFreeIndex()  (John Naylor <john.naylor@2ndquadrant.com>)
List pgsql-hackers
John Naylor <john.naylor@2ndquadrant.com> writes:
> On Fri, Dec 27, 2019 at 9:54 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> ... but couldn't the
>> right shift be elided in favor of changing the constant we
>> subtract clz's result from?  Shifting off those bits separately
>> made sense in the old implementation, but assuming that CLZ is
>> more or less constant-time, it doesn't with CLZ.

> That makes sense -- I'll look into doing that.

Actually, we could apply that insight to both code paths.
In the existing path, that requires assuming 
ALLOCSET_NUM_FREELISTS+ALLOC_MINBITS <= 17, but that's OK.
(Nowadays I'd probably add a StaticAssert about that.)

            regards, tom lane



pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: use CLZ instruction in AllocSetFreeIndex()
Next
From: Peter Eisentraut
Date:
Subject: Remove libpq.rc, use win32ver.rc for libpq