Skip to content

Commit f718b41

Browse files
committed
Added tracking for blocked send events
1 parent eb92cbc commit f718b41

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/protocol/results.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ pub struct TcpSendResult {
244244
pub duration: f32,
245245

246246
pub bytes_sent: u64,
247+
pub sends_blocked: u64,
247248
}
248249
impl TcpSendResult {
249250
fn from_json(value:serde_json::Value) -> BoxResult<TcpSendResult> {
@@ -288,12 +289,16 @@ impl IntervalResult for TcpSendResult {
288289
false => format!("megabytes/second: {:.3}", bytes_per_second / 1_000_000.00),
289290
};
290291

291-
format!("----------\n\
292+
let mut output = format!("----------\n\
292293
TCP send result over {:.2}s | stream: {}\n\
293294
bytes: {} | per second: {:.3} | {}",
294295
self.duration, self.stream_idx,
295296
self.bytes_sent, bytes_per_second, throughput,
296-
)
297+
);
298+
if self.sends_blocked > 0 {
299+
output.push_str(&format!("\nstalls due to full send-buffer: {}", self.sends_blocked));
300+
}
301+
output
297302
}
298303
}
299304

@@ -383,6 +388,7 @@ pub struct UdpSendResult {
383388

384389
pub bytes_sent: u64,
385390
pub packets_sent: u64,
391+
pub sends_blocked: u64,
386392
}
387393
impl UdpSendResult {
388394
fn from_json(value:serde_json::Value) -> BoxResult<UdpSendResult> {
@@ -427,14 +433,18 @@ impl IntervalResult for UdpSendResult {
427433
false => format!("megabytes/second: {:.3}", bytes_per_second / 1_000_000.00),
428434
};
429435

430-
format!("----------\n\
436+
let mut output = format!("----------\n\
431437
UDP send result over {:.2}s | stream: {}\n\
432438
bytes: {} | per second: {:.3} | {}\n\
433439
packets: {} per second: {:.3}",
434440
self.duration, self.stream_idx,
435441
self.bytes_sent, bytes_per_second, throughput,
436442
self.packets_sent, self.packets_sent as f32 / duration_divisor,
437-
)
443+
);
444+
if self.sends_blocked > 0 {
445+
output.push_str(&format!("\nstalls due to full send-buffer: {}", self.sends_blocked));
446+
}
447+
output
438448
}
439449
}
440450

src/stream/tcp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ pub mod sender {
517517
let bytes_to_send_per_interval_slice = ((bytes_to_send as f32) * self.send_interval) as i64;
518518
let mut bytes_to_send_per_interval_slice_remaining = bytes_to_send_per_interval_slice;
519519

520+
let mut sends_blocked:u64 = 0;
520521
let mut bytes_sent:u64 = 0;
521522

522523
let peer_addr = match stream.peer_addr() {
@@ -550,12 +551,14 @@ pub mod sender {
550551
duration: elapsed_time.as_secs_f32(),
551552

552553
bytes_sent: bytes_sent,
554+
sends_blocked: sends_blocked,
553555
})))
554556
}
555557
},
556558
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { //send-buffer is full
557559
//nothing to do, but avoid burning CPU cycles
558560
sleep(BUFFER_FULL_TIMEOUT);
561+
sends_blocked += 1;
559562
},
560563
Err(e) => {
561564
return Some(Err(Box::new(e)));
@@ -587,6 +590,7 @@ pub mod sender {
587590
duration: cycle_start.elapsed().as_secs_f32(),
588591

589592
bytes_sent: bytes_sent,
593+
sends_blocked: sends_blocked,
590594
})))
591595
} else {
592596
//indicate that the test is over by dropping the stream

src/stream/udp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ pub mod sender {
522522
let mut bytes_to_send_per_interval_slice_remaining = bytes_to_send_per_interval_slice;
523523

524524
let mut packets_sent:u64 = 0;
525+
let mut sends_blocked:u64 = 0;
525526
let mut bytes_sent:u64 = 0;
526527

527528
let cycle_start = Instant::now();
@@ -555,12 +556,14 @@ pub mod sender {
555556

556557
bytes_sent: bytes_sent,
557558
packets_sent: packets_sent,
559+
sends_blocked: sends_blocked,
558560
})))
559561
}
560562
},
561563
Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => { //send-buffer is full
562564
//nothing to do, but avoid burning CPU cycles
563565
sleep(BUFFER_FULL_TIMEOUT);
566+
sends_blocked += 1;
564567
//roll back the packet-ID because nothing was actually emitted
565568
self.next_packet_id -= 1;
566569
},
@@ -595,6 +598,7 @@ pub mod sender {
595598

596599
bytes_sent: bytes_sent,
597600
packets_sent: packets_sent,
601+
sends_blocked: sends_blocked,
598602
})))
599603
} else {
600604
//indicate that the test is over by sending the test ID by itself

0 commit comments

Comments
 (0)