Skip to content

Commit

Permalink
log mmap for accounts_index
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Nov 29, 2022
1 parent bdd1624 commit 6714560
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bucket_map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ license = "Apache-2.0"
edition = "2021"

[dependencies]
lazy_static = "1.4.0"
log = { version = "0.4.17" }
memmap2 = "0.5.3"
modular-bitfield = "0.11.2"
Expand Down
6 changes: 6 additions & 0 deletions bucket_map/src/bucket_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const UID_UNLOCKED: Uid = 0;

pub(crate) type Uid = u64;

lazy_static! {
pub static ref ACCOUNT_INDEX_MMAPPED_FILES_OPEN: AtomicU64 = AtomicU64::default();
}

#[repr(C)]
struct Header {
lock: u64,
Expand Down Expand Up @@ -92,6 +96,7 @@ pub enum BucketStorageError {
impl Drop for BucketStorage {
fn drop(&mut self) {
let _ = remove_file(&self.path);
ACCOUNT_INDEX_MMAPPED_FILES_OPEN.fetch_sub(1, Ordering::Relaxed);
}
}

Expand All @@ -107,6 +112,7 @@ impl BucketStorage {
) -> Self {
let cell_size = elem_size * num_elems + std::mem::size_of::<Header>() as u64;
let (mmap, path) = Self::new_map(&drives, cell_size as usize, capacity_pow2, &stats);
ACCOUNT_INDEX_MMAPPED_FILES_OPEN.fetch_add(1, Ordering::Relaxed);
Self {
path,
mmap,
Expand Down
4 changes: 4 additions & 0 deletions bucket_map/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#![allow(clippy::integer_arithmetic)]

#[macro_use]
extern crate lazy_static;

mod bucket;
pub mod bucket_api;
mod bucket_item;
Expand Down
1 change: 1 addition & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions runtime/src/bucket_map_holder_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ impl BucketMapHolderStats {
.swap(0, Ordering::Relaxed),
i64
),
(
"account_index_mmap_open",
ACCOUNT_INDEX_MMAPPED_FILES_OPEN.load(Ordering::Relaxed) as i64,
i64
),
);
} else {
datapoint_info!(
Expand Down Expand Up @@ -573,6 +578,11 @@ impl BucketMapHolderStats {
("items", self.items.swap(0, Ordering::Relaxed), i64),
("items_us", self.items_us.swap(0, Ordering::Relaxed), i64),
("keys", self.keys.swap(0, Ordering::Relaxed), i64),
(
"account_index_mmap_open",
ACCOUNT_INDEX_MMAPPED_FILES_OPEN.load(Ordering::Relaxed) as i64,
i64
),
);
}
}
Expand Down

0 comments on commit 6714560

Please sign in to comment.