Permalink
Browse files

http2: Use huge HTTP/2 windows

- Improve performance by using a huge HTTP/2 window size.

Bug: #1102
Reported-by: afrind@users.noreply.github.com
Assisted-by: Tatsuhiro Tsujikawa
  • Loading branch information...
jay committed Nov 16, 2016
1 parent 342aa47 commit a4d888857ede39a8e2aa5f961048c6362d3a5377
Showing with 13 additions and 10 deletions.
  1. +0 −8 docs/TODO
  2. +13 −2 lib/http2.c
View
@@ -63,7 +63,6 @@
5.1 Better persistency for HTTP 1.0
5.2 support FF3 sqlite cookie files
5.3 Rearrange request header order
5.4 Use huge HTTP/2 windows
5.5 auth= in URLs
5.6 Refuse "downgrade" redirects
5.7 Brotli compression
@@ -528,13 +527,6 @@ This is not detailed in any FTP specification.
headers use a default value so only headers that need to be moved have to be
specified.
5.4 Use huge HTTP/2 windows
We're currently using nghttp2's default window size which is terribly small
(64K). This becomes a bottle neck over high bandwidth networks. We should
instead make the window size to be very big (512MB?) as we really don't do
much flow control anyway.
5.5 auth= in URLs
Add the ability to specify the preferred authentication mechanism to use by
View
@@ -59,6 +59,8 @@
#define nghttp2_session_callbacks_set_error_callback(x,y)
#endif
#define HTTP2_HUGE_WINDOW_SIZE (1 << 30)
/*
* Curl_http2_init_state() is called when the easy handle is created and
* allows for HTTP/2 specific init of state.
@@ -965,7 +967,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
*/
static nghttp2_settings_entry settings[] = {
{ NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 100 },
{ NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, NGHTTP2_INITIAL_WINDOW_SIZE },
{ NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, HTTP2_HUGE_WINDOW_SIZE },
};
#define H2_BUFSIZE 32768
@@ -2031,14 +2033,23 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
else {
/* stream ID is unknown at this point */
stream->stream_id = -1;
rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE, NULL, 0);
rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE, settings,
sizeof(settings) / sizeof(settings[0]));
if(rv != 0) {
failf(data, "nghttp2_submit_settings() failed: %s(%d)",
nghttp2_strerror(rv), rv);
return CURLE_HTTP2;
}
}
rv = nghttp2_session_set_local_window_size(httpc->h2, NGHTTP2_FLAG_NONE, 0,
HTTP2_HUGE_WINDOW_SIZE);
if(rv != 0) {
failf(data, "nghttp2_session_set_local_window_size() failed: %s(%d)",
nghttp2_strerror(rv), rv);
return CURLE_HTTP2;
}
/* we are going to copy mem to httpc->inbuf. This is required since
mem is part of buffer pointed by stream->mem, and callbacks
called by nghttp2_session_mem_recv() will write stream specific

3 comments on commit a4d8888

@domenkozar

This comment has been minimized.

Show comment
Hide comment
@domenkozar

domenkozar replied Nov 23, 2016

🍻

@mkauf

This comment has been minimized.

Show comment
Hide comment
@mkauf

mkauf Nov 28, 2016

Contributor

The nghttp2_session_set_local_window_size() function is quite new (nghttp2 version 1.12, see https://github.com/nghttp2/nghttp2/releases/tag/v1.12.0 ).

The code or the configure script should check whether this function exists.

Contributor

mkauf replied Nov 28, 2016

The nghttp2_session_set_local_window_size() function is quite new (nghttp2 version 1.12, see https://github.com/nghttp2/nghttp2/releases/tag/v1.12.0 ).

The code or the configure script should check whether this function exists.

@jay

This comment has been minimized.

Show comment
Hide comment
@jay

jay Nov 28, 2016

Member

The nghttp2_session_set_local_window_size() function is quite new (nghttp2 version 1.12

Thanks, fixed in 19613fb.

Member

jay replied Nov 28, 2016

The nghttp2_session_set_local_window_size() function is quite new (nghttp2 version 1.12

Thanks, fixed in 19613fb.

Please sign in to comment.