add Copy trait to AccountInfo for fast copies to mmapped file (#19524)
This commit is contained in:
committed by
GitHub
parent
c550b32a44
commit
12dc8749cf
@ -212,7 +212,7 @@ impl GenerateIndexTimings {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Clone)]
|
||||
#[derive(Default, Debug, PartialEq, Clone, Copy)]
|
||||
pub struct AccountInfo {
|
||||
/// index identifying the append storage
|
||||
store_id: AppendVecId,
|
||||
@ -7933,12 +7933,12 @@ pub mod tests {
|
||||
let (slot1, account_info1) = accounts
|
||||
.accounts_index
|
||||
.get(&pubkey1, Some(&ancestors), None)
|
||||
.map(|(account_list1, index1)| account_list1.slot_list()[index1].clone())
|
||||
.map(|(account_list1, index1)| account_list1.slot_list()[index1])
|
||||
.unwrap();
|
||||
let (slot2, account_info2) = accounts
|
||||
.accounts_index
|
||||
.get(&pubkey2, Some(&ancestors), None)
|
||||
.map(|(account_list2, index2)| account_list2.slot_list()[index2].clone())
|
||||
.map(|(account_list2, index2)| account_list2.slot_list()[index2])
|
||||
.unwrap();
|
||||
assert_eq!(slot1, 0);
|
||||
assert_eq!(slot1, slot2);
|
||||
@ -8490,12 +8490,12 @@ pub mod tests {
|
||||
let (slot1, account_info1) = accounts
|
||||
.accounts_index
|
||||
.get(&pubkey, None, None)
|
||||
.map(|(account_list1, index1)| account_list1.slot_list()[index1].clone())
|
||||
.map(|(account_list1, index1)| account_list1.slot_list()[index1])
|
||||
.unwrap();
|
||||
let (slot2, account_info2) = accounts
|
||||
.accounts_index
|
||||
.get(&pubkey2, None, None)
|
||||
.map(|(account_list2, index2)| account_list2.slot_list()[index2].clone())
|
||||
.map(|(account_list2, index2)| account_list2.slot_list()[index2])
|
||||
.unwrap();
|
||||
assert_eq!(slot1, current_slot);
|
||||
assert_eq!(slot1, slot2);
|
||||
@ -10324,7 +10324,7 @@ pub mod tests {
|
||||
&Pubkey::default(),
|
||||
&[],
|
||||
&AccountSecondaryIndexes::default(),
|
||||
info1.clone(),
|
||||
info1,
|
||||
&mut reclaims,
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
@ -10344,7 +10344,7 @@ pub mod tests {
|
||||
&Pubkey::default(),
|
||||
&[],
|
||||
&AccountSecondaryIndexes::default(),
|
||||
info2.clone(),
|
||||
info2,
|
||||
&mut reclaims,
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
@ -11142,7 +11142,7 @@ pub mod tests {
|
||||
.get_account_read_entry(&account.meta.pubkey)
|
||||
.map(|locked_entry| {
|
||||
// Should only be one entry per key, since every key was only stored to slot 0
|
||||
locked_entry.slot_list()[0].clone()
|
||||
locked_entry.slot_list()[0]
|
||||
})
|
||||
.unwrap();
|
||||
let removed_data_size = account_info.1.stored_size;
|
||||
|
@ -46,7 +46,7 @@ pub type AccountMap<V> = HashMap<Pubkey, V>;
|
||||
|
||||
type AccountMapEntry<T> = Arc<AccountMapEntryInner<T>>;
|
||||
|
||||
pub trait IsCached: 'static + Clone + Debug + PartialEq + ZeroLamport {
|
||||
pub trait IsCached: 'static + Clone + Debug + PartialEq + ZeroLamport + Copy {
|
||||
fn is_cached(&self) -> bool;
|
||||
}
|
||||
|
||||
@ -1363,7 +1363,7 @@ impl<T: IsCached> AccountsIndex<T> {
|
||||
slot_list.retain(|(slot, item)| {
|
||||
let should_purge = slots_to_purge.contains(slot);
|
||||
if should_purge {
|
||||
reclaims.push((*slot, item.clone()));
|
||||
reclaims.push((*slot, *item));
|
||||
false
|
||||
} else {
|
||||
true
|
||||
@ -1709,7 +1709,7 @@ impl<T: IsCached> AccountsIndex<T> {
|
||||
Self::can_purge_older_entries(max_clean_root, newest_root_in_slot_list, *slot)
|
||||
&& !value.is_cached();
|
||||
if should_purge {
|
||||
reclaims.push((*slot, value.clone()));
|
||||
reclaims.push((*slot, *value));
|
||||
}
|
||||
!should_purge
|
||||
});
|
||||
@ -2885,12 +2885,12 @@ pub mod tests {
|
||||
&Pubkey::default(),
|
||||
&[],
|
||||
&AccountSecondaryIndexes::default(),
|
||||
account_infos[0].clone(),
|
||||
account_infos[0],
|
||||
&mut gc,
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
} else {
|
||||
let items = vec![(key, account_infos[0].clone())];
|
||||
let items = vec![(key, account_infos[0])];
|
||||
index.insert_new_if_missing_into_primary_index(slot0, items.len(), items.into_iter());
|
||||
}
|
||||
assert!(gc.is_empty());
|
||||
@ -2899,10 +2899,9 @@ pub mod tests {
|
||||
{
|
||||
let entry = index.get_account_read_entry(&key).unwrap();
|
||||
assert_eq!(entry.ref_count(), if is_cached { 0 } else { 1 });
|
||||
let expected = vec![(slot0, account_infos[0].clone())];
|
||||
let expected = vec![(slot0, account_infos[0])];
|
||||
assert_eq!(entry.slot_list().to_vec(), expected);
|
||||
let new_entry =
|
||||
WriteAccountMapEntry::new_entry_after_update(slot0, account_infos[0].clone());
|
||||
let new_entry = WriteAccountMapEntry::new_entry_after_update(slot0, account_infos[0]);
|
||||
assert_eq!(
|
||||
entry.slot_list().to_vec(),
|
||||
new_entry.slot_list.read().unwrap().to_vec(),
|
||||
@ -2917,12 +2916,12 @@ pub mod tests {
|
||||
&Pubkey::default(),
|
||||
&[],
|
||||
&AccountSecondaryIndexes::default(),
|
||||
account_infos[1].clone(),
|
||||
account_infos[1],
|
||||
&mut gc,
|
||||
UPSERT_PREVIOUS_SLOT_ENTRY_WAS_CACHED_FALSE,
|
||||
);
|
||||
} else {
|
||||
let items = vec![(key, account_infos[1].clone())];
|
||||
let items = vec![(key, account_infos[1])];
|
||||
index.insert_new_if_missing_into_primary_index(slot1, items.len(), items.into_iter());
|
||||
}
|
||||
assert!(gc.is_empty());
|
||||
@ -2945,14 +2944,10 @@ pub mod tests {
|
||||
assert_eq!(entry.ref_count(), if is_cached { 0 } else { 2 });
|
||||
assert_eq!(
|
||||
entry.slot_list().to_vec(),
|
||||
vec![
|
||||
(slot0, account_infos[0].clone()),
|
||||
(slot1, account_infos[1].clone())
|
||||
]
|
||||
vec![(slot0, account_infos[0]), (slot1, account_infos[1])]
|
||||
);
|
||||
|
||||
let new_entry =
|
||||
WriteAccountMapEntry::new_entry_after_update(slot1, account_infos[1].clone());
|
||||
let new_entry = WriteAccountMapEntry::new_entry_after_update(slot1, account_infos[1]);
|
||||
assert_eq!(entry.slot_list()[1], new_entry.slot_list.read().unwrap()[0],);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user