removes redundant slots sort in push_epoch_slots
This commit is contained in:
@ -900,9 +900,8 @@ impl ClusterInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn push_epoch_slots(&self, update: &[Slot]) {
|
pub(crate) fn push_epoch_slots(&self, mut update: &[Slot]) {
|
||||||
let mut num = 0;
|
let current_slots: Vec<_> = {
|
||||||
let mut current_slots: Vec<_> = {
|
|
||||||
let gossip =
|
let gossip =
|
||||||
self.time_gossip_read_lock("lookup_epoch_slots", &self.stats.epoch_slots_lookup);
|
self.time_gossip_read_lock("lookup_epoch_slots", &self.stats.epoch_slots_lookup);
|
||||||
(0..crds_value::MAX_EPOCH_SLOTS)
|
(0..crds_value::MAX_EPOCH_SLOTS)
|
||||||
@ -910,16 +909,15 @@ impl ClusterInfo {
|
|||||||
let label = CrdsValueLabel::EpochSlots(ix, self.id());
|
let label = CrdsValueLabel::EpochSlots(ix, self.id());
|
||||||
let epoch_slots = gossip.crds.get(&label)?.value.epoch_slots()?;
|
let epoch_slots = gossip.crds.get(&label)?.value.epoch_slots()?;
|
||||||
let first_slot = epoch_slots.first_slot()?;
|
let first_slot = epoch_slots.first_slot()?;
|
||||||
Some(((epoch_slots.wallclock, first_slot), ix))
|
Some((epoch_slots.wallclock, first_slot, ix))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
current_slots.sort_unstable();
|
|
||||||
let min_slot: Slot = current_slots
|
let min_slot: Slot = current_slots
|
||||||
.iter()
|
.iter()
|
||||||
.map(|((_, s), _)| *s)
|
.map(|(_wallclock, slot, _index)| *slot)
|
||||||
.min()
|
.min()
|
||||||
.unwrap_or(0);
|
.unwrap_or_default();
|
||||||
let max_slot: Slot = update.iter().max().cloned().unwrap_or(0);
|
let max_slot: Slot = update.iter().max().cloned().unwrap_or(0);
|
||||||
let total_slots = max_slot as isize - min_slot as isize;
|
let total_slots = max_slot as isize - min_slot as isize;
|
||||||
// WARN if CRDS is not storing at least a full epoch worth of slots
|
// WARN if CRDS is not storing at least a full epoch worth of slots
|
||||||
@ -934,8 +932,11 @@ impl ClusterInfo {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let mut reset = false;
|
let mut reset = false;
|
||||||
let mut epoch_slot_index = current_slots.last().map(|(_, x)| *x).unwrap_or(0);
|
let mut epoch_slot_index = match current_slots.iter().max() {
|
||||||
while num < update.len() {
|
Some((_wallclock, _slot, index)) => *index,
|
||||||
|
None => 0,
|
||||||
|
};
|
||||||
|
while !update.is_empty() {
|
||||||
let ix = (epoch_slot_index % crds_value::MAX_EPOCH_SLOTS) as u8;
|
let ix = (epoch_slot_index % crds_value::MAX_EPOCH_SLOTS) as u8;
|
||||||
let now = timestamp();
|
let now = timestamp();
|
||||||
let mut slots = if !reset {
|
let mut slots = if !reset {
|
||||||
@ -943,7 +944,8 @@ impl ClusterInfo {
|
|||||||
} else {
|
} else {
|
||||||
EpochSlots::new(self.id(), now)
|
EpochSlots::new(self.id(), now)
|
||||||
};
|
};
|
||||||
let n = slots.fill(&update[num..], now);
|
let n = slots.fill(update, now);
|
||||||
|
update = &update[n..];
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
let entry = CrdsValue::new_signed(CrdsData::EpochSlots(ix, slots), &self.keypair);
|
let entry = CrdsValue::new_signed(CrdsData::EpochSlots(ix, slots), &self.keypair);
|
||||||
self.local_message_pending_push_queue
|
self.local_message_pending_push_queue
|
||||||
@ -951,13 +953,10 @@ impl ClusterInfo {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.push(entry);
|
.push(entry);
|
||||||
}
|
}
|
||||||
num += n;
|
|
||||||
if num < update.len() {
|
|
||||||
epoch_slot_index += 1;
|
epoch_slot_index += 1;
|
||||||
reset = true;
|
reset = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn time_gossip_read_lock<'a>(
|
fn time_gossip_read_lock<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
Reference in New Issue
Block a user