From c6cd96635f59971667cdf722ac535231b5e45fc0 Mon Sep 17 00:00:00 2001 From: Jeff Biseda Date: Tue, 31 Jan 2023 03:12:25 -0800 Subject: [PATCH] get_best_weighted_repairs parameter cleanup (#30010) --- core/src/repair_service.rs | 24 ++++++++++++------------ core/src/repair_weight.rs | 37 +++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/core/src/repair_service.rs b/core/src/repair_service.rs index c6473aaf87..fcbcd8e402 100644 --- a/core/src/repair_service.rs +++ b/core/src/repair_service.rs @@ -342,8 +342,8 @@ impl RepairService { MAX_UNKNOWN_LAST_INDEX_REPAIRS, MAX_CLOSEST_COMPLETION_REPAIRS, &duplicate_slot_repair_statuses, - Some(&mut repair_timing), - Some(&mut best_repairs_stats), + &mut repair_timing, + &mut best_repairs_stats, ); repairs @@ -808,8 +808,8 @@ mod test { MAX_UNKNOWN_LAST_INDEX_REPAIRS, MAX_CLOSEST_COMPLETION_REPAIRS, &HashSet::default(), - None, - None, + &mut RepairTiming::default(), + &mut BestRepairsStats::default(), ), vec![ ShredRepairType::Orphan(2), @@ -845,8 +845,8 @@ mod test { MAX_UNKNOWN_LAST_INDEX_REPAIRS, MAX_CLOSEST_COMPLETION_REPAIRS, &HashSet::default(), - None, - None, + &mut RepairTiming::default(), + &mut BestRepairsStats::default(), ), vec![ShredRepairType::HighestShred(0, 0)] ); @@ -907,8 +907,8 @@ mod test { MAX_UNKNOWN_LAST_INDEX_REPAIRS, MAX_CLOSEST_COMPLETION_REPAIRS, &HashSet::default(), - None, - None, + &mut RepairTiming::default(), + &mut BestRepairsStats::default(), ), expected ); @@ -923,8 +923,8 @@ mod test { MAX_UNKNOWN_LAST_INDEX_REPAIRS, MAX_CLOSEST_COMPLETION_REPAIRS, &HashSet::default(), - None, - None, + &mut RepairTiming::default(), + &mut BestRepairsStats::default(), )[..], expected[0..expected.len() - 2] ); @@ -969,8 +969,8 @@ mod test { MAX_UNKNOWN_LAST_INDEX_REPAIRS, MAX_CLOSEST_COMPLETION_REPAIRS, &HashSet::default(), - None, - None, + &mut RepairTiming::default(), + &mut BestRepairsStats::default(), ), expected ); diff --git a/core/src/repair_weight.rs b/core/src/repair_weight.rs index 9ea3b82f11..294e96e5fe 100644 --- a/core/src/repair_weight.rs +++ b/core/src/repair_weight.rs @@ -157,8 +157,8 @@ impl RepairWeight { max_unknown_last_index_repairs: usize, max_closest_completion_repairs: usize, ignore_slots: &impl Contains<'a, Slot>, - repair_timing: Option<&mut RepairTiming>, - stats: Option<&mut BestRepairsStats>, + repair_timing: &mut RepairTiming, + stats: &mut BestRepairsStats, ) -> Vec { let mut repairs = vec![]; let mut processed_slots: HashSet = vec![self.root].into_iter().collect(); @@ -227,24 +227,21 @@ impl RepairWeight { repairs.extend(closest_completion_repairs); get_closest_completion_elapsed.stop(); - if let Some(stats) = stats { - stats.update( - num_orphan_slots as u64, - num_orphan_repairs as u64, - num_best_shreds_slots as u64, - num_best_shreds_repairs as u64, - num_unknown_last_index_slots as u64, - num_unknown_last_index_repairs as u64, - num_closest_completion_slots as u64, - num_closest_completion_repairs as u64, - ); - } - if let Some(repair_timing) = repair_timing { - repair_timing.get_best_orphans_elapsed += get_best_orphans_elapsed.as_us(); - repair_timing.get_best_shreds_elapsed += get_best_shreds_elapsed.as_us(); - repair_timing.get_unknown_last_index_elapsed += get_unknown_last_index_elapsed.as_us(); - repair_timing.get_closest_completion_elapsed += get_closest_completion_elapsed.as_us(); - } + stats.update( + num_orphan_slots as u64, + num_orphan_repairs as u64, + num_best_shreds_slots as u64, + num_best_shreds_repairs as u64, + num_unknown_last_index_slots as u64, + num_unknown_last_index_repairs as u64, + num_closest_completion_slots as u64, + num_closest_completion_repairs as u64, + ); + repair_timing.get_best_orphans_elapsed += get_best_orphans_elapsed.as_us(); + repair_timing.get_best_shreds_elapsed += get_best_shreds_elapsed.as_us(); + repair_timing.get_unknown_last_index_elapsed += get_unknown_last_index_elapsed.as_us(); + repair_timing.get_closest_completion_elapsed += get_closest_completion_elapsed.as_us(); + repairs }