pgsql: Inline pg_popcount() for small buffers. - Mailing list pgsql-committers

From Nathan Bossart
Subject pgsql: Inline pg_popcount() for small buffers.
Date
Msg-id E1rs4LU-000Kcm-DM@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Inline pg_popcount() for small buffers.

If there aren't many bytes to process, the function call overhead
of the optimized implementation isn't worth taking, so instead we
inline a loop that consults pg_number_of_ones in that case.  If
there are many bytes to process, we accept the function call
overhead because the optimized versions are likely to be faster.
The threshold at which we use the optimized implementation is set
to the smallest amount of data required to use special popcount
instructions.

Reviewed-by: Alvaro Herrera, Tom Lane
Discussion: https://postgr.es/m/20240402155301.GA2750455%40nathanxps13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/deb1486c7d36e5430b50b63e8c0f2d8405e24a2a

Modified Files
--------------
src/include/port/pg_bitutils.h | 38 ++++++++++++++++++++++++++++++++++++--
src/port/pg_bitutils.c         | 12 ++++++------
2 files changed, 42 insertions(+), 8 deletions(-)


pgsql-committers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: [MASSMAIL]pgsql: Refactor how heap_prune_chain() updates prunable_xid
Next
From: Alvaro Herrera
Date:
Subject: [MASSMAIL]pgsql: Split XLogCtl->LogwrtResult into separate struct members