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>, ancestors: Option<&Ancestors>,
) -> (SnapshotStorages, Vec<Slot>) { ) -> (SnapshotStorages, Vec<Slot>) {
let mut m = Measure::start("get slots"); let mut m = Measure::start("get slots");
let slots = self let slots_and_storages = self
.storage .storage
.iter() .iter()
.filter_map(|entry| { .filter_map(|entry| {
@ -8528,32 +8528,26 @@ impl AccountsDb {
let chunk_size = 5_000; let chunk_size = 5_000;
let wide = self.thread_pool_clean.install(|| { let wide = self.thread_pool_clean.install(|| {
slots slots_and_storages
.par_chunks(chunk_size) .par_chunks(chunk_size)
.map(|slots| { .map(|slots_and_storages| {
slots slots_and_storages
.iter() .iter()
.filter_map(|(slot, storages)| { .filter(|(slot, _)| {
if self.accounts_index.is_alive_root(*slot) self.accounts_index.is_alive_root(*slot)
|| ancestors || ancestors
.map(|ancestors| ancestors.contains_key(slot)) .map(|ancestors| ancestors.contains_key(slot))
.unwrap_or_default() .unwrap_or_default()
{ })
let storages = storages .filter_map(|(slot, storages)| {
.read() let storages = storages
.unwrap() .read()
.values() .unwrap()
.filter(|x| x.has_accounts()) .values()
.cloned() .filter(|x| x.has_accounts())
.collect::<Vec<_>>(); .cloned()
if !storages.is_empty() { .collect::<Vec<_>>();
Some((storages, *slot)) (!storages.is_empty()).then_some((storages, *slot))
} else {
None
}
} else {
None
}
}) })
.collect::<Vec<(SnapshotStorage, Slot)>>() .collect::<Vec<(SnapshotStorage, Slot)>>()
}) })
@ -8563,7 +8557,7 @@ impl AccountsDb {
let mut m3 = Measure::start("flatten"); let mut m3 = Measure::start("flatten");
// some slots we found above may not have been a root or met the slot # constraint. // 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. // 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 let result = wide
.into_iter() .into_iter()
.flatten() .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. \ .help("Enables faster starting of validators by skipping shrink. \
This option is for use during testing."), 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(
Arg::with_name("accounts_db_ancient_append_vecs") Arg::with_name("accounts_db_ancient_append_vecs")
.long("accounts-db-ancient-append-vecs") .long("accounts-db-ancient-append-vecs")