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::{
test_utils::{create_test_accounts, update_accounts_bench},
AccountShrinkThreshold, AccountsDb, CalcAccountsHashDataSource,
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS,
},
accounts_index::AccountSecondaryIndexes,
ancestors::Ancestors,
@ -69,11 +70,14 @@ fn main() {
if fs::remove_dir_all(path.clone()).is_err() {
println!("Warning: Couldn't remove {path:?}");
}
let accounts_db = AccountsDb::new_with_config_for_benches(
let accounts_db = AccountsDb::new_with_config(
vec![path],
&ClusterType::Testnet,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
None,
Arc::default(),
);
let accounts = Accounts::new(Arc::new(accounts_db));
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)
#[cfg(feature = "dev-context-only-utils")]
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(
&self,
ancestors: &Ancestors,

View File

@ -11,7 +11,7 @@ use {
accounts::{AccountAddressFilter, Accounts},
accounts_db::{
test_utils::create_test_accounts, AccountShrinkThreshold, AccountsDb,
VerifyAccountsHashAndLamportsConfig,
VerifyAccountsHashAndLamportsConfig, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS,
},
accounts_index::{AccountSecondaryIndexes, ScanConfig},
ancestors::Ancestors,
@ -36,6 +36,18 @@ use {
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> {
for t in 0..num {
let pubkey = solana_sdk::pubkey::new_rand();
@ -99,12 +111,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
#[bench]
fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
let accounts_db = AccountsDb::new_with_config_for_benches(
vec![PathBuf::from("bench_accounts_hash_internal")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts_db = new_accounts_db(vec![PathBuf::from("bench_accounts_hash_internal")]);
let accounts = Accounts::new(Arc::new(accounts_db));
let mut pubkeys: Vec<Pubkey> = vec![];
let num_accounts = 60_000;
@ -137,12 +144,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
#[bench]
fn test_update_accounts_hash(bencher: &mut Bencher) {
solana_logger::setup();
let accounts_db = AccountsDb::new_with_config_for_benches(
vec![PathBuf::from("update_accounts_hash")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts_db = new_accounts_db(vec![PathBuf::from("update_accounts_hash")]);
let accounts = Accounts::new(Arc::new(accounts_db));
let mut pubkeys: Vec<Pubkey> = vec![];
create_test_accounts(&accounts, &mut pubkeys, 50_000, 0);
@ -157,12 +159,7 @@ fn test_update_accounts_hash(bencher: &mut Bencher) {
#[bench]
fn test_accounts_delta_hash(bencher: &mut Bencher) {
solana_logger::setup();
let accounts_db = AccountsDb::new_with_config_for_benches(
vec![PathBuf::from("accounts_delta_hash")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts_db = new_accounts_db(vec![PathBuf::from("accounts_delta_hash")]);
let accounts = Accounts::new(Arc::new(accounts_db));
let mut pubkeys: Vec<Pubkey> = vec![];
create_test_accounts(&accounts, &mut pubkeys, 100_000, 0);
@ -174,12 +171,7 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) {
#[bench]
fn bench_delete_dependencies(bencher: &mut Bencher) {
solana_logger::setup();
let accounts_db = AccountsDb::new_with_config_for_benches(
vec![PathBuf::from("accounts_delete_deps")],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts_db = new_accounts_db(vec![PathBuf::from("accounts_delete_deps")]);
let accounts = Accounts::new(Arc::new(accounts_db));
let mut old_pubkey = Pubkey::default();
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,
{
let num_readers = 5;
let accounts_db = AccountsDb::new_with_config_for_benches(
vec![
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()))
.join(bench_name),
],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts_db = new_accounts_db(vec![PathBuf::from(
std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()),
)
.join(bench_name)]);
let accounts = Arc::new(Accounts::new(Arc::new(accounts_db)));
let num_keys = 1000;
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)>) {
let accounts_db = AccountsDb::new_with_config_for_benches(
vec![
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()))
.join("bench_dashmap_par_iter"),
],
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts_db = new_accounts_db(vec![PathBuf::from(
std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()),
)
.join("bench_dashmap_par_iter")]);
let accounts = Arc::new(Accounts::new(Arc::new(accounts_db)));
let dashmap = DashMap::new();
@ -399,12 +381,7 @@ fn bench_dashmap_iter(bencher: &mut Bencher) {
#[bench]
fn bench_load_largest_accounts(b: &mut Bencher) {
let accounts_db = AccountsDb::new_with_config_for_benches(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
AccountShrinkThreshold::default(),
);
let accounts_db = new_accounts_db(Vec::new());
let accounts = Accounts::new(Arc::new(accounts_db));
let mut rng = rand::thread_rng();
for _ in 0..10_000 {