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
main
Peter Dillinger 2 years ago committed by Facebook GitHub Bot
parent 5d6005c780
commit f87adcfb3f
  1. 14
      microbench/ribbon_bench.cc

@ -52,7 +52,9 @@ struct KeyMaker {
// 2. average data key length // 2. average data key length
// 3. data entry number // 3. data entry number
static void CustomArguments(benchmark::internal::Benchmark *b) { 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 bits_per_key : {10, 20}) {
for (int key_len_avg : {10, 100}) { for (int key_len_avg : {10, 100}) {
for (int64_t entry_num : {1 << 10, 1 << 20}) { for (int64_t entry_num : {1 << 10, 1 << 20}) {
@ -69,7 +71,7 @@ static void FilterBuild(benchmark::State &state) {
auto filter = BloomLikeFilterPolicy::Create( auto filter = BloomLikeFilterPolicy::Create(
BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)), BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)),
static_cast<double>(state.range(1))); 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)); KeyMaker km(state.range(2));
std::unique_ptr<const char[]> owner; std::unique_ptr<const char[]> owner;
const int64_t kEntryNum = state.range(3); const int64_t kEntryNum = state.range(3);
@ -92,7 +94,7 @@ static void FilterQueryPositive(benchmark::State &state) {
auto filter = BloomLikeFilterPolicy::Create( auto filter = BloomLikeFilterPolicy::Create(
BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)), BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)),
static_cast<double>(state.range(1))); 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)); KeyMaker km(state.range(2));
std::unique_ptr<const char[]> owner; std::unique_ptr<const char[]> owner;
const int64_t kEntryNum = state.range(3); const int64_t kEntryNum = state.range(3);
@ -103,7 +105,7 @@ static void FilterQueryPositive(benchmark::State &state) {
builder->AddKey(km.Get(filter_num, i)); builder->AddKey(km.Get(filter_num, i));
} }
auto data = builder->Finish(&owner); auto data = builder->Finish(&owner);
auto reader = filter->GetFilterBitsReader(data); std::unique_ptr<FilterBitsReader> reader{filter->GetFilterBitsReader(data)};
// run test // run test
uint32_t i = 0; uint32_t i = 0;
@ -120,7 +122,7 @@ static void FilterQueryNegative(benchmark::State &state) {
auto filter = BloomLikeFilterPolicy::Create( auto filter = BloomLikeFilterPolicy::Create(
BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)), BloomLikeFilterPolicy::GetAllFixedImpls().at(state.range(0)),
static_cast<double>(state.range(1))); 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)); KeyMaker km(state.range(2));
std::unique_ptr<const char[]> owner; std::unique_ptr<const char[]> owner;
const int64_t kEntryNum = state.range(3); const int64_t kEntryNum = state.range(3);
@ -131,7 +133,7 @@ static void FilterQueryNegative(benchmark::State &state) {
builder->AddKey(km.Get(filter_num, i)); builder->AddKey(km.Get(filter_num, i));
} }
auto data = builder->Finish(&owner); auto data = builder->Finish(&owner);
auto reader = filter->GetFilterBitsReader(data); std::unique_ptr<FilterBitsReader> reader{filter->GetFilterBitsReader(data)};
// run test // run test
uint32_t i = 0; uint32_t i = 0;

Loading…
Cancel
Save