Compute accounts data len during generate_index() (#21757)

This commit is contained in:
Brooks Prumo
2021-12-10 13:27:59 -06:00
committed by GitHub
parent 15a9fa6f53
commit ec7e17787e
3 changed files with 102 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ use {
accounts::Accounts,
accounts_db::{
AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AccountsDbConfig, AppendVecId,
BankHashInfo,
BankHashInfo, IndexGenerationInfo,
},
accounts_index::AccountSecondaryIndexes,
accounts_update_notifier_interface::AccountsUpdateNotifier,
@@ -334,7 +334,7 @@ fn reconstruct_bank_from_fields<E>(
where
E: SerializableStorage + std::marker::Sync,
{
let accounts_db = reconstruct_accountsdb_from_fields(
let (accounts_db, reconstructed_accounts_db_info) = reconstruct_accountsdb_from_fields(
snapshot_accounts_db_fields,
account_paths,
unpacked_append_vec_map,
@@ -347,6 +347,10 @@ where
accounts_db_config,
accounts_update_notifier,
)?;
debug!(
"accounts data len: {}",
reconstructed_accounts_db_info.accounts_data_len
);
let bank_rc = BankRc::new(Accounts::new_empty(accounts_db), bank_fields.slot);
@@ -386,6 +390,12 @@ where
Ok(())
}
/// This struct contains side-info while reconstructing the accounts DB from fields.
#[derive(Debug, Default, Copy, Clone)]
struct ReconstructedAccountsDbInfo {
accounts_data_len: u64,
}
#[allow(clippy::too_many_arguments)]
fn reconstruct_accountsdb_from_fields<E>(
snapshot_accounts_db_fields: SnapshotAccountsDbFields<E>,
@@ -399,7 +409,7 @@ fn reconstruct_accountsdb_from_fields<E>(
verify_index: bool,
accounts_db_config: Option<AccountsDbConfig>,
accounts_update_notifier: Option<AccountsUpdateNotifier>,
) -> Result<AccountsDb, Error>
) -> Result<(AccountsDb, ReconstructedAccountsDbInfo), Error>
where
E: SerializableStorage + std::marker::Sync,
{
@@ -536,11 +546,12 @@ where
})
.unwrap();
let _ = accounts_db.generate_index(
let IndexGenerationInfo { accounts_data_len } = accounts_db.generate_index(
limit_load_slot_count_from_snapshot,
verify_index,
genesis_config,
);
accounts_db.maybe_add_filler_accounts(&genesis_config.epoch_schedule);
handle.join().unwrap();
@@ -557,5 +568,8 @@ where
("accountsdb-notify-at-start-us", measure_notify.as_us(), i64),
);
Ok(Arc::try_unwrap(accounts_db).unwrap())
Ok((
Arc::try_unwrap(accounts_db).unwrap(),
ReconstructedAccountsDbInfo { accounts_data_len },
))
}