Add squashing metrics (#3573)

This commit is contained in:
carllin
2019-03-29 21:21:59 -07:00
committed by GitHub
parent f886b3b12b
commit 8660c3581e
2 changed files with 27 additions and 1 deletions

View File

@ -1,9 +1,12 @@
//! The `bank_forks` module implments BankForks a DAG of checkpointed Banks
use hashbrown::{HashMap, HashSet};
use solana_metrics::counter::Counter;
use solana_runtime::bank::Bank;
use solana_sdk::timing;
use std::ops::Index;
use std::sync::Arc;
use std::time::Instant;
pub struct BankForks {
banks: HashMap<u64, Arc<Bank>>,
@ -99,12 +102,17 @@ impl BankForks {
}
pub fn set_root(&mut self, root: u64) {
let set_root_start = Instant::now();
let root_bank = self
.banks
.get(&root)
.expect("root bank didn't exist in bank_forks");
root_bank.squash();
self.prune_non_root(root);
inc_new_counter_info!(
"bank-forks_set_root_ms",
timing::duration_as_ms(&set_root_start.elapsed()) as usize
);
}
fn prune_non_root(&mut self, root: u64) {