add stats for disk_index_find_entry_mut_us (#26753)

This commit is contained in:
Jeff Washington (jwash) 2022-07-25 14:47:17 -05:00 committed by GitHub
parent 5d038b9d2a
commit 6f5995c841
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View File

@ -151,6 +151,7 @@ impl<T: Clone + Copy> Bucket<T> {
key: &Pubkey,
random: u64,
) -> Option<(&'a mut IndexEntry, u64)> {
let mut m = Measure::start("bucket_find_entry_mut");
let ix = Self::bucket_index_ix(index, key, random);
for i in ix..ix + index.max_search() {
let ii = i % index.capacity();
@ -159,9 +160,19 @@ impl<T: Clone + Copy> Bucket<T> {
}
let elem: &mut IndexEntry = index.get_mut(ii);
if elem.key == *key {
m.stop();
index
.stats
.find_entry_mut_us
.fetch_add(m.as_us(), Ordering::Relaxed);
return Some((elem, ii));
}
}
m.stop();
index
.stats
.find_entry_mut_us
.fetch_add(m.as_us(), Ordering::Relaxed);
None
}
@ -191,6 +202,7 @@ impl<T: Clone + Copy> Bucket<T> {
random: u64,
is_resizing: bool,
) -> Result<u64, BucketMapError> {
let mut m = Measure::start("bucket_create_key");
let ix = Self::bucket_index_ix(index, key, random);
for i in ix..ix + index.max_search() {
let ii = i as u64 % index.capacity();
@ -203,8 +215,18 @@ impl<T: Clone + Copy> Bucket<T> {
// Since this part of the mmapped file could have previously been used by someone else, there can be garbage here.
elem.init(key);
//debug!( "INDEX ALLOC {:?} {} {} {}", key, ii, index.capacity, elem_uid );
m.stop();
index
.stats
.find_entry_mut_us
.fetch_add(m.as_us(), Ordering::Relaxed);
return Ok(ii);
}
m.stop();
index
.stats
.find_entry_mut_us
.fetch_add(m.as_us(), Ordering::Relaxed);
Err(BucketMapError::IndexNoSpace(index.capacity_pow2))
}

View File

@ -8,6 +8,7 @@ pub struct BucketStats {
pub new_file_us: AtomicU64,
pub flush_file_us: AtomicU64,
pub mmap_us: AtomicU64,
pub find_entry_mut_us: AtomicU64,
}
#[derive(Debug, Default)]

View File

@ -409,6 +409,16 @@ impl BucketMapHolderStats {
.unwrap_or_default(),
i64
),
(
"disk_index_find_entry_mut_us",
disk.map(|disk| disk
.stats
.index
.find_entry_mut_us
.swap(0, Ordering::Relaxed))
.unwrap_or_default(),
i64
),
(
"disk_index_flush_mmap_us",
disk.map(|disk| disk.stats.index.mmap_us.swap(0, Ordering::Relaxed))