refactor get_store_for_shrink (#22307)
This commit is contained in:
committed by
GitHub
parent
705084a25b
commit
100293c4b5
@ -2736,26 +2736,8 @@ impl AccountsDb {
|
|||||||
start.stop();
|
start.stop();
|
||||||
find_alive_elapsed = start.as_us();
|
find_alive_elapsed = start.as_us();
|
||||||
|
|
||||||
let mut start = Measure::start("create_and_insert_store_elapsed");
|
let (shrunken_store, time) = self.get_store_for_shrink(slot, aligned_total);
|
||||||
let shrunken_store = if let Some(new_store) =
|
create_and_insert_store_elapsed = time;
|
||||||
self.try_recycle_and_insert_store(slot, aligned_total, aligned_total + 1024)
|
|
||||||
{
|
|
||||||
new_store
|
|
||||||
} else {
|
|
||||||
let maybe_shrink_paths = self.shrink_paths.read().unwrap();
|
|
||||||
if let Some(ref shrink_paths) = *maybe_shrink_paths {
|
|
||||||
self.create_and_insert_store_with_paths(
|
|
||||||
slot,
|
|
||||||
aligned_total,
|
|
||||||
"shrink-w-path",
|
|
||||||
shrink_paths,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
self.create_and_insert_store(slot, aligned_total, "shrink")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
start.stop();
|
|
||||||
create_and_insert_store_elapsed = start.as_us();
|
|
||||||
|
|
||||||
// here, we're writing back alive_accounts. That should be an atomic operation
|
// here, we're writing back alive_accounts. That should be an atomic operation
|
||||||
// without use of rather wide locks in this whole function, because we're
|
// without use of rather wide locks in this whole function, because we're
|
||||||
@ -2864,6 +2846,34 @@ impl AccountsDb {
|
|||||||
total_accounts_after_shrink
|
total_accounts_after_shrink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// return a store that can contain 'aligned_total' bytes and the time it took to execute
|
||||||
|
fn get_store_for_shrink(
|
||||||
|
&self,
|
||||||
|
slot: Slot,
|
||||||
|
aligned_total: u64,
|
||||||
|
) -> (Arc<AccountStorageEntry>, u64) {
|
||||||
|
let mut start = Measure::start("create_and_insert_store_elapsed");
|
||||||
|
let shrunken_store = if let Some(new_store) =
|
||||||
|
self.try_recycle_and_insert_store(slot, aligned_total, aligned_total + 1024)
|
||||||
|
{
|
||||||
|
new_store
|
||||||
|
} else {
|
||||||
|
let maybe_shrink_paths = self.shrink_paths.read().unwrap();
|
||||||
|
if let Some(ref shrink_paths) = *maybe_shrink_paths {
|
||||||
|
self.create_and_insert_store_with_paths(
|
||||||
|
slot,
|
||||||
|
aligned_total,
|
||||||
|
"shrink-w-path",
|
||||||
|
shrink_paths,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
self.create_and_insert_store(slot, aligned_total, "shrink")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
start.stop();
|
||||||
|
(shrunken_store, start.as_us())
|
||||||
|
}
|
||||||
|
|
||||||
// Reads all accounts in given slot's AppendVecs and filter only to alive,
|
// Reads all accounts in given slot's AppendVecs and filter only to alive,
|
||||||
// then create a minimum AppendVec filled with the alive.
|
// then create a minimum AppendVec filled with the alive.
|
||||||
fn shrink_slot_forced(&self, slot: Slot) -> usize {
|
fn shrink_slot_forced(&self, slot: Slot) -> usize {
|
||||||
|
Reference in New Issue
Block a user