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
This commit is contained in:
Peter Dillinger 2022-06-17 12:53:57 -07:00 committed by Facebook GitHub Bot
parent 5d6005c780
commit f87adcfb3f
1 changed files with 8 additions and 6 deletions

View File

@ -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<int>(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<double>(state.range(1)));
auto tester = new mock::MockBlockBasedTableTester(filter);
auto tester = std::make_unique<mock::MockBlockBasedTableTester>(filter);
KeyMaker km(state.range(2));
std::unique_ptr<const char[]> 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<double>(state.range(1)));
auto tester = new mock::MockBlockBasedTableTester(filter);
auto tester = std::make_unique<mock::MockBlockBasedTableTester>(filter);
KeyMaker km(state.range(2));
std::unique_ptr<const char[]> 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<FilterBitsReader> 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<double>(state.range(1)));
auto tester = new mock::MockBlockBasedTableTester(filter);
auto tester = std::make_unique<mock::MockBlockBasedTableTester>(filter);
KeyMaker km(state.range(2));
std::unique_ptr<const char[]> 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<FilterBitsReader> reader{filter->GetFilterBitsReader(data)};
// run test
uint32_t i = 0;