Skip to content

Commit

Permalink
accounts-db/add counter for reopen append vec as file-io (solana-labs…
Browse files Browse the repository at this point in the history
…#1887)

* add counter for reopen append vec as file-io

* Update accounts-db/src/accounts_db.rs

Co-authored-by: Brooks <[email protected]>

---------

Co-authored-by: HaoranYi <[email protected]>
Co-authored-by: Brooks <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2024
1 parent edc8668 commit 2a049a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use {
},
append_vec::{
aligned_stored_size, APPEND_VEC_MMAPPED_FILES_DIRTY, APPEND_VEC_MMAPPED_FILES_OPEN,
STORE_META_OVERHEAD,
APPEND_VEC_REOPEN_AS_FILE_IO, STORE_META_OVERHEAD,
},
cache_hash_data::{
CacheHashData, CacheHashDataFileReference, DeletionPolicy as CacheHashDeletionPolicy,
Expand Down Expand Up @@ -1121,6 +1121,7 @@ impl AccountStorageEntry {
return None;
}

APPEND_VEC_REOPEN_AS_FILE_IO.fetch_add(1, Ordering::Relaxed);
let count_and_status = self.count_and_status.lock_write();
self.accounts.reopen_as_readonly().map(|accounts| Self {
id: self.id,
Expand Down Expand Up @@ -1917,6 +1918,11 @@ impl LatestAccountsIndexRootsStats {
"append_vecs_dirty",
APPEND_VEC_MMAPPED_FILES_DIRTY.load(Ordering::Relaxed),
i64
),
(
"append_vecs_open_as_file_io",
APPEND_VEC_REOPEN_AS_FILE_IO.load(Ordering::Relaxed),
i64
)
);

Expand Down
5 changes: 4 additions & 1 deletion accounts-db/src/append_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ const fn page_align(size: u64) -> u64 {
lazy_static! {
pub static ref APPEND_VEC_MMAPPED_FILES_OPEN: AtomicU64 = AtomicU64::default();
pub static ref APPEND_VEC_MMAPPED_FILES_DIRTY: AtomicU64 = AtomicU64::default();
pub static ref APPEND_VEC_REOPEN_AS_FILE_IO: AtomicU64 = AtomicU64::default();
}

impl Drop for AppendVec {
Expand All @@ -296,7 +297,9 @@ impl Drop for AppendVec {
APPEND_VEC_MMAPPED_FILES_DIRTY.fetch_sub(1, Ordering::Relaxed);
}
}
AppendVecFileBacking::File(_) => {}
AppendVecFileBacking::File(_) => {
APPEND_VEC_REOPEN_AS_FILE_IO.fetch_sub(1, Ordering::Relaxed);
}
}
if self.remove_file_on_drop.load(Ordering::Acquire) {
// If we're reopening in readonly mode, we don't delete the file. See
Expand Down

0 comments on commit 2a049a5

Please sign in to comment.