Skip to content

Commit a4d8888

Browse files
committed
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
1 parent 342aa47 commit a4d8888

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

docs/TODO

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
5.1 Better persistency for HTTP 1.0
6464
5.2 support FF3 sqlite cookie files
6565
5.3 Rearrange request header order
66-
5.4 Use huge HTTP/2 windows
6766
5.5 auth= in URLs
6867
5.6 Refuse "downgrade" redirects
6968
5.7 Brotli compression
@@ -528,13 +527,6 @@ This is not detailed in any FTP specification.
528527
headers use a default value so only headers that need to be moved have to be
529528
specified.
530529

531-
5.4 Use huge HTTP/2 windows
532-
533-
We're currently using nghttp2's default window size which is terribly small
534-
(64K). This becomes a bottle neck over high bandwidth networks. We should
535-
instead make the window size to be very big (512MB?) as we really don't do
536-
much flow control anyway.
537-
538530
5.5 auth= in URLs
539531

540532
Add the ability to specify the preferred authentication mechanism to use by

lib/http2.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
#define nghttp2_session_callbacks_set_error_callback(x,y)
6060
#endif
6161

62+
#define HTTP2_HUGE_WINDOW_SIZE (1 << 30)
63+
6264
/*
6365
* Curl_http2_init_state() is called when the easy handle is created and
6466
* allows for HTTP/2 specific init of state.
@@ -965,7 +967,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
965967
*/
966968
static nghttp2_settings_entry settings[] = {
967969
{ NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 100 },
968-
{ NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, NGHTTP2_INITIAL_WINDOW_SIZE },
970+
{ NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, HTTP2_HUGE_WINDOW_SIZE },
969971
};
970972

971973
#define H2_BUFSIZE 32768
@@ -2031,14 +2033,23 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
20312033
else {
20322034
/* stream ID is unknown at this point */
20332035
stream->stream_id = -1;
2034-
rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE, NULL, 0);
2036+
rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE, settings,
2037+
sizeof(settings) / sizeof(settings[0]));
20352038
if(rv != 0) {
20362039
failf(data, "nghttp2_submit_settings() failed: %s(%d)",
20372040
nghttp2_strerror(rv), rv);
20382041
return CURLE_HTTP2;
20392042
}
20402043
}
20412044

2045+
rv = nghttp2_session_set_local_window_size(httpc->h2, NGHTTP2_FLAG_NONE, 0,
2046+
HTTP2_HUGE_WINDOW_SIZE);
2047+
if(rv != 0) {
2048+
failf(data, "nghttp2_session_set_local_window_size() failed: %s(%d)",
2049+
nghttp2_strerror(rv), rv);
2050+
return CURLE_HTTP2;
2051+
}
2052+
20422053
/* we are going to copy mem to httpc->inbuf. This is required since
20432054
mem is part of buffer pointed by stream->mem, and callbacks
20442055
called by nghttp2_session_mem_recv() will write stream specific

0 commit comments

Comments
 (0)