Eliminate seed from XXH32_state_s #79
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#79
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?
The seed variable is stored in the XXH32_state_s struct because it's used when XXH32_digest_endian() is called after less than 16 bytes. However, that means that state->v1...v4 are is still unmodified and especially state->v3 has it's initial value which was state->seed.
If you replace line 665 by "h32 = state->v3 + PRIME32_5;" then we can get rid of state->seed.
See my xxHash implementation at http://create.stephan-brumme.com/xxhash/ (written from scratch) for a proof-of-concept.
I haven't analyzed xxHash64 yet, but after a quick look at your code it seems we could apply the same trick.
Thanks @stbrumme, this is an excellent idea.
While it's certainly possible to implement it, I'm nonetheless worried about a possible ABI break when reducing structure size.
A bad scenario would be as follows :
This scenario is supposed to be explicitly forbidden in
xxhash.h,but it's difficult to guarantee everyone follows the rules.
So a cautious transition scenario could be as follows :
seed, to be replaced bystate->v3instead.It should reduce risks in case of version mismatch, by allowing an "overlap" period, where the structure is compatible with older implementations, and implementation is compatible with future structure.
For discussion
Partly implemented in v0.6.2.
Tail space in now "reserved", neither read nor written.
Should be possible to remove it completely in a few versions.