disk index: add stat: disk_index_failed_resizes (#31039)

This commit is contained in:
Jeff Washington (jwash) 2023-04-04 11:39:06 -05:00 committed by GitHub
parent 514816a31f
commit aa3e0b9c20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -443,14 +443,15 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
}
let mut m = Measure::start("grow_index");
//debug!("GROW_INDEX: {}", current_capacity_pow2);
let increment = 1;
for i in increment.. {
let mut count = 0;
loop {
count += 1;
let mut index = BucketStorage::new_with_capacity(
Arc::clone(&self.drives),
1,
std::mem::size_of::<IndexEntry<T>>() as u64,
// the subtle `+ i` here causes us to grow from the starting size by a power of 2 on each iteration of the for loop
Capacity::Pow2(starting_size_pow2 + i),
Capacity::Pow2(starting_size_pow2 + count),
self.index.max_search,
Arc::clone(&self.stats.index),
Arc::clone(&self.index.count),
@ -487,6 +488,12 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
}
}
m.stop();
if count > 1 {
self.stats
.index
.failed_resizes
.fetch_add(count as u64 - 1, Ordering::Relaxed);
}
self.stats.index.resizes.fetch_add(1, Ordering::Relaxed);
self.stats
.index

View File

@ -6,6 +6,7 @@ use std::sync::{
#[derive(Debug, Default)]
pub struct BucketStats {
pub resizes: AtomicU64,
pub failed_resizes: AtomicU64,
pub max_size: AtomicU64,
pub resize_us: AtomicU64,
pub new_file_us: AtomicU64,

View File

@ -404,6 +404,12 @@ impl BucketMapHolderStats {
.unwrap_or_default(),
i64
),
(
"disk_index_failed_resizes",
disk.map(|disk| disk.stats.index.failed_resizes.swap(0, Ordering::Relaxed))
.unwrap_or_default(),
i64
),
(
"disk_index_max_size",
disk.map(|disk| { disk.stats.index.max_size.swap(0, Ordering::Relaxed) })