Обсуждение: Optimize Arm64 crc32 implementation in PostgreSQL

Поиск
Список
Период
Сортировка

Optimize Arm64 crc32 implementation in PostgreSQL

От
Xiang Gao
Дата:

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.

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Re: Optimize Arm64 crc32 implementation in PostgreSQL

От
Nathan Bossart
Дата:
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