-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace hash_gid
with FNV-1a
#422
base: rolling
Are you sure you want to change the base?
Conversation
We seem to have many uses of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a question inline.
// This function implemented FNV-1a 64-bit as the GID is small enough | ||
// (e.g. as of commit db4d05e of ros2/rmw RMW_GID_STORAGE_SIZE is set to 16) | ||
// and FNV is known to be efficient in such cases. | ||
// | ||
// See https://github.com/ros2/rmw/blob/db4d05e/rmw/include/rmw/types.h#L44 | ||
// and https://datatracker.ietf.org/doc/html/draft-eastlake-fnv-17.html | ||
static constexpr uint64_t FNV_OFFSET_BASIS_64 = 0x00000100000001b3; | ||
static constexpr uint64_t FNV_PRIME_64 = 0xcbf29ce484222325; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we are already using xxhash3 in liveliness_utils to take a string and hash it into a 128-bit quantity. Do we need to hash again? In other words, could we just use the 128-bit GID directly and use that as the key?
hash_gid
is called on Zenoh subscriber callbacks and shows up when profiling as a hot function. The use ofstd::stringstream
seems to be relatively inefficient. A significant portion ofhash_gid
's running time is spend allocating & deallocating thestd::stringstream
.