Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Add base_slot to get_snapshot_storages() #19348

Merged
merged 2 commits into from
Aug 20, 2021

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Aug 20, 2021

Problem

When taking a bank snapshot that is destined to be an incremental snapshot, we collect all the snapshot storages, then immediately filter/throw out the ones below the incremental snapshot base slot (aka last full snapshot slot). Ideally, we'd only collect the snapshot storages that we needed in the first place.

Summary of Changes

Add a snapshot_base_slot optional parameter to get_snapshot_storages(), and filter/retain only slots higher.

Related to #17088

@@ -788,7 +788,7 @@ mod tests {
.find(|elem| elem.slot == slot)
.ok_or_else(|| Error::new(ErrorKind::Other, "did not find snapshot with this path"))?;
let storages = {
let mut storages = bank.get_snapshot_storages();
let mut storages = bank.get_snapshot_storages(Some(incremental_snapshot_base_slot));
snapshot_utils::filter_snapshot_storages_for_incremental_snapshot(
Copy link
Contributor Author

@brooksprumo brooksprumo Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to filter_snapshot_storages_for_incremental_snapshot() will be removed in the next PR (#19349). I am trying to keep PRs as minimal as possible :)

Comment on lines -487 to -492
pub fn get_snapshot_storages(&self, slot: Slot) -> SnapshotStorages {
self.accounts
.accounts_db
.get_snapshot_storages(slot, None)
.0
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is never called, except by Bank below, so I've just moved it there.

@@ -1636,7 +1636,7 @@ pub fn bank_to_incremental_snapshot_archive(

let temp_dir = tempfile::tempdir_in(snapshots_dir)?;
let storages = {
let mut storages = bank.get_snapshot_storages();
let mut storages = bank.get_snapshot_storages(Some(full_snapshot_slot));
filter_snapshot_storages_for_incremental_snapshot(&mut storages, full_snapshot_slot);
Copy link
Contributor Author

@brooksprumo brooksprumo Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to filter_snapshot_storages_for_incremental_snapshot() will be removed in the next PR (#19349).

@brooksprumo brooksprumo marked this pull request as ready for review August 20, 2021 18:45
@codecov
Copy link

codecov bot commented Aug 20, 2021

Codecov Report

Merging #19348 (609c2a3) into master (f8fefc9) will decrease coverage by 0.0%.
The diff coverage is 78.7%.

@@            Coverage Diff            @@
##           master   #19348     +/-   ##
=========================================
- Coverage    82.8%    82.8%   -0.1%     
=========================================
  Files         457      457             
  Lines      130654   130690     +36     
=========================================
+ Hits       108282   108290      +8     
- Misses      22372    22400     +28     

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants