Warnings in xxh3.h on MSVC #249
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#249
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?
I get this on AppVeyor when building with 0.7.1 and XXH_INLINE_ALL:
Thanks for notification @pitrou ,
we probably need an additional test in
AppveyorCIto catch this issue.Actually, the
appveyorCIfound the issues, as you mentioned :https://ci.appveyor.com/project/YannCollet/xxhash/build/job/todic2778t438b7u#L59
but they were classified as silent warnings, instead of blocking errors.
So what we are lacking is an ability to make the test fail when it generates compilation warnings.
Passing
-DCMAKE_C_FLAGS="/WX"in the Visual Studio CMake build should do the trickThanks @wesm , this command works !
edit : well, it almost worked. If using
-DCMAKE_C_FLAGS=####after the project was already created and compiled properly, then it works. But if I start from an empty directory, then the script seems to be missing generation ofxxhash.lib, which makes the linking stage fails afterwards ...Hi @pitrou,
I was looking at ARROW repository recently, and noticed the following comment :
The next lines develop a custom algorithm for inputs <= 16 byte, using the same read access method as
XXH3, but with a different mixing algorithm. It suggests the custom method is considered faster for this use case.There is of course nothing in doing so, I'm just curious.
XXH3was developed with the hope that it could fix most hash / checksum situations, including hashing small inputs to generate random bits for indexing hash tables. The goal is to simplify hashing for user applications, by offering a one-stop shop for all needs. I see that it's apparently not the case for ARROW, and I'm wondering if there's something important that could be learned from it, eventually allowingXXH3to improve and get closer to the intended goal.edit : fixed project name : ARROW, within a final
SWell to be fair, XXH3's short hash is not as trivial as it seems, at least on A64.
Here is my best (read: not that good lol) handwritten asm version of XXH3_len_0to16_64b:
(
movlexpands tomov/movk)Granted, most of that is loading values which isn't changed.
@Cyan4973
(Nitpick: the project name is "Arrow", not "Arrows" :-))
Well, that's an interesting coincidence, because the "custom algorithm for inputs <= 16 byte" was developed before switching to xxh3. So I'm glad to learn the code I wrote makes sense :-)
We're using this benchmark for string hashing:
https://github.com/apache/arrow/blob/master/cpp/src/arrow/util/hashing_benchmark.cc#L80-L112
With the custom algorithm in place, I get the following results (gcc 7.4.0, Ryzen 7 1700, Ubuntu 18.04):
If I disable the custom algorithm (thus always using xxh3 regardless of length), the results are as follow:
Similarly on less micro-benchmarks relying on a hash table. With custom algorithm:
Without custom algorithm:
So, there is a noticeable slowdown, though far from catastrophic. Perhaps it's just this particular compiler. If you want I can check tomorrow with clang?
Finally, to be honest, if we had used xxh3 from the start, I'm not sure I'd have bothered with a custom algorithm for tiny strings, because xxh3 is very fast already. But our pre-xxh3 hashing algorithm wasn't very good on tiny strings, so the custom algorithm was developed at the time.
Great ASM investigation @easyaspi314 !
Note that I would expect some of these operations to be folded, depending on the exact variant.
The "full" variant must load the key values from the provided custom
secret, and add theseed.The "seed" variant uses the default
secret: in this case, I would expect the compiler to embed thesecretvalues directly into instructions. This would save a correspondingloadinstruction.The "default" variant does not even need to add the
seedto the defaultsecret, since it's0, saving yet another operation.Therefore, the
defaultvariant is supposed to be the fastest one, and seems the most appropriate for hash tables.At least, that would be my expectation. Obviously, it's compiler driven, and different compilers, flags and even versions may result in different outcomes.
Note also that, providing both
XXH3withXXH_INLINE_ALLand a custom secret bundled together should allow the compiler to make the same kind of optimization when using the "full" variant, resulting in the same instructions as the "default" variant, just different constants.Ok, I've tried with clang 7.0. The absolute numbers are different, but the slowdown is similar (~30% slower on the tiny string hashing micro-benchmark, 5-10% slower on the hashtable benchmarks).