Skip to content
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

Add slot deltas into the bank snapshot directory #29409

Conversation

xiangzhu70
Copy link
Contributor

@xiangzhu70 xiangzhu70 commented Dec 24, 2022

Problem

The slot_deltas is a necessary part of the bank state, needed for reconstructing the bank. It should be serialized together with the bank.

Summary of Changes

Serialize the slot_deltas into the bank snapshot directory in add_bank_snapshot, so it is generated with the bank file. Move it out of the AccountsPackage data structure. When building the archive, instead of using the data structure inside the AccountsPackage, hard-link the serialized slot-delta file in the bank snapshot directory.

This is one of the split PRs from #28745

Fixes #

@xiangzhu70 xiangzhu70 force-pushed the add_slot_delta_into_bank_snapshot_dir branch from ec592c6 to d374097 Compare January 4, 2023 06:01
@xiangzhu70 xiangzhu70 marked this pull request as ready for review January 4, 2023 15:03
Copy link
Contributor

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

Biggest concern is forward/backward compatibility. It seems like the status_cache was moved. Did you manually test each of these cases?

  1. Old code loading a snapshot archive prepared w/ this change
  2. New code loading a snapshot archive prepared w/o this change
  3. New code loading a snapshot archive prepared w/ this change

runtime/src/accounts_background_service.rs Show resolved Hide resolved
runtime/src/snapshot_utils.rs Show resolved Hide resolved
runtime/src/snapshot_utils.rs Show resolved Hide resolved
runtime/src/snapshot_utils.rs Show resolved Hide resolved
@xiangzhu70
Copy link
Contributor Author

concern is forward/backward compatibility.

The status_cache in the archive is the same. So the compatibility should not be an issue.

It is just generated earlier in add_bank_snapshot(), and hard-linked into the archive staging directory, vs the old way of directly generated in the archive staging directory.

Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Looks good overall. Some comments and requested changes below.

runtime/src/snapshot_utils.rs Outdated Show resolved Hide resolved
runtime/src/snapshot_utils.rs Outdated Show resolved Hide resolved
@xiangzhu70 xiangzhu70 force-pushed the add_slot_delta_into_bank_snapshot_dir branch from 343c1f1 to a68ca25 Compare January 5, 2023 23:59
@brooksprumo brooksprumo self-requested a review January 6, 2023 03:21
Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Need to write something here so that Github will mark this as "reviewed"

I think only #29409 (comment) is remaining.

@github-actions github-actions bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Jan 27, 2023
@xiangzhu70 xiangzhu70 force-pushed the add_slot_delta_into_bank_snapshot_dir branch from 5d983ef to d31c4c3 Compare January 31, 2023 01:49
@github-actions github-actions bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Jan 31, 2023
Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Looking good! A few questions/nits below.

Also, now that the 1.15 branch has been created, you may need to rebase (according to: https://discord.com/channels/428295358100013066/439194979856809985/1070111773946024049)

runtime/src/snapshot_package.rs Outdated Show resolved Hide resolved
runtime/src/snapshot_utils.rs Outdated Show resolved Hide resolved
runtime/src/snapshot_utils.rs Outdated Show resolved Hide resolved
@xiangzhu70 xiangzhu70 force-pushed the add_slot_delta_into_bank_snapshot_dir branch from 6211469 to cb7116a Compare February 1, 2023 18:12
Copy link
Contributor

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

I'm happy with the change with a minor nit - leaving final approval to @brooksprumo since he's the expert in this area.

Comment on lines +167 to +168
let mut bank_snapshot_pre_path = bank_snapshot_post_path.clone();
bank_snapshot_pre_path.set_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems equivalent but w/o lingering mutability:

Suggested change
let mut bank_snapshot_pre_path = bank_snapshot_post_path.clone();
bank_snapshot_pre_path.set_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION);
let bank_snapshot_pre_path = bank_snapshot_post_path.with_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION);

Comment on lines +166 to +167
let bank_snapshot_post_path = bank_snapshot_dir.join(get_snapshot_file_name(slot));
let mut bank_snapshot_pre_path = bank_snapshot_post_path.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit/optimization:
we only ever use the post path if the pre path does not exist. If we have a good way to directly get the pre path, it'd be better to check that, and only then generate the post path. Right now we have an extra PathBuf allocation.

Feel free to leave it as is for this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Agreed. I will make this change in the next PR. not worth rerun the auto tests just for this.

Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

lgtm!

@xiangzhu70 xiangzhu70 merged commit f107b8b into solana-labs:master Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants