-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
*: directly report statistics to pd #2337
Conversation
src/pd/metrics.rs
Outdated
|
||
pub static ref PD_REQ_COUNTER_VEC: CounterVec = | ||
register_counter_vec!( | ||
"tikv_raftstore_pd_request_sent_total", |
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.
Now, it does not belong to tikv_raftstore_
any more.
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.
+1
We should also update the grafana too.
PTAL @BusyJay |
Any update @nolouch |
src/pd/pd.rs
Outdated
@@ -395,6 +426,21 @@ impl<T: PdClient> Runner<T> { | |||
handle.spawn(f); | |||
self.is_hb_receiver_scheduled = true; | |||
} | |||
|
|||
fn handle_coprocessor_read_stats(&mut self, read_stats: CopRequestStatistics) { |
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.
remove the name of coprocessor here, PD should not know it.
src/pd/pd.rs
Outdated
@@ -444,6 +498,7 @@ impl<T: PdClient> Runnable<Task> for Runner<T> { | |||
} | |||
Task::ReportSplit { left, right } => self.handle_report_split(handle, left, right), | |||
Task::ValidatePeer { region, peer } => self.handle_validate_peer(handle, region, peer), | |||
Task::CopReadStats { read_stats } => self.handle_coprocessor_read_stats(read_stats), |
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.
ReadStats is fine.
@@ -63,14 +64,14 @@ const OUTDATED_ERROR_MSG: &'static str = "request outdated."; | |||
|
|||
const ENDPOINT_IS_BUSY: &'static str = "endpoint is busy"; | |||
|
|||
pub struct Host<R: CopSender + 'static> { | |||
pub struct Host { |
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.
use another PR for refactoring coprocessor.
@@ -800,7 +792,8 @@ mod tests { | |||
let engine = engine::new_local_engine(TEMP_DIR, &[]).unwrap(); | |||
let mut cfg = Config::default(); | |||
cfg.end_point_concurrency = 1; | |||
let mut end_point = Host::new(engine, worker.scheduler(), &cfg, MockCopSender::new()); | |||
let pd_worker = FutureWorker::new("test-pd-worker"); |
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.
how to check we have already sent the read statistics?
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.
maybe mock a pd runner?
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.
seem no need now.
src/raftstore/store/metrics.rs
Outdated
@@ -129,20 +129,6 @@ lazy_static! { | |||
exponential_buckets(1.0, 2.0, 20).unwrap() | |||
).unwrap(); | |||
|
|||
pub static ref REGION_READ_KEYS_HISTOGRAM: Histogram = |
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.
no this metric now?
src/pd/pd.rs
Outdated
self.store_stat.engine_last_total_bytes_read = self.store_stat.engine_total_bytes_read; | ||
self.store_stat.engine_last_total_keys_read = self.store_stat.engine_total_keys_read; | ||
|
||
for peer in self.region_peers.values() { |
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.
define a local metric and flush after the for loop like https://github.com/pingcap/tikv/blob/master/src/raftstore/store/store.rs#L1692
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.
I prefer handling write bytes/keys to PD worker too.
Any update @nolouch |
Cargo.toml
Outdated
@@ -80,7 +80,7 @@ git = "https://github.com/pingcap/kvproto.git" | |||
git = "https://github.com/pingcap/tipb.git" | |||
|
|||
[dependencies.prometheus] | |||
version = "0.3" | |||
git = "https://github.com/pingcap/rust-prometheus.git" |
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.
Please update the crate.
src/raftstore/store/store.rs
Outdated
@@ -1693,34 +1676,13 @@ impl<T: Transport, C: PdClient> Store<T, C> { | |||
for peer in self.region_peers.values_mut() { | |||
peer.peer_stat.last_written_bytes = peer.peer_stat.written_bytes; |
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.
can we save the last_written_bytes/keys in PD worker and update in the heartbeat msg?
PTAL |
src/pd/pd.rs
Outdated
let peer_stat = self.region_peers | ||
.entry(region.get_id()) | ||
.or_insert_with(PeerStat::default); | ||
let read_bytes_interval = peer_stat.read_bytes - peer_stat.last_read_bytes; |
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.
delta may be better than interval
Rest LGTM |
@@ -114,6 +157,8 @@ pub struct Runner<T: PdClient> { | |||
pd_client: Arc<T>, | |||
ch: SendCh<Msg>, | |||
db: Arc<DB>, | |||
region_peers: HashMap<u64, PeerStat>, |
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.
When a peer is dropped in raftstore, here should keep updated.
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
refactor coprocessor and report statistics to pd worker