summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-06 18:52:40 +0300
committerEd Tanous <ed@tanous.net>2024-04-30 18:48:48 +0300
commit88c7c427916c9baed4393ecf586980d36d7719fd (patch)
tree0b7225a19c48ef8f7ad9fdd571bba1a1eb6a2d06
parentccb05564803b01c16387ac604394afb8207cea3b (diff)
downloadbmcweb-88c7c427916c9baed4393ecf586980d36d7719fd.tar.xz
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 <ed@tanous.net>
-rw-r--r--http/http_body.hpp8
1 files changed, 8 insertions, 0 deletions
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 <fcntl.h>
#include <unistd.h>
#include <boost/beast/core/buffers_range.hpp>
@@ -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 = {};
}