From e428b440ddb09ffd575d4969793df15e29c02c39 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Fri, 29 Mar 2024 10:49:27 -0700 Subject: Increase the file buffer When we added file buffer, this number was picked arbitrarily. Prior to the file body patch series, files were buffered entirely in ram, regardless of what size they were. While not doing that was an improvement, I suspect that we were overly conservative in the buffer size. Nginx picks a default buffer size somewhere in the 8k - 64k range dependent on what paths the code takes. Using the higher end of that range seems like a better starting point, but generally we have more ram on the bmc than we have users. Increase the buffer to 64K. Tested: Unit tests pass. [1] https://docs.nginx.com/nginx-management-suite/acm/how-to/policies/http-backend-configuration/#buffers Change-Id: Idb472ccae02a8519c0976aab07b45562e327ce9b Signed-off-by: Ed Tanous --- http/http_body.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/http/http_body.hpp b/http/http_body.hpp index 46070cc60f..f4bfed58ec 100644 --- a/http/http_body.hpp +++ b/http/http_body.hpp @@ -178,7 +178,11 @@ class HttpBody::writer value_type& body; size_t sent = 0; - constexpr static size_t readBufSize = 4096; + // 64KB This number is arbitrary, and selected to try to optimize for larger + // files and fewer loops over per-connection reduction in memory usage. + // Nginx uses 16-32KB here, so we're in the range of what other webservers + // do. + constexpr static size_t readBufSize = 1024UL * 64UL; std::array fileReadBuf{}; public: -- cgit v1.2.3