Skip to content

feat: add OpenSSL backend for checksum utilities#12412

Open
sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:openssl-checksum-backend
Open

feat: add OpenSSL backend for checksum utilities#12412
sylvestre wants to merge 2 commits into
uutils:mainfrom
sylvestre:openssl-checksum-backend

Conversation

@sylvestre
Copy link
Copy Markdown
Contributor

Add an optional OpenSSL (libcrypto) backend for md5/sha1/sha2-family digest computations. OpenSSL provides hand-tuned assembly implementations (AVX2, SSSE3, etc.) that are substantially faster than the pure-Rust crates on CPUs without SHA-NI hardware instructions.

Benchmarks on Intel i9-7940X (no SHA-NI), 100MB file:
sha256sum: 470ms -> 234ms (was 1.9x slower than GNU, now ~1.0x)
sha1sum: 198ms -> 131ms (was 1.6x slower, now ~1.09x)
sha512sum: 246ms -> 166ms (was 1.4x slower, now ~0.96x - faster!)
md5sum: 185ms -> 174ms (was 1.2x slower, now ~1.09x)

Closes #12251

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 21, 2026

Can we use kernel modules for checksum?
Linux specific kernel modules is not a solution.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)

@xtqqczze
Copy link
Copy Markdown
Contributor

maybe add BENCHMARKING.md?

@sylvestre sylvestre marked this pull request as ready for review May 22, 2026 17:12
@sylvestre sylvestre force-pushed the openssl-checksum-backend branch from 9a1168b to c30707b Compare May 22, 2026 17:42
@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 22, 2026

I think expr is statically linking oniguruma if we don't set RUSTONIG_DYNAMIC_LIBONIG=1.
Is there any way to statically link openssl?

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 22, 2026

features = ["vendored"] or OPENSSL_STATIC. Worth to link https://docs.rs/openssl/latest/openssl/ .

sylvestre added 2 commits May 22, 2026 20:12
Add an optional OpenSSL (libcrypto) backend for md5/sha1/sha2-family
digest computations. OpenSSL provides hand-tuned assembly implementations
(AVX2, SSSE3, etc.) that are substantially faster than the pure-Rust
crates on CPUs without SHA-NI hardware instructions.

Benchmarks on Intel i9-7940X (no SHA-NI), 100MB file:
  sha256sum: 470ms -> 234ms (was 1.9x slower than GNU, now ~1.0x)
  sha1sum:   198ms -> 131ms (was 1.6x slower, now ~1.09x)
  sha512sum: 246ms -> 166ms (was 1.4x slower, now ~0.96x - faster!)
  md5sum:    185ms -> 174ms (was 1.2x slower, now ~1.09x)

Closes uutils#12251
@sylvestre sylvestre force-pushed the openssl-checksum-backend branch from c30707b to 8cf7de3 Compare May 22, 2026 18:13
Comment thread README.md
`sha384sum`, `sha512sum`, and `cksum`) by using OpenSSL's `libcrypto` instead of
the pure-Rust digest crates, enable the `openssl` feature:
```
cargo build --release --features unix,openssl
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thought about make's default? Personally, I think we can just make openssl default if it is vendored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checksum utilities, particularly sha1sum and sha256sum, slow compared to GNU coreutils

3 participants