cleanup get_snapshot_storages (#29488)

* cleanup get_snapshot_storages

* pr feedback
This commit is contained in:
Jeff Washington (jwash) 2023-01-03 14:22:28 -06:00 committed by GitHub
parent 95d2f002bd
commit 0f2bfa2b02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 30 deletions

View File

@ -8513,7 +8513,7 @@ impl AccountsDb {
ancestors: Option<&Ancestors>,
) -> (SnapshotStorages, Vec<Slot>) {
let mut m = Measure::start("get slots");
let slots = self
let slots_and_storages = self
.storage
.iter()
.filter_map(|entry| {
@ -8528,32 +8528,26 @@ impl AccountsDb {
let chunk_size = 5_000;
let wide = self.thread_pool_clean.install(|| {
slots
slots_and_storages
.par_chunks(chunk_size)
.map(|slots| {
slots
.map(|slots_and_storages| {
slots_and_storages
.iter()
.filter_map(|(slot, storages)| {
if self.accounts_index.is_alive_root(*slot)
.filter(|(slot, _)| {
self.accounts_index.is_alive_root(*slot)
|| ancestors
.map(|ancestors| ancestors.contains_key(slot))
.unwrap_or_default()
{
let storages = storages
.read()
.unwrap()
.values()
.filter(|x| x.has_accounts())
.cloned()
.collect::<Vec<_>>();
if !storages.is_empty() {
Some((storages, *slot))
} else {
None
}
} else {
None
}
})
.filter_map(|(slot, storages)| {
let storages = storages
.read()
.unwrap()
.values()
.filter(|x| x.has_accounts())
.cloned()
.collect::<Vec<_>>();
(!storages.is_empty()).then_some((storages, *slot))
})
.collect::<Vec<(SnapshotStorage, Slot)>>()
})
@ -8563,7 +8557,7 @@ impl AccountsDb {
let mut m3 = Measure::start("flatten");
// some slots we found above may not have been a root or met the slot # constraint.
// So the resulting 'slots' vector we return will be a subset of the raw keys we got initially.
let mut slots = Vec::with_capacity(slots.len());
let mut slots = Vec::with_capacity(slots_and_storages.len());
let result = wide
.into_iter()
.flatten()

View File

@ -1181,13 +1181,6 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> {
.help("Enables faster starting of validators by skipping shrink. \
This option is for use during testing."),
)
.arg(
Arg::with_name("accounts_db_skip_rewrites")
.long("accounts-db-skip-rewrites")
.help("Accounts that are rent exempt and have no changes are not rewritten. \
This produces snapshots that older versions cannot read.")
.hidden(true),
)
.arg(
Arg::with_name("accounts_db_ancient_append_vecs")
.long("accounts-db-ancient-append-vecs")