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

*: directly report statistics to pd #2337

Merged
merged 22 commits into from
Oct 13, 2017
Merged

*: directly report statistics to pd #2337

merged 22 commits into from
Oct 13, 2017

Conversation

nolouch
Copy link
Contributor

@nolouch nolouch commented Sep 25, 2017

refactor coprocessor and report statistics to pd worker


pub static ref PD_REQ_COUNTER_VEC: CounterVec =
register_counter_vec!(
"tikv_raftstore_pd_request_sent_total",
Copy link
Member

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.

Copy link
Contributor

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.

@nolouch nolouch changed the title *: move out pd work from raftstore [WIP] *: move out pd work from raftstore Sep 26, 2017
@siddontang
Copy link
Contributor

PTAL @BusyJay

@siddontang
Copy link
Contributor

Any update @nolouch

@nolouch nolouch changed the title [WIP] *: move out pd work from raftstore *: move out pd work from raftstore Oct 8, 2017
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) {
Copy link
Contributor

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),
Copy link
Contributor

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 {
Copy link
Contributor

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");
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

seem no need now.

@nolouch nolouch changed the title *: move out pd work from raftstore *: directly report statistics to pd Oct 9, 2017
@@ -129,20 +129,6 @@ lazy_static! {
exponential_buckets(1.0, 2.0, 20).unwrap()
).unwrap();

pub static ref REGION_READ_KEYS_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.

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() {
Copy link
Contributor

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

Copy link
Contributor

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.

@siddontang
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

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

@overvenus

Please update the crate.

@@ -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;
Copy link
Contributor

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?

@nolouch
Copy link
Contributor Author

nolouch commented Oct 12, 2017

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;
Copy link
Contributor

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

@siddontang
Copy link
Contributor

Rest LGTM

PTAL @huachaohuang @zhangjinpeng1987

@@ -114,6 +157,8 @@ pub struct Runner<T: PdClient> {
pd_client: Arc<T>,
ch: SendCh<Msg>,
db: Arc<DB>,
region_peers: HashMap<u64, PeerStat>,
Copy link
Member

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.

Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

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

LGTM

@nolouch nolouch merged commit 18beaa3 into master Oct 13, 2017
@nolouch nolouch deleted the shuning/extract-pd-work branch October 13, 2017 07:06
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.

4 participants