-
Notifications
You must be signed in to change notification settings - Fork 1k
v2.1: Refactors get_snapshot_storages() (backport of #3760) #3785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8278,44 +8278,27 @@ impl AccountsDb { | |
| &self, | ||
| requested_slots: impl RangeBounds<Slot> + Sync, | ||
| ) -> (Vec<Arc<AccountStorageEntry>>, Vec<Slot>) { | ||
| let mut m = Measure::start("get slots"); | ||
| let mut slots_and_storages = self | ||
| let start = Instant::now(); | ||
| let max_alive_root_exclusive = self | ||
| .accounts_index | ||
| .roots_tracker | ||
| .read() | ||
| .unwrap() | ||
| .alive_roots | ||
| .max_exclusive(); | ||
| let (slots, storages) = self | ||
| .storage | ||
| .iter() | ||
| .filter_map(|(slot, store)| { | ||
| requested_slots | ||
| .contains(&slot) | ||
| .then_some((slot, Some(store))) | ||
| .get_if(|slot, storage| { | ||
| (*slot < max_alive_root_exclusive) | ||
| && requested_slots.contains(slot) | ||
| && storage.has_accounts() | ||
| }) | ||
| .collect::<Vec<_>>(); | ||
| m.stop(); | ||
| let mut m2 = Measure::start("filter"); | ||
| let chunk_size = 5_000; | ||
| let (result, slots): (Vec<_>, Vec<_>) = self.thread_pool_clean.install(|| { | ||
| slots_and_storages | ||
| .par_chunks_mut(chunk_size) | ||
| .map(|slots_and_storages| { | ||
| slots_and_storages | ||
| .iter_mut() | ||
| .filter(|(slot, _)| self.accounts_index.is_alive_root(*slot)) | ||
| .filter_map(|(slot, store)| { | ||
| let store = std::mem::take(store).unwrap(); | ||
| store.has_accounts().then_some((store, *slot)) | ||
| }) | ||
| .collect::<Vec<(Arc<AccountStorageEntry>, Slot)>>() | ||
| }) | ||
| .flatten() | ||
| .unzip() | ||
| }); | ||
|
|
||
| m2.stop(); | ||
|
|
||
| debug!( | ||
| "hash_total: get slots: {}, filter: {}", | ||
| m.as_us(), | ||
| m2.as_us(), | ||
| ); | ||
| (result, slots) | ||
| .into_vec() | ||
| .into_iter() | ||
| .unzip(); | ||
|
Comment on lines
+8296
to
+8298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This For the unzip, we can refactor that as well. I'd love to do that. I didn't want to do that in a backport though. So we keep the same return types and keep the PR small. (Note in the original we also unzip, so we're not adding an unzip here in the backport. We also know that the backport is faster too.) |
||
| let duration = start.elapsed(); | ||
| debug!("get_snapshot_storages: {duration:?}"); | ||
| (storages, slots) | ||
| } | ||
|
|
||
| /// Returns the latest full snapshot slot | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assert does exist in the old version as well.
In the old version we do:
agave/accounts-db/src/accounts_db.rs
Lines 8276 to 8284 in d07fc9b
and that
.iter()also has the assert:agave/accounts-db/src/account_storage.rs
Lines 140 to 144 in d07fc9b