log # append vecs open (#28958)

This commit is contained in:
Jeff Washington (jwash) 2022-11-29 18:48:02 -06:00 committed by GitHub
parent e42649a8ba
commit c8cc1270f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -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},
@ -1796,6 +1796,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

View File

@ -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(),