Thread: Optimize Arm64 crc32 implementation in PostgreSQL
Hi all,
Currently PostgreSQL has three different variants of a 32-bit CRC calculation: CRC-32C, CRC-32(Ethernet polynomial),
and a legacy CRC-32 version that uses the lookup table. Some ARMv8 (AArch64) CPUs implement the CRC32 extension which
is equivalent with CRC-32(Ethernet polynomial), so they can also benefit from hardware acceleration.
Can I propose a patch to optimize crc32 calculation with Arm64 specific instructions?
Any comments or feedback are welcome.
On Mon, Aug 21, 2023 at 09:32:42AM +0000, Xiang Gao wrote: > Currently PostgreSQL has three different variants of a 32-bit CRC calculation: CRC-32C, CRC-32(Ethernet polynomial), > and a legacy CRC-32 version that uses the lookup table. Some ARMv8 (AArch64) CPUs implement the CRC32 extension which > is equivalent with CRC-32(Ethernet polynomial), so they can also benefit from hardware acceleration. > > Can I propose a patch to optimize crc32 calculation with Arm64 specific instructions? We have support for ARMv8 CRC instructions for CRC-32C (see src/port/pg_crc32c_armv8.c), but AFAICT Postgres has no such optimization for CRC-32. The CRC-32 macros have a comment indicating that they are currently only used in ltree and hstore, so there might not be terribly much demand for hardware acceleration, though. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com