Inline CRC computation for small fixed-length input on x86
authorJohn Naylor <john.naylor@postgresql.org>
Fri, 28 Feb 2025 09:27:30 +0000 (16:27 +0700)
committerJohn Naylor <john.naylor@postgresql.org>
Mon, 31 Mar 2025 06:17:21 +0000 (13:17 +0700)
commite2809e3a1015697832ee4d37b75ba1cd0caac0f0
treed6ae406c76a2bffb9f7f5ee40bbadf5312ab9c10
parent4694aedf63bf5b5d91f766cb6d6d6d14a9e4434b
Inline CRC computation for small fixed-length input on x86

pg_crc32c.h now has a simplified copy of the loop in pg_crc32c_sse42.c
suitable for inlining where possible.

This may slightly reduce contention for the WAL insertion lock,
but that hasn't been tested. The motivation for this change is avoid
regressing for a future commit that will use a function pointer for
non-constant input in all x86 builds.

While it's technically possible to make a similar change for Arm and
LoongArch, there are some questions about how inlining should work
since those platforms prefer stricter alignment. There are also no
immediate plans to add additional implementations for them.

Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Raghuveer Devulapalli <raghuveer.devulapalli@intel.com>
Discussion: https://postgr.es/m/CANWCAZZEiTzhZcuwTiJ2=opiNpAUn1vuDRu1N02z61AthwRZLA@mail.gmail.com
Discussion: https://postgr.es/m/CANWCAZYRhLHArpyfV4uRK-Rw9N5oV5HMkkKtBehcuTjNOMwCZg@mail.gmail.com
src/include/port/pg_crc32c.h