Skip to content

feat: add OpenSSL backend for checksum utilities#12412

Draft
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:openssl-checksum-backend
Draft

feat: add OpenSSL backend for checksum utilities#12412
sylvestre wants to merge 1 commit 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

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
@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

GNU testsuite comparison:

GNU test failed: tests/tail/pipe-f2. tests/tail/pipe-f2 is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/date/resolution (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cut/cut-huge-range is now passing!

Comment thread src/uucore/Cargo.toml
xattr = { workspace = true, optional = true }
# OpenSSL is only used on Unix targets. On Windows, enabling the `openssl`
# feature is a no-op and the pure-Rust digest implementations are used.
openssl = { workspace = true, optional = true }
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.

nitpick: alphabetize

Comment thread src/uucore/Cargo.toml
# Use OpenSSL (libcrypto) for md5/sha1/sha2-family digests instead of the
# pure-Rust crates. This dramatically speeds up checksum utilities on CPUs
# without SHA-NI by using OpenSSL's optimized assembly implementations.
openssl = ["dep: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.

nitpick: alphabetize

@xtqqczze
Copy link
Copy Markdown
Contributor

maybe add BENCHMARKING.md?

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