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

kvdb-rocksdb: expose RocksDB stats #347

Merged
merged 8 commits into from
Feb 27, 2020
Merged

kvdb-rocksdb: expose RocksDB stats #347

merged 8 commits into from
Feb 27, 2020

Conversation

ordian
Copy link
Member

@ordian ordian commented Feb 27, 2020

For some reason in tests block.cache.hit/miss is always 0, not sure why.

@ordian ordian changed the title kvdb-rocksdb: expose stats kvdb-rocksdb: expose RocksDB stats Feb 27, 2020
let overall_stats = self.stats.overall();
let old_cache_hit_count = overall_stats.raw.cache_hit_count;

self.stats.tally_cache_hit_count(cache_hit_count - old_cache_hit_count);
Copy link
Member Author

@ordian ordian Feb 27, 2020

Choose a reason for hiding this comment

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

this hack is needed because get_statistics() returns only overall stats, it has probably a race condition
ideas how to make this better are welcome!

@ordian ordian requested a review from NikVolf February 27, 2020 13:44
@@ -304,6 +306,8 @@ fn is_corrupted(err: &Error) -> bool {
fn generate_options(config: &DatabaseConfig) -> Options {
let mut opts = Options::default();

opts.set_report_bg_io_stats(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

well it should be optional, since it is up to 10% performance hit
https://github.com/facebook/rocksdb/wiki/Statistics

Copy link
Member Author

Choose a reason for hiding this comment

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

added a config option as requested, this particular parameter (report_bg_io_stats) shouldn't have a perf impact though

Copy link
Contributor

Choose a reason for hiding this comment

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

To be clear: background stats has negligable performance impact, while the "other one" can be expensive (10%). Here we're enabling the cheap one for all and making the other configurable. Did I get that right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

kvdb-rocksdb/src/lib.rs Outdated Show resolved Hide resolved
Co-Authored-By: Nikolay Volf <nikvolf@gmail.com>
@ordian ordian requested a review from dvdplm February 27, 2020 17:29
Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

A few nits but lgtm.

@@ -167,6 +167,12 @@ pub struct DatabaseConfig {
pub columns: u32,
/// Specify the maximum number of info/debug log files to be kept.
pub keep_log_file_num: i32,
/// Enable native RocksDB statistics.
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 dumb q but can it be enabled/disabled on the fly? Or at start only? Would be fantastic to be able to turn it on dynamically.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is only enable_statistics method and no disable_, this option is passed on db::open, so there is no way to change it dynamically unfortunately.

@@ -304,6 +306,8 @@ fn is_corrupted(err: &Error) -> bool {
fn generate_options(config: &DatabaseConfig) -> Options {
let mut opts = Options::default();

opts.set_report_bg_io_stats(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

To be clear: background stats has negligable performance impact, while the "other one" can be expensive (10%). Here we're enabling the cheap one for all and making the other configurable. Did I get that right?

@@ -767,7 +797,7 @@ impl KeyValueDB for Database {
stats.transactions = taken_stats.raw.transactions;
stats.bytes_written = taken_stats.raw.bytes_written;
stats.bytes_read = taken_stats.raw.bytes_read;

stats.cache_reads = taken_stats.raw.cache_hit_count;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep the same name: stats.cache_hit_count = taken_stats.raw.cache_hit_count;

Copy link
Member Author

Choose a reason for hiding this comment

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

that would be a breaking change to kvdb and is out of scope of the PR

@ordian ordian merged commit 68dadf2 into master Feb 27, 2020
@ordian ordian deleted the ao-rocksdb-stats branch February 27, 2020 19:23
ordian added a commit that referenced this pull request Mar 2, 2020
* master:
  kvdb-rocksdb: bump version (#348)
  kvdb-rocksdb: expose RocksDB stats (#347)
  Implement Error for FromDecStrErr (#346)
  Fix clippy lints for rlp-derive (#345)
ordian added a commit that referenced this pull request Mar 6, 2020
* master:
  kvdb-rocksdb: bump version (#348)
  kvdb-rocksdb: expose RocksDB stats (#347)
  Implement Error for FromDecStrErr (#346)
  Fix clippy lints for rlp-derive (#345)
  prepare rlp-derive release (#344)
  Update/change licenses: MIT/Apache2.0 (#342)
  rlp-derive extracted (#343)
  Format for readme and changelog corrected (#341)
  Parity runtime moved to parity common for publication in crates.io (#271)
  Disable cache if explicit memory budget=0 passed (#339)
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

3 participants