Skip to content

Commit

Permalink
change default hash function for balancer states hashtable
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Evzman committed Mar 26, 2024
1 parent d58eb9d commit 0e36f44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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));
}

class spinlock_t final
{
public:
Expand Down

0 comments on commit 0e36f44

Please sign in to comment.