From feaf7a15cf142c2b96f08b3914ab768b36b4002e Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 10 Aug 2025 16:32:52 +0300 Subject: [PATCH] Use CRC32C implementation from ISA-L when available - enables VPCLMULQDQ version with AVX512 which is ~2x faster --- src/blockstore/CMakeLists.txt | 1 + src/disk_tool/CMakeLists.txt | 1 + src/util/crc32c.c | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/src/blockstore/CMakeLists.txt b/src/blockstore/CMakeLists.txt index b2e41581..34cc071c 100644 --- a/src/blockstore/CMakeLists.txt +++ b/src/blockstore/CMakeLists.txt @@ -9,6 +9,7 @@ add_library(vitastor_blk SHARED ) target_link_libraries(vitastor_blk ${LIBURING_LIBRARIES} + ${ISAL_LIBRARIES} tcmalloc_minimal # for timerfd_manager vitastor_common diff --git a/src/disk_tool/CMakeLists.txt b/src/disk_tool/CMakeLists.txt index 3d238022..6aa55d02 100644 --- a/src/disk_tool/CMakeLists.txt +++ b/src/disk_tool/CMakeLists.txt @@ -12,4 +12,5 @@ add_executable(vitastor-disk target_link_libraries(vitastor-disk tcmalloc_minimal ${LIBURING_LIBRARIES} + ${ISAL_LIBRARIES} ) diff --git a/src/util/crc32c.c b/src/util/crc32c.c index 6b658c3b..ab9da5f7 100644 --- a/src/util/crc32c.c +++ b/src/util/crc32c.c @@ -39,6 +39,17 @@ #include #include "crc32c.h" +#ifdef WITH_ISAL + +#include + +uint32_t crc32c(uint32_t crc, const void *buf, size_t len) +{ + return crc32_iscsi((unsigned char*)buf, len, crc ^ 0xffffffff) ^ 0xffffffff; +} + +#else + /* CRC-32C (iSCSI) polynomial in reversed bit order. */ #define POLY 0x82f63b78 @@ -377,6 +388,8 @@ uint32_t crc32c(uint32_t crc, const void *buf, size_t len) #endif } +#endif + static uint8_t zero_page[4096] = {}; uint32_t crc32c_pad(uint32_t prev_crc, const void *buf, size_t len, size_t left_pad, size_t right_pad)