From f7b0445ae0e230bd37774e928f036bc81df1c7b4 Mon Sep 17 00:00:00 2001 From: yihau Date: Wed, 7 Aug 2024 23:37:40 +0800 Subject: [PATCH 1/5] docs fix: accounts-db --- accounts-db/src/account_storage.rs | 5 +++-- accounts-db/src/accounts_db.rs | 2 ++ accounts-db/src/accounts_index.rs | 1 + accounts-db/src/ancient_append_vecs.rs | 7 ++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/accounts-db/src/account_storage.rs b/accounts-db/src/account_storage.rs index 738d7d958e9ce2..0c67c5553f9f0b 100644 --- a/accounts-db/src/account_storage.rs +++ b/accounts-db/src/account_storage.rs @@ -43,8 +43,9 @@ impl AccountStorage { /// Callers to this function have 2 choices: /// 1. hold the account index read lock for the pubkey so that the account index entry cannot be changed prior to or during this call. (scans do this) /// 2. expect to be ready to start over and read the index again if this function returns None - /// Operations like shrinking or write cache flushing may have updated the index between when the caller read the index and called this function to - /// load from the append vec specified in the index. + /// Operations like shrinking or write cache flushing may have updated the index between when the caller read the index and called this function to + /// load from the append vec specified in the index. + /// /// In practice, this fn will return the entry from the map in the very first lookup unless a shrink is in progress. /// The third lookup will only be called if a requesting thread exactly interposes itself between the 2 map manipulations in the drop of 'shrink_in_progress'. pub(crate) fn get_account_storage_entry( diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 28610eb79eb20a..85885a7bf7e4e5 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -325,6 +325,7 @@ pub enum StoreReclaims { /// 3. use it (slot, append_vec, etc.) /// 4. re-create it sometimes /// 5. goto 3 +/// /// If a caller uses it before initializing it, it will be a runtime unwrap() error, similar to an assert. /// That condition is an illegal use pattern and is justifiably an assertable condition. #[derive(Default)] @@ -9099,6 +9100,7 @@ impl AccountsDb { /// 1. get the _duplicate_ accounts data len from the given pubkeys /// 2. get the slots that contained duplicate pubkeys /// 3. update rent stats + /// /// Note this should only be used when ALL entries in the accounts index are roots. /// returns (data len sum of all older duplicates, slots that contained duplicate pubkeys) fn visit_duplicate_pubkeys_during_startup( diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index dc10df29d67e35..3b4ddbe3927e5d 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -376,6 +376,7 @@ impl PreAllocatedAccountMapEntry { /// create an entry that is equivalent to this process: /// 1. new empty (refcount=0, slot_list={}) /// 2. update(slot, account_info) + /// /// This code is called when the first entry [ie. (slot,account_info)] for a pubkey is inserted into the index. pub fn new + Into>( slot: Slot, diff --git a/accounts-db/src/ancient_append_vecs.rs b/accounts-db/src/ancient_append_vecs.rs index ffe025e7474a39..561d78d17a4c13 100644 --- a/accounts-db/src/ancient_append_vecs.rs +++ b/accounts-db/src/ancient_append_vecs.rs @@ -2,7 +2,7 @@ //! an ancient append vec is: //! 1. a slot that is older than an epoch old //! 2. multiple 'slots' squashed into a single older (ie. ancient) slot for convenience and performance -//! Otherwise, an ancient append vec is the same as any other append vec +//! Otherwise, an ancient append vec is the same as any other append vec use { crate::{ account_storage::ShrinkInProgress, @@ -717,8 +717,9 @@ impl AccountsDb { /// given all accounts per ancient slot, in slots that we want to combine together: /// 1. Look up each pubkey in the index /// 2. separate, by slot, into: - /// 2a. pubkeys with refcount = 1. This means this pubkey exists NOWHERE else in accounts db. - /// 2b. pubkeys with refcount > 1 + /// 2a. pubkeys with refcount = 1. This means this pubkey exists NOWHERE else in accounts db. + /// 2b. pubkeys with refcount > 1 + /// /// Note that the return value can contain fewer items than 'accounts_per_storage' if we find storages which won't be affected. /// 'accounts_per_storage' should be sorted by slot fn calc_accounts_to_combine<'a>( From 07d26edf5040ded0504a2f61e2fb8a6471f1f3dd Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Fri, 9 Aug 2024 15:11:06 +0800 Subject: [PATCH 2/5] Update accounts-db/src/account_storage.rs Co-authored-by: Brooks --- accounts-db/src/account_storage.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/accounts-db/src/account_storage.rs b/accounts-db/src/account_storage.rs index 0c67c5553f9f0b..3882907130fe32 100644 --- a/accounts-db/src/account_storage.rs +++ b/accounts-db/src/account_storage.rs @@ -43,6 +43,7 @@ impl AccountStorage { /// Callers to this function have 2 choices: /// 1. hold the account index read lock for the pubkey so that the account index entry cannot be changed prior to or during this call. (scans do this) /// 2. expect to be ready to start over and read the index again if this function returns None + /// /// Operations like shrinking or write cache flushing may have updated the index between when the caller read the index and called this function to /// load from the append vec specified in the index. /// From 0b9aa15684d1f26c169c6e74d3d6f27b846b57aa Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Fri, 9 Aug 2024 15:11:12 +0800 Subject: [PATCH 3/5] Update accounts-db/src/ancient_append_vecs.rs Co-authored-by: Brooks --- accounts-db/src/ancient_append_vecs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/accounts-db/src/ancient_append_vecs.rs b/accounts-db/src/ancient_append_vecs.rs index 561d78d17a4c13..20d6a98d64c09d 100644 --- a/accounts-db/src/ancient_append_vecs.rs +++ b/accounts-db/src/ancient_append_vecs.rs @@ -2,6 +2,7 @@ //! an ancient append vec is: //! 1. a slot that is older than an epoch old //! 2. multiple 'slots' squashed into a single older (ie. ancient) slot for convenience and performance +//! //! Otherwise, an ancient append vec is the same as any other append vec use { crate::{ From 1b6f3992e9913e7a013445ecb4b00193dd898d47 Mon Sep 17 00:00:00 2001 From: yihau Date: Sat, 10 Aug 2024 01:30:34 +0800 Subject: [PATCH 4/5] remove redundant indent --- accounts-db/src/account_storage.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts-db/src/account_storage.rs b/accounts-db/src/account_storage.rs index 3882907130fe32..da25092a59be09 100644 --- a/accounts-db/src/account_storage.rs +++ b/accounts-db/src/account_storage.rs @@ -44,8 +44,8 @@ impl AccountStorage { /// 1. hold the account index read lock for the pubkey so that the account index entry cannot be changed prior to or during this call. (scans do this) /// 2. expect to be ready to start over and read the index again if this function returns None /// - /// Operations like shrinking or write cache flushing may have updated the index between when the caller read the index and called this function to - /// load from the append vec specified in the index. + /// Operations like shrinking or write cache flushing may have updated the index between when the caller read the index and called this function to + /// load from the append vec specified in the index. /// /// In practice, this fn will return the entry from the map in the very first lookup unless a shrink is in progress. /// The third lookup will only be called if a requesting thread exactly interposes itself between the 2 map manipulations in the drop of 'shrink_in_progress'. From 828cad45b93368b88c9fd4760bd59cec66d099c6 Mon Sep 17 00:00:00 2001 From: yihau Date: Sat, 10 Aug 2024 01:31:51 +0800 Subject: [PATCH 5/5] remove redundant indent --- accounts-db/src/ancient_append_vecs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts-db/src/ancient_append_vecs.rs b/accounts-db/src/ancient_append_vecs.rs index 20d6a98d64c09d..095c7dd21881eb 100644 --- a/accounts-db/src/ancient_append_vecs.rs +++ b/accounts-db/src/ancient_append_vecs.rs @@ -3,7 +3,7 @@ //! 1. a slot that is older than an epoch old //! 2. multiple 'slots' squashed into a single older (ie. ancient) slot for convenience and performance //! -//! Otherwise, an ancient append vec is the same as any other append vec +//! Otherwise, an ancient append vec is the same as any other append vec use { crate::{ account_storage::ShrinkInProgress,