-
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 kOptionsStatistics to GetProperty() #3966
Conversation
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.
@zhichao-cao has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
include/rocksdb/db.h
Outdated
|
||
// "rocksdb.immutable_db_options_statistic" - returns the statistic | ||
// of immutable db options | ||
static const std::string kImmutableDBOptionStatistic; |
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 name is not clear enough for people who operates this system. They may not know what immutable_db_options is. immutable_db_options is in fact an internal data structure. Telling people the location of the stat object is not helpful.
We usually call this object statistics
. Maybe we can just call it rocksdb.statistics
. I know it's a little bit confusing becasue we already have "rocksdb.stats" and "rocksdb.dbstats". If you think it's too confusing, something like rocksdb.statistics.in.options
will be better than the name it is currently picked.
5fed6bb
to
e4738b7
Compare
@zhichao-cao has updated the pull request. |
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.
@zhichao-cao has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
db/db_impl.cc
Outdated
@@ -1845,6 +1845,14 @@ bool DBImpl::GetProperty(ColumnFamilyHandle* column_family, | |||
InstrumentedMutexLock l(&mutex_); | |||
return cfd->internal_stats()->GetStringProperty(*property_info, property, | |||
value); | |||
} else if (property_info->is_immutable_db_statistic) { | |||
assert(value != nullptr); | |||
auto dbstats = immutable_db_options_.statistics.get(); |
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.
Google C++ Style discourage usage of auto
like this: https://google.github.io/styleguide/cppguide.html#auto
db/internal_stats.h
Outdated
@@ -45,6 +45,9 @@ struct DBPropertyInfo { | |||
|
|||
// @param props Map of general properties to populate | |||
bool (InternalStats::*handle_map)(std::map<std::string, std::string>* props); | |||
|
|||
// special case to get the immutable db statistics | |||
bool is_immutable_db_statistic; |
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.
It doesn't create much value to parse to this bool and still do the work in DBImpl::GetProperty() info.
Either we still provide a callback here with type like
bool (DBImpl::handle_string_dbimpl)(std::string value);
Or you do the parsing and execution all in DBImpl::GetProperty(), before calling GetPropertyInfo().
e4738b7
to
90ff99d
Compare
@zhichao-cao has updated the pull request. |
90ff99d
to
520a85e
Compare
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 you change the title of the PR to include the property name? At the same time, I think we don't have to mention immutable_db_options_.statistics.
@zhichao-cao has updated the pull request. |
db/db_impl.cc
Outdated
@@ -1911,6 +1918,16 @@ bool DBImpl::GetIntPropertyInternal(ColumnFamilyData* cfd, | |||
} | |||
} | |||
|
|||
bool DBImpl::HandleImmutableOptionStatistics(std::string* value) { | |||
assert(value != nullptr); | |||
auto dbstats = immutable_db_options_.statistics.get(); |
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.
auto
is not suggested in the usage like this. See https://google.github.io/styleguide/cppguide.html#auto
db/db_impl.h
Outdated
@@ -1379,6 +1379,7 @@ class DBImpl : public DB { | |||
bool GetIntPropertyInternal(ColumnFamilyData* cfd, | |||
const DBPropertyInfo& property_info, | |||
bool is_locked, uint64_t* value); | |||
bool HandleImmutableOptionStatistics(std::string* value); |
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 is a function of DBImpl. This function name is not clear enough under this class. Mention something related to property. Also, I suggest we don't mention "ImmutableOption" here. statistics is statistics. The reason it is in ImmutableOption, is that we decided to currently put it there. It can be moved as we wish in the future. If we do that, we have to remember to update this function name. Otherwise, it will be invalid.
@zhichao-cao has updated the pull request. View: changes, changes since last import |
db/db_impl.h
Outdated
@@ -1379,6 +1379,7 @@ class DBImpl : public DB { | |||
bool GetIntPropertyInternal(ColumnFamilyData* cfd, | |||
const DBPropertyInfo& property_info, | |||
bool is_locked, uint64_t* value); | |||
bool HandleDBStatisticsInOptions(std::string* value); |
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.
It still doesn't tell the function is to handle get property requests.
f870a67
to
d99c5d5
Compare
@zhichao-cao has updated the pull request. |
db/internal_stats.cc
Outdated
nullptr}}, | ||
{DB::Properties::kDBStatisticsInOptions, |
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 naming is confusing. They aren't really DB statistics since the same Statistics
object can be shared across DBs. How about calling it kStatistics
?
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.
Thanks for the suggestion and now it is changed to kStatistics.
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.
All names are updated to **OptionsStatistics. Comments are changed too.
…b_options_.statistics->ToString(), if it is not empty.
Summary: Add a new DB property to DB::GetProperty(), which returns immutable_db_options_.statistics->ToString(), if it is not empty. Test Plan: Added the unite test for this property, run asan_check and check Reviewers: Siying Dong Subscribers: Tasks:T30165586 Tags:
Summary: Add a new DB property to DB::GetProperty(), which returns immutable_db_options_.statistics->ToString(), if it is not empty. Using the DBimpl callback and setup a new category Test Plan: Added the unite test for this property, run asan_check and check Reviewers: Siying Dong Subscribers: Tasks:T30165586 Tags:
Summary: Add a new DB property to DB::GetProperty(), which returns the statistics of the DB in Options, if it is not empty. Using the DBimpl callback and setup a new category. Fixed the naming and format issues Test Plan:Added the unite test for this property, run asan_check and check Reviewers: Subscribers: Tasks: Tags:
Summary: Add a new DB property to DB::GetProperty(), which returns the statistics of the DB in Options, if it is not empty. Using the DBimpl callback and setup a new category. Fixed the naming and format issues Test Plan: Added the unite test for this property, run asan_check and check Reviewers: Subscribers: Tasks: Tags:
d99c5d5
to
10835ad
Compare
@zhichao-cao has updated the pull request. |
include/rocksdb/db.h
Outdated
@@ -621,6 +621,10 @@ class DB { | |||
// "rocksdb.block-cache-pinned-usage" - returns the memory size for the | |||
// entries being pinned. | |||
static const std::string kBlockCachePinnedUsage; | |||
|
|||
// "rocksdb.db_statistics_in_options" - returns multi-line string |
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.
Fix this comment.
include/rocksdb/db.h
Outdated
@@ -621,6 +621,10 @@ class DB { | |||
// "rocksdb.block-cache-pinned-usage" - returns the memory size for the | |||
// entries being pinned. | |||
static const std::string kBlockCachePinnedUsage; | |||
|
|||
// "rocksdb.db_statistics_in_options" - returns multi-line string | |||
// containing the statistics of the db in options |
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 saying "options.statistics", rather than "the statistics of the db in the options".
db/internal_stats.cc
Outdated
@@ -249,6 +249,7 @@ static const std::string estimate_oldest_key_time = "estimate-oldest-key-time"; | |||
static const std::string block_cache_capacity = "block-cache-capacity"; | |||
static const std::string block_cache_usage = "block-cache-usage"; | |||
static const std::string block_cache_pinned_usage = "block-cache-pinned-usage"; | |||
static const std::string db_statistics_in_options = "db-statistics-in-options"; |
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.
Fix it.
@zhichao-cao has updated the pull request. View: changes, changes since last import |
@@ -621,6 +621,10 @@ class DB { | |||
// "rocksdb.block-cache-pinned-usage" - returns the memory size for the | |||
// entries being pinned. | |||
static const std::string kBlockCachePinnedUsage; | |||
|
|||
// "rocksdb.options-statistics" - returns multi-line string |
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 confuses me that the property name kStatistics = "rocksdb.options-statistics".
@zhichao-cao has updated the pull request. View: changes, changes since last import |
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.
Please make sure @ajkr is OK with this new name before landing it.
db/internal_stats.h
Outdated
@@ -45,6 +45,10 @@ struct DBPropertyInfo { | |||
|
|||
// @param props Map of general properties to populate | |||
bool (InternalStats::*handle_map)(std::map<std::string, std::string>* props); | |||
|
|||
// handle the private or protected property info of 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.
What does "private or protected" mean?
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.
If the property is not the private or protected member of DBImpl, they can be directly handled by GetIntProperty or GetStringProperty. Only the private or protected members's property need to use the DBImpl callback to return the value.
include/rocksdb/db.h
Outdated
@@ -621,6 +621,10 @@ class DB { | |||
// "rocksdb.block-cache-pinned-usage" - returns the memory size for the | |||
// entries being pinned. | |||
static const std::string kBlockCachePinnedUsage; | |||
|
|||
// "rocksdb.options-statistics" - returns multi-line string | |||
// containing options.statistics |
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.
"containing options.statistics" feels a little bit odd to me. Maybe "for options.statistics", or "of options.statistics"?
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.
I will fix it, using "of options.statistics"
@zhichao-cao has updated the pull request. View: changes, changes since last import |
@zhichao-cao has updated the pull request. View: changes, changes since last import |
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.
Looks good to me. Good job!
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.
@zhichao-cao has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@zhichao-cao are you going to land it? |
@siying Sorry, I forgot this one has been approved. I will land it now. |
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.
@zhichao-cao is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Add a new DB property to DB::GetProperty(), which returns the option.statistics. Test is updated to pass. Closes facebook#3966 Differential Revision: D8311139 Pulled By: zhichao-cao fbshipit-source-id: ea78f4727358c807b0e5a0ea62e09defb10ad9ac
Add a new DB property to DB::GetProperty(), which returns the option.statistics. Test is updated to pass.