From 41f4973f0d6caedc5fe594e6615626a82a20b295 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Fri, 6 Aug 2021 12:36:42 -0500 Subject: [PATCH] accounts default refactoring stragglers (#19097) --- runtime/benches/accounts.rs | 14 +++++++------- runtime/src/accounts.rs | 17 +++++++++++++++++ runtime/tests/accounts.rs | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/runtime/benches/accounts.rs b/runtime/benches/accounts.rs index 919624d731..84deea0e61 100644 --- a/runtime/benches/accounts.rs +++ b/runtime/benches/accounts.rs @@ -95,7 +95,7 @@ fn test_accounts_squash(bencher: &mut Bencher) { #[bench] fn test_accounts_hash_bank_hash(bencher: &mut Bencher) { - let accounts = Accounts::new_with_config( + let accounts = Accounts::new_with_config_for_benches( vec![PathBuf::from("bench_accounts_hash_internal")], &ClusterType::Development, AccountSecondaryIndexes::default(), @@ -122,7 +122,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) { #[bench] fn test_update_accounts_hash(bencher: &mut Bencher) { solana_logger::setup(); - let accounts = Accounts::new_with_config( + let accounts = Accounts::new_with_config_for_benches( vec![PathBuf::from("update_accounts_hash")], &ClusterType::Development, AccountSecondaryIndexes::default(), @@ -140,7 +140,7 @@ fn test_update_accounts_hash(bencher: &mut Bencher) { #[bench] fn test_accounts_delta_hash(bencher: &mut Bencher) { solana_logger::setup(); - let accounts = Accounts::new_with_config( + let accounts = Accounts::new_with_config_for_benches( vec![PathBuf::from("accounts_delta_hash")], &ClusterType::Development, AccountSecondaryIndexes::default(), @@ -157,7 +157,7 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) { #[bench] fn bench_delete_dependencies(bencher: &mut Bencher) { solana_logger::setup(); - let accounts = Accounts::new_with_config( + let accounts = Accounts::new_with_config_for_benches( vec![PathBuf::from("accounts_delete_deps")], &ClusterType::Development, AccountSecondaryIndexes::default(), @@ -188,7 +188,7 @@ fn store_accounts_with_possible_contention( F: Fn(&Accounts, &[Pubkey]) + Send + Copy, { let num_readers = 5; - let accounts = Arc::new(Accounts::new_with_config( + let accounts = Arc::new(Accounts::new_with_config_for_benches( vec![ PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string())) .join(bench_name), @@ -324,7 +324,7 @@ fn bench_rwlock_hashmap_single_reader_with_n_writers(bencher: &mut Bencher) { } fn setup_bench_dashmap_iter() -> (Arc, DashMap) { - let accounts = Arc::new(Accounts::new_with_config( + let accounts = Arc::new(Accounts::new_with_config_for_benches( vec![ PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string())) .join("bench_dashmap_par_iter"), @@ -382,7 +382,7 @@ fn bench_dashmap_iter(bencher: &mut Bencher) { #[bench] fn bench_load_largest_accounts(b: &mut Bencher) { - let accounts = Accounts::new_with_config( + let accounts = Accounts::new_with_config_for_benches( Vec::new(), &ClusterType::Development, AccountSecondaryIndexes::default(), diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 1806d0366c..85633a21c4 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -147,6 +147,23 @@ impl Accounts { ) } + pub fn new_with_config_for_benches( + paths: Vec, + cluster_type: &ClusterType, + account_indexes: AccountSecondaryIndexes, + caching_enabled: bool, + shrink_ratio: AccountShrinkThreshold, + ) -> Self { + // will diverge + Self::new_with_config( + paths, + cluster_type, + account_indexes, + caching_enabled, + shrink_ratio, + ) + } + pub fn new_with_config( paths: Vec, cluster_type: &ClusterType, diff --git a/runtime/tests/accounts.rs b/runtime/tests/accounts.rs index 5b882537a3..5b2d60d663 100644 --- a/runtime/tests/accounts.rs +++ b/runtime/tests/accounts.rs @@ -73,7 +73,7 @@ fn test_shrink_and_clean() { fn test_bad_bank_hash() { solana_logger::setup(); use solana_sdk::signature::{Keypair, Signer}; - let db = AccountsDb::new(Vec::new(), &ClusterType::Development); + let db = AccountsDb::new_for_tests(Vec::new(), &ClusterType::Development); let some_slot: Slot = 0; let ancestors = Ancestors::from(vec![some_slot]);