perf: optimize seeded XXH3 and streaming XXH32 - #16
Merged
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
no_stdsupport, and allocation-free implementationDesign Notes
The seeded XXH3 runtime and const derivation paths intentionally use different iteration forms. This avoids private helper calls on affected Apple LLVM code generation without forcing inline expansion that regresses Linux AArch64; a unit test verifies both paths produce identical secrets.
XXH32 stores adjacent logical accumulators in reverse order internally. This allows AArch64 LLVM to use a vector load, multiply, pair reversal, and vector accumulator update while restoring the canonical logical order for finalization.
Benchmarks
Apple M4 Max, AArch64 macOS, rustc nightly 1.99 / LLVM 23:
twox-hash: 6.54 ns)twox-hash: 83.98 ns)twox-hash: 7.20 GB/s)Native AArch64 Linux container, rustc 1.90 / LLVM 20:
twox-hash: 6.91 ns)twox-hash: 85.03 ns)twox-hash: 12.29 GB/s)twox-hash: 12.26 GB/s)Validation
cargo x testcargo x lintcargo x build --lockedcargo x bench