add hash calc config.use_write_cache (#24005)

This commit is contained in:
Jeff Washington (jwash) 2022-03-30 17:19:34 -05:00 committed by GitHub
parent 82c5230bc2
commit 125f9634fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 8 deletions

View File

@ -129,6 +129,7 @@ impl AccountsHashVerifier {
use_bg_thread_pool: true,
check_hash: false,
ancestors: None,
use_write_cache: false,
},
timings,
)

View File

@ -5518,6 +5518,7 @@ impl AccountsDb {
use_bg_thread_pool: !is_startup,
check_hash,
ancestors: can_cached_slot_be_unflushed.then(|| ancestors),
use_write_cache: can_cached_slot_be_unflushed,
},
timings,
);
@ -5533,6 +5534,7 @@ impl AccountsDb {
use_bg_thread_pool: !is_startup,
check_hash,
ancestors: Some(ancestors),
use_write_cache: can_cached_slot_be_unflushed,
},
)
}
@ -5760,9 +5762,15 @@ impl AccountsDb {
PUBKEY_BINS_FOR_CALCULATING_HASHES,
&bounds,
config.check_hash,
config
.ancestors
.map(|a| (&self.accounts_cache, a, &self.accounts_index)),
// if we can use write cache, then pass Some(write cache, ancestors, index)
// otherwise, ancestors is irrelevant because storages were accumulated using ancestors already
(config.use_write_cache && config.ancestors.is_some()).then(|| {
(
&self.accounts_cache,
config.ancestors.unwrap(),
&self.accounts_index,
)
}),
hash.filler_account_suffix.as_ref(),
)?;
@ -7949,6 +7957,7 @@ pub mod tests {
use_bg_thread_pool: false,
check_hash: false,
ancestors: None,
use_write_cache: false,
},
HashStats::default(),
)
@ -7975,6 +7984,7 @@ pub mod tests {
use_bg_thread_pool: false,
check_hash: false,
ancestors: None,
use_write_cache: false,
},
HashStats::default(),
)

View File

@ -22,14 +22,17 @@ pub struct PreviousPass {
/// parameters to calculate accounts hash
pub struct CalcAccountsHashConfig<'a> {
pub storages: &'a SortedStorages<'a>,
/// true to use a thread pool dedicated to bg operations
pub use_bg_thread_pool: bool,
/// verify every hash in append vec/write cache with a recalculated hash
/// this option will be removed
pub check_hash: bool,
/// 'ancestors' is used to get storages and also used if 'use_write_cache' is true to
/// get account data from the write cache
pub ancestors: Option<&'a Ancestors>,
// to come soon
/*
pub rent_collector: RentCollector,
pub epoch_schedule: EpochSchedule,
*/
/// does hash calc need to consider account data that exists in the write cache?
/// if so, 'ancestors' will be used for this purpose as well as storages.
pub use_write_cache: bool,
}
// smallest, 3 quartiles, largest, average