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

Removes unnecessary AccountsDb::new_with_config_for_benches() #34484

Merged
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
6 changes: 5 additions & 1 deletion accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
steviez marked this conversation as resolved.
Show resolved Hide resolved
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");
Expand Down
17 changes: 0 additions & 17 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
75 changes: 26 additions & 49 deletions runtime/benches/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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());
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down