Skip to content

Commit

Permalink
Refactors storage flushing when taking a snapshot (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Apr 1, 2024
1 parent 620f565 commit bc7b274
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 7 additions & 0 deletions runtime/src/snapshot_bank_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ pub fn add_bank_snapshot(
bank_snapshot_path.display(),
);

let (_, measure_flush) = measure!(for storage in snapshot_storages {
storage
.flush()
.map_err(|err| AddBankSnapshotError::FlushStorage(err, storage.get_path()))?;
});

// We are constructing the snapshot directory to contain the full snapshot state information to allow
// constructing a bank from this directory. It acts like an archive to include the full state.
// The set of the account storages files is the necessary part of this snapshot state. Hard-link them
Expand Down Expand Up @@ -157,6 +163,7 @@ pub fn add_bank_snapshot(
("slot", slot, i64),
("bank_size", bank_snapshot_consumed_size, i64),
("status_cache_size", status_cache_consumed_size, i64),
("flush_storages_us", measure_flush.as_us(), i64),
("hard_link_storages_us", measure_hard_linking.as_us(), i64),
("bank_serialize_us", bank_serialize.as_us(), i64),
(
Expand Down
9 changes: 3 additions & 6 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ pub enum AddBankSnapshotError {
#[error("failed to create snapshot dir '{1}': {0}")]
CreateSnapshotDir(#[source] IoError, PathBuf),

#[error("failed to flush storage '{1}': {0}")]
FlushStorage(#[source] AccountsFileError, PathBuf),

#[error("failed to hard link storages: {0}")]
HardLinkStorages(#[source] HardLinkStoragesToSnapshotError),

Expand Down Expand Up @@ -507,9 +510,6 @@ pub enum HardLinkStoragesToSnapshotError {
#[error("failed to create accounts hard links dir '{1}': {0}")]
CreateAccountsHardLinksDir(#[source] IoError, PathBuf),

#[error("failed to flush storage: {0}")]
FlushStorage(#[source] AccountsFileError),

#[error("failed to get the snapshot's accounts hard link dir: {0}")]
GetSnapshotHardLinksDir(#[from] GetSnapshotAccountsHardLinkDirError),

Expand Down Expand Up @@ -1259,9 +1259,6 @@ pub fn hard_link_storages_to_snapshot(

let mut account_paths: HashSet<PathBuf> = HashSet::new();
for storage in snapshot_storages {
storage
.flush()
.map_err(HardLinkStoragesToSnapshotError::FlushStorage)?;
let storage_path = storage.accounts.get_path();
let snapshot_hardlink_dir = get_snapshot_accounts_hardlink_dir(
&storage_path,
Expand Down

0 comments on commit bc7b274

Please sign in to comment.