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

[wip] Make generate_index 2-pass for dead slots cleanup#8337

Closed
ryoqun wants to merge 6 commits intosolana-labs:masterfrom
ryoqun:2-pass-generate-index
Closed

[wip] Make generate_index 2-pass for dead slots cleanup#8337
ryoqun wants to merge 6 commits intosolana-labs:masterfrom
ryoqun:2-pass-generate-index

Conversation

@ryoqun
Copy link
Copy Markdown
Contributor

@ryoqun ryoqun commented Feb 20, 2020

Problem

#8168

Summary of Changes

This is still rough; but works.

When backporting, do so in tandem with #8148. Only backporting with one of the two introduces bugs.

Fixes #8168

@ryoqun ryoqun added the work in progress This isn't quite right yet label Feb 20, 2020
@ryoqun ryoqun requested a review from sakridge February 20, 2020 00:17
}

let mut reclaims: Vec<(u64, AccountInfo)> = vec![];
accounts_index.clear();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We start over the generation of index here. :)

} else {
trace!("id: {} clearing count", id);
store.count_and_status.write().unwrap().0 = 0;
let mut c = store.count_and_status.write().unwrap();
Copy link
Copy Markdown
Contributor Author

@ryoqun ryoqun Feb 20, 2020

Choose a reason for hiding this comment

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

This part is the main dish in this PR; In this condition, we're pretty sure we can remove those Storages (=AppendVecs). And majority of thoese storages are under this category.

AccountsDB::merge(&mut account_maps, &maps);
}
for (pubkey, (_, account_info)) in account_maps.iter() {
accounts_index.insert(*alive_slot, pubkey, account_info.clone(), &mut reclaims);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We had to be conservative here; purge_zero_lamport_account didn't work since the introduction of #8218 after generate_index and before verify_snapshot().

Corresponding test is this https://github.com/solana-labs/solana/pull/8337/files#diff-2099c5256db4eb5975c8834af38f6456R2307

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

convervative means previously we only kept the last entry for each given pubkey in account index. That's very aggressive in a way. That's because this is updating the index after marking the updated slot as root before that.

@ryoqun ryoqun force-pushed the 2-pass-generate-index branch from e6fc62d to 549ee14 Compare February 21, 2020 07:15
Comment thread runtime/src/accounts_db.rs Outdated
let mut account_maps = accumulator.pop().unwrap();
let mut account_maps = std::collections::BTreeMap::new();
while let Some(maps) = accumulator.pop() {
AccountsDB::merge(&mut account_maps, &maps);
Copy link
Copy Markdown
Contributor Author

@ryoqun ryoqun Feb 22, 2020

Choose a reason for hiding this comment

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

we can't merge here; we must faithfully recalculate the store count here.

@@ -1431,6 +1522,12 @@ impl AccountsDB {

//d b g!(&reclaims);
self.handle_reclaims(&reclaims);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

move this inner loop

accounts.add_root(current_slot);

current_slot += 1;
accounts.store(current_slot, &[(&dummy_pubkey, &dummy_account)]);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is now gone thanks to #8148

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Originally, this workaround is added here: https://github.com/solana-labs/solana/pull/8176/files#r376724066

To add next artificial slot, in addition of just add_root, I also had to store a dummy account otherwise missing bank hash error occurred.

dead_slots
}

// The caller must ensure given slots are actually dead (= older than the root)
Copy link
Copy Markdown
Contributor Author

@ryoqun ryoqun Feb 22, 2020

Choose a reason for hiding this comment

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

What I wanted to include in #8148

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 22, 2020

Codecov Report

Merging #8337 into master will increase coverage by 0.0%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master   #8337    +/-   ##
=======================================
  Coverage    80.3%   80.4%            
=======================================
  Files         254     254            
  Lines       55683   55883   +200     
=======================================
+ Hits        44765   44965   +200     
  Misses      10918   10918            

@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Feb 22, 2020

Phew, CI's back to green!!!

@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Mar 5, 2020

This PR still contains the something to be merged. I'll work on this today.

@ryoqun ryoqun reopened this Mar 5, 2020
@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Mar 5, 2020

To be clear, the very cleaning logic is still not landed on the master...

@stale
Copy link
Copy Markdown

stale Bot commented Mar 13, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale Bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Mar 13, 2020
@ryoqun
Copy link
Copy Markdown
Contributor Author

ryoqun commented Mar 13, 2020

To be clear, the very cleaning logic is still not landed on the master...

Conservative ones got landed at #8811

@stale stale Bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Mar 13, 2020
@ryoqun ryoqun closed this Mar 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

work in progress This isn't quite right yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The number of accounts/ files in TdS and SLP snapshots is too high

1 participant