Use option for account index bucket parameter (#19150)
This commit is contained in:
parent
8557dac51d
commit
651343688d
|
@ -191,7 +191,7 @@ mod tests {
|
||||||
check_hash_calculation,
|
check_hash_calculation,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
solana_runtime::accounts_index::BINS_FOR_TESTING,
|
Some(solana_runtime::accounts_index::BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ mod tests {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
solana_runtime::accounts_index::BINS_FOR_TESTING,
|
Some(solana_runtime::accounts_index::BINS_FOR_TESTING),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_eq!(bank, &deserialized_bank);
|
assert_eq!(bank, &deserialized_bank);
|
||||||
|
|
|
@ -132,7 +132,7 @@ fn load_from_snapshot(
|
||||||
process_options.accounts_db_test_hash_calculation,
|
process_options.accounts_db_test_hash_calculation,
|
||||||
process_options.accounts_db_skip_shrink,
|
process_options.accounts_db_skip_shrink,
|
||||||
process_options.verify_index,
|
process_options.verify_index,
|
||||||
solana_runtime::accounts_index::BINS_DEFAULT,
|
None,
|
||||||
)
|
)
|
||||||
.expect("Load from snapshot failed");
|
.expect("Load from snapshot failed");
|
||||||
|
|
||||||
|
|
|
@ -416,7 +416,7 @@ pub fn process_blockstore(
|
||||||
opts.accounts_db_caching_enabled,
|
opts.accounts_db_caching_enabled,
|
||||||
opts.shrink_ratio,
|
opts.shrink_ratio,
|
||||||
false,
|
false,
|
||||||
solana_runtime::accounts_index::BINS_DEFAULT,
|
None, // later, this will be passed from ProcessOptions
|
||||||
);
|
);
|
||||||
let bank0 = Arc::new(bank0);
|
let bank0 = Arc::new(bank0);
|
||||||
info!("processing ledger for slot 0...");
|
info!("processing ledger for slot 0...");
|
||||||
|
|
|
@ -127,7 +127,7 @@ fn initialize_from_snapshot(
|
||||||
process_options.accounts_db_test_hash_calculation,
|
process_options.accounts_db_test_hash_calculation,
|
||||||
false,
|
false,
|
||||||
process_options.verify_index,
|
process_options.verify_index,
|
||||||
solana_runtime::accounts_index::BINS_DEFAULT,
|
None,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ extern crate test;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
accounts_db::AccountInfo,
|
accounts_db::AccountInfo,
|
||||||
accounts_index::{AccountSecondaryIndexes, AccountsIndex, BINS_DEFAULT},
|
accounts_index::{AccountSecondaryIndexes, AccountsIndex, BINS_FOR_BENCHMARKS},
|
||||||
};
|
};
|
||||||
use solana_sdk::pubkey::{self, Pubkey};
|
use solana_sdk::pubkey::{self, Pubkey};
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
@ -18,7 +18,7 @@ fn bench_accounts_index(bencher: &mut Bencher) {
|
||||||
const NUM_FORKS: u64 = 16;
|
const NUM_FORKS: u64 = 16;
|
||||||
|
|
||||||
let mut reclaims = vec![];
|
let mut reclaims = vec![];
|
||||||
let index = AccountsIndex::<AccountInfo>::new(BINS_DEFAULT);
|
let index = AccountsIndex::<AccountInfo>::new(Some(BINS_FOR_BENCHMARKS));
|
||||||
for f in 0..NUM_FORKS {
|
for f in 0..NUM_FORKS {
|
||||||
for pubkey in pubkeys.iter().take(NUM_PUBKEYS) {
|
for pubkey in pubkeys.iter().take(NUM_PUBKEYS) {
|
||||||
index.upsert(
|
index.upsert(
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl Accounts {
|
||||||
account_indexes,
|
account_indexes,
|
||||||
caching_enabled,
|
caching_enabled,
|
||||||
shrink_ratio,
|
shrink_ratio,
|
||||||
BINS_FOR_TESTING,
|
Some(BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ impl Accounts {
|
||||||
account_indexes,
|
account_indexes,
|
||||||
caching_enabled,
|
caching_enabled,
|
||||||
shrink_ratio,
|
shrink_ratio,
|
||||||
BINS_FOR_BENCHMARKS,
|
Some(BINS_FOR_BENCHMARKS),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ impl Accounts {
|
||||||
account_indexes: AccountSecondaryIndexes,
|
account_indexes: AccountSecondaryIndexes,
|
||||||
caching_enabled: bool,
|
caching_enabled: bool,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
accounts_db: Arc::new(AccountsDb::new_with_config(
|
accounts_db: Arc::new(AccountsDb::new_with_config(
|
||||||
|
|
|
@ -1420,7 +1420,7 @@ impl AccountsDb {
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
false,
|
false,
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
BINS_FOR_TESTING,
|
Some(BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1430,7 +1430,7 @@ impl AccountsDb {
|
||||||
account_indexes: AccountSecondaryIndexes,
|
account_indexes: AccountSecondaryIndexes,
|
||||||
caching_enabled: bool,
|
caching_enabled: bool,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let accounts_index = AccountsIndex::new(accounts_index_bins);
|
let accounts_index = AccountsIndex::new(accounts_index_bins);
|
||||||
let mut new = if !paths.is_empty() {
|
let mut new = if !paths.is_empty() {
|
||||||
|
@ -6227,7 +6227,7 @@ impl AccountsDb {
|
||||||
account_indexes,
|
account_indexes,
|
||||||
caching_enabled,
|
caching_enabled,
|
||||||
shrink_ratio,
|
shrink_ratio,
|
||||||
BINS_FOR_TESTING,
|
Some(BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -761,10 +761,10 @@ pub struct AccountsIndex<T> {
|
||||||
|
|
||||||
impl<T: IsCached> AccountsIndex<T> {
|
impl<T: IsCached> AccountsIndex<T> {
|
||||||
pub fn default_for_tests() -> Self {
|
pub fn default_for_tests() -> Self {
|
||||||
Self::new(BINS_FOR_TESTING)
|
Self::new(Some(BINS_FOR_TESTING))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(bins: usize) -> Self {
|
pub fn new(bins: Option<usize>) -> Self {
|
||||||
let (account_maps, bin_calculator) = Self::allocate_accounts_index(bins);
|
let (account_maps, bin_calculator) = Self::allocate_accounts_index(bins);
|
||||||
Self {
|
Self {
|
||||||
account_maps,
|
account_maps,
|
||||||
|
@ -784,7 +784,8 @@ impl<T: IsCached> AccountsIndex<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allocate_accounts_index(bins: usize) -> (LockMapType<T>, PubkeyBinCalculator16) {
|
fn allocate_accounts_index(bins: Option<usize>) -> (LockMapType<T>, PubkeyBinCalculator16) {
|
||||||
|
let bins = bins.unwrap_or(BINS_DEFAULT);
|
||||||
let account_maps = (0..bins)
|
let account_maps = (0..bins)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|_| RwLock::new(AccountMap::default()))
|
.map(|_| RwLock::new(AccountMap::default()))
|
||||||
|
@ -4023,6 +4024,6 @@ pub mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "bins.is_power_of_two()")]
|
#[should_panic(expected = "bins.is_power_of_two()")]
|
||||||
fn test_illegal_bins() {
|
fn test_illegal_bins() {
|
||||||
AccountsIndex::<bool>::new(3);
|
AccountsIndex::<bool>::new(Some(3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1190,7 +1190,7 @@ impl Bank {
|
||||||
accounts_db_caching_enabled,
|
accounts_db_caching_enabled,
|
||||||
shrink_ratio,
|
shrink_ratio,
|
||||||
debug_do_not_add_builtins,
|
debug_do_not_add_builtins,
|
||||||
BINS_FOR_TESTING,
|
Some(BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1215,7 +1215,7 @@ impl Bank {
|
||||||
accounts_db_caching_enabled,
|
accounts_db_caching_enabled,
|
||||||
shrink_ratio,
|
shrink_ratio,
|
||||||
debug_do_not_add_builtins,
|
debug_do_not_add_builtins,
|
||||||
BINS_FOR_BENCHMARKS,
|
Some(BINS_FOR_BENCHMARKS),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1230,7 +1230,7 @@ impl Bank {
|
||||||
accounts_db_caching_enabled: bool,
|
accounts_db_caching_enabled: bool,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
debug_do_not_add_builtins: bool,
|
debug_do_not_add_builtins: bool,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let accounts = Accounts::new_with_config(
|
let accounts = Accounts::new_with_config(
|
||||||
paths,
|
paths,
|
||||||
|
|
|
@ -197,7 +197,7 @@ pub(crate) fn bank_from_streams<R>(
|
||||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
verify_index: bool,
|
verify_index: bool,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> std::result::Result<Bank, Error>
|
) -> std::result::Result<Bank, Error>
|
||||||
where
|
where
|
||||||
R: Read,
|
R: Read,
|
||||||
|
@ -328,7 +328,7 @@ fn reconstruct_bank_from_fields<E>(
|
||||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
verify_index: bool,
|
verify_index: bool,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Result<Bank, Error>
|
) -> Result<Bank, Error>
|
||||||
where
|
where
|
||||||
E: SerializableStorage + std::marker::Sync,
|
E: SerializableStorage + std::marker::Sync,
|
||||||
|
@ -395,7 +395,7 @@ fn reconstruct_accountsdb_from_fields<E>(
|
||||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
verify_index: bool,
|
verify_index: bool,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Result<AccountsDb, Error>
|
) -> Result<AccountsDb, Error>
|
||||||
where
|
where
|
||||||
E: SerializableStorage + std::marker::Sync,
|
E: SerializableStorage + std::marker::Sync,
|
||||||
|
|
|
@ -81,7 +81,7 @@ where
|
||||||
None,
|
None,
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
false,
|
false,
|
||||||
crate::accounts_index::BINS_FOR_TESTING,
|
Some(crate::accounts_index::BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ fn test_bank_serialize_style(serde_style: SerdeStyle) {
|
||||||
None,
|
None,
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
false,
|
false,
|
||||||
crate::accounts_index::BINS_FOR_TESTING,
|
Some(crate::accounts_index::BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
dbank.src = ref_sc;
|
dbank.src = ref_sc;
|
||||||
|
|
|
@ -726,7 +726,7 @@ pub fn bank_from_snapshot_archives(
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
accounts_db_skip_shrink: bool,
|
accounts_db_skip_shrink: bool,
|
||||||
verify_index: bool,
|
verify_index: bool,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Result<(Bank, BankFromArchiveTimings)> {
|
) -> Result<(Bank, BankFromArchiveTimings)> {
|
||||||
check_are_snapshots_compatible(
|
check_are_snapshots_compatible(
|
||||||
full_snapshot_archive_info,
|
full_snapshot_archive_info,
|
||||||
|
@ -833,7 +833,7 @@ pub fn bank_from_latest_snapshot_archives(
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
accounts_db_skip_shrink: bool,
|
accounts_db_skip_shrink: bool,
|
||||||
verify_index: bool,
|
verify_index: bool,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Result<(Bank, BankFromArchiveTimings)> {
|
) -> Result<(Bank, BankFromArchiveTimings)> {
|
||||||
let full_snapshot_archive_info = get_highest_full_snapshot_archive_info(&snapshot_archives_dir)
|
let full_snapshot_archive_info = get_highest_full_snapshot_archive_info(&snapshot_archives_dir)
|
||||||
.ok_or(SnapshotError::NoSnapshotArchives)?;
|
.ok_or(SnapshotError::NoSnapshotArchives)?;
|
||||||
|
@ -1371,7 +1371,7 @@ fn rebuild_bank_from_snapshots(
|
||||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
verify_index: bool,
|
verify_index: bool,
|
||||||
accounts_index_bins: usize,
|
accounts_index_bins: Option<usize>,
|
||||||
) -> Result<Bank> {
|
) -> Result<Bank> {
|
||||||
let (full_snapshot_version, full_snapshot_root_paths) =
|
let (full_snapshot_version, full_snapshot_root_paths) =
|
||||||
verify_unpacked_snapshots_dir_and_version(
|
verify_unpacked_snapshots_dir_and_version(
|
||||||
|
@ -2490,7 +2490,7 @@ mod tests {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
crate::accounts_index::BINS_FOR_TESTING,
|
Some(crate::accounts_index::BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2581,7 +2581,7 @@ mod tests {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
crate::accounts_index::BINS_FOR_TESTING,
|
Some(crate::accounts_index::BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2691,7 +2691,7 @@ mod tests {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
crate::accounts_index::BINS_FOR_TESTING,
|
Some(crate::accounts_index::BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2790,7 +2790,7 @@ mod tests {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
crate::accounts_index::BINS_FOR_TESTING,
|
Some(crate::accounts_index::BINS_FOR_TESTING),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue