Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
Description
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 (
MDEV-19830).
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.
Attachments
Issue Links
- is blocked by
-
MDEV-22641 Provide SIMD optimized wrapper for zlib crc32()
-
- Closed
-
-
MDEV-22749 Implement portable PCLMUL accelerated crc32() with Intel intrinsics
-
- Closed
-
- relates to
-
MDEV-27208 Implement 2-ary CRC32() and the CRC32C() function
-
- Closed
-
-
MDEV-9872 Add common optimized CRC32 function interface
-
- Closed
-
-
MDEV-19830 MyRocks build fails on ppc64le: cinttypes: No such file or directory
-
- Closed
-
-
MDEV-23900 x86_32 fail to build on innodb crc32q
-
- Closed
-
An unified interface (with acceleration) for the zlib crc32() function will be introduced by
MDEV-22641, using the function my_checksum().After that, what remains to be done (in this task) is unifying the interface to CRC-32C (using the Castagnoli polynomial), which is used by MyRocks (RocksDB) and InnoDB. The RocksDB implementation is superior to InnoDB’s, because it can make use of the pclmul instruction, which apparently can outperform the SSE4.2 crc32 instructions that InnoDB is using.
The run-time check for the pclmul instruction should use the
MDEV-22641predicate crc32_pclmul_enabled().