Re: Use compiler intrinsics for bit ops in hash
John Naylor <john.naylor@2ndquadrant.com>
From: John Naylor <john.naylor@2ndquadrant.com>
To: David Fetter <david@fetter.org>
Cc: Jesse Zhang <sbjesse@gmail.com>, PostgreSQL Development <pgsql-hackers@postgresql.org>
Date: 2020-01-18T03:46:24Z
Lists: pgsql-hackers
On Wed, Jan 15, 2020 at 6:09 AM David Fetter <david@fetter.org> wrote:
> [v2 patch]
Hi David,
I have a stylistic comment on this snippet:
- for (i = _hash_log2(metap->hashm_bsize); i > 0; --i)
- {
- if ((1 << i) <= metap->hashm_bsize)
- break;
- }
+ i = pg_leftmost_one_pos32(metap->hashm_bsize);
Assert(i > 0);
metap->hashm_bmsize = 1 << i;
metap->hashm_bmshift = i + BYTE_TO_BIT;
Naming the variable "i" made sense when it was a loop counter, but it
seems out of place now. Same with the Assert.
Also, this
+ * using BSR where available */
is not directly tied to anything in this function, or even in the
function it calls, and could get out of date easily.
--
John Naylor https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Modify additional power 2 calculations to use new helper functions
- 02a2e8b44200 13.0 landed
-
Modify various power 2 calculations to use new helper functions
- d025cf88ba5a 13.0 landed
-
Add functions to calculate the next power of 2
- f0705bb6286d 13.0 landed
-
Move src/backend/utils/hash/hashfn.c to src/common
- 05d8449e7369 13.0 cited