Skip to content

Commit 970f0c0

Browse files
andreas-abelcopybara-github
authored andcommitted
Fix InsertMiss_Cold
`sc.GetNonExistingKeys` requires that the sets vector that is passed as a reference parameter is not modified between calls to this function. However, this requirement is currently not satisfied if `kLookup` is false. Because of this, runs of different benchmarks are not independent, and later benchmarks can erroneously get the keys vector of earlier benchmarks. PiperOrigin-RevId: 748662999 Change-Id: I3a31276387625f2cbf889139acb8ad6e076221ae
1 parent ae7f50b commit 970f0c0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fleetbench/swissmap/cold_swissmap_benchmark.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ static void FindMiss_Cold(benchmark::State& state) {
4242
static constexpr size_t kMinTotalBytes = 256 << 20;
4343

4444
auto& sc = SetsCache<Set>::GetInstance();
45+
std::vector<Set>& cached_sets =
46+
sc.GetGeneratedSets(state.range(0), kMinTotalBytes / kValueSizeT,
47+
static_cast<Density>(state.range(1)));
48+
std::vector<uint32_t>& keys = sc.GetNonExistingKeys(cached_sets);
49+
4550
// If kLookup is false, we need to create a copy of the cached sets vector
4651
// because the benchmark loop modifies it.
4752
std::conditional_t<kLookup, std::vector<Set>&, std::vector<Set>> sets =
48-
sc.GetGeneratedSets(state.range(0), kMinTotalBytes / kValueSizeT,
49-
static_cast<Density>(state.range(1)));
50-
auto& keys = sc.GetNonExistingKeys(sets);
53+
cached_sets;
5154

5255
int warmup = 5;
5356
while (true) {

0 commit comments

Comments
 (0)