From 2a049a5d6aff8dfb023481232d5be84f2b0fd322 Mon Sep 17 00:00:00 2001 From: HaoranYi <219428+HaoranYi@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:05:48 -0500 Subject: [PATCH] accounts-db/add counter for reopen append vec as file-io (#1887) * add counter for reopen append vec as file-io * Update accounts-db/src/accounts_db.rs Co-authored-by: Brooks --------- Co-authored-by: HaoranYi Co-authored-by: Brooks --- accounts-db/src/accounts_db.rs | 8 +++++++- accounts-db/src/append_vec.rs | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 9ce0fc6f4eaeb9..4b911a6fe8662c 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -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, @@ -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, @@ -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 ) ); diff --git a/accounts-db/src/append_vec.rs b/accounts-db/src/append_vec.rs index d809b1399bc783..286a99632207df 100644 --- a/accounts-db/src/append_vec.rs +++ b/accounts-db/src/append_vec.rs @@ -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 { @@ -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