Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
add hash calc config.use_write_cache (#24005)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Mar 30, 2022
1 parent 82c5230 commit 125f963
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions core/src/accounts_hash_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl AccountsHashVerifier {
use_bg_thread_pool: true,
check_hash: false,
ancestors: None,
use_write_cache: false,
},
timings,
)
Expand Down
16 changes: 13 additions & 3 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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,
},
)
}
Expand Down Expand Up @@ -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(),
)?;

Expand Down Expand Up @@ -7949,6 +7957,7 @@ pub mod tests {
use_bg_thread_pool: false,
check_hash: false,
ancestors: None,
use_write_cache: false,
},
HashStats::default(),
)
Expand All @@ -7975,6 +7984,7 @@ pub mod tests {
use_bg_thread_pool: false,
check_hash: false,
ancestors: None,
use_write_cache: false,
},
HashStats::default(),
)
Expand Down
13 changes: 8 additions & 5 deletions runtime/src/accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 125f963

Please sign in to comment.