locks gossip only once in push_epoch_slots
push_epoch_slots is unlocking and locking again gossip when iterating over epoch slot indices which is wasteful: https://github.com/solana-labs/solana/blob/0486df02b/core/src/cluster_info.rs#L915-L929
This commit is contained in:
parent
8758e9ed82
commit
9339a6f8f3
|
@ -900,23 +900,20 @@ impl ClusterInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_epoch_slots(&self, update: &[Slot]) {
|
pub(crate) fn push_epoch_slots(&self, update: &[Slot]) {
|
||||||
let mut num = 0;
|
let mut num = 0;
|
||||||
let mut current_slots: Vec<_> = (0..crds_value::MAX_EPOCH_SLOTS)
|
let mut current_slots: Vec<_> = {
|
||||||
.filter_map(|ix| {
|
let gossip =
|
||||||
Some((
|
self.time_gossip_read_lock("lookup_epoch_slots", &self.stats.epoch_slots_lookup);
|
||||||
self.time_gossip_read_lock(
|
(0..crds_value::MAX_EPOCH_SLOTS)
|
||||||
"lookup_epoch_slots",
|
.filter_map(|ix| {
|
||||||
&self.stats.epoch_slots_lookup,
|
let label = CrdsValueLabel::EpochSlots(ix, self.id());
|
||||||
)
|
let epoch_slots = gossip.crds.get(&label)?.value.epoch_slots()?;
|
||||||
.crds
|
let first_slot = epoch_slots.first_slot()?;
|
||||||
.lookup(&CrdsValueLabel::EpochSlots(ix, self.id()))
|
Some(((epoch_slots.wallclock, first_slot), ix))
|
||||||
.and_then(CrdsValue::epoch_slots)
|
})
|
||||||
.and_then(|x| Some((x.wallclock, x.first_slot()?)))?,
|
.collect()
|
||||||
ix,
|
};
|
||||||
))
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
current_slots.sort_unstable();
|
current_slots.sort_unstable();
|
||||||
let min_slot: Slot = current_slots
|
let min_slot: Slot = current_slots
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Reference in New Issue