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 55ac78b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 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
12 changes: 11 additions & 1 deletion bucket_map/src/bucket_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
use {
crate::{bucket_api::BucketApi, bucket_stats::BucketMapStats, MaxSearch, RefCount},
solana_sdk::pubkey::Pubkey,
std::{convert::TryInto, fmt::Debug, fs, path::PathBuf, sync::Arc},
std::{
convert::TryInto,
fmt::Debug,
fs,
path::PathBuf,
sync::{atomic::AtomicU64, Arc},
},
tempfile::TempDir,
};

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

#[derive(Debug, Default, Clone)]
pub struct BucketMapConfig {
pub max_buckets: usize,
Expand Down
4 changes: 3 additions & 1 deletion bucket_map/src/bucket_storage.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
crate::{bucket_stats::BucketStats, MaxSearch},
crate::{bucket_map::ACCOUNT_INDEX_MMAPPED_FILES_OPEN, bucket_stats::BucketStats, MaxSearch},
memmap2::MmapMut,
rand::{thread_rng, Rng},
solana_measure::measure::Measure,
Expand Down Expand Up @@ -92,6 +92,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 +108,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.

11 changes: 11 additions & 0 deletions runtime/src/bucket_map_holder_stats.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
crate::{accounts_index::IndexValue, bucket_map_holder::BucketMapHolder},
solana_bucket_map::bucket_map::ACCOUNT_INDEX_MMAPPED_FILES_OPEN,
solana_sdk::timing::AtomicInterval,
std::{
fmt::Debug,
Expand Down Expand Up @@ -478,6 +479,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 +579,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 55ac78b

Please sign in to comment.