Increase number of assembler gaps to 32 for std/alloc targets
Only allowing four missing packets is hurting performance for large receive windows. The new value was picked by observing good performance with 500 kB socket buffers. Closes: #264 Approved by: whitequark
This commit is contained in:
parent
2047aaea28
commit
15c6c24a87
|
@ -104,7 +104,7 @@ The TCP protocol is supported over IPv4 and IPv6, and server and client TCP sock
|
|||
* Maximum segment size is negotiated.
|
||||
* Window scaling is negotiated.
|
||||
* Multiple packets are transmitted without waiting for an acknowledgement.
|
||||
* Reassembly of out-of-order segments is supported, with no more than 4 gaps in sequence space.
|
||||
* Reassembly of out-of-order segments is supported, with no more than 4 or 32 gaps in sequence space.
|
||||
* Keep-alive packets may be sent at a configurable interval.
|
||||
* Retransmission timeout starts at a fixed interval of 100 ms and doubles every time.
|
||||
* Time-wait timeout has a fixed interval of 10 s.
|
||||
|
|
|
@ -62,15 +62,26 @@ impl Contig {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::boxed::Box;
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
use alloc::boxed::Box;
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
const CONTIG_COUNT: usize = 32;
|
||||
|
||||
#[cfg(not(any(feature = "std", feature = "alloc")))]
|
||||
const CONTIG_COUNT: usize = 4;
|
||||
|
||||
/// A buffer (re)assembler.
|
||||
///
|
||||
/// Currently, up to a hardcoded limit of four holes can be tracked in the buffer.
|
||||
/// Currently, up to a hardcoded limit of 4 or 32 holes can be tracked in the buffer.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(test, derive(PartialEq, Eq, Clone))]
|
||||
pub struct Assembler {
|
||||
contigs: [Contig; CONTIG_COUNT]
|
||||
#[cfg(not(any(feature = "std", feature = "alloc")))]
|
||||
contigs: [Contig; CONTIG_COUNT],
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
contigs: Box<[Contig; CONTIG_COUNT]>,
|
||||
}
|
||||
|
||||
impl fmt::Display for Assembler {
|
||||
|
@ -88,7 +99,10 @@ impl fmt::Display for Assembler {
|
|||
impl Assembler {
|
||||
/// Create a new buffer assembler for buffers of the given size.
|
||||
pub fn new(size: usize) -> Assembler {
|
||||
#[cfg(not(any(feature = "std", feature = "alloc")))]
|
||||
let mut contigs = [Contig::empty(); CONTIG_COUNT];
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
let mut contigs = Box::new([Contig::empty(); CONTIG_COUNT]);
|
||||
contigs[0] = Contig::hole(size);
|
||||
Assembler { contigs }
|
||||
}
|
||||
|
@ -283,7 +297,10 @@ mod test {
|
|||
|
||||
impl From<Vec<(usize, usize)>> for Assembler {
|
||||
fn from(vec: Vec<(usize, usize)>) -> Assembler {
|
||||
#[cfg(not(any(feature = "std", feature = "alloc")))]
|
||||
let mut contigs = [Contig::empty(); CONTIG_COUNT];
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
let mut contigs = Box::new([Contig::empty(); CONTIG_COUNT]);
|
||||
for (i, &(hole_size, data_size)) in vec.iter().enumerate() {
|
||||
contigs[i] = Contig { hole_size, data_size };
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue