Skip to content

Commit dd6f0fa

Browse files
committed
Reduce overhead associated with packet-ID tracking
1 parent 1009f99 commit dd6f0fa

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/stream/udp.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,6 @@ pub mod sender {
507507
//the next eight are the seconds part of the UNIX timestamp and the following four are the nanoseconds
508508
self.staged_packet[24..32].copy_from_slice(&now.as_secs().to_be_bytes());
509509
self.staged_packet[32..36].copy_from_slice(&now.subsec_nanos().to_be_bytes());
510-
511-
//prepare for the next packet
512-
self.next_packet_id += 1;
513510
}
514511
}
515512
impl super::TestStream for UdpSender {
@@ -537,6 +534,8 @@ pub mod sender {
537534
log::trace!("wrote {} bytes in UDP stream {}", packet_size, self.stream_idx);
538535

539536
packets_sent += 1;
537+
//reflect that a packet is in-flight
538+
self.next_packet_id += 1;
540539

541540
let bytes_written = packet_size as i64 + super::UDP_HEADER_SIZE as i64;
542541
bytes_sent += bytes_written as u64;
@@ -564,8 +563,6 @@ pub mod sender {
564563
//nothing to do, but avoid burning CPU cycles
565564
sleep(BUFFER_FULL_TIMEOUT);
566565
sends_blocked += 1;
567-
//roll back the packet-ID because nothing was actually emitted
568-
self.next_packet_id -= 1;
569566
},
570567
Err(e) => {
571568
return Some(Err(Box::new(e)));

0 commit comments

Comments
 (0)