Skip to content

Commit 60c4e72

Browse files
ezbrcopybara-github
authored andcommitted
Update swissmap benchmarks to use a low cost hash function that has entropy in high bits when the keys are random 32-bit integers.
PiperOrigin-RevId: 765205174 Change-Id: I8e701e06efd6543f2218fd38547db8a06a8bf744
1 parent fcb9a89 commit 60c4e72

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fleetbench/swissmap/swissmap_benchmark.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,12 @@ class alignas(kSize < 8 ? 4 : 8) Value : private Ballast<kSize - 4> {
356356
uint32_t value_;
357357
};
358358

359-
// Use a zero cost hash function. The purpose of this benchmark is to focus on
359+
// Use a low cost hash function. The purpose of this benchmark is to focus on
360360
// the implementations of the containers, not the quality or speed of their hash
361-
// functions.
361+
// functions. We can't use identity hash function with random 32-bit keys
362+
// because then the high bits of the hashes would be always 0.
362363
struct Hash {
363-
size_t operator()(size_t x) const { return x; }
364+
size_t operator()(size_t x) const { return x ^ (x << 32); }
364365
};
365366

366367
struct Eq {

0 commit comments

Comments
 (0)