@@ -4576,17 +4576,13 @@ impl AccountsDb {
4576
4576
alive_ratio: f64,
4577
4577
store: Arc<AccountStorageEntry>,
4578
4578
}
4579
- let mut measure = Measure::start("select_top_sparse_storage_entries-ms");
4580
4579
let mut store_usage: Vec<StoreUsageInfo> = Vec::with_capacity(shrink_slots.len());
4581
4580
let mut total_alive_bytes: u64 = 0;
4582
- let mut candidates_count: usize = 0;
4583
4581
let mut total_bytes: u64 = 0;
4584
- let mut total_candidate_stores: usize = 0;
4585
4582
for slot in shrink_slots {
4586
4583
let Some(store) = self.storage.get_slot_storage_entry(*slot) else {
4587
4584
continue;
4588
4585
};
4589
- candidates_count += 1;
4590
4586
let alive_bytes = store.alive_bytes();
4591
4587
total_alive_bytes += alive_bytes as u64;
4592
4588
total_bytes += store.capacity();
@@ -4596,7 +4592,6 @@ impl AccountsDb {
4596
4592
alive_ratio,
4597
4593
store: store.clone(),
4598
4594
});
4599
- total_candidate_stores += 1;
4600
4595
}
4601
4596
store_usage.sort_by(|a, b| {
4602
4597
a.alive_ratio
@@ -4633,20 +4628,6 @@ impl AccountsDb {
4633
4628
shrink_slots.insert(usage.slot, Arc::clone(store));
4634
4629
}
4635
4630
}
4636
- measure.stop();
4637
- inc_new_counter_debug!(
4638
- "shrink_select_top_sparse_storage_entries-ms",
4639
- measure.as_ms() as usize
4640
- );
4641
- inc_new_counter_debug!(
4642
- "shrink_select_top_sparse_storage_entries-seeds",
4643
- candidates_count
4644
- );
4645
- inc_new_counter_debug!(
4646
- "shrink_total_preliminary_candidate_stores",
4647
- total_candidate_stores
4648
- );
4649
-
4650
4631
(shrink_slots, shrink_slots_next_batch)
4651
4632
}
4652
4633
@@ -5050,8 +5031,8 @@ impl AccountsDb {
5050
5031
5051
5032
let shrink_candidates_slots =
5052
5033
std::mem::take(&mut *self.shrink_candidate_slots.lock().unwrap());
5053
-
5054
- let (shrink_slots, shrink_slots_next_batch) = {
5034
+ let candidates_count = shrink_candidates_slots.len();
5035
+ let (( shrink_slots, shrink_slots_next_batch), select_time_us) = measure_us!( {
5055
5036
if let AccountShrinkThreshold::TotalSpace { shrink_ratio } = self.shrink_ratio {
5056
5037
let (shrink_slots, shrink_slots_next_batch) =
5057
5038
self.select_candidates_by_total_usage(&shrink_candidates_slots, shrink_ratio);
@@ -5070,7 +5051,7 @@ impl AccountsDb {
5070
5051
None,
5071
5052
)
5072
5053
}
5073
- };
5054
+ }) ;
5074
5055
5075
5056
if shrink_slots.is_empty()
5076
5057
&& shrink_slots_next_batch
@@ -5084,41 +5065,43 @@ impl AccountsDb {
5084
5065
let _guard = (!shrink_slots.is_empty())
5085
5066
.then_some(|| self.active_stats.activate(ActiveStatItem::Shrink));
5086
5067
5087
- let mut measure_shrink_all_candidates = Measure::start("shrink_all_candidate_slots-ms");
5088
- let num_candidates = shrink_slots.len();
5089
- let shrink_candidates_count = shrink_slots.len();
5090
- self.thread_pool_clean.install(|| {
5091
- shrink_slots
5092
- .into_par_iter()
5093
- .for_each(|(slot, slot_shrink_candidate)| {
5094
- if self.ancient_append_vec_offset.is_some() && slot < oldest_non_ancient_slot {
5095
- self.shrink_stats
5096
- .num_ancient_slots_shrunk
5097
- .fetch_add(1, Ordering::Relaxed);
5098
- }
5099
- let mut measure = Measure::start("shrink_candidate_slots-ms");
5100
- self.shrink_storage(&slot_shrink_candidate);
5101
- measure.stop();
5102
- inc_new_counter_info!("shrink_candidate_slots-ms", measure.as_ms() as usize);
5103
- });
5068
+ let num_selected = shrink_slots.len();
5069
+ let (_, shrink_all_us) = measure_us!({
5070
+ self.thread_pool_clean.install(|| {
5071
+ shrink_slots
5072
+ .into_par_iter()
5073
+ .for_each(|(slot, slot_shrink_candidate)| {
5074
+ if self.ancient_append_vec_offset.is_some()
5075
+ && slot < oldest_non_ancient_slot
5076
+ {
5077
+ self.shrink_stats
5078
+ .num_ancient_slots_shrunk
5079
+ .fetch_add(1, Ordering::Relaxed);
5080
+ }
5081
+ self.shrink_storage(&slot_shrink_candidate);
5082
+ });
5083
+ })
5104
5084
});
5105
- measure_shrink_all_candidates.stop();
5106
- inc_new_counter_info!(
5107
- "shrink_all_candidate_slots-ms",
5108
- measure_shrink_all_candidates.as_ms() as usize
5109
- );
5110
- inc_new_counter_info!("shrink_all_candidate_slots-count", shrink_candidates_count);
5085
+
5111
5086
let mut pended_counts: usize = 0;
5112
5087
if let Some(shrink_slots_next_batch) = shrink_slots_next_batch {
5113
5088
let mut shrink_slots = self.shrink_candidate_slots.lock().unwrap();
5114
- pended_counts + = shrink_slots_next_batch.len();
5089
+ pended_counts = shrink_slots_next_batch.len();
5115
5090
for slot in shrink_slots_next_batch {
5116
5091
shrink_slots.insert(slot);
5117
5092
}
5118
5093
}
5119
- inc_new_counter_info!("shrink_pended_stores-count", pended_counts);
5120
5094
5121
- num_candidates
5095
+ datapoint_info!(
5096
+ "shrink_candidate_slots",
5097
+ ("select_time_us", select_time_us, i64),
5098
+ ("shrink_all_us", shrink_all_us, i64),
5099
+ ("candidates_count", candidates_count, i64),
5100
+ ("selected_count", num_selected, i64),
5101
+ ("deferred_to_next_round_count", pended_counts, i64)
5102
+ );
5103
+
5104
+ num_selected
5122
5105
}
5123
5106
5124
5107
/// This is only called at startup from bank when we are being extra careful such as when we downloaded a snapshot.
0 commit comments