Skip to content

Commit

Permalink
cleanup get_snapshot_storages (#29488)
Browse files Browse the repository at this point in the history
* cleanup get_snapshot_storages

* pr feedback
  • Loading branch information
jeffwashington authored Jan 3, 2023
1 parent 95d2f00 commit 0f2bfa2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
40 changes: 17 additions & 23 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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)>>()
})
Expand All @@ -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()
Expand Down
7 changes: 0 additions & 7 deletions validator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0f2bfa2

Please sign in to comment.