is_cached_store, bool -> Storage enum (#30057)
This commit is contained in:
parent
0cf93da4b4
commit
5769dbf36b
|
@ -161,6 +161,14 @@ pub enum CreateAncientStorage {
|
|||
Pack,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
enum StoreTo {
|
||||
/// write to cache
|
||||
Cache,
|
||||
/// write to storage
|
||||
Storage,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
/// hold alive accounts and bytes used by those accounts
|
||||
/// alive means in the accounts index
|
||||
|
@ -6575,7 +6583,7 @@ impl AccountsDb {
|
|||
hashes: Option<Vec<impl Borrow<Hash>>>,
|
||||
storage_finder: F,
|
||||
mut write_version_producer: P,
|
||||
is_cached_store: bool,
|
||||
store_to: StoreTo,
|
||||
txn_signatures: Option<&[Option<&'a Signature>]>,
|
||||
) -> Vec<AccountInfo> {
|
||||
let mut calc_stored_meta_time = Measure::start("calc_stored_meta");
|
||||
|
@ -6589,7 +6597,7 @@ impl AccountsDb {
|
|||
.calc_stored_meta
|
||||
.fetch_add(calc_stored_meta_time.as_us(), Ordering::Relaxed);
|
||||
|
||||
if is_cached_store {
|
||||
if store_to == StoreTo::Cache {
|
||||
let signature_iter: Box<dyn std::iter::Iterator<Item = &Option<&Signature>>> =
|
||||
match txn_signatures {
|
||||
Some(txn_signatures) => {
|
||||
|
@ -8163,7 +8171,12 @@ impl AccountsDb {
|
|||
accounts: impl StorableAccounts<'a, T>,
|
||||
txn_signatures: Option<&'a [Option<&'a Signature>]>,
|
||||
) {
|
||||
self.store(accounts, true, txn_signatures, StoreReclaims::Default);
|
||||
self.store(
|
||||
accounts,
|
||||
StoreTo::Cache,
|
||||
txn_signatures,
|
||||
StoreReclaims::Default,
|
||||
);
|
||||
}
|
||||
|
||||
/// Store the account update.
|
||||
|
@ -8171,7 +8184,7 @@ impl AccountsDb {
|
|||
pub fn store_uncached(&self, slot: Slot, accounts: &[(&Pubkey, &AccountSharedData)]) {
|
||||
self.store(
|
||||
(slot, accounts, INCLUDE_SLOT_IN_HASH_TESTS),
|
||||
false,
|
||||
StoreTo::Storage,
|
||||
None,
|
||||
StoreReclaims::Default,
|
||||
);
|
||||
|
@ -8180,7 +8193,7 @@ impl AccountsDb {
|
|||
fn store<'a, T: ReadableAccount + Sync + ZeroLamport + 'a>(
|
||||
&self,
|
||||
accounts: impl StorableAccounts<'a, T>,
|
||||
is_cached_store: bool,
|
||||
store_to: StoreTo,
|
||||
txn_signatures: Option<&'a [Option<&'a Signature>]>,
|
||||
reclaim: StoreReclaims,
|
||||
) {
|
||||
|
@ -8216,7 +8229,7 @@ impl AccountsDb {
|
|||
self.store_accounts_unfrozen(
|
||||
accounts,
|
||||
None::<Vec<Hash>>,
|
||||
is_cached_store,
|
||||
store_to,
|
||||
txn_signatures,
|
||||
reclaim,
|
||||
);
|
||||
|
@ -8350,7 +8363,7 @@ impl AccountsDb {
|
|||
&self,
|
||||
accounts: impl StorableAccounts<'a, T>,
|
||||
hashes: Option<Vec<impl Borrow<Hash>>>,
|
||||
is_cached_store: bool,
|
||||
store_to: StoreTo,
|
||||
txn_signatures: Option<&'a [Option<&'a Signature>]>,
|
||||
reclaim: StoreReclaims,
|
||||
) {
|
||||
|
@ -8367,7 +8380,7 @@ impl AccountsDb {
|
|||
hashes,
|
||||
None,
|
||||
None::<Box<dyn Iterator<Item = u64>>>,
|
||||
is_cached_store,
|
||||
store_to,
|
||||
reset_accounts,
|
||||
txn_signatures,
|
||||
reclaim,
|
||||
|
@ -8386,13 +8399,12 @@ impl AccountsDb {
|
|||
// the append vec so that hashing could happen on the store
|
||||
// and accounts in the append_vec can be unrefed correctly
|
||||
let reset_accounts = false;
|
||||
let is_cached_store = false;
|
||||
self.store_accounts_custom(
|
||||
accounts,
|
||||
hashes,
|
||||
storage,
|
||||
write_version_producer,
|
||||
is_cached_store,
|
||||
StoreTo::Storage,
|
||||
reset_accounts,
|
||||
None,
|
||||
reclaim,
|
||||
|
@ -8405,7 +8417,7 @@ impl AccountsDb {
|
|||
hashes: Option<Vec<impl Borrow<Hash>>>,
|
||||
storage: Option<&Arc<AccountStorageEntry>>,
|
||||
write_version_producer: Option<Box<dyn Iterator<Item = u64>>>,
|
||||
is_cached_store: bool,
|
||||
store_to: StoreTo,
|
||||
reset_accounts: bool,
|
||||
txn_signatures: Option<&[Option<&Signature>]>,
|
||||
reclaim: StoreReclaims,
|
||||
|
@ -8435,7 +8447,7 @@ impl AccountsDb {
|
|||
hashes,
|
||||
storage_finder,
|
||||
write_version_producer,
|
||||
is_cached_store,
|
||||
store_to,
|
||||
txn_signatures,
|
||||
);
|
||||
store_accounts_time.stop();
|
||||
|
@ -8446,7 +8458,7 @@ impl AccountsDb {
|
|||
|
||||
let reclaim = if matches!(reclaim, StoreReclaims::Ignore) {
|
||||
UpsertReclaim::IgnoreReclaims
|
||||
} else if is_cached_store {
|
||||
} else if store_to == StoreTo::Cache {
|
||||
UpsertReclaim::PreviousSlotEntryWasCached
|
||||
} else {
|
||||
UpsertReclaim::PopulateReclaims
|
||||
|
@ -8469,7 +8481,7 @@ impl AccountsDb {
|
|||
// entries
|
||||
reclaims.retain(|(_, r)| !r.is_cached());
|
||||
|
||||
if is_cached_store {
|
||||
if store_to == StoreTo::Cache {
|
||||
assert!(reclaims.is_empty());
|
||||
}
|
||||
|
||||
|
@ -12377,7 +12389,7 @@ pub mod tests {
|
|||
db.store_accounts_unfrozen(
|
||||
(some_slot, &[(&key, &account)][..]),
|
||||
Some(vec![&Hash::default()]),
|
||||
false,
|
||||
StoreTo::Storage,
|
||||
None,
|
||||
StoreReclaims::Default,
|
||||
);
|
||||
|
@ -12645,7 +12657,7 @@ pub mod tests {
|
|||
db.store_accounts_unfrozen(
|
||||
(some_slot, accounts),
|
||||
Some(vec![&some_hash]),
|
||||
false,
|
||||
StoreTo::Storage,
|
||||
None,
|
||||
StoreReclaims::Default,
|
||||
);
|
||||
|
@ -16066,7 +16078,7 @@ pub mod tests {
|
|||
pub fn store_for_tests(&self, slot: Slot, accounts: &[(&Pubkey, &AccountSharedData)]) {
|
||||
self.store(
|
||||
(slot, accounts, INCLUDE_SLOT_IN_HASH_TESTS),
|
||||
true,
|
||||
StoreTo::Cache,
|
||||
None,
|
||||
StoreReclaims::Default,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue