Skip to content

Commit

Permalink
get_best_weighted_repairs parameter cleanup (#30010)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbiseda authored Jan 31, 2023
1 parent 6163a6c commit c6cd966
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
24 changes: 12 additions & 12 deletions core/src/repair_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)]
);
Expand Down Expand Up @@ -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
);
Expand All @@ -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]
);
Expand Down Expand Up @@ -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
);
Expand Down
37 changes: 17 additions & 20 deletions core/src/repair_weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ShredRepairType> {
let mut repairs = vec![];
let mut processed_slots: HashSet<Slot> = vec![self.root].into_iter().collect();
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit c6cd966

Please sign in to comment.