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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeremy Kerr <jk(at)ozlabs(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH v3] Avoid manual shift-and-test logic in AllocSetFreeIndex
Date: 2009-07-20 01:34:11
Message-ID: 14195.1248053651@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jeremy Kerr <jk(at)ozlabs(dot)org> writes:
>>> - inline is forbidden to use in PostgreSQL - you need exception or
>>> do it differently

> (inline again: should I just make this a static, the compiler can inline
> where possible? or do you want a macro?)

I don't know where Zdenek got the idea that we have something against
"inline".

So far as I can see, recent versions of gcc claim to support
__builtin_clz on all supported architectures. On some it might be no
faster than our existing loop, but it seems unlikely to be slower.

The two comments I have are

* do something other than the hardwired "32" for word size; perhaps
sizeof(int) * BITS_PER_BYTE.

* do not use the separate "fls" function. On a compiler that fails to
inline it, this patch would be a net performance loss, which we're not
likely to tolerate for a patch that has no other reason to live than
performance. Just #if the builtin right into the one place where it
will be used.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-07-20 01:35:47 Re: [PATCH 1/2 v3] [libpq] rework sigpipe-handling macros
Previous Message KaiGai Kohei 2009-07-20 01:09:33 Re: SE-PostgreSQL?