Skip to content

Commit

Permalink
disk index: add stat: disk_index_failed_resizes (#31039)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Apr 4, 2023
1 parent 514816a commit aa3e0b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bucket_map/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions bucket_map/src/bucket_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions runtime/src/bucket_map_holder_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
Expand Down

0 comments on commit aa3e0b9

Please sign in to comment.