Skip to content

[2.0.0-dev] add xxhash#1868

Closed
spoonincode wants to merge 2 commits intorelease/2.0from
xxh3
Closed

[2.0.0-dev] add xxhash#1868
spoonincode wants to merge 2 commits intorelease/2.0from
xxh3

Conversation

@spoonincode
Copy link
Contributor

Adds new non-cryptographic hash type to libfc

{ obj.data() } -> std::convertible_to<const char*>;
{ obj.size() } -> std::unsigned_integral;
};
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need a better place for stuff like this -- even just putting in detail here doesn't protect against against ODR oopsies since it's just in fc::detail still.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put in a separate file with a different name space?

xxh3() = default;
explicit xxh3(const uint64_t h) : _hash(h) {}

///no data() since would that be confusing LE/BE? but that breaks common interface across hash types
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like how the hash interface is a little different for xxh3 vs other hash types (well, the sha3 one is different too). They really all should conform to an identical interface. This comment explains my hesitancy to put in data(), but the reason for the hash_raw() (that may remember from some earlier PRs like #1719!) is that the single-shot fixed-length hash tends to be about 25% faster in my tests, so I really want that.

target_include_directories(xxhash INTERFACE .)
target_compile_definitions(xxhash INTERFACE -DXXH_INLINE_ALL=1)

install(FILES xxHash/xxhash.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/springxxhash/xxHash" COMPONENT dev EXCLUDE_FROM_ALL) No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library is used header only now; fwiw in an earlier revision I was compiling it as a library and this allows me to access the "x86dispatch" optimizations,
https://github.com/AntelopeIO/spring/blob/c8edec420f4121ca665ceb3d506608c09f81203f/libraries/libfc/libraries/xxhash/CMakeLists.txt
I might explore that again some time, but the current single-shot performance is around 15ns on my box which is plenty fast enough for our event use case I believe.

@spoonincode spoonincode closed this Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants