solana_accounts_db/accounts_db/
accounts_db_config.rs

1use {
2    super::{
3        AccountShrinkThreshold, MarkObsoleteAccounts, DEFAULT_ACCOUNTS_SHRINK_THRESHOLD_OPTION,
4        MEMLOCK_BUDGET_SIZE_FOR_TESTS,
5    },
6    crate::{
7        accounts_file::StorageAccess,
8        accounts_index::{
9            AccountSecondaryIndexes, AccountsIndexConfig, ScanFilter,
10            ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS, ACCOUNTS_INDEX_CONFIG_FOR_TESTING,
11        },
12        partitioned_rewards::{
13            PartitionedEpochRewardsConfig, DEFAULT_PARTITIONED_EPOCH_REWARDS_CONFIG,
14        },
15    },
16    std::{num::NonZeroUsize, path::PathBuf},
17};
18
19#[derive(Debug, Default, Clone)]
20pub struct AccountsDbConfig {
21    pub index: Option<AccountsIndexConfig>,
22    pub account_indexes: Option<AccountSecondaryIndexes>,
23    /// Base directory for various necessary files
24    pub base_working_path: Option<PathBuf>,
25    pub shrink_paths: Option<Vec<PathBuf>>,
26    pub shrink_ratio: AccountShrinkThreshold,
27    /// The low and high watermark sizes for the read cache, in bytes.
28    /// If None, defaults will be used.
29    pub read_cache_limit_bytes: Option<(usize, usize)>,
30    /// The number of elements that will be randomly sampled at eviction time,
31    /// the oldest of which will get evicted.
32    pub read_cache_evict_sample_size: Option<usize>,
33    pub write_cache_limit_bytes: Option<u64>,
34    /// if None, ancient append vecs are set to ANCIENT_APPEND_VEC_DEFAULT_OFFSET
35    /// Some(offset) means include slots up to (max_slot - (slots_per_epoch - 'offset'))
36    pub ancient_append_vec_offset: Option<i64>,
37    pub ancient_storage_ideal_size: Option<u64>,
38    pub max_ancient_storages: Option<usize>,
39    pub skip_initial_hash_calc: bool,
40    pub exhaustively_verify_refcounts: bool,
41    pub partitioned_epoch_rewards_config: PartitionedEpochRewardsConfig,
42    pub storage_access: StorageAccess,
43    pub scan_filter_for_shrinking: ScanFilter,
44    pub mark_obsolete_accounts: MarkObsoleteAccounts,
45    /// Number of threads for background operations (`thread_pool_background')
46    pub num_background_threads: Option<NonZeroUsize>,
47    /// Number of threads for foreground operations (`thread_pool_foreground`)
48    pub num_foreground_threads: Option<NonZeroUsize>,
49    /// Amount of memory (in bytes) that is allowed to be locked during db operations.
50    /// On linux it's verified on start-up with the kernel limits, such that during runtime
51    /// parts of it can be utilized without panicking.
52    pub memlock_budget_size: usize,
53}
54
55pub const ACCOUNTS_DB_CONFIG_FOR_TESTING: AccountsDbConfig = AccountsDbConfig {
56    index: Some(ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
57    account_indexes: None,
58    base_working_path: None,
59    shrink_paths: None,
60    shrink_ratio: DEFAULT_ACCOUNTS_SHRINK_THRESHOLD_OPTION,
61    read_cache_limit_bytes: None,
62    read_cache_evict_sample_size: None,
63    write_cache_limit_bytes: None,
64    ancient_append_vec_offset: None,
65    ancient_storage_ideal_size: None,
66    max_ancient_storages: None,
67    skip_initial_hash_calc: false,
68    exhaustively_verify_refcounts: false,
69    partitioned_epoch_rewards_config: DEFAULT_PARTITIONED_EPOCH_REWARDS_CONFIG,
70    storage_access: StorageAccess::File,
71    scan_filter_for_shrinking: ScanFilter::OnlyAbnormalTest,
72    mark_obsolete_accounts: MarkObsoleteAccounts::Disabled,
73    num_background_threads: None,
74    num_foreground_threads: None,
75    memlock_budget_size: MEMLOCK_BUDGET_SIZE_FOR_TESTS,
76};
77
78pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig {
79    index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS),
80    account_indexes: None,
81    base_working_path: None,
82    shrink_paths: None,
83    shrink_ratio: DEFAULT_ACCOUNTS_SHRINK_THRESHOLD_OPTION,
84    read_cache_limit_bytes: None,
85    read_cache_evict_sample_size: None,
86    write_cache_limit_bytes: None,
87    ancient_append_vec_offset: None,
88    ancient_storage_ideal_size: None,
89    max_ancient_storages: None,
90    skip_initial_hash_calc: false,
91    exhaustively_verify_refcounts: false,
92    partitioned_epoch_rewards_config: DEFAULT_PARTITIONED_EPOCH_REWARDS_CONFIG,
93    storage_access: StorageAccess::File,
94    scan_filter_for_shrinking: ScanFilter::OnlyAbnormal,
95    mark_obsolete_accounts: MarkObsoleteAccounts::Disabled,
96    num_background_threads: None,
97    num_foreground_threads: None,
98    memlock_budget_size: MEMLOCK_BUDGET_SIZE_FOR_TESTS,
99};