From 346ac9dbcfd853ecab264c1e7d08c14903a07a5a Mon Sep 17 00:00:00 2001 From: Vitaly Goldshteyn Date: Tue, 14 Oct 2025 11:03:56 -0700 Subject: [PATCH] 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 --- .../internal/raw_hash_set_probe_benchmark.cc | 63 ++----------------- 1 file changed, 6 insertions(+), 57 deletions(-) diff --git a/absl/container/internal/raw_hash_set_probe_benchmark.cc b/absl/container/internal/raw_hash_set_probe_benchmark.cc index 458038e0..2712160f 100644 --- a/absl/container/internal/raw_hash_set_probe_benchmark.cc +++ b/absl/container/internal/raw_hash_set_probe_benchmark.cc @@ -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 +#include +#include +#include #include #include // NOLINT +#include +#include #include #include "absl/base/no_destructor.h" @@ -227,24 +233,6 @@ Ptr* MakePtr(uintptr_t v) { return reinterpret_cast*>(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 -struct PtrIdentity { - explicit PtrIdentity(uintptr_t val = PointerForAlignment()) : 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 { - struct type { - size_t operator()(IntIdentity t) const { return t.i; } - }; -}; - -template -struct DefaultHash> { - struct type { - size_t operator()(PtrIdentity t) const { return t.i; } - }; -}; - template struct Sequential { T operator()() const { return current++; } @@ -389,20 +363,6 @@ struct Random*, Dist> { } }; -template -struct Random { - IntIdentity operator()() const { - return IntIdentity{Random{}()}; - } -}; - -template -struct Random, Dist> { - PtrIdentity operator()() const { - return PtrIdentity{Random{}() * Align}; - } -}; - template struct Random, 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 std::string Name(Ptr**) { return absl::StrCat("Ptr", Align); } -template -std::string Name(PtrIdentity*) { - return absl::StrCat("PtrIdentity", Align); -} - template std::string Name(String*) { switch (size) { @@ -558,15 +512,10 @@ int main(int argc, char** argv) { std::vector results; RunForType(results); - RunForType(results); RunForType*>(results); RunForType*>(results); RunForType*>(results); RunForType*>(results); - RunForType>(results); - RunForType>(results); - RunForType>(results); - RunForType>(results); RunForType>(results); RunForType>(results); RunForType>(results);