add metric for collecting storages (#17527)
This commit is contained in:
parent
a43c29e858
commit
72bb271a94
|
@ -4244,11 +4244,19 @@ impl AccountsDb {
|
|||
check_hash: bool,
|
||||
) -> Result<(Hash, u64), BankHashVerificationError> {
|
||||
if !use_index {
|
||||
let mut time = Measure::start("collect");
|
||||
let combined_maps = self.get_snapshot_storages(slot);
|
||||
time.stop();
|
||||
|
||||
let timings = HashStats {
|
||||
collect_snapshots_us: time.as_us(),
|
||||
..HashStats::default()
|
||||
};
|
||||
|
||||
Self::calculate_accounts_hash_without_index(
|
||||
&combined_maps,
|
||||
Some(&self.thread_pool_clean),
|
||||
timings,
|
||||
check_hash,
|
||||
)
|
||||
} else {
|
||||
|
@ -4365,10 +4373,10 @@ impl AccountsDb {
|
|||
pub fn calculate_accounts_hash_without_index(
|
||||
storages: &[SnapshotStorage],
|
||||
thread_pool: Option<&ThreadPool>,
|
||||
mut stats: HashStats,
|
||||
check_hash: bool,
|
||||
) -> Result<(Hash, u64), BankHashVerificationError> {
|
||||
let scan_and_hash = || {
|
||||
let mut stats = HashStats::default();
|
||||
let mut scan_and_hash = move || {
|
||||
// When calculating hashes, it is helpful to break the pubkeys found into bins based on the pubkey value.
|
||||
// More bins means smaller vectors to sort, copy, etc.
|
||||
const PUBKEY_BINS_FOR_CALCULATING_HASHES: usize = 64;
|
||||
|
@ -5951,8 +5959,13 @@ pub mod tests {
|
|||
solana_logger::setup();
|
||||
|
||||
let (storages, _size, _slot_expected) = sample_storage();
|
||||
let result =
|
||||
AccountsDb::calculate_accounts_hash_without_index(&storages, None, false).unwrap();
|
||||
let result = AccountsDb::calculate_accounts_hash_without_index(
|
||||
&storages,
|
||||
None,
|
||||
HashStats::default(),
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
let expected_hash = Hash::from_str("GKot5hBsd81kMupNCXHaqbhv3huEbxAFMLnpcX2hniwn").unwrap();
|
||||
assert_eq!(result, (expected_hash, 0));
|
||||
}
|
||||
|
@ -5967,8 +5980,13 @@ pub mod tests {
|
|||
item.hash
|
||||
});
|
||||
let sum = raw_expected.iter().map(|item| item.lamports).sum();
|
||||
let result =
|
||||
AccountsDb::calculate_accounts_hash_without_index(&storages, None, false).unwrap();
|
||||
let result = AccountsDb::calculate_accounts_hash_without_index(
|
||||
&storages,
|
||||
None,
|
||||
HashStats::default(),
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(result, (expected_hash, sum));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ pub struct HashStats {
|
|||
pub hash_total: usize,
|
||||
pub unreduced_entries: usize,
|
||||
pub num_snapshot_storage: usize,
|
||||
pub collect_snapshots_us: u64,
|
||||
}
|
||||
impl HashStats {
|
||||
fn log(&mut self) {
|
||||
|
@ -35,6 +36,7 @@ impl HashStats {
|
|||
+ self.zeros_time_total_us
|
||||
+ self.hash_time_total_us
|
||||
+ self.sort_time_total_us
|
||||
+ self.collect_snapshots_us
|
||||
+ self.flatten_time_total_us;
|
||||
datapoint_info!(
|
||||
"calculate_accounts_hash_without_index",
|
||||
|
@ -45,6 +47,11 @@ impl HashStats {
|
|||
("hash_total", self.hash_total, i64),
|
||||
("flatten", self.flatten_time_total_us, i64),
|
||||
("unreduced_entries", self.unreduced_entries as i64, i64),
|
||||
(
|
||||
"collect_snapshots_us",
|
||||
self.collect_snapshots_us as i64,
|
||||
i64
|
||||
),
|
||||
(
|
||||
"num_snapshot_storage",
|
||||
self.num_snapshot_storage as i64,
|
||||
|
|
|
@ -1002,6 +1002,7 @@ pub fn process_accounts_package_pre(
|
|||
let (hash, lamports) = AccountsDb::calculate_accounts_hash_without_index(
|
||||
&accounts_package.storages,
|
||||
thread_pool,
|
||||
crate::accounts_hash::HashStats::default(),
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
Loading…
Reference in New Issue