Skip to content

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

Merged
merged 16 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Architecture check
run: cargo run arch-check
- name: Architecture check (Optimized)
run: cargo run --features=optimize_crc32_auto arch-check
run: cargo run arch-check
- if: ${{ matrix.rust-toolchain != 'nightly' }}
name: Format
run: cargo fmt -- --check
Expand All @@ -36,8 +36,6 @@ jobs:
run: cargo clippy
- name: Test
run: cargo test
- name: Test (Optimized)
run: cargo test --features=optimize_crc32_auto

test-x86:
name: Test accelerated (x86)
Expand All @@ -61,8 +59,6 @@ jobs:
run: cross check --target ${{ matrix.target }}
- name: Test
run: cross test --target ${{ matrix.target }}
- name: Test (Optimized)
run: cross test --features=optimize_crc32_auto --target ${{ matrix.target }}

test-software:
name: Test software fallback
Expand All @@ -85,6 +81,4 @@ jobs:
- name: Check
run: cross check --target ${{ matrix.target }}
- name: Test
run: cross test --target ${{ matrix.target }}
- name: Test (Optimized)
run: cross test --features=optimize_crc32_auto --target ${{ matrix.target }}
run: cross test --target ${{ matrix.target }}
45 changes: 7 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 10 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ criterion = "0.5"
cbindgen = "0.28"
bindgen = "0.70" # 0.70 is the last version that supports Rust 1.81 due to 'unsafe extern' blocks

[build-dependencies]
cc = { version = "1.2", features = ["parallel"] }

# lto=true has a big improvement in performance
[profile.release]
lto = true
Expand All @@ -47,36 +44,15 @@ harness = false
[features]
alloc = []

# enable VPCLMULQDQ support in Rust for x86_64 using nightly toolchain builds
# enable experimental VPCLMULQDQ support, which landed in Rust 1.89.0-nightly, will deprecate after 1.89.0 is stable
vpclmulqdq = []

# enable AVX512 support in Rust for x86_64 using nightly toolchain builds
avx512 = []

# enable using fast-crc32 optimized C implementations for CRC-32/ISCSI and CRC-32/ISO-HDLC, automatically detected
optimize_crc32_auto = []

# the following features enable forcing custom optimized build features (rather than "auto" which attemps to pick the
# best) for CRC-32/ISCSI and CRC-32/ISO-HDLC calculations, since architecture support and performance varies

# aarch64 NEON options
optimize_crc32_neon_eor3_v9s3x2e_s3 = []
optimize_crc32_neon_v12e_v1 = []
optimize_crc32_neon_v3s4x2e_v2 = []

# blends eor3_v9s3x2e_s3 for "large" (>1KiB) payloads, and v12e_v1 for "small" ones, which tends to yield the best
# results on modern aarch64 such as Graviton and Apple Silicon
optimize_crc32_neon_blended = []

# x86 SSE+ options
# this will blend automagically for CRC-32/ISO-HDLC which tends to have poor hardware support, but typically great
# support for CRC-32/ISCSI
optimize_crc32_avx512_vpclmulqdq_v3x2 = []

# non-blended alternatives
optimize_crc32_avx512_v4s3x3 = []
optimize_crc32_sse_v4s3x3 = []

[lints.rust]
# build-time feature enablement
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(optimized_crc32_iscsi)','cfg(optimized_crc32_iso_hdlc)' ] }
# the features below aren't in use, are deprecated, and will be removed in the next MAJOR version
optimize_crc32_auto = [] # deprecated
optimize_crc32_neon_eor3_v9s3x2e_s3 = [] # deprecated
optimize_crc32_neon_v12e_v1 = [] # deprecated
optimize_crc32_neon_v3s4x2e_v2 = [] # deprecated
optimize_crc32_neon_blended = [] # deprecated
optimize_crc32_avx512_vpclmulqdq_v3x2 = [] # deprecated
optimize_crc32_avx512_v4s3x3 = [] # deprecated
optimize_crc32_sse_v4s3x3 = [] # deprecated
Loading
Loading