mark_dirty_dead_stores (#25114)
This commit is contained in:
parent
e9e267947e
commit
dc6e28099b
|
@ -2835,18 +2835,7 @@ impl AccountsDb {
|
||||||
|
|
||||||
// Purge old, overwritten storage entries
|
// Purge old, overwritten storage entries
|
||||||
let mut start = Measure::start("write_storage_elapsed");
|
let mut start = Measure::start("write_storage_elapsed");
|
||||||
if let Some(slot_stores) = self.storage.get_slot_stores(slot) {
|
self.mark_dirty_dead_stores(slot, &mut dead_storages, |store| store.count() > 0);
|
||||||
slot_stores.write().unwrap().retain(|_key, store| {
|
|
||||||
if store.count() == 0 {
|
|
||||||
self.dirty_stores
|
|
||||||
.insert((slot, store.append_vec_id()), store.clone());
|
|
||||||
dead_storages.push(store.clone());
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
start.stop();
|
start.stop();
|
||||||
write_storage_elapsed = start.as_us();
|
write_storage_elapsed = start.as_us();
|
||||||
}
|
}
|
||||||
|
@ -2901,6 +2890,29 @@ impl AccountsDb {
|
||||||
total_accounts_after_shrink
|
total_accounts_after_shrink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// get stores for 'slot'
|
||||||
|
/// retain only the stores where 'should_retain(store)' == true
|
||||||
|
/// for stores not retained, insert in 'dirty_stores' and 'dead_storages'
|
||||||
|
fn mark_dirty_dead_stores(
|
||||||
|
&self,
|
||||||
|
slot: Slot,
|
||||||
|
dead_storages: &mut Vec<Arc<AccountStorageEntry>>,
|
||||||
|
should_retain: impl Fn(&AccountStorageEntry) -> bool,
|
||||||
|
) {
|
||||||
|
if let Some(slot_stores) = self.storage.get_slot_stores(slot) {
|
||||||
|
slot_stores.write().unwrap().retain(|_key, store| {
|
||||||
|
if !should_retain(store) {
|
||||||
|
self.dirty_stores
|
||||||
|
.insert((slot, store.append_vec_id()), store.clone());
|
||||||
|
dead_storages.push(store.clone());
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn drop_or_recycle_stores(&self, dead_storages: Vec<Arc<AccountStorageEntry>>) {
|
fn drop_or_recycle_stores(&self, dead_storages: Vec<Arc<AccountStorageEntry>>) {
|
||||||
let mut recycle_stores_write_elapsed = Measure::start("recycle_stores_write_time");
|
let mut recycle_stores_write_elapsed = Measure::start("recycle_stores_write_time");
|
||||||
let mut recycle_stores = self.recycle_stores.write().unwrap();
|
let mut recycle_stores = self.recycle_stores.write().unwrap();
|
||||||
|
|
Loading…
Reference in New Issue