sha1-checked: implement hardware acceleration on arm64 and x86_64 - #910
Open
srijs wants to merge 1 commit into
Open
sha1-checked: implement hardware acceleration on arm64 and x86_64#910srijs wants to merge 1 commit into
srijs wants to merge 1 commit into
Conversation
srijs
commented
Aug 22, 2026
Author
There was a problem hiding this comment.
This is existing code, moved over from compress.rs.
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.
re #909
Implements hardware acceleration for
sha1-checkedon botharm64andx86_64architectures.Tried to take
sha1as an example and match how this works as best as possible (e.g. usingcpufeaturesandcfg-if). Let me know where you'd like me to adjust this.In general, the way this works is by running the happy path via the specialized hardware instructions, and falling back to the scalar implementation only if a potential collision is detected.
Measured with the crate's own bench suite:
sha_ni, cloud sandbox)For comparison, performance relative to plain
sha1on the same backend, i.e. what fraction of un-checked SHA-1's speed detection reaches:sha_ni)Note: On
aarch64, hardware acceleration speeds upsha1andsha1-checkedby about the same factor, so the relative gap to plain SHA-1 barely moves. Onx86_64it doesn't, instead the gap actually widens (but of course still improving the absolute performance). My theory is thatsha1's own SHA-NI backend gets more speedup thansha1-checked's fixed per-block bookkeeping (ubc_check, etc., which isn't accelerated) does.