Suggestions list for future evolutions #458
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#458
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?
Objectives for v0.8.3
cmakeminimum version tov3.10(#988) - completedxxhsumwithDISPATCHenabled by default (#986) - completedObjectives for v0.9.0
XXH_generateSecret()xxhash.hinto multiple smaller files, and ship an ability to create a single amalgamated file from them ? (tentative)XXH_ENABLE_XXH32,XXH_ENABLE_XXH64andXXH_ENABLE_XXH3XXH32(withXXH_NO_LONG_LONG), orXXH32+XXH64(withXXH_NO_XXH3) or everything. It's not possible to compile selectively onlyXXH64for example.libxxhashdynamic library with runtime vector extension detection enabled by default (xxh_x64dispatch) ? (tentative)DISPATCHmust therefore substitute its symbols to original ones.arm64dispatchvariant, for SVE/NEON dispatch (tentative, based on #762)XXH_OLDNAME(or maybe v1.0 ?)Another one I was thinking was an option to disable streaming.
The streaming API takes up a good chunk of the binary size:
Edit:
-O3:Another
cheatoptimization is to use__attribute__((__pure__))on as many xxHash functions as possible.It says, roughly:
Basically,
__pure__is the magic behind thestrlenoptimization. (Excluding the second optimization where the compiler treats it as a built-in function and inlines/const props it)Any decent compiler will change it to this:
Although it is easiest to see with this code:
Equivalent code with how Clang shuffles registers on x86_64:
This could possibly improve performance on some hash tables depending on how they are used. Primarily thinking of code that looks like this:
Note that the compiler sometimes can figure this out on its own if xxHash is inlined, but this applies to both inline and extern functions.
I would have an option added to explicitly disable it for a fair benchmark.
Other ideas:
XXH3_64bitsto drop in as a replacement for commonstd::hashuses in C++std::is_trivial,std::has_unique_object_representationsin C++17, checklen % sizeof(T))noexcept/__attribute__((__nothrow__))specifier since the single shot functions will never throw an exception allowing the compiler to leave out unwind tables and shrink code size a bit.Yes, I like pure functions, so I'm all for it.
Also note the existence of
constfunctions ingcc, with an even stricter set of restrictions.In general, I would expect
-O3to spend enough cpu to discover which functions are pure, so it's unclear ifxxhashwill receive a measurable boost to performance with these function qualifiers,that being said, I like them even if the only impact is to provide better code documentation.
Also, in the context of library linking, this is an information that the linker can't guess from just the function signature, so it could end up being actually useful on the user side.
It appears that with XXH_INLINE_ALL, Clang and GCC can't tell that XXH3 is pure without the annotation, but it can figure out XXH32 and XXH64.
A few months ago, you mentioned how XXH3 is threadable. Obviously this would be an opt-in feature, as some programs like compilers (which I know at least Clang and GNU LD use XXH64) are designed to remain on a single thread to parallelize with
make.With some experimentation, it seems to be beneficial to spawn a second thread once you get to ~8-16MB.
On my phone (haven't tested on my PC yet because I have yet to master Windows threads), 6-8 MB seems to be the range where it is beneficial, with a max speed of 7.3 GB/s compared to 5.2 GB/s on one thread.
The implementation would be pretty simple; the most complicated thing here is dealing with the pthread struct and the accumulate loop which should probably be outlined to its own function to avoid copypasta.
I believe we can do a similar thing with
CreateThreadon Windows.Note that this would technically conflict with the
__attribute__((__pure__))idea, although if we talk about the end effects, it will still be pure.Code I was testing
As I mention in the comment, I don't see any reason to spawn more than one helper thread, as we waste hundreds of thousands of possible accumulate loops by setting up each pthread, meaning 4 threads would likely require a ridiculous 64-128 MB and a much more complicated error handling routine.
So I was wondering if we should start doing Doxygen? We don't necessarily have to set up a server for it.
Especially since
xxhash.his massive now, having a little Doxygen site might help and would probably be easier than writingxxh3_spec.mdIt also gives us some opportunity to document the internals because we can group them.
Here are some examples:
Also, didn't we plan on switching
XXH64_hash_ttounsigned longon 64-bit Linux?Yes, that's a good idea.
Moving code comments to Doxygen parsing convention can be done progressively.
I don't see a benefit in such a change
uint64_tisunsigned longon LP64, so it would be consistent.In
gnu90mode,-Wformatfires off because on LP64,PRIx64is"lx".The reverse is true if you do
"%llx", it will fire a warning on C++ and C99.Some Doxygen documentation added in #462
Declaring relevant functions as
pureandconstwould be a good follow up.XXH_SIZEOPTconfig option==0: normal==1: Disables forceinline and manual unrolling==2: Reuse streaming API for single shot, other dirty size hacks?I didn't see any benefit on NEON AArch64 no matter how many NEON lanes I chose, and ARMv7 and SSE2 don't have enough registers.
However, I think that AVX2 and AVX512 would likely benefit since their loops are tighter. I will benchmark on Ryzen when I get a chance.
Edit: Clang has no difference on Ryzen 5 3600 and GCC clearly gets confused.
Updated list of objectives for
v0.8.2I was considering (as a tentative objective) shipping
DISPATCH=1by default for the generation ofxxhsumCLI, but there is still a significant amount of work to do to reach this stage safely, and I'm concerned it would delayv0.8.2release by too long.So, instead, I've pushed this objective to an hypothetical
v0.8.3future release.(will be folded into
v0.9.0if need be).As for
XXH_OLD_NAMES, should we add deprecation message for it inv0.8.2?This seems like a good idea.
If I understand properly,
XXH_OLD_NAMESis disabled by default, so the warning could be triggered just on detecting if it's set.We can add "Milestone" via right side pane of issue view. And we also can assign/reuse it to other issues to indicate the milestone. It'll be useful at the future review of issues.
For example, we can assign
v0.9.0milestone to #483.