Removes unnecessary AccountsDb::new_with_config_for_benches() (#34484)

This commit is contained in:
Brooks 2023-12-18 06:52:41 -05:00 committed by GitHub
parent cbe8a02029
commit 4181ea4677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 67 deletions

View File

@ -10,6 +10,7 @@ use {
accounts_db::{ accounts_db::{
test_utils::{create_test_accounts, update_accounts_bench}, test_utils::{create_test_accounts, update_accounts_bench},
AccountShrinkThreshold, AccountsDb, CalcAccountsHashDataSource, AccountShrinkThreshold, AccountsDb, CalcAccountsHashDataSource,
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS,
}, },
accounts_index::AccountSecondaryIndexes, accounts_index::AccountSecondaryIndexes,
ancestors::Ancestors, ancestors::Ancestors,
@ -69,11 +70,14 @@ fn main() {
if fs::remove_dir_all(path.clone()).is_err() { if fs::remove_dir_all(path.clone()).is_err() {
println!("Warning: Couldn't remove {path:?}"); println!("Warning: Couldn't remove {path:?}");
} }
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = AccountsDb::new_with_config(
vec![path], vec![path],
&ClusterType::Testnet, &ClusterType::Testnet,
AccountSecondaryIndexes::default(), AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(), AccountShrinkThreshold::default(),
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
None,
Arc::default(),
); );
let accounts = Accounts::new(Arc::new(accounts_db)); let accounts = Accounts::new(Arc::new(accounts_db));
println!("Creating {num_accounts} accounts"); println!("Creating {num_accounts} accounts");

View File

@ -9522,23 +9522,6 @@ pub(crate) enum UpdateIndexThreadSelection {
// These functions/fields are only usable from a dev context (i.e. tests and benches) // These functions/fields are only usable from a dev context (i.e. tests and benches)
#[cfg(feature = "dev-context-only-utils")] #[cfg(feature = "dev-context-only-utils")]
impl AccountsDb { impl AccountsDb {
pub fn new_with_config_for_benches(
paths: Vec<PathBuf>,
cluster_type: &ClusterType,
account_indexes: AccountSecondaryIndexes,
shrink_ratio: AccountShrinkThreshold,
) -> Self {
Self::new_with_config(
paths,
cluster_type,
account_indexes,
shrink_ratio,
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
None,
Arc::default(),
)
}
pub fn load_without_fixed_root( pub fn load_without_fixed_root(
&self, &self,
ancestors: &Ancestors, ancestors: &Ancestors,

View File

@ -11,7 +11,7 @@ use {
accounts::{AccountAddressFilter, Accounts}, accounts::{AccountAddressFilter, Accounts},
accounts_db::{ accounts_db::{
test_utils::create_test_accounts, AccountShrinkThreshold, AccountsDb, test_utils::create_test_accounts, AccountShrinkThreshold, AccountsDb,
VerifyAccountsHashAndLamportsConfig, VerifyAccountsHashAndLamportsConfig, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS,
}, },
accounts_index::{AccountSecondaryIndexes, ScanConfig}, accounts_index::{AccountSecondaryIndexes, ScanConfig},
ancestors::Ancestors, ancestors::Ancestors,
@ -36,6 +36,18 @@ use {
test::Bencher, test::Bencher,
}; };
fn new_accounts_db(account_paths: Vec<PathBuf>) -> AccountsDb {
AccountsDb::new_with_config(
account_paths,
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
None,
Arc::default(),
)
}
fn deposit_many(bank: &Bank, pubkeys: &mut Vec<Pubkey>, num: usize) -> Result<(), LamportsError> { fn deposit_many(bank: &Bank, pubkeys: &mut Vec<Pubkey>, num: usize) -> Result<(), LamportsError> {
for t in 0..num { for t in 0..num {
let pubkey = solana_sdk::pubkey::new_rand(); let pubkey = solana_sdk::pubkey::new_rand();
@ -99,12 +111,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
#[bench] #[bench]
fn test_accounts_hash_bank_hash(bencher: &mut Bencher) { fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = new_accounts_db(vec![PathBuf::from("bench_accounts_hash_internal")]);
vec![PathBuf::from("bench_accounts_hash_internal")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts = Accounts::new(Arc::new(accounts_db)); let accounts = Accounts::new(Arc::new(accounts_db));
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];
let num_accounts = 60_000; let num_accounts = 60_000;
@ -137,12 +144,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
#[bench] #[bench]
fn test_update_accounts_hash(bencher: &mut Bencher) { fn test_update_accounts_hash(bencher: &mut Bencher) {
solana_logger::setup(); solana_logger::setup();
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = new_accounts_db(vec![PathBuf::from("update_accounts_hash")]);
vec![PathBuf::from("update_accounts_hash")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts = Accounts::new(Arc::new(accounts_db)); let accounts = Accounts::new(Arc::new(accounts_db));
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];
create_test_accounts(&accounts, &mut pubkeys, 50_000, 0); create_test_accounts(&accounts, &mut pubkeys, 50_000, 0);
@ -157,12 +159,7 @@ fn test_update_accounts_hash(bencher: &mut Bencher) {
#[bench] #[bench]
fn test_accounts_delta_hash(bencher: &mut Bencher) { fn test_accounts_delta_hash(bencher: &mut Bencher) {
solana_logger::setup(); solana_logger::setup();
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = new_accounts_db(vec![PathBuf::from("accounts_delta_hash")]);
vec![PathBuf::from("accounts_delta_hash")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts = Accounts::new(Arc::new(accounts_db)); let accounts = Accounts::new(Arc::new(accounts_db));
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];
create_test_accounts(&accounts, &mut pubkeys, 100_000, 0); create_test_accounts(&accounts, &mut pubkeys, 100_000, 0);
@ -174,12 +171,7 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) {
#[bench] #[bench]
fn bench_delete_dependencies(bencher: &mut Bencher) { fn bench_delete_dependencies(bencher: &mut Bencher) {
solana_logger::setup(); solana_logger::setup();
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = new_accounts_db(vec![PathBuf::from("accounts_delete_deps")]);
vec![PathBuf::from("accounts_delete_deps")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts = Accounts::new(Arc::new(accounts_db)); let accounts = Accounts::new(Arc::new(accounts_db));
let mut old_pubkey = Pubkey::default(); let mut old_pubkey = Pubkey::default();
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner()); let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
@ -204,15 +196,10 @@ fn store_accounts_with_possible_contention<F: 'static>(
F: Fn(&Accounts, &[Pubkey]) + Send + Copy, F: Fn(&Accounts, &[Pubkey]) + Send + Copy,
{ {
let num_readers = 5; let num_readers = 5;
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = new_accounts_db(vec![PathBuf::from(
vec![ std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()),
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string())) )
.join(bench_name), .join(bench_name)]);
],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts = Arc::new(Accounts::new(Arc::new(accounts_db))); let accounts = Arc::new(Accounts::new(Arc::new(accounts_db)));
let num_keys = 1000; let num_keys = 1000;
let slot = 0; let slot = 0;
@ -341,15 +328,10 @@ fn bench_rwlock_hashmap_single_reader_with_n_writers(bencher: &mut Bencher) {
} }
fn setup_bench_dashmap_iter() -> (Arc<Accounts>, DashMap<Pubkey, (AccountSharedData, Hash)>) { fn setup_bench_dashmap_iter() -> (Arc<Accounts>, DashMap<Pubkey, (AccountSharedData, Hash)>) {
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = new_accounts_db(vec![PathBuf::from(
vec![ std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()),
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string())) )
.join("bench_dashmap_par_iter"), .join("bench_dashmap_par_iter")]);
],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts = Arc::new(Accounts::new(Arc::new(accounts_db))); let accounts = Arc::new(Accounts::new(Arc::new(accounts_db)));
let dashmap = DashMap::new(); let dashmap = DashMap::new();
@ -399,12 +381,7 @@ fn bench_dashmap_iter(bencher: &mut Bencher) {
#[bench] #[bench]
fn bench_load_largest_accounts(b: &mut Bencher) { fn bench_load_largest_accounts(b: &mut Bencher) {
let accounts_db = AccountsDb::new_with_config_for_benches( let accounts_db = new_accounts_db(Vec::new());
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts = Accounts::new(Arc::new(accounts_db)); let accounts = Accounts::new(Arc::new(accounts_db));
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
for _ in 0..10_000 { for _ in 0..10_000 {