From f329ae0ff903a74e7386e674fe86d3d944f1f325 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 30 Mar 2020 16:28:58 -0700 Subject: [PATCH] refactor(benches): add adaptive_window http2 benchmark --- benches/end_to_end.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/benches/end_to_end.rs b/benches/end_to_end.rs index 918d3adf..f6ff2cfd 100644 --- a/benches/end_to_end.rs +++ b/benches/end_to_end.rs @@ -139,6 +139,18 @@ fn http2_parallel_x10_req_10kb_100_chunks(b: &mut test::Bencher) { .bench(b) } +#[bench] +fn http2_parallel_x10_req_10kb_100_chunks_adaptive_window(b: &mut test::Bencher) { + let body = &[b'x'; 1024 * 10]; + opts() + .http2() + .parallel(10) + .method(Method::POST) + .request_chunks(body, 100) + .http2_adaptive_window() + .bench(b) +} + #[bench] fn http2_parallel_x10_req_10kb_100_chunks_max_window(b: &mut test::Bencher) { let body = &[b'x'; 1024 * 10]; @@ -182,6 +194,7 @@ struct Opts { http2: bool, http2_stream_window: Option, http2_conn_window: Option, + http2_adaptive_window: bool, parallel_cnt: u32, request_method: Method, request_body: Option<&'static [u8]>, @@ -194,6 +207,7 @@ fn opts() -> Opts { http2: false, http2_stream_window: None, http2_conn_window: None, + http2_adaptive_window: false, parallel_cnt: 1, request_method: Method::GET, request_body: None, @@ -209,15 +223,24 @@ impl Opts { } fn http2_stream_window(mut self, sz: impl Into>) -> Self { + assert!(!self.http2_adaptive_window); self.http2_stream_window = sz.into(); self } fn http2_conn_window(mut self, sz: impl Into>) -> Self { + assert!(!self.http2_adaptive_window); self.http2_conn_window = sz.into(); self } + fn http2_adaptive_window(mut self) -> Self { + assert!(self.http2_stream_window.is_none()); + assert!(self.http2_conn_window.is_none()); + self.http2_adaptive_window = true; + self + } + fn method(mut self, m: Method) -> Self { self.request_method = m; self @@ -272,6 +295,7 @@ impl Opts { .http2_only(self.http2) .http2_initial_stream_window_size(self.http2_stream_window) .http2_initial_connection_window_size(self.http2_conn_window) + .http2_adaptive_window(self.http2_adaptive_window) .build::<_, Body>(connector); let url: hyper::Uri = format!("http://{}/hello", addr).parse().unwrap(); @@ -337,6 +361,7 @@ fn spawn_server(rt: &mut tokio::runtime::Runtime, opts: &Opts) -> SocketAddr { .http2_only(opts.http2) .http2_initial_stream_window_size(opts.http2_stream_window) .http2_initial_connection_window_size(opts.http2_conn_window) + .http2_adaptive_window(opts.http2_adaptive_window) .serve(make_service_fn(move |_| async move { Ok::<_, hyper::Error>(service_fn(move |req: Request| async move { let mut req_body = req.into_body();