Skip to content

Commit

Permalink
Add more metrics for tree & state keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Mar 23, 2022
1 parent 20e5ec3 commit 9da0da7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
13 changes: 12 additions & 1 deletion core/bin/zksync_core/src/state_keeper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl ZkSyncStateKeeper {

pub async fn execute_reverted_blocks(&mut self) {
while let Some(block) = self.reverted_blocks.pop_front() {
self.execute_incomplete_block(block).await
self.execute_incomplete_block(block).await;
}
}

Expand Down Expand Up @@ -276,6 +276,7 @@ impl ZkSyncStateKeeper {
// Generate and execute new miniblock every miniblock_interval
async fn run(mut self, miniblock_interval: Duration) {
let mut timer = time::interval(miniblock_interval);
let mut last_iteration = Instant::now();
loop {
timer.tick().await;

Expand All @@ -288,6 +289,11 @@ impl ZkSyncStateKeeper {

let block_timestamp = self.pending_block.timestamp;
let proposed_block = self.propose_new_block(block_timestamp).await;
metrics::histogram!("miniblock_size", proposed_block.size() as f64);

// Report timings between two miniblocks.
metrics::histogram!("miniblock_interval", last_iteration.elapsed());
last_iteration = Instant::now();

self.execute_proposed_block(proposed_block).await;
}
Expand Down Expand Up @@ -825,6 +831,11 @@ impl ZkSyncStateKeeper {
self.pending_block.chunks_left,
self.pending_block.pending_block_iteration
);
metrics::gauge!(
"last_processed_block",
block_commit_request.block.block_number.0 as f64,
"stage" => "state_keeper"
);

let commit_request =
CommitRequest::SealIncompleteBlock((block_commit_request, applied_updates_request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl RootHashCalculator {

metrics::histogram!("root_hash_calculator.process_job", start.elapsed());
metrics::gauge!(
"last_process_block",
"last_processed_block",
job.block.0 as f64,
"stage" => "root_hash_calculator"
);
Expand Down
6 changes: 6 additions & 0 deletions core/bin/zksync_witness_generator/src/witness_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ impl<DB: DatabaseInterface> WitnessGenerator<DB> {
metrics::histogram!("witness_generator", start.elapsed(), "stage" => "store_witness");

metrics::histogram!("witness_generator", fn_start.elapsed(), "stage" => "prepare_witness_and_save_it");

metrics::gauge!(
"last_processed_block",
block.block_number.0 as f64,
"stage" => "witness_generator"
);
Ok(())
}

Expand Down
4 changes: 4 additions & 0 deletions core/lib/mempool/src/block_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ impl ProposedBlock {
pub fn is_empty(&self) -> bool {
self.priority_ops.is_empty() && self.txs.is_empty()
}

pub fn size(&self) -> usize {
self.priority_ops.len() + self.txs.len()
}
}

#[derive(Debug)]
Expand Down

0 comments on commit 9da0da7

Please sign in to comment.