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 kOptionsStatistics to GetProperty() #3966

Closed

Conversation

zhichao-cao
Copy link
Contributor

@zhichao-cao zhichao-cao commented Jun 7, 2018

Add a new DB property to DB::GetProperty(), which returns the option.statistics. Test is updated to pass.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.


// "rocksdb.immutable_db_options_statistic" - returns the statistic
// of immutable db options
static const std::string kImmutableDBOptionStatistic;
Copy link
Contributor

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.

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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();
Copy link
Contributor

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

@@ -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;
Copy link
Contributor

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().

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request.

Copy link
Contributor

@siying siying left a 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.

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request.

@zhichao-cao zhichao-cao changed the title Add immutable_db_options_.statistics to GetProperty() Add kDBStatisticsInOptions to GetProperty() Jun 8, 2018
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();
Copy link
Contributor

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);
Copy link
Contributor

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.

@facebook-github-bot
Copy link
Contributor

@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);
Copy link
Contributor

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.

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request.

nullptr}},
{DB::Properties::kDBStatisticsInOptions,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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:
@zhichao-cao zhichao-cao changed the title Add kDBStatisticsInOptions to GetProperty() Add kStatistics to GetProperty() Jun 8, 2018
@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix this comment.

@@ -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
Copy link
Contributor

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".

@@ -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";
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix it.

@facebook-github-bot
Copy link
Contributor

@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
Copy link
Contributor

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".

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request. View: changes, changes since last import

@zhichao-cao zhichao-cao changed the title Add kStatistics to GetProperty() Add kOptionsStatistics to GetProperty() Jun 8, 2018
Copy link
Contributor

@siying siying left a 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.

@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -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
Copy link
Contributor

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"?

Copy link
Contributor Author

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"

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request. View: changes, changes since last import

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has updated the pull request. View: changes, changes since last import

Copy link
Contributor

@siying siying left a 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!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@siying
Copy link
Contributor

siying commented Jun 15, 2018

@zhichao-cao are you going to land it?

@zhichao-cao
Copy link
Contributor Author

@siying Sorry, I forgot this one has been approved. I will land it now.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

rcane pushed a commit to rcane/rocksdb that referenced this pull request Sep 13, 2018
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
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