perf(http): utilize writev when possible

By using `AsyncWrite::write_buf`, we can avoid some copies in some
cases. This especially helps throughput for chunked encoding.
This commit is contained in:
Sean McArthur
2018-01-25 12:45:55 -08:00
parent 11b49c2cc8
commit 68377ede70
10 changed files with 679 additions and 500 deletions

View File

@@ -3,6 +3,7 @@
extern crate futures;
extern crate hyper;
extern crate pretty_env_logger;
extern crate test;
use std::io::{Read, Write};
@@ -17,6 +18,7 @@ use hyper::server::{self, Service};
macro_rules! bench_server {
($b:ident, $header:expr, $body:expr) => ({
let _ = pretty_env_logger::try_init();
let (_until_tx, until_rx) = oneshot::channel();
let addr = {
let (addr_tx, addr_rx) = mpsc::channel();
@@ -53,7 +55,7 @@ macro_rules! bench_server {
sum += tcp.read(&mut buf).unwrap();
}
assert_eq!(sum, total_bytes);
})
});
})
}