XXH128 questions #479
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#479
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?
Hi,
I have some questions on how xxh128 works:
Yes
Probably for v1.0. not anytime soon.
Thanks!
Following the question- is xxh128_low a permutation (the low bits 64 bits) between 8B keys and 8B keys?
What do you mean ? Are you referring to a specific operation in the pipeline ?
Or do you inquire about the status of the lower 64-bits of
XXH128when the input is always a 64-bit value ?This- i.e., the input is always 64-bit, the output is the low 64 bits of xxh3-128.
The high 64-bits can be shown that they are not a permutation.
Using https://en.wikipedia.org/wiki/Cycle_detection, it can be shown two inputs x,y of 64bit, such that xxhash128low(x)=xxhash128low(y).
This means, xxhash128low does not avoids collisions, as opposed to xxh3-64.
The inputs 4547874448270207647 17028758783872633121, have the same 64-bit output (18437082715045604585).
Indeed,
XXH3_64bits()is designed for 64->64 permutation,while
XXH3_128bits()is designed for 128->128 permutation.It never was an objective to make
XXH3_128.low64a permutation of 64 bits input, and it seems it doesn't.Thanks!
Also, why there is a difference between 17-128B version, with 128B-240B and 240B-inf versions?
Why not use for all cases the 17-128B version?
Because then it would just be MUM hash.
Joking aside, the main reason is latency. The long loop uses SIMD code which often takes hundreds of cycles to start up
Indeed, the main loop is designed for vector processing.
But it's only efficient for a certain "minimum amount" of data (exact amount varies depending on cpu and compiler).
The 17-128B codec is designed to bridge that gap.
Later on, it was discovered that 128B might not be enough, since there is systematically a performance drop at 129B.
So this "area" was extended to 240B. However, as the formula for 17-128B wasn't immediately adaptable for 129-240B, another one was created instead for this second range.
There is a case to say that 17-240B could have been merged into a single range with a single formula, and that's fair. It wasn't that straightforward though, would have negatively impacted the existing 17-128 range, and with every change requiring a time-intensive validation, there is only so much time and attention available. So this 2-areas setup became permanent.
I understand.
Do you know the quality of using the 17-128B codec over large keys?
For my purposes, I want to investigate the hash function as a term of quality and number of operations (i.e. minimize the number of adding, multiplying by constant, shifting and rotating). This is regardless of CPU.
The 17-128B codec seems to me simple, and maybe with great smhasher quality.
You mean, using it for inputs larger than 128B ?
As mentioned, the 17-128 formula is not generic enough to go above 128B.
If it's updated naively in order to support more than 128B, there are some issues with risks of repeats and cancelations across 128B segments.
The 129-240B is much better in this respect, and could potentially be generalized to larger sizes. Yet, it has only been validated for 2x 128B segments, and going beyond that would likely require time and validation, as the scrambling stage and secret variability are a bit rigid. In short, it would require some work to reach "high quality" levels.
Please have tiny typo correction: ↥
Err… Sorry, but I am lost.
xxhsum(0.8.0) says-Hswitch (aggrrhh, have to press SHIFT, why not-aor something) enables us to select an algorithm to use: either0,1, or2(aggrrhh, enumerating countable objects from zero is beyond my comprehension). Now, here comes the confusion, because there are XXH32, XXH64, XXH128, and… XXH3. And some hashing apps pour on the fire. Could you be so kind to state clearly, once and for all, which is which?I would recommend to rather use
-H32,-H64and-H128for clarity.Now, more accurately :
-H32=>XXH32(,,0)-H64=>XXH64(,,0)-H128=>XXH128(,,0)=>XXH3_128bits()As one can see, there is no option to make
xxhsumoutputXXH3_64bits()return value,precisely to avoid confusion with
XXH64()return value (which is still the default).Though this capability has been asked a few times already,
so maybe an option will be created for it.
Be sure that when it happens, it will be designed in a way which avoids confusion with
XXH64().And one more thing, once and for all, @Cyan4973. Is it true that XXH (preferably with
-H128) is to be used (by the masses) instead ofCRC32only to check if data is transmitted w/o errors and to detect data rot, whereas if one needs to detect malicious changes when filesize stays the same, it is recommended to use Blake3 or another (not broken) cryptohash?cc: @oconnor663, @namazso, @Dhyfer1
Yep, that's correct.
Although for the second case, one also has to design an out-of-band channel to pass the crypto checksum, not just send it alongside the data, otherwise it's just as easy to simply change both the content and the checksum so they still match.
@Cyan4973, just to let you know how confusion about XXH128 vs XXH3 spreads. Now it comes from Rsync.
XXH3_64b algo, not ready to be used via
-Hswitch at present, is yet competing with others during the benchmark.I wonder if it will replace the current default XXH64 over time, given its more impressive results?
XXH3_64bwill never "replace"XXH64, since this last one is present since a long time and has been deployed in many applications,but it could be added as another output format,
provided there is a way to guarantee that its output can't be confused with
XXH64.0.8.1 changelog contains a few claims about the performance improvement, but (0.8.0 results)…
v0.8.1performance improvements are only for the streaming mode, which is not tested in the "basic"-bbenchmark mode.For example, to benchmark
XXH3_streamon v0.8.1, tryxxhsum -b21.The exact list of modes can change depending on versions. For a detailed list of all benchmarked modes, try
xxhsum -b99i0So, in case I want to hash a 128 bits key to a 64 bits hash value, what should be my preferred option,
XXH3_64bits()orXXH3_128bits()(and taking only the low/high bits)? In terms of speed and collision ratio.XXH3_64bits()is expected to be slightly better for this scenario.hi @Cyan4973
Correct me if I am wrong.
A bijective function from 16 Bytes input to 16 Bytes is able to do the reverse compute. like this:
The default XXH3_128bits is not able to do this. Any comments ?
Your example would imply that bijective functions are their own inverse.
Such corner case is called an involution.
Most bijective functions are not involutions.
Thanks for explain.
Is is possible to modify XXH128 to make it involution?
No, this would mean changing
XXH128results so that they are no longer compatible with already deployedXXH128.