diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index e04c8ee1a..4e3d9069a 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -152,6 +152,15 @@ pub enum IncludeSlotInHash { IrrelevantAssertOnUse, } +#[derive(Debug, Default, Clone, Copy)] +pub enum CreateAncientStorage { + /// ancient storages are created by appending + #[default] + Append, + /// ancient storages are created by 1-shot write to pack multiple accounts together more efficiently with new formats + Pack, +} + #[derive(Default)] /// hold alive accounts and bytes used by those accounts /// alive means in the accounts index @@ -425,6 +434,7 @@ pub const ACCOUNTS_DB_CONFIG_FOR_TESTING: AccountsDbConfig = AccountsDbConfig { skip_initial_hash_calc: false, exhaustively_verify_refcounts: false, assert_stakes_cache_consistency: true, + create_ancient_storage: CreateAncientStorage::Append, }; pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig { index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS), @@ -435,6 +445,7 @@ pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig skip_initial_hash_calc: false, exhaustively_verify_refcounts: false, assert_stakes_cache_consistency: false, + create_ancient_storage: CreateAncientStorage::Append, }; pub type BinnedHashData = Vec>; @@ -494,6 +505,8 @@ pub struct AccountsDbConfig { pub exhaustively_verify_refcounts: bool, /// when stakes cache consistency check occurs, assert that cached accounts match accounts db pub assert_stakes_cache_consistency: bool, + /// how to create ancient storages + pub create_ancient_storage: CreateAncientStorage, } #[cfg(not(test))] @@ -1287,8 +1300,13 @@ pub struct AccountsDb { pub(crate) storage: AccountStorage, + /// from AccountsDbConfig pub(crate) assert_stakes_cache_consistency: bool, + #[allow(dead_code)] + /// from AccountsDbConfig + create_ancient_storage: CreateAncientStorage, + pub accounts_cache: AccountsCache, write_cache_limit_bytes: Option, @@ -2306,6 +2324,7 @@ impl AccountsDb { AccountsDb { assert_stakes_cache_consistency: false, + create_ancient_storage: CreateAncientStorage::Append, verify_accounts_hash_in_bg: VerifyAccountsHashInBackground::default(), filler_accounts_per_slot: AtomicU64::default(), filler_account_slots_remaining: AtomicU64::default(), @@ -2429,6 +2448,11 @@ impl AccountsDb { .map(|config| config.assert_stakes_cache_consistency) .unwrap_or_default(); + let create_ancient_storage = accounts_db_config + .as_ref() + .map(|config| config.create_ancient_storage) + .unwrap_or(CreateAncientStorage::Append); + let filler_account_suffix = if filler_accounts_config.count > 0 { Some(solana_sdk::pubkey::new_rand()) } else { @@ -2446,6 +2470,7 @@ impl AccountsDb { filler_accounts_config, filler_account_suffix, assert_stakes_cache_consistency, + create_ancient_storage, write_cache_limit_bytes: accounts_db_config .as_ref() .and_then(|x| x.write_cache_limit_bytes), diff --git a/validator/src/cli.rs b/validator/src/cli.rs index 2f5be98a5..0d8da1569 100644 --- a/validator/src/cli.rs +++ b/validator/src/cli.rs @@ -1182,6 +1182,12 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> { .help("Enables faster starting of validators by skipping shrink. \ This option is for use during testing."), ) + .arg( + Arg::with_name("accounts_db_create_ancient_storage_packed") + .long("accounts-db-create-ancient-storage-packed") + .help("Create ancient storages in one shot instead of appending.") + .hidden(true), + ) .arg( Arg::with_name("accounts_db_ancient_append_vecs") .long("accounts-db-ancient-append-vecs") diff --git a/validator/src/main.rs b/validator/src/main.rs index a0cb82dbb..32f9e4df1 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -28,7 +28,10 @@ use { solana_rpc_client::rpc_client::RpcClient, solana_rpc_client_api::config::RpcLeaderScheduleConfig, solana_runtime::{ - accounts_db::{AccountShrinkThreshold, AccountsDb, AccountsDbConfig, FillerAccountsConfig}, + accounts_db::{ + AccountShrinkThreshold, AccountsDb, AccountsDbConfig, CreateAncientStorage, + FillerAccountsConfig, + }, accounts_index::{ AccountIndex, AccountSecondaryIndexes, AccountSecondaryIndexesIncludeExclude, AccountsIndexConfig, IndexLimitMb, @@ -1046,6 +1049,10 @@ pub fn main() { .map(|mb| mb * MB as u64), ancient_append_vec_offset: value_t!(matches, "accounts_db_ancient_append_vecs", i64).ok(), exhaustively_verify_refcounts: matches.is_present("accounts_db_verify_refcounts"), + create_ancient_storage: matches + .is_present("accounts_db_create_ancient_storage_packed") + .then_some(CreateAncientStorage::Pack) + .unwrap_or_default(), ..AccountsDbConfig::default() };