Skip to content

Commit

Permalink
log # append vecs open
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Nov 29, 2022
1 parent 45291a5 commit 53942d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion runtime/src/append_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use {
mem,
path::{Path, PathBuf},
sync::{
atomic::{AtomicUsize, Ordering},
atomic::{AtomicU64, AtomicUsize, Ordering},
Mutex,
},
},
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 53942d6

Please sign in to comment.