Repository navigation
Add XXHash64, XXHash3, and XXHash128 to smithy-checksums - #870
Draft
jonathan343 wants to merge 2 commits into
Draft
jonathan343 wants to merge 2 commits into
jonathan343 wants to merge 2 commits into
Conversation
jonathan343
force-pushed
the
feat/smithy-checksums-xxhash
branch
from
October 25, 2026 04:59
bfa1af9 to
e1b2e71
Compare
Contributor
|
please also review aws/aws-sdk-js-v3#8383 while this is fresh 😄 |
jonathan343
force-pushed
the
feat/smithy-checksums-xxhash
branch
from
October 27, 2026 15:47
e1b2e71 to
6dc8617
Compare
jonathan343
force-pushed
the
feat/smithy-checksums-xxhash
branch
from
October 27, 2026 19:11
6dc8617 to
9c97635
Compare
jonathan343
force-pushed
the
feat/smithy-checksums-xxhash
branch
from
October 27, 2026 19:15
9c97635 to
6f993da
Compare
Adds the XXHash checksum algorithms S3 supports, backed by the native extension (twox-hash) with a pure-Python fallback ported from the reference implementation, and available through new(). The pure-Python implementations are checked against the native ones and against the CRT.
XXH3 and XXH128 key each block of input with one big-integer XOR, read the keyed words as 32-bit halves, and accumulate with an unrolled loop that masks the accumulators once per block instead of after every operation. That takes them from about 39 MB/s to about 74 MB/s. XXH64's rounds are a serial chain of 64-bit operations per lane, so instead its four lanes are packed into one integer, 128 bits apart, and each step of a round runs on all four at once. Every lane is multiplied by the first prime in one operation per 64 KiB. Inputs under 512 bytes, where spreading the input costs more than it saves, use inlined per-lane rounds. That takes XXH64 from about 35 MB/s to about 57 MB/s. The native-versus-pure test now covers inputs past 64 KiB.
jonathan343
force-pushed
the
feat/smithy-checksums-xxhash
branch
from
October 27, 2026 21:04
6f993da to
ac36924
Compare
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.
Note
Stacked on #868, targeting
feat/smithy-checksums-crc64nvmeso this PR contains only the XXHash algorithms.Summary
S3 also supports XXHash64, XXHash3 (64-bit), and XXHash128 checksums. This PR adds them to
smithy-checksumsasXXHash64,XXHash3, andXXHash128, also available throughnew(). The native side uses thetwox-hashcrate (MIT, added toLICENSE-THIRD-PARTY). The pure-Python side is a port of the xxHash reference implementation, limited to the seed of zero and default secret that checksums use. It runs at about 35 MB/s, faster than the pure-Python CRC32C.Example
The native and pure-Python builds print the same thing. These are also the
x-amz-checksum-xxhash*header values botocore's tests expect for the same input:Testing
The known answers include 15 of xxHash's own sanity-test vectors per algorithm, from
tests/sanity_test_vectors.h. They cover every XXH3 size class and block boundary. Both implementations are also compared against the CRT and against each other:uv run pytest packages/smithy-checksums -k "xxhash and (known_answers or matches_crt or native_matches_pure)" --no-cov -qI also ran all 12,483 seed-zero vectors in that file once, covering every input length from 0 to 4,160 bytes. Both implementations matched every one.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.