Skip to content

Commit

Permalink
add counter
Browse files Browse the repository at this point in the history
  • Loading branch information
bchocho committed Jan 16, 2024
1 parent bc1baa9 commit ba18903
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion consensus/src/quorum_store/batch_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,15 @@ impl BatchGenerator {
let batches = self.handle_scheduled_pull(dynamic_pull_max_txn).await;
if !batches.is_empty() {
last_non_empty_pull = tick_start;
// TODO: time how long this takes

let persist_start = Instant::now();
let mut persist_requests = vec![];
for batch in batches.clone().into_iter() {
persist_requests.push(batch.into());
}
self.batch_writer.persist(persist_requests);
counters::BATCH_CREATION_PERSIST_LATENCY.observe_duration(persist_start.elapsed());

network_sender.broadcast_batch_msg(batches).await;
} else if tick_start.elapsed() > interval.period().checked_div(2).unwrap_or(Duration::ZERO) {
// If the pull takes too long, it's also accounted as a non-empty pull to avoid pulling too often.
Expand Down
11 changes: 11 additions & 0 deletions consensus/src/quorum_store/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,17 @@ pub static BATCH_CREATION_COMPUTE_LATENCY: Lazy<DurationHistogram> = Lazy::new(|
)
});

/// Histogram of the time it takes to persist batches generated locally to the DB.
pub static BATCH_CREATION_PERSIST_LATENCY: Lazy<DurationHistogram> = Lazy::new(|| {
DurationHistogram::new(
register_histogram!(
"quorum_store_batch_creation_persist_latency",
"Histogram of the time it takes to persist batches generated locally to the DB.",
)
.unwrap(),
)
});

/// Histogram of the time durations from created batch to created PoS.
pub static BATCH_TO_POS_DURATION: Lazy<DurationHistogram> = Lazy::new(|| {
DurationHistogram::new(
Expand Down

0 comments on commit ba18903

Please sign in to comment.