@@ -139,6 +139,18 @@ fn http2_parallel_x10_req_10kb_100_chunks(b: &mut test::Bencher) {
139139 . bench ( b)
140140}
141141
142+ #[ bench]
143+ fn http2_parallel_x10_req_10kb_100_chunks_adaptive_window ( b : & mut test:: Bencher ) {
144+ let body = & [ b'x' ; 1024 * 10 ] ;
145+ opts ( )
146+ . http2 ( )
147+ . parallel ( 10 )
148+ . method ( Method :: POST )
149+ . request_chunks ( body, 100 )
150+ . http2_adaptive_window ( )
151+ . bench ( b)
152+ }
153+
142154#[ bench]
143155fn http2_parallel_x10_req_10kb_100_chunks_max_window ( b : & mut test:: Bencher ) {
144156 let body = & [ b'x' ; 1024 * 10 ] ;
@@ -182,6 +194,7 @@ struct Opts {
182194 http2 : bool ,
183195 http2_stream_window : Option < u32 > ,
184196 http2_conn_window : Option < u32 > ,
197+ http2_adaptive_window : bool ,
185198 parallel_cnt : u32 ,
186199 request_method : Method ,
187200 request_body : Option < & ' static [ u8 ] > ,
@@ -194,6 +207,7 @@ fn opts() -> Opts {
194207 http2 : false ,
195208 http2_stream_window : None ,
196209 http2_conn_window : None ,
210+ http2_adaptive_window : false ,
197211 parallel_cnt : 1 ,
198212 request_method : Method :: GET ,
199213 request_body : None ,
@@ -209,15 +223,24 @@ impl Opts {
209223 }
210224
211225 fn http2_stream_window ( mut self , sz : impl Into < Option < u32 > > ) -> Self {
226+ assert ! ( !self . http2_adaptive_window) ;
212227 self . http2_stream_window = sz. into ( ) ;
213228 self
214229 }
215230
216231 fn http2_conn_window ( mut self , sz : impl Into < Option < u32 > > ) -> Self {
232+ assert ! ( !self . http2_adaptive_window) ;
217233 self . http2_conn_window = sz. into ( ) ;
218234 self
219235 }
220236
237+ fn http2_adaptive_window ( mut self ) -> Self {
238+ assert ! ( self . http2_stream_window. is_none( ) ) ;
239+ assert ! ( self . http2_conn_window. is_none( ) ) ;
240+ self . http2_adaptive_window = true ;
241+ self
242+ }
243+
221244 fn method ( mut self , m : Method ) -> Self {
222245 self . request_method = m;
223246 self
@@ -272,6 +295,7 @@ impl Opts {
272295 . http2_only ( self . http2 )
273296 . http2_initial_stream_window_size ( self . http2_stream_window )
274297 . http2_initial_connection_window_size ( self . http2_conn_window )
298+ . http2_adaptive_window ( self . http2_adaptive_window )
275299 . build :: < _ , Body > ( connector) ;
276300
277301 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 {
337361 . http2_only ( opts. http2 )
338362 . http2_initial_stream_window_size ( opts. http2_stream_window )
339363 . http2_initial_connection_window_size ( opts. http2_conn_window )
364+ . http2_adaptive_window ( opts. http2_adaptive_window )
340365 . serve ( make_service_fn ( move |_| async move {
341366 Ok :: < _ , hyper:: Error > ( service_fn ( move |req : Request < Body > | async move {
342367 let mut req_body = req. into_body ( ) ;
0 commit comments