-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto-tune (dynamic) stream receive window (#176)
- Send Yamux' Pings on an interval to measure the connection round-trip-time. - Dynamically grow the stream receive window based on the round-trip-time and the estimated bandwidth.
- Loading branch information
Showing
15 changed files
with
769 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[workspace] | ||
members = ["yamux", "test-harness"] | ||
members = ["yamux", "test-harness", "quickcheck-ext"] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "quickcheck-ext" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
license = "Unlicense/MIT" | ||
|
||
[package.metadata.release] | ||
release = false | ||
|
||
[dependencies] | ||
quickcheck = "1" | ||
num-traits = "0.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] | ||
|
||
pub use quickcheck::*; | ||
|
||
use core::ops::Range; | ||
use num_traits::sign::Unsigned; | ||
|
||
pub trait GenRange { | ||
fn gen_range<T: Unsigned + Arbitrary + Copy>(&mut self, _range: Range<T>) -> T; | ||
|
||
fn gen_index(&mut self, ubound: usize) -> usize { | ||
if ubound <= (core::u32::MAX as usize) { | ||
self.gen_range(0..ubound as u32) as usize | ||
} else { | ||
self.gen_range(0..ubound) | ||
} | ||
} | ||
} | ||
|
||
impl GenRange for Gen { | ||
fn gen_range<T: Unsigned + Arbitrary + Copy>(&mut self, range: Range<T>) -> T { | ||
<T as Arbitrary>::arbitrary(self) % (range.end - range.start) + range.start | ||
} | ||
} | ||
|
||
pub trait SliceRandom { | ||
fn shuffle<T>(&mut self, arr: &mut [T]); | ||
fn choose_multiple<'a, T>( | ||
&mut self, | ||
arr: &'a [T], | ||
amount: usize, | ||
) -> std::iter::Take<std::vec::IntoIter<&'a T>> { | ||
let mut v: Vec<&T> = arr.iter().collect(); | ||
self.shuffle(&mut v); | ||
v.into_iter().take(amount) | ||
} | ||
} | ||
|
||
impl SliceRandom for Gen { | ||
fn shuffle<T>(&mut self, arr: &mut [T]) { | ||
for i in (1..arr.len()).rev() { | ||
// invariant: elements with index > i have been locked in place. | ||
arr.swap(i, self.gen_index(i + 1)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.