Remove IntIdentity and PtrIdentity from raw_hash_set_probe_benchmark.

Identity hash is not well supported by SwissTable anymore since we use highest bits for H2. The results for these benchmarks are irrelevant and confusing.

Also, add missing includes.

PiperOrigin-RevId: 819307505
Change-Id: Ifaa8874030cfcdec4e5f52d47974bd3b056e61e4
This commit is contained in:
Vitaly Goldshteyn
2025-10-14 11:03:56 -07:00
committed by Copybara-Service
parent e12330f35b
commit 346ac9dbcf

View File

@@ -15,8 +15,14 @@
// Generates probe length statistics for many combinations of key types and key
// distributions, all using the default hash function for swisstable.
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <memory>
#include <regex> // NOLINT
#include <string>
#include <utility>
#include <vector>
#include "absl/base/no_destructor.h"
@@ -227,24 +233,6 @@ Ptr<Align>* MakePtr(uintptr_t v) {
return reinterpret_cast<Ptr<Align>*>(v);
}
struct IntIdentity {
uint64_t i;
friend bool operator==(IntIdentity a, IntIdentity b) { return a.i == b.i; }
IntIdentity operator++(int) { return IntIdentity{i++}; }
};
template <int Align>
struct PtrIdentity {
explicit PtrIdentity(uintptr_t val = PointerForAlignment<Align>()) : i(val) {}
uintptr_t i;
friend bool operator==(PtrIdentity a, PtrIdentity b) { return a.i == b.i; }
PtrIdentity operator++(int) {
PtrIdentity p(i);
i += Align;
return p;
}
};
enum class StringSize { kSmall, kMedium, kLarge, kExtraLarge };
constexpr char kStringFormat[] = "%s/name-%07d-of-9999999.txt";
@@ -270,20 +258,6 @@ struct String {
}
};
template <>
struct DefaultHash<IntIdentity> {
struct type {
size_t operator()(IntIdentity t) const { return t.i; }
};
};
template <int Align>
struct DefaultHash<PtrIdentity<Align>> {
struct type {
size_t operator()(PtrIdentity<Align> t) const { return t.i; }
};
};
template <class T>
struct Sequential {
T operator()() const { return current++; }
@@ -389,20 +363,6 @@ struct Random<Ptr<Align>*, Dist> {
}
};
template <class Dist>
struct Random<IntIdentity, Dist> {
IntIdentity operator()() const {
return IntIdentity{Random<uint64_t, Dist>{}()};
}
};
template <class Dist, int Align>
struct Random<PtrIdentity<Align>, Dist> {
PtrIdentity<Align> operator()() const {
return PtrIdentity<Align>{Random<uintptr_t, Dist>{}() * Align};
}
};
template <class Dist, StringSize size>
struct Random<String<size>, Dist> {
std::string operator()() const {
@@ -423,18 +383,12 @@ std::string Name();
std::string Name(uint32_t*) { return "u32"; }
std::string Name(uint64_t*) { return "u64"; }
std::string Name(IntIdentity*) { return "IntIdentity"; }
template <int Align>
std::string Name(Ptr<Align>**) {
return absl::StrCat("Ptr", Align);
}
template <int Align>
std::string Name(PtrIdentity<Align>*) {
return absl::StrCat("PtrIdentity", Align);
}
template <StringSize size>
std::string Name(String<size>*) {
switch (size) {
@@ -558,15 +512,10 @@ int main(int argc, char** argv) {
std::vector<Result> results;
RunForType<uint64_t>(results);
RunForType<IntIdentity>(results);
RunForType<Ptr<8>*>(results);
RunForType<Ptr<16>*>(results);
RunForType<Ptr<32>*>(results);
RunForType<Ptr<64>*>(results);
RunForType<PtrIdentity<8>>(results);
RunForType<PtrIdentity<16>>(results);
RunForType<PtrIdentity<32>>(results);
RunForType<PtrIdentity<64>>(results);
RunForType<std::pair<uint32_t, uint32_t>>(results);
RunForType<String<StringSize::kSmall>>(results);
RunForType<String<StringSize::kMedium>>(results);