accounts_clean: Convert stack dependency calculation with iterative (#11067)

* accounts_clean: Convert stack dependency calculation with iterative

* optimize clean with by creating a reverse-lookup hashset of the affected
keys

* Add dependency bench

reduce bench

* Huge clean
This commit is contained in:
sakridge
2020-07-15 06:49:22 -07:00
committed by GitHub
parent d81c7250b0
commit 8bf3a0aa05
3 changed files with 83 additions and 51 deletions

View File

@ -95,3 +95,22 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) {
accounts.accounts_db.get_accounts_delta_hash(0);
});
}
#[bench]
fn bench_delete_dependencies(bencher: &mut Bencher) {
solana_logger::setup();
let accounts = Accounts::new(vec![PathBuf::from("accounts_delete_deps")]);
let mut old_pubkey = Pubkey::default();
let zero_account = Account::new(0, 0, &Account::default().owner);
for i in 0..1000 {
let pubkey = Pubkey::new_rand();
let account = Account::new((i + 1) as u64, 0, &Account::default().owner);
accounts.store_slow(i, &pubkey, &account);
accounts.store_slow(i, &old_pubkey, &zero_account);
old_pubkey = pubkey;
accounts.add_root(i);
}
bencher.iter(|| {
accounts.accounts_db.clean_accounts();
});
}