Skip to content

kvdb-rocksdb: expose RocksDB stats#347

Merged
ordian merged 8 commits into
masterfrom
ao-rocksdb-stats
Feb 27, 2020
Merged

kvdb-rocksdb: expose RocksDB stats#347
ordian merged 8 commits into
masterfrom
ao-rocksdb-stats

Conversation

@ordian
Copy link
Copy Markdown
Contributor

@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
Comment thread kvdb-rocksdb/src/lib.rs
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
Copy Markdown
Contributor 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
Comment thread kvdb-rocksdb/src/lib.rs
fn generate_options(config: &DatabaseConfig) -> Options {
let mut opts = Options::default();

opts.set_report_bg_io_stats(true);
Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes

Comment thread kvdb-rocksdb/src/lib.rs Outdated
Co-Authored-By: Nikolay Volf <nikvolf@gmail.com>
@ordian ordian requested a review from dvdplm February 27, 2020 17:29
Copy link
Copy Markdown
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.

Comment thread kvdb-rocksdb/src/lib.rs
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
Copy Markdown
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
Copy Markdown
Contributor 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.

Comment thread kvdb-rocksdb/src/lib.rs
fn generate_options(config: &DatabaseConfig) -> Options {
let mut opts = Options::default();

opts.set_report_bg_io_stats(true);
Copy link
Copy Markdown
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?

Comment thread kvdb-rocksdb/src/lib.rs
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
Copy Markdown
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
Copy Markdown
Contributor 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.

3 participants