From 2c6b3074fc924b61ab98326bd75ef55a1fa970ca Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 19 Oct 2020 14:41:29 +0200 Subject: [PATCH] Increase the default HTTPClient download chunk size to 64 KiB This improves download speeds at the cost of increased memory usage. This change also effects HTTPRequest automatically. See #32807 and #33862. (cherry picked from commit 13357095eef1bf644ae3f878143716f73e2afd2a) --- core/io/http_client.cpp | 3 ++- doc/classes/HTTPClient.xml | 2 +- doc/classes/HTTPRequest.xml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 9614c0d1f91..f5ee5c24c8a 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -749,7 +749,8 @@ HTTPClient::HTTPClient() { ssl = false; blocking = false; handshaking = false; - read_chunk_size = 4096; + // 64 KiB by default (favors fast download speeds at the cost of memory usage). + read_chunk_size = 65536; } HTTPClient::~HTTPClient() { diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml index cf40d57b242..623a5ce2476 100644 --- a/doc/classes/HTTPClient.xml +++ b/doc/classes/HTTPClient.xml @@ -181,7 +181,7 @@ The connection to use for this client. - + The size of the buffer used and maximum bytes to read per iteration. See [method read_response_body_chunk]. diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index e566e6d17b3..1d2c6fafcb9 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -125,9 +125,9 @@ Maximum allowed size for response bodies. - + The size of the buffer used and maximum bytes to read per iteration. See [member HTTPClient.read_chunk_size]. - Set this to a higher value (e.g. 65536 for 64 KiB) when downloading large files to achieve better speeds at the cost of memory. + Set this to a lower value (e.g. 4096 for 4 KiB) when downloading small files to decrease memory usage at the cost of download speeds. The file to download into. Will output any received file into it.