Co-authored-by: Carl Lin <carl@solana.com>
(cherry picked from commit 592013eaf4
)
Co-authored-by: sakridge <sakridge@gmail.com>
This commit is contained in:
@ -2472,12 +2472,20 @@ impl AccountsDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn shrink_all_slots(&self, is_startup: bool) {
|
pub fn shrink_all_slots(&self, is_startup: bool) {
|
||||||
|
const DIRTY_STORES_CLEANING_THRESHOLD: usize = 10_000;
|
||||||
|
const OUTER_CHUNK_SIZE: usize = 2000;
|
||||||
|
const INNER_CHUNK_SIZE: usize = OUTER_CHUNK_SIZE / 8;
|
||||||
if is_startup && self.caching_enabled {
|
if is_startup && self.caching_enabled {
|
||||||
let slots = self.all_slots_in_storage();
|
let slots = self.all_slots_in_storage();
|
||||||
let chunk_size = std::cmp::max(slots.len() / 8, 1); // approximately 400k slots in a snapshot
|
let inner_chunk_size = std::cmp::max(INNER_CHUNK_SIZE, 1);
|
||||||
slots.par_chunks(chunk_size).for_each(|slots| {
|
slots.chunks(OUTER_CHUNK_SIZE).for_each(|chunk| {
|
||||||
for slot in slots {
|
chunk.par_chunks(inner_chunk_size).for_each(|slots| {
|
||||||
self.shrink_slot_forced(*slot, is_startup);
|
for slot in slots {
|
||||||
|
self.shrink_slot_forced(*slot, is_startup);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if self.dirty_stores.len() > DIRTY_STORES_CLEANING_THRESHOLD {
|
||||||
|
self.clean_accounts(None, is_startup);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -2487,6 +2495,9 @@ impl AccountsDb {
|
|||||||
} else {
|
} else {
|
||||||
self.do_shrink_slot_forced_v1(slot);
|
self.do_shrink_slot_forced_v1(slot);
|
||||||
}
|
}
|
||||||
|
if self.dirty_stores.len() > DIRTY_STORES_CLEANING_THRESHOLD {
|
||||||
|
self.clean_accounts(None, is_startup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user