General equality of first 8 bytes of XXH128 and XXH3 #1016
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#1016
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello.
I am heavily utilizing XXH3 (because it is the fastest), and at some point wanted to see if there are any collisions for what I am doing (spoiler - no collisions). So I calculated XXH128 on pretty much everything, generally remembered that first 8 bytes should be equivalent to XXH3 and I could just take if from XXH128 when I need it.
Worked out it is not so for empty inputs! XXH3 produces a different value.
Since "this is what it is, cannot change it by now" state of affairs (maybe mention it in man page and documentation?), I have a naive ELI5 question
How does it work that different starting value starts to produce exactly the same value starting first byte, always and forever?
Thank you!
Guaranteeing the equality of the first 64-bit of
xxh128withxxh3wasn't part of the initial objectives.It ended up happening as a consequence of sharing much of the same code, and partly because I started to notice that some users had this expectation near the end of the development. But unfortunately, it was too close to the finish line to refactor the entire project around this new property. So it ended up being a "best effort".
From what I remember, the equality happens for "large" data only.
Note that, in the context of
xxhsum, "large" means > 240 bytes (XXH3_MIDSIZE_MAX).So indeed, when checksumming files, it is likely that most files will belong to this category.
For smaller data sets, the hash values of
xxh128andxxh3typically differ, with a notable exception for segments of length 1-3. This inequality extends beyond empty input; for example:Your note makes me appreciate that, for users manipulating mostly large data, seeing that this property is "generally" respected ends up implying that it's likely always true. Which it is not, but then maybe it should be better documented.
Thank you kindly for the explanation. I guess I have to redo all the files now with sizes less then half a kilobyte, and use pure xxh3 next time.