@@ -46,12 +46,13 @@ bazel run -c opt \
4646#include " absl/log/absl_log.h"
4747#include " absl/log/log.h"
4848#include " absl/status/status.h"
49+ #include " absl/strings/match.h"
4950#include " absl/strings/str_format.h"
5051#include " absl/strings/string_view.h"
5152#include " absl/synchronization/mutex.h"
5253#include " absl/time/clock.h"
5354#include " absl/time/time.h"
54- #include < nlohmann/json_fwd .hpp>
55+ #include < nlohmann/json .hpp>
5556#include " tensorstore/array.h"
5657#include " tensorstore/context.h"
5758#include " absl/flags/parse.h"
@@ -60,6 +61,7 @@ bazel run -c opt \
6061#include " tensorstore/internal/json_binding/std_array.h" // IWYU pragma: keep
6162#include " tensorstore/internal/metrics/metadata.h"
6263#include " tensorstore/internal/metrics/value.h"
64+ #include " tensorstore/internal/os/file_util.h"
6365#include " tensorstore/open.h"
6466#include " tensorstore/open_mode.h"
6567#include " tensorstore/spec.h"
@@ -304,6 +306,26 @@ void RunBenchmark(tensorstore::Context::Spec context_spec,
304306 }
305307 }
306308}
309+ void CheckTransparentHugePages () {
310+ #if defined(__linux__)
311+ auto hugepages = internal_os::ReadAllToString (
312+ " /sys/kernel/mm/transparent_hugepage/enabled" );
313+ if (hugepages.ok () && absl::StrContains (hugepages.value (), " [always]" )) {
314+ return ;
315+ } else if (hugepages.ok ()) {
316+ ABSL_LOG (WARNING)
317+ << " See https://docs.kernel.org/admin-guide/mm/transhuge.html\n "
318+ " Transparent huge pages should be set to \" always\" ; the current "
319+ " setting of \" "
320+ << hugepages.value () << " \" may cause reduced read performance." ;
321+ } else {
322+ ABSL_LOG (INFO)
323+ << " See https://docs.kernel.org/admin-guide/mm/transhuge.html\n "
324+ " Transparent huge page settings are unknown; "
325+ " /sys/kernel/mm/transparent_hugepage/enabled is not readable." ;
326+ }
327+ #endif
328+ }
307329
308330void Run (int argc, char ** argv) {
309331 ABSL_CHECK (absl::GetFlag (FLAGS_repeat_reads) > 0 );
@@ -322,6 +344,8 @@ void Run(int argc, char** argv) {
322344 ABSL_QCHECK (!specs.empty ()) << " Empty config; supply non-empty --read_config "
323345 " or pass specs on the command line." ;
324346
347+ CheckTransparentHugePages ();
348+
325349 if (absl::GetFlag (FLAGS_ith_spec) >= 0 ) {
326350 ABSL_LOG (INFO) << " Reading only spec #" << absl::GetFlag (FLAGS_ith_spec);
327351 specs = {specs[absl::GetFlag (FLAGS_ith_spec)]};
0 commit comments