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, use_bg_thread_pool: true,
check_hash: false, check_hash: false,
ancestors: None, ancestors: None,
use_write_cache: false,
}, },
timings, timings,
) )

View File

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

View File

@ -22,14 +22,17 @@ pub struct PreviousPass {
/// parameters to calculate accounts hash /// parameters to calculate accounts hash
pub struct CalcAccountsHashConfig<'a> { pub struct CalcAccountsHashConfig<'a> {
pub storages: &'a SortedStorages<'a>, pub storages: &'a SortedStorages<'a>,
/// true to use a thread pool dedicated to bg operations
pub use_bg_thread_pool: bool, 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, 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>, pub ancestors: Option<&'a Ancestors>,
// to come soon /// 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 rent_collector: RentCollector, pub use_write_cache: bool,
pub epoch_schedule: EpochSchedule,
*/
} }
// smallest, 3 quartiles, largest, average // smallest, 3 quartiles, largest, average