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

Create bank snapshots #3671

Merged
merged 7 commits into from
May 10, 2019
Merged

Create bank snapshots #3671

merged 7 commits into from
May 10, 2019

Conversation

sambley
Copy link
Contributor

@sambley sambley commented Apr 8, 2019

Problem

Full node startup is slow when many transactions have been processed as this involved querying for the full ledger and replaying it.

Summary of Changes

Serialize bank state into a snapshot and try to restore from that on boot.

Fixes #2475

@sambley
Copy link
Contributor Author

sambley commented Apr 8, 2019

@sakridge, could you check on how this is looking

@codecov
Copy link

codecov bot commented Apr 9, 2019

Codecov Report

Merging #3671 into master will increase coverage by 0.1%.
The diff coverage is 91.6%.

@@           Coverage Diff            @@
##           master   #3671     +/-   ##
========================================
+ Coverage    79.6%   79.7%   +0.1%     
========================================
  Files         155     156      +1     
  Lines       24930   25266    +336     
========================================
+ Hits        19855   20148    +293     
- Misses       5075    5118     +43

@codecov
Copy link

codecov bot commented Apr 9, 2019

Codecov Report

Merging #3671 into master will increase coverage by 0.2%.
The diff coverage is 88.1%.

@@           Coverage Diff            @@
##           master   #3671     +/-   ##
========================================
+ Coverage    78.3%   78.5%   +0.2%     
========================================
  Files         165     166      +1     
  Lines       28549   29133    +584     
========================================
+ Hits        22368   22891    +523     
- Misses       6181    6242     +61

