Skip to content
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

Add city hash as default hash function for balancer states #142

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dataplane/globalbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ using wan_ht = hashtable_mod_spinlock_dynamic<nat64stateful_wan_key, nat64statef

namespace balancer
{
using state_ht = hashtable_mod_spinlock_dynamic<balancer_state_key_t, balancer_state_value_t, 16>;
using state_ht = hashtable_mod_spinlock_dynamic<balancer_state_key_t, balancer_state_value_t, 16, dataplane::calculate_hash_city<balancer_state_key_t>>;
}

class atomic
Expand Down
7 changes: 7 additions & 0 deletions dataplane/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "common.h"

#include "ext/city.h"
#include "ext/murmurhash3.h"
#include "ext/xxhash32.h"

Expand Down Expand Up @@ -73,6 +74,12 @@ inline uint32_t calculate_hash_xxh32(const key_t& key)
return XXHash32::hash(&key, sizeof(key), 19);
}

template<typename key_t>
inline uint32_t calculate_hash_city(const key_t& key)
{
return CityHash32((char*)&key, sizeof(key));
Copy link
Collaborator

Choose a reason for hiding this comment

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

reinterpret_cast<const char*>(&key)

}

class spinlock_t final
{
public:
Expand Down
Loading