diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index c105884d046862..e772d6da36a94b 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -42,7 +42,7 @@ use { }, append_vec::{ AppendVec, StorableAccountsWithHashesAndWriteVersions, StoredAccountMeta, StoredMeta, - StoredMetaWriteVersion, + StoredMetaWriteVersion, APPEND_VEC_MMAPPED_FILES_OPEN, }, bank::Rewrites, cache_hash_data::{CacheHashData, CacheHashDataFile}, @@ -1805,6 +1805,11 @@ impl LatestAccountsIndexRootsStats { self.clean_dead_slot_us.swap(0, Ordering::Relaxed) as i64, i64 ), + ( + "append_vecs_open", + APPEND_VEC_MMAPPED_FILES_OPEN.load(Ordering::Relaxed) as i64, + i64 + ) ); // Don't need to reset since this tracks the latest updates, not a cumulative total diff --git a/runtime/src/append_vec.rs b/runtime/src/append_vec.rs index 0b0c42ce4b715e..2e5898758cfefb 100644 --- a/runtime/src/append_vec.rs +++ b/runtime/src/append_vec.rs @@ -24,7 +24,7 @@ use { mem, path::{Path, PathBuf}, sync::{ - atomic::{AtomicUsize, Ordering}, + atomic::{AtomicU64, AtomicUsize, Ordering}, Mutex, }, }, @@ -284,9 +284,14 @@ pub struct AppendVec { remove_on_drop: bool, } +lazy_static! { + pub static ref APPEND_VEC_MMAPPED_FILES_OPEN: AtomicU64 = AtomicU64::default(); +} + impl Drop for AppendVec { fn drop(&mut self) { if self.remove_on_drop { + APPEND_VEC_MMAPPED_FILES_OPEN.fetch_sub(1, Ordering::Relaxed); if let Err(_e) = remove_file(&self.path) { // promote this to panic soon. // disabled due to many false positive warnings while running tests. @@ -341,6 +346,7 @@ impl AppendVec { ); std::process::exit(1); }); + APPEND_VEC_MMAPPED_FILES_OPEN.fetch_add(1, Ordering::Relaxed); AppendVec { path: file.to_path_buf(), @@ -450,6 +456,7 @@ impl AppendVec { } result? }; + APPEND_VEC_MMAPPED_FILES_OPEN.fetch_add(1, Ordering::Relaxed); Ok(AppendVec { path: path.as_ref().to_path_buf(),