Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjinpeng87 committed Jan 16, 2017
1 parent 01e3a96 commit 8f337fe
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions src/raftstore/store/local_metrics.rs
Expand Up @@ -23,7 +23,7 @@ pub struct RaftReadyMetrics {
pub commit: u64,
pub append: u64,
pub snapshot: u64,
pub store_keys_written: u64,
pub store_written_keys: u64,
}

impl RaftReadyMetrics {
Expand Down Expand Up @@ -54,9 +54,9 @@ impl RaftReadyMetrics {
.unwrap();
self.snapshot = 0;
}
if self.store_keys_written > 0 {
STORE_KEYS_WRITTEN_COUNTER.inc_by(self.store_keys_written as f64).unwrap();
self.store_keys_written = 0;
if self.store_written_keys > 0 {
STORE_WRITTEN_KEYS_COUNTER.inc_by(self.store_written_keys as f64).unwrap();
self.store_written_keys = 0;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/raftstore/store/metrics.rs
Expand Up @@ -143,22 +143,22 @@ lazy_static! {
&["cf"]
).unwrap();

pub static ref STORE_KEYS_WRITTEN_COUNTER: Counter =
pub static ref STORE_WRITTEN_KEYS_COUNTER: Counter =
register_counter!(
"tikv_engine_keys_written_count",
"tikv_engine_written_keys_count",
"Count of keys has been written for this interval"
).unwrap();

pub static ref REGION_BYTES_WRITTEN_HISTOGRAM: Histogram =
pub static ref REGION_WRITTEN_BYTES_HISTOGRAM: Histogram =
register_histogram!(
"tikv_region_bytes_written",
"tikv_region_written_bytes",
"Histogram of bytes written for regions",
exponential_buckets(256.0, 2.0, 20).unwrap()
).unwrap();

pub static ref REGION_KEYS_WRITTEN_HISTOGRAM: Histogram =
pub static ref REGION_WRITTEN_KEYS_HISTOGRAM: Histogram =
register_histogram!(
"tikv_region_keys_written",
"tikv_region_written_keys",
"Histogram of keys written for regions",
exponential_buckets(1.0, 2.0, 20).unwrap()
).unwrap();
Expand Down
14 changes: 7 additions & 7 deletions src/raftstore/store/peer.rs
Expand Up @@ -247,8 +247,8 @@ pub struct Peer {
leader_lease_expired_time: Option<Timespec>,
election_timeout: TimeDuration,

pub bytes_written: u64,
pub keys_written: u64,
pub written_bytes: u64,
pub written_keys: u64,
}

impl Peer {
Expand Down Expand Up @@ -345,8 +345,8 @@ impl Peer {
leader_lease_expired_time: None,
election_timeout: TimeDuration::milliseconds(cfg.raft_base_tick_interval as i64) *
cfg.raft_election_timeout_ticks as i32,
bytes_written: 0,
keys_written: 0,
written_bytes: 0,
written_keys: 0,
};

peer.load_all_coprocessors();
Expand Down Expand Up @@ -1376,9 +1376,9 @@ impl Peer {
.unwrap_or_else(|e| panic!("{} failed to save apply context: {:?}", self.tag, e));
}

metrics.store_keys_written += ctx.wb.count() as u64;
self.bytes_written += ctx.wb.data_size() as u64;
self.keys_written += ctx.wb.count() as u64;
metrics.store_written_keys += ctx.wb.count() as u64;
self.written_bytes += ctx.wb.data_size() as u64;
self.written_keys += ctx.wb.count() as u64;

// Commit write and change storage fields atomically.
self.mut_store()
Expand Down
24 changes: 12 additions & 12 deletions src/raftstore/store/store.rs
Expand Up @@ -111,8 +111,8 @@ pub struct Store<T: Transport, C: PdClient + 'static> {
start_time: Timespec,
is_busy: bool,

region_bytes_written: LocalHistogram,
region_keys_written: LocalHistogram,
region_written_bytes: LocalHistogram,
region_written_keys: LocalHistogram,
}

pub fn create_event_loop<T, C>(cfg: &Config) -> Result<EventLoop<Store<T, C>>>
Expand Down Expand Up @@ -182,8 +182,8 @@ impl<T: Transport, C: PdClient> Store<T, C> {
tag: tag,
start_time: time::get_time(),
is_busy: false,
region_bytes_written: REGION_BYTES_WRITTEN_HISTOGRAM.local(),
region_keys_written: REGION_KEYS_WRITTEN_HISTOGRAM.local(),
region_written_bytes: REGION_WRITTEN_BYTES_HISTOGRAM.local(),
region_written_keys: REGION_WRITTEN_KEYS_HISTOGRAM.local(),
};
try!(s.init());
Ok(s)
Expand Down Expand Up @@ -1162,18 +1162,18 @@ impl<T: Transport, C: PdClient> Store<T, C> {
fn on_report_region_flow(&mut self, event_loop: &mut EventLoop<Self>) {
for (_, peer) in &mut self.region_peers {
if !peer.is_leader() {
peer.bytes_written = 0;
peer.keys_written = 0;
peer.written_bytes = 0;
peer.written_keys = 0;
continue;
}

self.region_bytes_written.observe(peer.bytes_written as f64);
self.region_keys_written.observe(peer.keys_written as f64);
peer.bytes_written = 0;
peer.keys_written = 0;
self.region_written_bytes.observe(peer.written_bytes as f64);
self.region_written_keys.observe(peer.written_keys as f64);
peer.written_bytes = 0;
peer.written_keys = 0;
}
self.region_bytes_written.flush();
self.region_keys_written.flush();
self.region_written_bytes.flush();
self.region_written_keys.flush();

self.register_report_region_flow_tick(event_loop);
}
Expand Down

0 comments on commit 8f337fe

Please sign in to comment.