-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Conversation
42cf782
to
dc9eead
Compare
@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@jay-zhuang has updated the pull request. You must reimport the pull request before landing. |
@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@jay-zhuang has updated the pull request. You must reimport the pull request before landing. |
} | ||
return error_handler_.GetBGError(); | ||
} | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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> |
There was a problem hiding this comment.
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"); | ||
|
There was a problem hiding this comment.
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.
microbench/db_basic_bench.cc
Outdated
uint64_t key_num = max_data / per_key_size; | ||
|
||
// setup DB | ||
static DB* db; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
microbench/db_basic_bench.cc
Outdated
|
||
if (state.thread_index == 0) { | ||
auto db_full = static_cast_with_check<DBImpl>(db); | ||
auto s = db_full->WaitForCompact(true); |
There was a problem hiding this comment.
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.
microbench/db_basic_bench.cc
Outdated
"enable_filter"}); | ||
} | ||
|
||
static const uint64_t PrefixSeekNum = 10l << 10; |
There was a problem hiding this comment.
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
.
microbench/db_basic_bench.cc
Outdated
BlockContents contents; | ||
contents.data = rawblock; | ||
Block reader(std::move(contents)); | ||
const InternalKeyComparator icmp(BytewiseComparator()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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
|
it should work, can you try install benchmark:
|
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 |
693c0e2
to
a65c251
Compare
@jay-zhuang has updated the pull request. You must reimport the pull request before landing. |
a65c251
to
375b236
Compare
@jay-zhuang has updated the pull request. You must reimport the pull request before landing. |
@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this 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.
microbench/db_basic_bench.cc
Outdated
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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
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 |
@jay-zhuang has updated the pull request. You must reimport the pull request before landing. |
@jay-zhuang has updated the pull request. You must reimport the pull request before landing. |
@jay-zhuang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Test: CI