From f87adcfb3f247a02c9b08a662c4b8aca971e620e Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Fri, 17 Jun 2022 12:53:57 -0700 Subject: [PATCH] Fix overflow in ribbon_bench after #10184 (#10195) Summary: Ribbon micro-bench needs updating after re-numbering `BloomLikeFilterPolicy::GetAllFixedImpls()` entries. (CircleCI nightly failure.) Also fixed memory leaks while using ASAN to validate my fix. (I assume the leaks weren't intentional for some performance characteristic.) Pull Request resolved: https://github.com/facebook/rocksdb/pull/10195 Test Plan: run with ASAN Reviewed By: jay-zhuang Differential Revision: D37244459 Pulled By: pdillinger fbshipit-source-id: 5a363e10de3c4c9c88099c937e3dc3b4cf24fd30 --- microbench/ribbon_bench.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/microbench/ribbon_bench.cc b/microbench/ribbon_bench.cc index 0191464d4..d0fb2ec9a 100644 --- a/microbench/ribbon_bench.cc +++ b/microbench/ribbon_bench.cc @@ -52,7 +52,9 @@ struct KeyMaker { // 2. average data key length // 3. data entry number static void CustomArguments(benchmark::internal::Benchmark *b) { - for (int filter_impl : {0, 2, 3}) { + const auto kImplCount = + static_cast(BloomLikeFilterPolicy::GetAllFixedImpls().size()); + for (int filter_impl = 0; filter_impl < kImplCount; ++filter_impl) { for (int bits_per_key : {10, 20}) { for (int key_len_avg : {10, 100}) { for (int64_t entry_num : {1 << 10, 1 << 20}) { @@ -69,7 +71,7 @@ static void FilterBuild(benchmark::State &state) { auto filter = BloomLikeFilterPolicy::Create( BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)), static_cast(state.range(1))); - auto tester = new mock::MockBlockBasedTableTester(filter); + auto tester = std::make_unique(filter); KeyMaker km(state.range(2)); std::unique_ptr owner; const int64_t kEntryNum = state.range(3); @@ -92,7 +94,7 @@ static void FilterQueryPositive(benchmark::State &state) { auto filter = BloomLikeFilterPolicy::Create( BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)), static_cast(state.range(1))); - auto tester = new mock::MockBlockBasedTableTester(filter); + auto tester = std::make_unique(filter); KeyMaker km(state.range(2)); std::unique_ptr owner; const int64_t kEntryNum = state.range(3); @@ -103,7 +105,7 @@ static void FilterQueryPositive(benchmark::State &state) { builder->AddKey(km.Get(filter_num, i)); } auto data = builder->Finish(&owner); - auto reader = filter->GetFilterBitsReader(data); + std::unique_ptr reader{filter->GetFilterBitsReader(data)}; // run test uint32_t i = 0; @@ -120,7 +122,7 @@ static void FilterQueryNegative(benchmark::State &state) { auto filter = BloomLikeFilterPolicy::Create( BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)), static_cast(state.range(1))); - auto tester = new mock::MockBlockBasedTableTester(filter); + auto tester = std::make_unique(filter); KeyMaker km(state.range(2)); std::unique_ptr owner; const int64_t kEntryNum = state.range(3); @@ -131,7 +133,7 @@ static void FilterQueryNegative(benchmark::State &state) { builder->AddKey(km.Get(filter_num, i)); } auto data = builder->Finish(&owner); - auto reader = filter->GetFilterBitsReader(data); + std::unique_ptr reader{filter->GetFilterBitsReader(data)}; // run test uint32_t i = 0;