-
Notifications
You must be signed in to change notification settings - Fork 6
Replace C bindings for CRC32 fusion calculation #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The C bindings approach has proven to be problematic across a variety of CI/CD implementations, particularly when cross-compiling to other targets. Moving to a pure Rust implementation should eliminate those issues.
By fusing CLMUL and native CRC32 instructions, we can achieve more throughput on platforms which have native CRC32 instruction support. These were generated using the ‘fast-crc32’ project, then converted from C to Rust with the help of Claude.ai. https://github.com/corsix/fast-crc32/ https://www.corsix.org/content/fast-crc32c-4k https://www.corsix.org/content/alternative-exposition-crc32_4k_pclmulqdq https://dougallj.wordpress.com/2022/05/22/faster-crc32-on-the-apple-m1/
AVX512 support has landed in 1.89.0, so we can deprecate the feature flag and instead rely on the Rust version for AVX512 support, including VPCLMULQDQ. https://releases.rs/docs/1.89.0/ rust-lang/rust#138940
Updates the README to include latest benchmarking numbers and information about acceleration targets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes fragile C bindings for CRC-32/ISCSI and CRC-32/ISO-HDLC, replacing them with pure Rust implementations gated by Rust 1.89+ feature detection, and updates benchmark code accordingly.
- Deleted all generated C source and header files under
include/
- Simplified
build.rs
by removing C compilation paths - Adjusted
benches/benchmark.rs
to refine the set of algorithms, add measurement times, and swap benchmark order
Reviewed Changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated no comments.
File | Description |
---|---|
include/* | All C-based CRC implementation files and headers deleted |
build.rs | Removed C-binding build logic and feature-flag overrides |
benches/benchmark.rs | Updated CRC algorithm list, enabled Duration measurement, reordered |
I’m going to put this in another PR instead, waiting for 1.89 to hit stable first. I’ll keep this gated on the “vpclmulqdq” feature flag until then.
Elminate redundant features that are already implictly enabled. https://doc.rust-lang.org/reference/attributes/codegen.html#r-attributes.codegen.target_feature.x86 https://doc.rust-lang.org/reference/attributes/codegen.html#r-attributes.codegen.target_feature.aarch64
The Problems
The C bindings used to accelerate CRC-32/ISCSI and CRC-32/ISO-HDLC using a fusion approach were fragile and problematic for some environments and build processes.
The Solution
Remove the C bindings and replace them with pure Rust implementations. This also resulted in a material performance boost for smaller inputs (1 KiB).
Changes
Planned version bump
MINOR
Links
Notes
This makes this library 100% pure Rust. 👍