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

mertrics: report region flow #1517

Merged
merged 10 commits into from Jan 16, 2017
Merged

Conversation

zhangjinpeng87
Copy link
Member

@@ -1372,6 +1375,7 @@ impl Peer {
}

metrics.keys_written += ctx.wb.count() as u64;
self.bytes_written += ctx.wb.data_size() as u64;
Copy link
Member

Choose a reason for hiding this comment

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

Why not put it into RaftReadyMetrics?And we may need to count the size of entries written into rocksdb too.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we put it into RaftReadyMetrics , each region need a variable.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so. RaftReadyMetrics is stored in Store.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is ok here, we may report this to PD later.

continue;
}

REGION_BYTES_WRITTEN_HISTOGRAM.observe(peer.bytes_written as f64);
Copy link
Contributor

Choose a reason for hiding this comment

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

use a local histogram then flush, see rust Prometheus
LocalHistogram

Copy link
Member Author

Choose a reason for hiding this comment

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

LocalHistogram not export yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

merged, you can use it now.

@@ -140,4 +140,11 @@ lazy_static! {
"tikv_engine_keys_written_count",
"Count of keys has been written for this interval"
).unwrap();

pub static ref REGION_BYTES_WRITTEN_HISTOGRAM: Histogram =
Copy link
Contributor

Choose a reason for hiding this comment

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

We can check kv count too

@@ -34,6 +34,7 @@ pub enum Tick {
SnapGc,
CompactLockCf,
ConsistencyCheck,
ReportWriteBytes,
Copy link
Contributor

Choose a reason for hiding this comment

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

it is not only for Bytes now.

@@ -113,6 +115,8 @@ pub struct Config {

// Interval (ms) to check region whether the data is consistent.
pub consistency_check_tick_interval: u64,

pub report_write_bytes_interval: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

use a short value in test so we can cover this feature.

@zhangjinpeng87 zhangjinpeng87 changed the title mertrics: region bytes written mertrics: report region flow Jan 15, 2017
};
}

fn on_report_region_flow(&mut self, event_loop: &mut EventLoop<Self>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please cover it in test

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

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

Rest LGTM

@siddontang
Copy link
Contributor

PTAL @BusyJay @hhkbp2

@hhkbp2
Copy link
Contributor

hhkbp2 commented Jan 15, 2017

LGTM

@@ -28,6 +28,7 @@ use super::sync_storage::SyncStorage;

fn new_raft_storage() -> (Cluster<ServerCluster>, SyncStorage, Context) {
let mut cluster = new_server_cluster_with_cfs(0, 1, ALL_CFS);
cluster.cfg.raft_store.report_region_flow_interval = 100; // 100ms
Copy link
Contributor

Choose a reason for hiding this comment

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

initialize this in new_store_cfg directly.

@siddontang
Copy link
Contributor

PTAL @BusyJay

@@ -23,7 +23,7 @@ pub struct RaftReadyMetrics {
pub commit: u64,
pub append: u64,
pub snapshot: u64,
pub keys_written: u64,
pub store_keys_written: u64,
Copy link
Contributor

Choose a reason for hiding this comment

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

written_keys,written_bytes may be better?

/cc @BusyJay @hhkbp2

Copy link
Contributor

Choose a reason for hiding this comment

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

peer.bytes_written peer.keys_written
store.region_bytes_written store. region_keys_written
metrics.store_keys_written

The prefix levels look fine to me.

@zhangjinpeng87 zhangjinpeng87 force-pushed the zhangjinpeng/metrics-region-write-bytes branch from 4d3ce7a to 8f337fe Compare January 16, 2017 03:28
@zhangjinpeng87
Copy link
Member Author

PING


fn on_report_region_flow(&mut self, event_loop: &mut EventLoop<Self>) {
for (_, peer) in &mut self.region_peers {
if !peer.is_leader() {
Copy link
Member

Choose a reason for hiding this comment

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

If peer steps down, all records will be lost.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is ok, we don't need exact result.

@@ -143,9 +143,23 @@ lazy_static! {
&["cf"]
).unwrap();

pub static ref STORE_KEYS_WRITTEN_COUNTER: Counter =
pub static ref STORE_WRITTEN_KEYS_COUNTER: Counter =
Copy link
Member

Choose a reason for hiding this comment

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

I think just REGION_WRITTEN_KEY_HISTOGRAM is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

Em, here we may just want to know the written keys rate, if too high, the store may have a high load, so Counter is ok.

@siddontang
Copy link
Contributor

PTAL @BusyJay

continue;
}

self.region_written_bytes.observe(peer.written_bytes as f64);
Copy link
Member

Choose a reason for hiding this comment

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

Why observe it here rather every time handle ready?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, then we can remove the timer here.

Copy link
Member Author

Choose a reason for hiding this comment

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

on_raft_ready know nothing about time, what we want is to get region flow in a period of time.

@BusyJay
Copy link
Member

BusyJay commented Jan 16, 2017

LGTM

@siddontang siddontang merged commit 1b42363 into master Jan 16, 2017
@siddontang siddontang deleted the zhangjinpeng/metrics-region-write-bytes branch January 16, 2017 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants