removes the nested for loop from retransmit-stage
The code can be simplified by just flattening the vector of packets.
This commit is contained in:
@ -330,10 +330,10 @@ fn retransmit(
|
||||
let packets = r_lock.recv_timeout(RECV_TIMEOUT)?;
|
||||
let mut timer_start = Measure::start("retransmit");
|
||||
let mut total_packets = packets.packets.len();
|
||||
let mut packet_v = vec![packets];
|
||||
let mut packets = vec![packets];
|
||||
while let Ok(nq) = r_lock.try_recv() {
|
||||
total_packets += nq.packets.len();
|
||||
packet_v.push(nq);
|
||||
packets.push(nq);
|
||||
if total_packets >= MAX_PACKET_BATCH_SIZE {
|
||||
break;
|
||||
}
|
||||
@ -382,8 +382,7 @@ fn retransmit(
|
||||
let mut packets_by_slot: HashMap<Slot, usize> = HashMap::new();
|
||||
let mut packets_by_source: HashMap<String, usize> = HashMap::new();
|
||||
let mut max_slot = 0;
|
||||
for packets in packet_v {
|
||||
for packet in packets.packets.iter() {
|
||||
for packet in packets.iter().flat_map(|p| p.packets.iter()) {
|
||||
// skip discarded packets and repair packets
|
||||
if packet.meta.discard {
|
||||
total_packets -= 1;
|
||||
@ -425,9 +424,9 @@ fn retransmit(
|
||||
packet.meta.seed,
|
||||
);
|
||||
// If the node is on the critical path (i.e. the first node in each
|
||||
// neighborhood), then we expect that the packet arrives at tvu
|
||||
// socket as opposed to tvu-forwards. If this is not the case, then
|
||||
// the turbine broadcast/retransmit tree mismatch across nodes.
|
||||
// neighborhood), then we expect that the packet arrives at tvu socket
|
||||
// as opposed to tvu-forwards. If this is not the case, then the
|
||||
// turbine broadcast/retransmit tree is mismatched across nodes.
|
||||
if packet.meta.forward == (my_index % DATA_PLANE_FANOUT == 0) {
|
||||
retransmit_tree_mismatch += 1;
|
||||
}
|
||||
@ -437,9 +436,9 @@ fn retransmit(
|
||||
.into_iter()
|
||||
.map(|(_, index)| index)
|
||||
.collect();
|
||||
debug_assert_eq!(my_id, r_epoch_stakes_cache.peers[indexes[my_index]].id);
|
||||
|
||||
let (neighbors, children) =
|
||||
compute_retransmit_peers(DATA_PLANE_FANOUT, my_index, &indexes);
|
||||
let (neighbors, children) = compute_retransmit_peers(DATA_PLANE_FANOUT, my_index, &indexes);
|
||||
let neighbors: Vec<_> = neighbors
|
||||
.into_iter()
|
||||
.filter_map(|index| {
|
||||
@ -458,10 +457,10 @@ fn retransmit(
|
||||
compute_turbine_peers.stop();
|
||||
compute_turbine_peers_total += compute_turbine_peers.as_us();
|
||||
|
||||
*packets_by_slot.entry(packet.meta.slot).or_insert(0) += 1;
|
||||
*packets_by_slot.entry(packet.meta.slot).or_default() += 1;
|
||||
*packets_by_source
|
||||
.entry(packet.meta.addr().to_string())
|
||||
.or_insert(0) += 1;
|
||||
.or_default() += 1;
|
||||
|
||||
let mut retransmit_time = Measure::start("retransmit_to");
|
||||
if !packet.meta.forward {
|
||||
@ -471,7 +470,6 @@ fn retransmit(
|
||||
retransmit_time.stop();
|
||||
retransmit_total += retransmit_time.as_us();
|
||||
}
|
||||
}
|
||||
max_slots.retransmit.fetch_max(max_slot, Ordering::Relaxed);
|
||||
timer_start.stop();
|
||||
debug!(
|
||||
|
Reference in New Issue
Block a user