@@ -16,7 +16,8 @@ pub trait BloomHashIndex {
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
pub struct Bloom<T: BloomHashIndex> {
pub keys: Vec<u64>,
pub bits: BitVec<u8>,
pub bits: BitVec<u64>,
num_bits_set: u64,
Copy link
Member

Choose a reason for hiding this comment

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

Do we use this anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its being used in crds gossip push and pull

@sambley sambley force-pushed the snapshot branch 2 times, most recently from 1a9aaa6 to a96876d Compare April 14, 2019 16:56
@aeyakovenko
Copy link
Member

aeyakovenko commented Apr 14, 2019

@sambley, can you take a look at #3613. Index can be recovered from storage. We just need the last root from blocktree

you should be able to use AccountsDB::scan_account_storage defined in #3613 to recreate the index.

@sambley sambley force-pushed the snapshot branch 3 times, most recently from 158c2d8 to 4d9845e Compare April 18, 2019 05:35
@mvines
Copy link
Member

mvines commented Apr 22, 2019

Is this PR still being worked on?

@sambley
Copy link
Contributor Author

sambley commented Apr 22, 2019

Is this PR still being worked on?

@mvines, yes I am working on this one.

@aeyakovenko
Copy link
Member

@sambley I think scan + getting the root from blocktree should get you there

@sambley
Copy link
Contributor Author

sambley commented Apr 22, 2019

@sambley I think scan + getting the root from blocktree should get you there

@aeyakovenko, currently the frozen set of banks (32) are serialized (added/removed as they are pruned) with the serialized data containing the path to the append vec and when deserializing the accounts is restored back by pointing to the appropriate append vec. When you are referring to scan + getting root from blocktree, are you referring to the above or a different mechanism.

@aeyakovenko
Copy link
Member

@sambley

https://github.com/solana-labs/solana/blob/master/runtime/src/accounts_db.rs#L196

There are examples of usage in accounts.rs. But basically the appendvec stores a single fork, so booting the checkpoint just means scanning all the vecs and reconstructing the index based on write_version.

@sambley sambley force-pushed the snapshot branch 2 times, most recently from 333eaf1 to 0fa5b6e Compare April 24, 2019 06:02
@sambley
Copy link
Contributor Author

sambley commented Apr 24, 2019

@sambley

https://github.com/solana-labs/solana/blob/master/runtime/src/accounts_db.rs#L196

There are examples of usage in accounts.rs. But basically the appendvec stores a single fork, so booting the checkpoint just means scanning all the vecs and reconstructing the index based on write_version.

@aeyakovenko, currently AccountsIndex get serialized / deserialized and should restore back the index on deserialize. The bank snapshot are added / removed with below logic.
https://github.com/solana-labs/solana/pull/3671/files#diff-0e517bfb897cd6ee46d83d239efb1cb7R131

Do you see any issue with this?

@aeyakovenko
Copy link
Member

@sambley, it doesn't need to be. if we recover from scanning the storage, we can also GC it in that step and recreate the index. Serializing the index adds another level of complexity, since it's hard to make sure the index is in sync with storage.

@sambley sambley force-pushed the snapshot branch 2 times, most recently from 2892e4c to 44a6d31 Compare April 25, 2019 05:44
@@ -20,7 +20,7 @@ log = "0.4.2"
memmap = "0.6.2"
rand = "0.6.5"
rayon = "1.0.0"
serde = "1.0.88"
serde = { version = "1.0.88", features = ["rc"] }
Copy link
Contributor

@rob-solana rob-solana Apr 25, 2019

Choose a reason for hiding this comment

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

this looks like it might be a really nasty thing to turn on...
https://serde.rs/feature-flags.html#-features-rc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will work on serializing / deserializing with out having to turn on this feature.

@aeyakovenko
Copy link
Member

@sambley so my goal with using AppendVec data directly without a saved index is that the bank can recover from a killed process, and the index can be fresh, basically garbage collected from boot.

@sambley
Copy link
Contributor Author

sambley commented Apr 26, 2019

@sambley so my goal with using AppendVec data directly without a saved index is that the bank can recover from a killed process, and the index can be fresh, basically garbage collected from boot.

Yes, I will work on that as well to not have to serialize the index and instead recover from the appendvec. Still looking into an issue with the continuation once the bank snapshots are restored.

@sambley sambley force-pushed the snapshot branch 4 times, most recently from 003a4a0 to deb5108 Compare May 3, 2019 03:58
@rob-solana rob-solana merged commit abf2b30 into solana-labs:master May 10, 2019
rob-solana added a commit that referenced this pull request May 10, 2019
rob-solana added a commit that referenced this pull request May 10, 2019
@rob-solana
Copy link
Contributor

sorry, Sathish: I fat-fingered the merge button

sambley added a commit to sambley/solana that referenced this pull request May 10, 2019
sambley added a commit to sambley/solana that referenced this pull request May 13, 2019
sambley added a commit to sambley/solana that referenced this pull request May 14, 2019
sambley added a commit to sambley/solana that referenced this pull request May 15, 2019
sambley added a commit to sambley/solana that referenced this pull request May 15, 2019
sambley added a commit to sambley/solana that referenced this pull request May 17, 2019
sambley added a commit to sambley/solana that referenced this pull request May 17, 2019
sambley added a commit to sambley/solana that referenced this pull request May 19, 2019
sambley added a commit to sambley/solana that referenced this pull request May 24, 2019
sambley added a commit to sambley/solana that referenced this pull request May 25, 2019
sambley added a commit to sambley/solana that referenced this pull request May 26, 2019
sambley added a commit to sambley/solana that referenced this pull request May 30, 2019
sambley added a commit to sambley/solana that referenced this pull request May 31, 2019
sambley added a commit that referenced this pull request May 31, 2019
* Revert "Revert "Create bank snapshots (#3671)" (#4243)"

This reverts commit 81fa69d.

* keep saved and unsaved copies of status cache

* fix format check

* bench for status cache serialize

* misc cleanup

* remove appendvec storage on purge

* fix accounts restore

* cleanup

* Pass snapshot path as args

* Fix clippy
@brooksprumo brooksprumo mentioned this pull request May 6, 2021
29 tasks
brooksprumo pushed a commit to brooksprumo/solana that referenced this pull request Nov 20, 2024
* Remove SVM's dependency on vote crate

* remove dep from json-rpc example

* use callback to get epoch vote stake
gregcusack pushed a commit to gregcusack/solana that referenced this pull request Dec 4, 2024
* Remove SVM's dependency on vote crate

* remove dep from json-rpc example

* use callback to get epoch vote stake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fullnode startup is slow
5 participants