switch to a hyper vendor branch with Nagle fix

There were Nagle's algorithm delays in both the "fresh_client" and
"reuse_client" versions of the .mp4 serving benchmark. Now performance is much
more consistent.
This commit is contained in:
Scott Lamb 2017-02-26 19:05:05 -08:00
parent f24daba299
commit f3b17a4bd8
3 changed files with 22 additions and 35 deletions

19
Cargo.lock generated
View File

@ -11,7 +11,7 @@ dependencies = [
"ffmpeg-sys 2.8.9 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"http-entity 0.0.1 (git+https://github.com/scottlamb/http-entity)",
"hyper 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.10.4 (git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.10.x)",
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazycell 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
@ -220,7 +220,7 @@ dependencies = [
[[package]]
name = "http-entity"
version = "0.0.1"
source = "git+https://github.com/scottlamb/http-entity#b725b61e009d12fd13156eac62459e11cdc8cfad"
source = "git+https://github.com/scottlamb/http-entity#9ff2911937fa90b34ae6a2c5a60cb73ac61544cf"
dependencies = [
"hyper 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -236,7 +236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hyper"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.10.x#a8db574da9df986f0b05cac2788a2971162de695"
dependencies = [
"httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -246,12 +246,18 @@ dependencies = [
"rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hyper"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
replace = "hyper 0.10.4 (git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.10.x)"
[[package]]
name = "idna"
version = "0.1.0"
@ -771,7 +777,7 @@ dependencies = [
[[package]]
name = "traitobject"
version = "0.0.1"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -901,6 +907,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
"checksum http-entity 0.0.1 (git+https://github.com/scottlamb/http-entity)" = "<none>"
"checksum httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e7a63e511f9edffbab707141fbb8707d1a3098615fb2adbd5769cdfcc9b17d"
"checksum hyper 0.10.4 (git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.10.x)" = "<none>"
"checksum hyper 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)" = "220407e5a263f110ec30a071787c9535918fdfc97def5680c90013c3f30c38c1"
"checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11"
"checksum isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fa500db770a99afe2a0f2229be2a3d09c7ed9d7e4e8440bf71253141994e240f"
@ -966,7 +973,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum thread_local 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7793b722f0f77ce716e7f1acf416359ca32ff24d04ffbac4269f44a4a83be05d"
"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade"
"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4"
"checksum traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "07eaeb7689bb7fca7ce15628319635758eda769fed481ecfe6686ddef2600616"
"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
"checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764"
"checksum unicode-bidi 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b61814f3e7fd0e0f15370f767c7c943e08bc2e3214233ae8f88522b334ceb778"

View File

@ -13,7 +13,7 @@ chan-signal = "0.2"
docopt = "0.7"
fnv = "1.0"
http-entity = { git = "https://github.com/scottlamb/http-entity" }
hyper = "0.10"
hyper = { git = "https://github.com/scottlamb/hyper", branch = "moonfire-on-0.10.x" }
lazycell = "0.5"
lazy_static = "0.2"
libc = "0.2"
@ -63,3 +63,6 @@ debug = true
[profile.bench]
lto = true
debug = true
[replace]
"hyper:0.10.4" = { git = "https://github.com/scottlamb/hyper", branch = "moonfire-on-0.10.x" }

View File

@ -1772,39 +1772,14 @@ mod bench {
/// Benchmarks serving the generated part of a `.mp4` file (up to the first byte from disk).
#[bench]
fn serve_generated_bytes_fresh_client(b: &mut Bencher) {
testutil::init();
let server = &*SERVER;
let p = server.generated_len;
let mut buf = Vec::with_capacity(p as usize);
b.bytes = p;
b.iter(|| {
let client = hyper::Client::new();
let mut resp =
client.get(server.url.clone())
.header(header::Range::Bytes(vec![header::ByteRangeSpec::FromTo(0, p - 1)]))
.send()
.unwrap();
buf.clear();
use std::io::Read;
let size = resp.read_to_end(&mut buf).unwrap();
assert_eq!(p, size as u64);
});
}
/// Another benchmark of serving generated bytes, but reusing the `hyper::Client`.
/// This should be faster than the `fresh` version, but see
/// [this hyper issue](https://github.com/hyperium/hyper/issues/944) relating to Nagle's
/// algorithm.
#[bench]
fn serve_generated_bytes_reuse_client(b: &mut Bencher) {
fn serve_generated_bytes(b: &mut Bencher) {
testutil::init();
let server = &*SERVER;
let p = server.generated_len;
let mut buf = Vec::with_capacity(p as usize);
b.bytes = p;
let client = hyper::Client::new();
b.iter(|| {
let mut run = || {
let mut resp =
client.get(server.url.clone())
.header(header::Range::Bytes(vec![header::ByteRangeSpec::FromTo(0, p - 1)]))
@ -1814,7 +1789,9 @@ mod bench {
use std::io::Read;
let size = resp.read_to_end(&mut buf).unwrap();
assert_eq!(p, size as u64);
});
};
run(); // warm.
b.iter(run);
}
#[bench]