feat: add IEEE CRC32 and CRC32C checksums - #27
Draft
tisonkun wants to merge 1 commit into
Draft
Conversation
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
Add IEEE CRC32 and Castagnoli CRC32C for checksumming existing records, pages, and protocol payloads. Both variants live under
hashcrew::crc, behind the opt-incrcfeature, and preserve the dependency-free, allocation-free,no_stdlibrary and Rust 1.85 MSRV.crc32_iso_hdlc/Crc32IsoHdlcandcrc32_iscsi/Crc32Iscsi, with incremental updates, repeatabledigest, reset, finalized-checksum resumption, andstd::io::Writeintegration.u64byte length.crc,crc32fast, andcrc32c, covering byte boundaries, arbitrary partitions, zeroed checksum fields, resumption, concatenation, and lengths beyond 4 GiB.Design Notes
Each state stores one
u32.from_digesttakes a finalized checksum, not a raw register seed;digestpreserves the state. The two polynomials have distinct types and names. CRC operates on raw bytes withoutHasherorBuildHasheradapters. Output byte order belongs to the consuming format.This draft establishes the API and a safe slicing-by-8 scalar baseline with an 8 KiB compile-time table per variant. Hardware acceleration remains follow-up work. Ecosystem benchmarks cover short and large inputs and several streaming chunk sizes; competing crates retain their available hardware acceleration.
crc-fast1.10 is an optional benchmark comparison requiring Rust 1.89+, so ordinary workspace build/test workflows remain compatible with 1.85.Local 1 MiB one-shot medians on Apple M4 Max, aarch64-apple-darwin, Rust 1.99.0-nightly (3d6c19bb9), in microseconds (lower is better):
At 1 MiB with 64 KiB updates, Hashcrew measured 433.0 / 431.5 microseconds (IEEE / CRC32C). These short local runs establish the optimization gap; they are not a cross-platform performance claim.
Validation passed:
cargo +1.85.0 x build --locked,cargo +1.85.0 x test,cargo +1.85.0 x check,cargo x lint,cargo x miri, andcargo x check --target <target> --no-stdforthumbv7em-none-eabihfandwasm32-unknown-unknown.Benchmark commands: