Skip to content

Commit

Permalink
Deallocation code path performance - test hash function
Browse files Browse the repository at this point in the history
Re-test the collision rate of the hash we use.
  • Loading branch information
r1viollet committed Sep 8, 2023
1 parent e5797c5 commit 167264f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/address_bitset-ut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ TEST(address_bitset, many_addresses) {
EXPECT_EQ(0, address_bitset.nb_addresses());
}

// This test is mostly to tune the hash approach (it would slow down CI)
// This test to tune the hash approach
// Collision rate is around 5.7%, which will have an impact on sampling
//#define COLLISION_TEST
#ifdef COLLISION_TEST
// Your hash function
# ifdef TEST_IDENTITY
inline uint64_t my_hash(uintptr_t h1) { return h1; }
# else
inline uint64_t my_hash(uintptr_t h1) { return h1 >> 8; }
inline uint64_t my_hash(uintptr_t h1) {
h1 = h1 >> 4;
uint32_t high = (uint32_t)(h1 >> 32);
uint32_t low = (uint32_t)h1;
return high ^ low;
}
# endif

TEST(address_bitset, hash_function) {
Expand Down

0 comments on commit 167264f

Please sign in to comment.