Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more micro-benchmark tests #9436

Closed
wants to merge 7 commits into from
Closed

Conversation

jay-zhuang
Copy link
Contributor

@jay-zhuang jay-zhuang commented Jan 25, 2022

  • Add more micro-benchmark tests
  • Expose an API in DBImpl for waiting for compactions (still not visible to the user)
  • Add argument name for ribbon_bench
  • remove benchmark run from CI, as it runs too long.

Test: CI

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

}
return error_handler_.GetBGError();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the thing I added to db_bench be switched to using this? Not asking you to do that in this diff.
https://github.com/facebook/rocksdb/blob/main/tools/db_bench_tool.cc#L7788

Also, does this work for leveled, universal and integrated BlobDB? The thing I added to db_bench doesn't work for universal, see #9275

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the thing I added to db_bench be switched to using this?

This is still an internal API which was used for unittest. To be used for db_bench, we need to expose this as a public API, which at least needs more polish and other considerations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdcallag looking at the code, I think you can do dbimpl = static_cast<DBImpl*>(db_.db), but as @jay-zhuang pointed out, this is an internal function and may subject to change in the future.

Copy link
Contributor

@riversand963 riversand963 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments.

// this is a simple micro-benchmark for compare ribbon filter vs. other filter
// for more comprehensive, please check the dedicate util/filter_bench.
#include <benchmark/benchmark.h>
#include <unistd.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be a good idea to exclude Windows from compilation.

DB* db;
Options options;
SetupDB(state, options, &db, "DBOpen");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be a good idea to init to nullptr.

uint64_t key_num = max_data / per_key_size;

// setup DB
static DB* db;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the intention to make db a static variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's used for multi-threaded test, the db is shared between threads: https://github.com/google/benchmark/blob/main/docs/user_guide.md#multithreaded-benchmarks


if (state.thread_index == 0) {
auto db_full = static_cast_with_check<DBImpl>(db);
auto s = db_full->WaitForCompact(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be minor. According to https://google.github.io/styleguide/cppguide.html#Type_deduction which we follow, we usually use auto when it's clear what the type is. The static_cast cases fall into this category. For others, if the type is not that clear, we should still explicitly spell out the type.

"enable_filter"});
}

static const uint64_t PrefixSeekNum = 10l << 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: constexpr may be better, but this is minor. The name should be kPrefixSeekNum.

BlockContents contents;
contents.data = rawblock;
Block reader(std::move(contents));
const InternalKeyComparator icmp(BytewiseComparator());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is BytesiseComparator() intended to be hard-coded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, removed that and use options.comparator instead.

@riversand963
Copy link
Contributor

Also, building on non-fb machine will fail because the dependency on google benchmark is hardcoded. It will be nice to make it work for the following

ROCKSDB_NO_FBCODE=1 make -j20 db_basic_bench

@jay-zhuang
Copy link
Contributor Author

Also, building on non-fb machine will fail because the dependency on google benchmark is hardcoded. It will be nice to make it work for the following

ROCKSDB_NO_FBCODE=1 make -j20 db_basic_bench

it should work, can you try install benchmark:

sudo dnf install google-benchmark-devel
make clean && ROCKSDB_NO_FBCODE=1 make -j20 db_basic_bench

@riversand963
Copy link
Contributor

Sorry for the confusion. I meant "making the detection of benchmark-devel package more automatic", like what we do for some other packages, e.g. gflags, etc. We can detect the package in CMakeLists.txt and set some variables. In the .cc file, we put #ifdef GOOGLE_BENCHMARK around the code that rely on it.
Not that important, I do not have a strong opinion on this.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@riversand963 riversand963 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't review in too much detail. LGTM since it's microbenchmark and in active development phase.

options.level0_stop_writes_trigger = (1 << 30);
options.soft_pending_compaction_bytes_limit = 0;
options.hard_pending_compaction_bytes_limit = 0;
options.write_buffer_size = 2 << 30; // 2G to avoid auto flush
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a good idea to cast 2 first before shifting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, do you mean like:

options.write_buffer_size = 2l << 30;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2ull << 30 or static_cast<size_t>(2) << 30

@jay-zhuang
Copy link
Contributor Author

Sorry for the confusion. I meant "making the detection of benchmark-devel package more automatic", like what we do for some other packages, e.g. gflags, etc. We can detect the package in CMakeLists.txt and set some variables. In the .cc file, we put #ifdef GOOGLE_BENCHMARK around the code that rely on it. Not that important, I do not have a strong opinion on this.

I see, I think microbenchmark might be different. It is required to build all mircobench tests: https://github.com/facebook/rocksdb/blob/main/microbench/CMakeLists.txt#L1
If the user don't want to build it or don't have gbenchmark installed, they should not try build it. By default, it's disabled: https://github.com/facebook/rocksdb/blob/main/CMakeLists.txt#L1463

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants