run initial hash calc in background, using background threads (#28239)

This commit is contained in:
Jeff Washington (jwash) 2022-10-05 19:42:06 -07:00 committed by GitHub
parent eec2a2a301
commit 435d4aded9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 4 deletions

View File

@ -113,6 +113,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
false, false,
false, false,
true, true,
false,
)) ))
}); });
} }

View File

@ -834,6 +834,7 @@ impl Accounts {
ignore_mismatch: bool, ignore_mismatch: bool,
store_detailed_debug_info: bool, store_detailed_debug_info: bool,
enable_rehashing: bool, enable_rehashing: bool,
use_bg_thread_pool: bool,
) -> bool { ) -> bool {
if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports_new( if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports_new(
slot, slot,
@ -845,6 +846,7 @@ impl Accounts {
ignore_mismatch, ignore_mismatch,
store_detailed_debug_info, store_detailed_debug_info,
enable_rehashing, enable_rehashing,
use_bg_thread_pool,
) { ) {
warn!("verify_bank_hash failed: {:?}, slot: {}", err, slot); warn!("verify_bank_hash failed: {:?}, slot: {}", err, slot);
false false

View File

@ -7513,6 +7513,7 @@ impl AccountsDb {
epoch_schedule: &EpochSchedule, epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector, rent_collector: &RentCollector,
enable_rehashing: bool, enable_rehashing: bool,
use_bg_thread_pool: bool,
) -> Result<(), BankHashVerificationError> { ) -> Result<(), BankHashVerificationError> {
self.verify_bank_hash_and_lamports_new( self.verify_bank_hash_and_lamports_new(
slot, slot,
@ -7524,6 +7525,7 @@ impl AccountsDb {
false, false,
false, false,
enable_rehashing, enable_rehashing,
use_bg_thread_pool,
) )
} }
@ -7540,20 +7542,19 @@ impl AccountsDb {
ignore_mismatch: bool, ignore_mismatch: bool,
store_hash_raw_data_for_debug: bool, store_hash_raw_data_for_debug: bool,
enable_rehashing: bool, enable_rehashing: bool,
use_bg_thread_pool: bool,
) -> Result<(), BankHashVerificationError> { ) -> Result<(), BankHashVerificationError> {
use BankHashVerificationError::*; use BankHashVerificationError::*;
let use_index = false; let use_index = false;
let check_hash = false; // this will not be supported anymore let check_hash = false; // this will not be supported anymore
// interesting to consider this
let is_startup = true;
let (calculated_hash, calculated_lamports) = self let (calculated_hash, calculated_lamports) = self
.calculate_accounts_hash_helper_with_verify( .calculate_accounts_hash_helper_with_verify(
use_index, use_index,
test_hash_calculation, test_hash_calculation,
slot, slot,
CalcAccountsHashConfig { CalcAccountsHashConfig {
use_bg_thread_pool: !is_startup, use_bg_thread_pool,
check_hash, check_hash,
ancestors: Some(ancestors), ancestors: Some(ancestors),
epoch_schedule, epoch_schedule,
@ -11843,6 +11844,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
) )
.unwrap(); .unwrap();
} }
@ -12247,6 +12249,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
), ),
Ok(_) Ok(_)
); );
@ -12261,6 +12264,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
), ),
Err(MissingBankHash) Err(MissingBankHash)
); );
@ -12284,6 +12288,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
), ),
Err(MismatchedBankHash) Err(MismatchedBankHash)
); );
@ -12313,6 +12318,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
), ),
Ok(_) Ok(_)
); );
@ -12335,12 +12341,13 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
), ),
Ok(_) Ok(_)
); );
assert_matches!( assert_matches!(
db.verify_bank_hash_and_lamports(some_slot, &ancestors, 10, true, &EpochSchedule::default(), &RentCollector::default(), true,), db.verify_bank_hash_and_lamports(some_slot, &ancestors, 10, true, &EpochSchedule::default(), &RentCollector::default(), true, false,),
Err(MismatchedTotalLamports(expected, actual)) if expected == 2 && actual == 10 Err(MismatchedTotalLamports(expected, actual)) if expected == 2 && actual == 10
); );
} }
@ -12368,6 +12375,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
), ),
Ok(_) Ok(_)
); );
@ -12412,6 +12420,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
), ),
Err(MismatchedBankHash) Err(MismatchedBankHash)
); );
@ -13032,6 +13041,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
) )
.unwrap(); .unwrap();
@ -13045,6 +13055,7 @@ pub mod tests {
&EpochSchedule::default(), &EpochSchedule::default(),
&RentCollector::default(), &RentCollector::default(),
true, true,
false,
) )
.unwrap(); .unwrap();

View File

@ -7010,6 +7010,8 @@ impl Bank {
config.ignore_mismatch, config.ignore_mismatch,
config.store_hash_raw_data_for_debug, config.store_hash_raw_data_for_debug,
enable_rehashing, enable_rehashing,
// true to run using bg thread pool
true,
); );
accounts_ accounts_
.accounts_db .accounts_db
@ -7031,6 +7033,8 @@ impl Bank {
config.ignore_mismatch, config.ignore_mismatch,
config.store_hash_raw_data_for_debug, config.store_hash_raw_data_for_debug,
enable_rehashing, enable_rehashing,
// fg is waiting for this to run, so we can use the fg thread pool
false,
); );
self.set_initial_accounts_hash_verification_completed(); self.set_initial_accounts_hash_verification_completed();
result result