-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Support GetMapProperty()
with "rocksdb.dbstats"
#9057
Conversation
bc49ccd
to
742f78c
Compare
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
(*db_stats)[db_stats_type_to_info.at(type).property_name] = | ||
std::to_string(GetDBStats(type)); | ||
} | ||
double seconds_up = (clock_->NowMicros() - started_at_) / kMicrosInSec; |
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.
We may use the same calculation, either remove the "1" in DumpDBStats or add "1" here.....
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.
OK, I removed the + 1
from the old calculation (I didn't want to bring the + 1
to the new code because it would make testing difficult). But let me know if you can think of a reason why it was there in the first place -- I have no idea.
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.
Oh it's because seconds_up
is used as a denominator later. Oddly other code to handle this situation uses std::max(interval_seconds_up, 0.001)
. Let me use that instead for handling zero uptime without dividing by zero.
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.
LGTM
@ajkr has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
@ajkr has updated the pull request. You must reimport the pull request before landing. |
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 review! BTW I also increased test coverage a bit.
(*db_stats)[db_stats_type_to_info.at(type).property_name] = | ||
std::to_string(GetDBStats(type)); | ||
} | ||
double seconds_up = (clock_->NowMicros() - started_at_) / kMicrosInSec; |
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.
OK, I removed the + 1
from the old calculation (I didn't want to bring the + 1
to the new code because it would make testing difficult). But let me know if you can think of a reason why it was there in the first place -- I have no idea.
@ajkr has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
@ajkr has updated the pull request. You must reimport the pull request before landing. |
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
db/internal_stats.cc
Outdated
@@ -1324,7 +1362,7 @@ void InternalStats::DumpDBStats(std::string* value) { | |||
NumberToHumanString(write_with_wal).c_str(), | |||
NumberToHumanString(wal_synced).c_str(), | |||
write_with_wal / static_cast<double>(wal_synced + 1), |
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.
Should we also change "wal_synced + 1"?
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.
Sure.
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.
Done here and a few more places, but not yet all + 1
s in the file...
@@ -1895,7 +1915,80 @@ TEST_F(DBPropertiesTest, BlockCacheProperties) { | |||
ASSERT_EQ(0, value); | |||
} | |||
|
|||
TEST_F(DBPropertiesTest, GetMapPropertyDbStats) { |
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.
The test looks good to me. I think we do not need to cover user_write_stall_micros
in this test
HISTORY.md
Outdated
@@ -18,6 +18,7 @@ | |||
* Introduce an experimental feature to dump out the blocks from block cache and insert them to the secondary cache to reduce the cache warmup time (e.g., used while migrating DB instance). More information are in `class CacheDumper` and `CacheDumpedLoader` at `rocksdb/utilities/cache_dump_load.h` Note that, this feature is subject to the potential change in the future, it is still experimental. | |||
* Introduced a new BlobDB configuration option `blob_garbage_collection_force_threshold`, which can be used to trigger compactions targeting the SST files which reference the oldest blob files when the ratio of garbage in those blob files meets or exceeds the specified threshold. This can reduce space amplification with skewed workloads where the affected SST files might not otherwise get picked up for compaction. | |||
* Added EXPERIMENTAL support for table file (SST) unique identifiers that are stable and universally unique, available with new function `GetUniqueIdFromTableProperties`. Only SST files from RocksDB >= 6.24 support unique IDs. | |||
* Added `GetMapProperty()` support for "rocksdb.dbstats" (`DB::Properties::kDBStats`). As a map property, it only includes cumulative stats over the DB's lifetime. |
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 only includes cumulative stats (i.e., user write related) over.....
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 includes everything in InternalDBStatsType
(which, yes, happen to be all write related) and also uptime.
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.
Done, added more description of the map's contents.
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 review. BTW, needs Phabricator accept (assuming you think it's ready).
HISTORY.md
Outdated
@@ -18,6 +18,7 @@ | |||
* Introduce an experimental feature to dump out the blocks from block cache and insert them to the secondary cache to reduce the cache warmup time (e.g., used while migrating DB instance). More information are in `class CacheDumper` and `CacheDumpedLoader` at `rocksdb/utilities/cache_dump_load.h` Note that, this feature is subject to the potential change in the future, it is still experimental. | |||
* Introduced a new BlobDB configuration option `blob_garbage_collection_force_threshold`, which can be used to trigger compactions targeting the SST files which reference the oldest blob files when the ratio of garbage in those blob files meets or exceeds the specified threshold. This can reduce space amplification with skewed workloads where the affected SST files might not otherwise get picked up for compaction. | |||
* Added EXPERIMENTAL support for table file (SST) unique identifiers that are stable and universally unique, available with new function `GetUniqueIdFromTableProperties`. Only SST files from RocksDB >= 6.24 support unique IDs. | |||
* Added `GetMapProperty()` support for "rocksdb.dbstats" (`DB::Properties::kDBStats`). As a map property, it only includes cumulative stats over the DB's lifetime. |
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 includes everything in InternalDBStatsType
(which, yes, happen to be all write related) and also uptime.
db/internal_stats.cc
Outdated
@@ -1324,7 +1362,7 @@ void InternalStats::DumpDBStats(std::string* value) { | |||
NumberToHumanString(write_with_wal).c_str(), | |||
NumberToHumanString(wal_synced).c_str(), | |||
write_with_wal / static_cast<double>(wal_synced + 1), |
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.
Sure.
028d170
to
d911049
Compare
@ajkr has updated the pull request. You must reimport the pull request before landing. |
@ajkr has updated the pull request. You must reimport the pull request before landing. |
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Accepted in Phabricator |
Summary: This PR supports querying `GetMapProperty()` with "rocksdb.dbstats" to get the DB-level stats in a map format. It only reports cumulative stats over the DB lifetime and, as such, does not update the baseline for interval stats. Like other map properties, the string keys are not (yet) exposed in the public API. Pull Request resolved: facebook/rocksdb#9057 Test Plan: new unit test Reviewed By: zhichao-cao Differential Revision: D31781495 Pulled By: ajkr fbshipit-source-id: 6f77d3aee8b4b1a015061b8c260a123859ceaf9b
This PR supports querying
GetMapProperty()
with "rocksdb.dbstats" to get the DB-level stats in a map format. It only reports cumulative stats over the DB lifetime and, as such, does not update the baseline for interval stats. Like other map properties, the string keys are not (yet) exposed in the public API.Test Plan: new unit test