Skip to content

Commit

Permalink
type AccountSecondaryIndexes = HashSet (#17108)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored May 10, 2021
1 parent a6a1355 commit f39dda0
Show file tree
Hide file tree
Showing 13 changed files with 224 additions and 139 deletions.
12 changes: 8 additions & 4 deletions accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use rayon::prelude::*;
use solana_measure::measure::Measure;
use solana_runtime::{
accounts::{create_test_accounts, update_accounts_bench, Accounts},
accounts_index::Ancestors,
accounts_index::{AccountSecondaryIndexes, Ancestors},
};
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
use std::{collections::HashSet, env, fs, path::PathBuf};
use std::{env, fs, path::PathBuf};

fn main() {
solana_logger::setup();
Expand Down Expand Up @@ -58,8 +58,12 @@ fn main() {
if fs::remove_dir_all(path.clone()).is_err() {
println!("Warning: Couldn't remove {:?}", path);
}
let accounts =
Accounts::new_with_config(vec![path], &ClusterType::Testnet, HashSet::new(), false);
let accounts = Accounts::new_with_config(
vec![path],
&ClusterType::Testnet,
AccountSecondaryIndexes::default(),
false,
);
println!("Creating {} accounts", num_accounts);
let mut create_time = Measure::start("create accounts");
let pubkeys: Vec<_> = (0..num_slots)
Expand Down
6 changes: 3 additions & 3 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use solana_ledger::{
use solana_measure::measure::Measure;
use solana_metrics::datapoint_info;
use solana_runtime::{
accounts_index::AccountIndex,
accounts_index::AccountSecondaryIndexes,
bank::Bank,
bank_forks::{BankForks, SnapshotConfig},
commitment::BlockCommitmentCache,
Expand Down Expand Up @@ -125,7 +125,7 @@ pub struct ValidatorConfig {
pub no_poh_speed_test: bool,
pub poh_pinned_cpu_core: usize,
pub poh_hashes_per_batch: u64,
pub account_indexes: HashSet<AccountIndex>,
pub account_indexes: AccountSecondaryIndexes,
pub accounts_db_caching_enabled: bool,
pub warp_slot: Option<Slot>,
pub accounts_db_test_hash_calculation: bool,
Expand Down Expand Up @@ -181,7 +181,7 @@ impl Default for ValidatorConfig {
no_poh_speed_test: true,
poh_pinned_cpu_core: poh_service::DEFAULT_PINNED_CPU_CORE,
poh_hashes_per_batch: poh_service::DEFAULT_HASHES_PER_BATCH,
account_indexes: HashSet::new(),
account_indexes: AccountSecondaryIndexes::default(),
accounts_db_caching_enabled: false,
warp_slot: None,
accounts_db_test_hash_calculation: false,
Expand Down
5 changes: 3 additions & 2 deletions core/tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod tests {
use solana_runtime::{
accounts_background_service::{AbsRequestSender, SnapshotRequestHandler},
accounts_db,
accounts_index::AccountSecondaryIndexes,
bank::{Bank, BankSlotDelta},
bank_forks::{ArchiveFormat, BankForks, SnapshotConfig},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
Expand Down Expand Up @@ -106,7 +107,7 @@ mod tests {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
bank0.freeze();
Expand Down Expand Up @@ -163,7 +164,7 @@ mod tests {
old_genesis_config,
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
)
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use solana_measure::measure::Measure;
use solana_metrics::{datapoint_error, inc_new_counter_debug};
use solana_rayon_threadlimit::get_thread_count;
use solana_runtime::{
accounts_index::AccountIndex,
accounts_index::AccountSecondaryIndexes,
bank::{
Bank, ExecuteTimings, InnerInstructionsList, TransactionBalancesSet,
TransactionExecutionResult, TransactionLogMessages, TransactionResults,
Expand Down Expand Up @@ -366,7 +366,7 @@ pub struct ProcessOptions {
pub new_hard_forks: Option<Vec<Slot>>,
pub frozen_accounts: Vec<Pubkey>,
pub debug_keys: Option<Arc<HashSet<Pubkey>>>,
pub account_indexes: HashSet<AccountIndex>,
pub account_indexes: AccountSecondaryIndexes,
pub accounts_db_caching_enabled: bool,
pub allow_dead_slots: bool,
}
Expand Down Expand Up @@ -2990,7 +2990,7 @@ pub mod tests {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
*bank.epoch_schedule()
Expand Down
26 changes: 15 additions & 11 deletions runtime/benches/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rand::Rng;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use solana_runtime::{
accounts::{create_test_accounts, AccountAddressFilter, Accounts},
accounts_index::Ancestors,
accounts_index::{AccountSecondaryIndexes, Ancestors},
bank::*,
};
use solana_sdk::{
Expand Down Expand Up @@ -56,7 +56,7 @@ fn test_accounts_create(bencher: &mut Bencher) {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
bencher.iter(|| {
Expand All @@ -75,7 +75,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
));
let mut pubkeys: Vec<Pubkey> = vec![];
Expand All @@ -100,7 +100,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("bench_accounts_hash_internal")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut pubkeys: Vec<Pubkey> = vec![];
Expand All @@ -118,7 +118,7 @@ fn test_update_accounts_hash(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("update_accounts_hash")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut pubkeys: Vec<Pubkey> = vec![];
Expand All @@ -135,7 +135,7 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("accounts_delta_hash")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut pubkeys: Vec<Pubkey> = vec![];
Expand All @@ -151,7 +151,7 @@ fn bench_delete_dependencies(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("accounts_delete_deps")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut old_pubkey = Pubkey::default();
Expand Down Expand Up @@ -184,7 +184,7 @@ fn store_accounts_with_possible_contention<F: 'static>(
.join(bench_name),
],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
));
let num_keys = 1000;
Expand Down Expand Up @@ -313,7 +313,7 @@ fn setup_bench_dashmap_iter() -> (Arc<Accounts>, DashMap<Pubkey, (AccountSharedD
.join("bench_dashmap_par_iter"),
],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
));

Expand Down Expand Up @@ -364,8 +364,12 @@ fn bench_dashmap_iter(bencher: &mut Bencher) {

#[bench]
fn bench_load_largest_accounts(b: &mut Bencher) {
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let mut rng = rand::thread_rng();
for _ in 0..10_000 {
let lamports = rng.gen();
Expand Down
10 changes: 6 additions & 4 deletions runtime/benches/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
extern crate test;

use rand::{thread_rng, Rng};
use solana_runtime::{accounts_db::AccountInfo, accounts_index::AccountsIndex};
use solana_runtime::{
accounts_db::AccountInfo,
accounts_index::{AccountSecondaryIndexes, AccountsIndex},
};
use solana_sdk::pubkey::{self, Pubkey};
use std::collections::HashSet;
use test::Bencher;

#[bench]
Expand All @@ -24,7 +26,7 @@ fn bench_accounts_index(bencher: &mut Bencher) {
pubkey,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
AccountInfo::default(),
&mut reclaims,
);
Expand All @@ -41,7 +43,7 @@ fn bench_accounts_index(bencher: &mut Bencher) {
&pubkeys[pubkey],
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
AccountInfo::default(),
&mut reclaims,
);
Expand Down
Loading

0 comments on commit f39dda0

Please sign in to comment.