From 88c7c427916c9baed4393ecf586980d36d7719fd Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Sat, 6 Apr 2024 08:52:40 -0700 Subject: Use fadvise to trigger sequential reading Nginx and other webservers use fadvise to inform the kernel of in-order reading. We should to the same. Tested: Webui loads correctly, no direct performance benefits immediately obvious, but likely would operate better under load. Change-Id: I4acce316c719df7df012cea8cb89237b28932c15 Signed-off-by: Ed Tanous --- http/http_body.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'http') diff --git a/http/http_body.hpp b/http/http_body.hpp index f2ec53fec2..46070cc60f 100644 --- a/http/http_body.hpp +++ b/http/http_body.hpp @@ -3,6 +3,7 @@ #include "logging.hpp" #include "utility.hpp" +#include #include #include @@ -139,6 +140,13 @@ class HttpBody::value_type { BMCWEB_LOG_WARNING("Failed to read file size on {}", path); } + + int fadvise = posix_fadvise(fileHandle.native_handle(), 0, 0, + POSIX_FADV_SEQUENTIAL); + if (fadvise != 0) + { + BMCWEB_LOG_WARNING("Fasvise returned {} ignoring", fadvise); + } ec = {}; } -- cgit v1.2.3