The MariaDB code base contains quite a few implementations of CRC-32, some (or all?) of them using the CRC-32C polynomial. It would be good to create a uniform interface and remove any code duplication.
- There is a crc32() function defined somewhere. Is it always the same, or does the bundled zlib use something else?
- Mariabackup defines crc32_intel_pclmul(), which is enabled on AMD64 based on CPUID flags.
- InnoDB defines its own things in ut_crc32_init(), most recently an interface to ARMv8 (AArch64, ARM64) crc32c_aarch64(). Apparently this function is not being used anywhere else.
MDEV-9872introduced POWER crc32_vpmsum() that was later (in MariaDB Server 10.3) replaced with a C-based implementation.
- A recent update of MyRocks introduced a duplicated implementation of crc32_vpmsum(), noticed by me due to build breakage (
At the very least, we should have a common CRC-32C implementation on all platforms and remove ut0crc32.cc from InnoDB code base. (Maybe it is not worth touching the code in the bundled zlib.)
If other CRC-32 polynomials are needed, then we should define a common interface for those as well.