From aa3e0b9c2056dfa2d19e1b33fa3fc757ad41faf5 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 4 Apr 2023 11:39:06 -0500 Subject: [PATCH] disk index: add stat: disk_index_failed_resizes (#31039) --- bucket_map/src/bucket.rs | 13 ++++++++++--- bucket_map/src/bucket_stats.rs | 1 + runtime/src/bucket_map_holder_stats.rs | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bucket_map/src/bucket.rs b/bucket_map/src/bucket.rs index 8e81d3e70a70f1..ee244337bebca0 100644 --- a/bucket_map/src/bucket.rs +++ b/bucket_map/src/bucket.rs @@ -443,14 +443,15 @@ impl<'b, T: Clone + Copy + 'static> Bucket { } 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::>() 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 { } } 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 diff --git a/bucket_map/src/bucket_stats.rs b/bucket_map/src/bucket_stats.rs index 5940d3467943e7..3ccb7ae420a22c 100644 --- a/bucket_map/src/bucket_stats.rs +++ b/bucket_map/src/bucket_stats.rs @@ -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, diff --git a/runtime/src/bucket_map_holder_stats.rs b/runtime/src/bucket_map_holder_stats.rs index eba225765f165c..1d82c5d5ae4c30 100644 --- a/runtime/src/bucket_map_holder_stats.rs +++ b/runtime/src/bucket_map_holder_stats.rs @@ -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) })