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>
diff --git a/http/http_body.hpp b/http/http_body.hpp
index f2ec53f..46070cc 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 @@
{
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 = {};
}