Enable hardware-accelerated CRC32C in Abseil and TCMalloc builds#342
Draft
kai-franz wants to merge 1 commit intoyugabyte:masterfrom
Draft
Enable hardware-accelerated CRC32C in Abseil and TCMalloc builds#342kai-franz wants to merge 1 commit intoyugabyte:masterfrom
kai-franz wants to merge 1 commit intoyugabyte:masterfrom
Conversation
Abseil's CRC32C implementation supports SSE4.2 CRC32 instructions and PCLMULQDQ carry-less multiply for fast large-buffer folding, but these code paths are gated on compile-time checks for __SSE4_2__ and __PCLMUL__. Without -msse4.2 and -mpclmul, the hardware acceleration is compiled out and Abseil falls back to a software table-based CRC32C — significantly slower than even the existing crcutil 3-way-striped SSE4.2 implementation. Add -msse4.2 and -mpclmul to the Abseil and TCMalloc build definitions on x86_64. TCMalloc needs the same flags because it builds its own copy of Abseil from source via Bazel local_repository. No aarch64 changes are needed: the existing GRAVITON_COMPILER_FLAGS (-march=armv8.2-a+...+crypto) already define __ARM_FEATURE_CRC32 and __ARM_FEATURE_CRYPTO, which activate Abseil's ARM SIMD CRC path. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-msse4.2and-mpclmulcompiler flags to the Abseil and TCMalloc build definitions on x86_64, enabling Abseil's hardware-accelerated CRC32C implementation.__SSE4_2__and__PCLMUL__are compiled out entirely —TryNewCRC32AcceleratedX86ARMCombined()compiles toreturn 0(a stub), and all CRC32C operations fall back to a slow software table-based implementation.crc32hardware instructions for small buffers and PCLMULQDQ carry-less multiply for fast large-buffer folding — matching or exceeding the performance of the existing crcutil library's 3-way-striped approach.local_repository.GRAVITON_COMPILER_FLAGS(-march=armv8.2-a+...+crypto) already define__ARM_FEATURE_CRC32and__ARM_FEATURE_CRYPTO, activating Abseil's ARM SIMD CRC path.Test plan
libabsl.a/libabsl.socontainscrc32qandpclmulqdqinstructions (viaobjdump -d | grep -c pclmulqdq)TryNewCRC32AcceleratedX86ARMCombined()no longer returns 0 in the compiled libraryMade with Cursor