pass stats separately from CalcAccountsHashConfig (#23892)
This commit is contained in:
committed by
GitHub
parent
82328fd9d8
commit
37c36ce3fa
@ -114,13 +114,15 @@ impl AccountsHashVerifier {
|
|||||||
let (hash, lamports) = accounts_package
|
let (hash, lamports) = accounts_package
|
||||||
.accounts
|
.accounts
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(
|
||||||
|
&CalcAccountsHashConfig {
|
||||||
storages: &sorted_storages,
|
storages: &sorted_storages,
|
||||||
use_bg_thread_pool: true,
|
use_bg_thread_pool: true,
|
||||||
stats: HashStats::default(),
|
|
||||||
check_hash: false,
|
check_hash: false,
|
||||||
ancestors: None,
|
ancestors: None,
|
||||||
})
|
},
|
||||||
|
HashStats::default(),
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(accounts_package.expected_capitalization, lamports);
|
assert_eq!(accounts_package.expected_capitalization, lamports);
|
||||||
|
@ -5513,13 +5513,15 @@ impl AccountsDb {
|
|||||||
};
|
};
|
||||||
timings.calc_storage_size_quartiles(&combined_maps);
|
timings.calc_storage_size_quartiles(&combined_maps);
|
||||||
|
|
||||||
self.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
self.calculate_accounts_hash_without_index(
|
||||||
|
&CalcAccountsHashConfig {
|
||||||
storages: &storages,
|
storages: &storages,
|
||||||
use_bg_thread_pool: !is_startup,
|
use_bg_thread_pool: !is_startup,
|
||||||
stats: timings,
|
|
||||||
check_hash,
|
check_hash,
|
||||||
ancestors: can_cached_slot_be_unflushed.then(|| ancestors),
|
ancestors: can_cached_slot_be_unflushed.then(|| ancestors),
|
||||||
})
|
},
|
||||||
|
timings,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
self.calculate_accounts_hash(slot, ancestors, check_hash)
|
self.calculate_accounts_hash(slot, ancestors, check_hash)
|
||||||
}
|
}
|
||||||
@ -5715,7 +5717,8 @@ impl AccountsDb {
|
|||||||
// intended to be faster than calculate_accounts_hash
|
// intended to be faster than calculate_accounts_hash
|
||||||
pub fn calculate_accounts_hash_without_index(
|
pub fn calculate_accounts_hash_without_index(
|
||||||
&self,
|
&self,
|
||||||
config: &mut CalcAccountsHashConfig<'_>,
|
config: &CalcAccountsHashConfig<'_>,
|
||||||
|
mut stats: HashStats,
|
||||||
) -> Result<(Hash, u64), BankHashVerificationError> {
|
) -> Result<(Hash, u64), BankHashVerificationError> {
|
||||||
let (num_hash_scan_passes, bins_per_pass) = Self::bins_per_pass(self.num_hash_scan_passes);
|
let (num_hash_scan_passes, bins_per_pass) = Self::bins_per_pass(self.num_hash_scan_passes);
|
||||||
let use_bg_thread_pool = config.use_bg_thread_pool;
|
let use_bg_thread_pool = config.use_bg_thread_pool;
|
||||||
@ -5742,7 +5745,7 @@ impl AccountsDb {
|
|||||||
let result = Self::scan_snapshot_stores_with_cache(
|
let result = Self::scan_snapshot_stores_with_cache(
|
||||||
&cache_hash_data,
|
&cache_hash_data,
|
||||||
config.storages,
|
config.storages,
|
||||||
&mut config.stats,
|
&mut stats,
|
||||||
PUBKEY_BINS_FOR_CALCULATING_HASHES,
|
PUBKEY_BINS_FOR_CALCULATING_HASHES,
|
||||||
&bounds,
|
&bounds,
|
||||||
config.check_hash,
|
config.check_hash,
|
||||||
@ -5754,7 +5757,7 @@ impl AccountsDb {
|
|||||||
|
|
||||||
let (hash, lamports, for_next_pass) = hash.rest_of_hash_calculation(
|
let (hash, lamports, for_next_pass) = hash.rest_of_hash_calculation(
|
||||||
result,
|
result,
|
||||||
&mut config.stats,
|
&mut stats,
|
||||||
pass == num_hash_scan_passes - 1,
|
pass == num_hash_scan_passes - 1,
|
||||||
previous_pass,
|
previous_pass,
|
||||||
bins_per_pass,
|
bins_per_pass,
|
||||||
@ -7917,13 +7920,15 @@ pub mod tests {
|
|||||||
let (storages, _size, _slot_expected) = sample_storage();
|
let (storages, _size, _slot_expected) = sample_storage();
|
||||||
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||||
let result = db
|
let result = db
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(
|
||||||
|
&CalcAccountsHashConfig {
|
||||||
storages: &get_storage_refs(&storages),
|
storages: &get_storage_refs(&storages),
|
||||||
use_bg_thread_pool: false,
|
use_bg_thread_pool: false,
|
||||||
stats: HashStats::default(),
|
|
||||||
check_hash: false,
|
check_hash: false,
|
||||||
ancestors: None,
|
ancestors: None,
|
||||||
})
|
},
|
||||||
|
HashStats::default(),
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let expected_hash = Hash::from_str("GKot5hBsd81kMupNCXHaqbhv3huEbxAFMLnpcX2hniwn").unwrap();
|
let expected_hash = Hash::from_str("GKot5hBsd81kMupNCXHaqbhv3huEbxAFMLnpcX2hniwn").unwrap();
|
||||||
assert_eq!(result, (expected_hash, 0));
|
assert_eq!(result, (expected_hash, 0));
|
||||||
@ -7941,13 +7946,15 @@ pub mod tests {
|
|||||||
let sum = raw_expected.iter().map(|item| item.lamports).sum();
|
let sum = raw_expected.iter().map(|item| item.lamports).sum();
|
||||||
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
let db = AccountsDb::new(Vec::new(), &ClusterType::Development);
|
||||||
let result = db
|
let result = db
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(
|
||||||
|
&CalcAccountsHashConfig {
|
||||||
storages: &get_storage_refs(&storages),
|
storages: &get_storage_refs(&storages),
|
||||||
use_bg_thread_pool: false,
|
use_bg_thread_pool: false,
|
||||||
stats: HashStats::default(),
|
|
||||||
check_hash: false,
|
check_hash: false,
|
||||||
ancestors: None,
|
ancestors: None,
|
||||||
})
|
},
|
||||||
|
HashStats::default(),
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(result, (expected_hash, sum));
|
assert_eq!(result, (expected_hash, sum));
|
||||||
|
@ -23,7 +23,6 @@ pub struct PreviousPass {
|
|||||||
pub struct CalcAccountsHashConfig<'a> {
|
pub struct CalcAccountsHashConfig<'a> {
|
||||||
pub storages: &'a SortedStorages<'a>,
|
pub storages: &'a SortedStorages<'a>,
|
||||||
pub use_bg_thread_pool: bool,
|
pub use_bg_thread_pool: bool,
|
||||||
pub stats: HashStats,
|
|
||||||
pub check_hash: bool,
|
pub check_hash: bool,
|
||||||
pub ancestors: Option<&'a Ancestors>,
|
pub ancestors: Option<&'a Ancestors>,
|
||||||
// to come soon
|
// to come soon
|
||||||
|
Reference in New Issue
Block a user