introduce AtomicAppendVecId (#21793)

This commit is contained in:
Jeff Washington (jwash) 2021-12-11 21:34:35 -06:00 committed by GitHub
parent a400b5e63d
commit 4c0373b72a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -114,7 +114,7 @@ const MAX_ITEMS_PER_CHUNK: Slot = 2_500;
// operations that take a storage entry can maintain a common interface
// when interacting with cached accounts. This id is "virtual" in that it
// doesn't actually refer to an actual storage entry.
const CACHE_VIRTUAL_STORAGE_ID: usize = AppendVecId::MAX;
const CACHE_VIRTUAL_STORAGE_ID: AppendVecId = AppendVecId::MAX;
// A specially reserved write version (identifier for ordering writes in an AppendVec)
// for entries in the cache, so that operations that take a storage entry can maintain
@ -365,6 +365,7 @@ impl<'a> MultiThreadProgress<'a> {
}
/// An offset into the AccountsDb::storage vector
pub type AtomicAppendVecId = AtomicUsize;
pub type AppendVecId = usize;
pub type SnapshotStorage = Vec<Arc<AccountStorageEntry>>;
pub type SnapshotStorages = Vec<SnapshotStorage>;
@ -627,7 +628,7 @@ struct CleanKeyTimings {
/// Persistent storage structure holding the accounts
#[derive(Debug)]
pub struct AccountStorageEntry {
pub(crate) id: AtomicUsize,
pub(crate) id: AtomicAppendVecId,
pub(crate) slot: AtomicU64,
@ -659,7 +660,7 @@ impl AccountStorageEntry {
let accounts = AppendVec::new(&path, true, file_size as usize);
Self {
id: AtomicUsize::new(id),
id: AtomicAppendVecId::new(id),
slot: AtomicU64::new(slot),
accounts,
count_and_status: RwLock::new((0, AccountStorageStatus::Available)),
@ -675,7 +676,7 @@ impl AccountStorageEntry {
num_accounts: usize,
) -> Self {
Self {
id: AtomicUsize::new(id),
id: AtomicAppendVecId::new(id),
slot: AtomicU64::new(slot),
accounts,
count_and_status: RwLock::new((0, AccountStorageStatus::Available)),
@ -979,7 +980,7 @@ pub struct AccountsDb {
recycle_stores: RwLock<RecycleStores>,
/// distribute the accounts across storage lists
pub next_id: AtomicUsize,
pub next_id: AtomicAppendVecId,
/// Set of shrinkable stores organized by map of slot to append_vec_id
pub shrink_candidate_slots: Mutex<ShrinkCandidates>,
@ -1570,7 +1571,7 @@ impl AccountsDb {
read_only_accounts_cache: ReadOnlyAccountsCache::new(MAX_READ_ONLY_CACHE_DATA_SIZE),
recycle_stores: RwLock::new(RecycleStores::default()),
uncleaned_pubkeys: DashMap::new(),
next_id: AtomicUsize::new(0),
next_id: AtomicAppendVecId::new(0),
shrink_candidate_slots_v1: Mutex::new(Vec::new()),
shrink_candidate_slots: Mutex::new(HashMap::new()),
write_cache_limit_bytes: None,

View File

@ -5,7 +5,7 @@ use {
accounts::Accounts,
accounts_db::{
AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AccountsDbConfig, AppendVecId,
BankHashInfo, IndexGenerationInfo,
AtomicAppendVecId, BankHashInfo, IndexGenerationInfo,
},
accounts_index::AccountSecondaryIndexes,
accounts_update_notifier_interface::AccountsUpdateNotifier,
@ -437,7 +437,7 @@ where
// Remap the deserialized AppendVec paths to point to correct local paths
let num_collisions = AtomicUsize::new(0);
let next_append_vec_id = AtomicUsize::new(0);
let next_append_vec_id = AtomicAppendVecId::new(0);
let mut measure_remap = Measure::start("remap");
let mut storage = (0..snapshot_storages.len())
.into_par_iter()