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

Feature/accum hash #22

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion accounts-db/benches/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use {
solana_accounts_db::{
accounts::{AccountAddressFilter, Accounts},
accounts_db::{
test_utils::create_test_accounts, AccountShrinkThreshold, AccountsDb,
test_utils::create_test_accounts, AccountShrinkThreshold, AccountsDb, LTHashCacheMap,
VerifyAccountsHashAndLamportsConfig, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS,
},
accounts_hash::AccountLTHash,
accounts_index::{AccountSecondaryIndexes, ScanConfig},
ancestors::Ancestors,
},
Expand All @@ -26,6 +27,7 @@ use {
},
std::{
collections::{HashMap, HashSet},
hint::black_box,
path::PathBuf,
sync::{Arc, RwLock},
thread::Builder,
Expand Down Expand Up @@ -341,3 +343,32 @@ fn bench_load_largest_accounts(b: &mut Bencher) {
)
});
}

/// Bench for computing lattice hash
/// test test_accounts_lt_hash ... bench: 5,420,262 ns/iter (+/- 60,676) -- seq
/// test test_accounts_lt_hash ... bench: 2,857,909 ns/iter (+/- 30,022) -- par_chunks (500)
/// test test_accounts_lt_hash ... bench: 2,476,487 ns/iter (+/- 55,287) -- par_chunks (250)
/// test test_accounts_lt_hash ... bench: 2,415,198 ns/iter (+/- 64,917) -- enum cache value
/// test test_accounts_lt_hash ... bench: 1,783,466 ns/iter (+/- 210,289) -- boxing AccountLTHash
/// test test_accounts_lt_hash ... bench: 1,631,536 ns/iter (+/- 310,180) -- boxing AccountSharedData
#[bench]
fn test_accounts_lt_hash(bencher: &mut Bencher) {
solana_logger::setup();
let accounts_db = new_accounts_db(vec![PathBuf::from("accounts_lt_hash")]);
let accounts = Accounts::new(Arc::new(accounts_db));
let mut pubkeys: Vec<Pubkey> = vec![];
create_test_accounts(&accounts, &mut pubkeys, 1_000, 0);

let mut ancestor = Ancestors::default();
ancestor.insert(0, 1);

bencher.iter(|| {
black_box(accounts.accounts_db.accumulate_accounts_lt_hash(
0,
&ancestor,
&RwLock::new(Some(AccountLTHash::default())),
&LTHashCacheMap::default(),
&LTHashCacheMap::default(),
))
});
}
1 change: 1 addition & 0 deletions accounts-db/src/accounts_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ pub type CachedAccount = Arc<CachedAccountInner>;
pub struct CachedAccountInner {
pub account: AccountSharedData,
hash: SeqLock<Option<AccountHash>>,
// TODO: add lt_hash
pubkey: Pubkey,
}

Expand Down
Loading
Loading