Skip to content

Commit 346ac9d

Browse files
goldvitalycopybara-github
authored andcommitted
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
1 parent e12330f commit 346ac9d

File tree

1 file changed

+6
-57
lines changed

1 file changed

+6
-57
lines changed

absl/container/internal/raw_hash_set_probe_benchmark.cc

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
// Generates probe length statistics for many combinations of key types and key
1616
// distributions, all using the default hash function for swisstable.
1717

18+
#include <algorithm>
19+
#include <cstddef>
20+
#include <cstdint>
21+
#include <limits>
1822
#include <memory>
1923
#include <regex> // NOLINT
24+
#include <string>
25+
#include <utility>
2026
#include <vector>
2127

2228
#include "absl/base/no_destructor.h"
@@ -227,24 +233,6 @@ Ptr<Align>* MakePtr(uintptr_t v) {
227233
return reinterpret_cast<Ptr<Align>*>(v);
228234
}
229235

230-
struct IntIdentity {
231-
uint64_t i;
232-
friend bool operator==(IntIdentity a, IntIdentity b) { return a.i == b.i; }
233-
IntIdentity operator++(int) { return IntIdentity{i++}; }
234-
};
235-
236-
template <int Align>
237-
struct PtrIdentity {
238-
explicit PtrIdentity(uintptr_t val = PointerForAlignment<Align>()) : i(val) {}
239-
uintptr_t i;
240-
friend bool operator==(PtrIdentity a, PtrIdentity b) { return a.i == b.i; }
241-
PtrIdentity operator++(int) {
242-
PtrIdentity p(i);
243-
i += Align;
244-
return p;
245-
}
246-
};
247-
248236
enum class StringSize { kSmall, kMedium, kLarge, kExtraLarge };
249237
constexpr char kStringFormat[] = "%s/name-%07d-of-9999999.txt";
250238

@@ -270,20 +258,6 @@ struct String {
270258
}
271259
};
272260

273-
template <>
274-
struct DefaultHash<IntIdentity> {
275-
struct type {
276-
size_t operator()(IntIdentity t) const { return t.i; }
277-
};
278-
};
279-
280-
template <int Align>
281-
struct DefaultHash<PtrIdentity<Align>> {
282-
struct type {
283-
size_t operator()(PtrIdentity<Align> t) const { return t.i; }
284-
};
285-
};
286-
287261
template <class T>
288262
struct Sequential {
289263
T operator()() const { return current++; }
@@ -389,20 +363,6 @@ struct Random<Ptr<Align>*, Dist> {
389363
}
390364
};
391365

392-
template <class Dist>
393-
struct Random<IntIdentity, Dist> {
394-
IntIdentity operator()() const {
395-
return IntIdentity{Random<uint64_t, Dist>{}()};
396-
}
397-
};
398-
399-
template <class Dist, int Align>
400-
struct Random<PtrIdentity<Align>, Dist> {
401-
PtrIdentity<Align> operator()() const {
402-
return PtrIdentity<Align>{Random<uintptr_t, Dist>{}() * Align};
403-
}
404-
};
405-
406366
template <class Dist, StringSize size>
407367
struct Random<String<size>, Dist> {
408368
std::string operator()() const {
@@ -423,18 +383,12 @@ std::string Name();
423383

424384
std::string Name(uint32_t*) { return "u32"; }
425385
std::string Name(uint64_t*) { return "u64"; }
426-
std::string Name(IntIdentity*) { return "IntIdentity"; }
427386

428387
template <int Align>
429388
std::string Name(Ptr<Align>**) {
430389
return absl::StrCat("Ptr", Align);
431390
}
432391

433-
template <int Align>
434-
std::string Name(PtrIdentity<Align>*) {
435-
return absl::StrCat("PtrIdentity", Align);
436-
}
437-
438392
template <StringSize size>
439393
std::string Name(String<size>*) {
440394
switch (size) {
@@ -558,15 +512,10 @@ int main(int argc, char** argv) {
558512

559513
std::vector<Result> results;
560514
RunForType<uint64_t>(results);
561-
RunForType<IntIdentity>(results);
562515
RunForType<Ptr<8>*>(results);
563516
RunForType<Ptr<16>*>(results);
564517
RunForType<Ptr<32>*>(results);
565518
RunForType<Ptr<64>*>(results);
566-
RunForType<PtrIdentity<8>>(results);
567-
RunForType<PtrIdentity<16>>(results);
568-
RunForType<PtrIdentity<32>>(results);
569-
RunForType<PtrIdentity<64>>(results);
570519
RunForType<std::pair<uint32_t, uint32_t>>(results);
571520
RunForType<String<StringSize::kSmall>>(results);
572521
RunForType<String<StringSize::kMedium>>(results);

0 commit comments

Comments
 (0)