Skip to content

Commit f8165c3

Browse files
filipe-cantarelliRalith
authored andcommitted
refactor: move max_datagrams limit at poll_transmit from quinn-proto to quinn
1 parent cc7608a commit f8165c3

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl Connection {
453453
assert!(max_datagrams != 0);
454454
let max_datagrams = match self.config.enable_segmentation_offload {
455455
false => 1,
456-
true => max_datagrams.min(MAX_TRANSMIT_SEGMENTS),
456+
true => max_datagrams,
457457
};
458458

459459
let mut num_datagrams = 0;
@@ -3950,13 +3950,6 @@ const MIN_PACKET_SPACE: usize = MAX_HANDSHAKE_OR_0RTT_HEADER_SIZE + 32;
39503950
const MAX_HANDSHAKE_OR_0RTT_HEADER_SIZE: usize =
39513951
1 + 4 + 1 + MAX_CID_SIZE + 1 + MAX_CID_SIZE + VarInt::from_u32(u16::MAX as u32).size() + 4;
39523952

3953-
/// The maximum amount of datagrams that are sent in a single transmit
3954-
///
3955-
/// This can be lower than the maximum platform capabilities, to avoid excessive
3956-
/// memory allocations when calling `poll_transmit()`. Benchmarks have shown
3957-
/// that numbers around 10 are a good compromise.
3958-
const MAX_TRANSMIT_SEGMENTS: usize = 10;
3959-
39603953
/// Perform key updates this many packets before the AEAD confidentiality limit.
39613954
///
39623955
/// Chosen arbitrarily, intended to be large enough to prevent spurious connection loss.

quinn/src/connection.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,10 @@ impl State {
981981
let now = self.runtime.now();
982982
let mut transmits = 0;
983983

984-
let max_datagrams = self.socket.max_transmit_segments();
984+
let max_datagrams = self
985+
.socket
986+
.max_transmit_segments()
987+
.min(MAX_TRANSMIT_SEGMENTS);
985988

986989
loop {
987990
// Retry the last transmit, or get a new one.
@@ -1288,3 +1291,10 @@ pub enum SendDatagramError {
12881291
/// This limits the amount of CPU resources consumed by datagram generation,
12891292
/// and allows other tasks (like receiving ACKs) to run in between.
12901293
const MAX_TRANSMIT_DATAGRAMS: usize = 20;
1294+
1295+
/// The maximum amount of datagrams that are sent in a single transmit
1296+
///
1297+
/// This can be lower than the maximum platform capabilities, to avoid excessive
1298+
/// memory allocations when calling `poll_transmit()`. Benchmarks have shown
1299+
/// that numbers around 10 are a good compromise.
1300+
const MAX_TRANSMIT_SEGMENTS: usize = 10;

0 commit comments

Comments
 (0)