Skip to content

Commit 973f981

Browse files
committed
chore(benches): add a few parallel + body end-to-end configurations
1 parent d1183a8 commit 973f981

File tree

1 file changed

+64
-8
lines changed

1 file changed

+64
-8
lines changed

Diff for: benches/end_to_end.rs

+64-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn http1_post(b: &mut test::Bencher) {
3030
}
3131

3232
#[bench]
33-
fn http1_body_100kb(b: &mut test::Bencher) {
33+
fn http1_body_both_100kb(b: &mut test::Bencher) {
3434
let body = &[b'x'; 1024 * 100];
3535
opts()
3636
.method(Method::POST)
@@ -40,7 +40,7 @@ fn http1_body_100kb(b: &mut test::Bencher) {
4040
}
4141

4242
#[bench]
43-
fn http1_body_10mb(b: &mut test::Bencher) {
43+
fn http1_body_both_10mb(b: &mut test::Bencher) {
4444
let body = &[b'x'; 1024 * 1024 * 10];
4545
opts()
4646
.method(Method::POST)
@@ -50,12 +50,22 @@ fn http1_body_10mb(b: &mut test::Bencher) {
5050
}
5151

5252
#[bench]
53-
fn http1_get_parallel(b: &mut test::Bencher) {
53+
fn http1_parallel_x10_empty(b: &mut test::Bencher) {
5454
opts()
5555
.parallel(10)
5656
.bench(b)
5757
}
5858

59+
#[bench]
60+
fn http1_parallel_x10_req_10mb(b: &mut test::Bencher) {
61+
let body = &[b'x'; 1024 * 1024 * 10];
62+
opts()
63+
.parallel(10)
64+
.method(Method::POST)
65+
.request_body(body)
66+
.bench(b)
67+
}
68+
5969
#[bench]
6070
fn http2_get(b: &mut test::Bencher) {
6171
opts()
@@ -73,17 +83,42 @@ fn http2_post(b: &mut test::Bencher) {
7383
}
7484

7585
#[bench]
76-
fn http2_get_parallel(b: &mut test::Bencher) {
86+
fn http2_req_100kb(b: &mut test::Bencher) {
87+
let body = &[b'x'; 1024 * 100];
88+
opts()
89+
.http2()
90+
.method(Method::POST)
91+
.request_body(body)
92+
.bench(b)
93+
}
94+
95+
#[bench]
96+
fn http2_parallel_x10_empty(b: &mut test::Bencher) {
7797
opts()
7898
.http2()
7999
.parallel(10)
80100
.bench(b)
81101
}
82102

103+
#[bench]
104+
fn http2_parallel_x10_req_10mb(b: &mut test::Bencher) {
105+
let body = &[b'x'; 1024 * 1024 * 10];
106+
opts()
107+
.http2()
108+
.parallel(10)
109+
.method(Method::POST)
110+
.request_body(body)
111+
.http2_stream_window(std::u32::MAX >> 1)
112+
.http2_conn_window(std::u32::MAX >> 1)
113+
.bench(b)
114+
}
115+
83116
// ==== Benchmark Options =====
84117

85118
struct Opts {
86119
http2: bool,
120+
http2_stream_window: Option<u32>,
121+
http2_conn_window: Option<u32>,
87122
parallel_cnt: u32,
88123
request_method: Method,
89124
request_body: Option<&'static [u8]>,
@@ -93,6 +128,8 @@ struct Opts {
93128
fn opts() -> Opts {
94129
Opts {
95130
http2: false,
131+
http2_stream_window: None,
132+
http2_conn_window: None,
96133
parallel_cnt: 1,
97134
request_method: Method::GET,
98135
request_body: None,
@@ -106,6 +143,16 @@ impl Opts {
106143
self
107144
}
108145

146+
fn http2_stream_window(mut self, sz: impl Into<Option<u32>>) -> Self {
147+
self.http2_stream_window = sz.into();
148+
self
149+
}
150+
151+
fn http2_conn_window(mut self, sz: impl Into<Option<u32>>) -> Self {
152+
self.http2_conn_window = sz.into();
153+
self
154+
}
155+
109156
fn method(mut self, m: Method) -> Self {
110157
self.request_method = m;
111158
self
@@ -133,11 +180,13 @@ impl Opts {
133180

134181
b.bytes = self.response_body.len() as u64 + self.request_body.map(|b| b.len()).unwrap_or(0) as u64;
135182

136-
let addr = spawn_hello(&mut rt, self.response_body);
183+
let addr = spawn_hello(&mut rt, &self);
137184

138185
let connector = HttpConnector::new(1);
139186
let client = hyper::Client::builder()
140187
.http2_only(self.http2)
188+
.http2_initial_stream_window_size(self.http2_stream_window)
189+
.http2_initial_connection_window_size(self.http2_conn_window)
141190
.build::<_, Body>(connector);
142191

143192
let url: hyper::Uri = format!("http://{}/hello", addr).parse().unwrap();
@@ -181,12 +230,19 @@ impl Opts {
181230
}
182231
}
183232

184-
fn spawn_hello(rt: &mut Runtime, body: &'static [u8]) -> SocketAddr {
233+
fn spawn_hello(rt: &mut Runtime, opts: &Opts) -> SocketAddr {
185234
use hyper::service::{service_fn};
186235
let addr = "127.0.0.1:0".parse().unwrap();
187236

188-
let srv = Server::bind(&addr)
189-
.serve(move || {
237+
let body = opts.response_body;
238+
let mut builder = Server::bind(&addr)
239+
.http2_only(opts.http2);
240+
// api woopsie
241+
builder
242+
.http2_initial_stream_window_size(opts.http2_stream_window)
243+
.http2_initial_connection_window_size(opts.http2_conn_window);
244+
245+
let srv = builder.serve(move || {
190246
service_fn(move |req: Request<Body>| {
191247
req
192248
.into_body()

0 commit comments

Comments
 (0)