diff --git a/presto-native-execution/presto_cpp/main/LinuxMemoryChecker.cpp b/presto-native-execution/presto_cpp/main/LinuxMemoryChecker.cpp index 9a1055917f4a8..8c09ba6697c2e 100644 --- a/presto-native-execution/presto_cpp/main/LinuxMemoryChecker.cpp +++ b/presto-native-execution/presto_cpp/main/LinuxMemoryChecker.cpp @@ -18,6 +18,7 @@ #include #include "presto_cpp/main/PeriodicMemoryChecker.h" #include "presto_cpp/main/common/Configs.h" +#include "presto_cpp/main/common/Utils.h" namespace facebook::presto { @@ -30,16 +31,16 @@ class LinuxMemoryChecker : public PeriodicMemoryChecker { struct stat buffer; if ((stat(kCgroupV1Path, &buffer) == 0)) { statFile_ = kCgroupV1Path; - LOG(INFO) << fmt::format( - "Using cgroup v1 memory stat file: {}", statFile_); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("Using cgroup v1 memory stat file: {}", statFile_); } else if ((stat(kCgroupV2Path, &buffer) == 0)) { statFile_ = kCgroupV2Path; - LOG(INFO) << fmt::format( - "Using cgroup v2 memory stat file: {}", statFile_); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("Using cgroup v2 memory stat file: {}", statFile_); } else { statFile_ = "None"; - LOG(INFO) << fmt::format( - "Could not find memory stat file: {}", statFile_); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("Could not find memory stat file: {}", statFile_); } // Set memMaxFile_ to: @@ -48,16 +49,19 @@ class LinuxMemoryChecker : public PeriodicMemoryChecker { // "/sys/fs/cgroup/memory.max" for cgroup v2. if ((stat(kCgroupV1MaxMemFilePath, &buffer) == 0)) { memMaxFile_ = kCgroupV1MaxMemFilePath; - LOG(INFO) << fmt::format( - "Using cgroup v1 memory max file {}", memMaxFile_); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("Using cgroup v1 memory max file {}", memMaxFile_); } else if ((stat(kCgroupV2MaxMemFilePath, &buffer) == 0)) { memMaxFile_ = kCgroupV2MaxMemFilePath; - LOG(INFO) << fmt::format( - "Using cgroup v2 memory max file {}", memMaxFile_); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("Using cgroup v2 memory max file {}", memMaxFile_); } else { memMaxFile_ = "None"; - LOG(INFO) << fmt::format("Could not find memory max file: {}", statFile_); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("Could not find memory max file: {}", memMaxFile_); } + + checkMemoryConfigs(); } ~LinuxMemoryChecker() override {} @@ -82,19 +86,20 @@ class LinuxMemoryChecker : public PeriodicMemoryChecker { LOG(INFO) << fmt::format("Changed to using meminfo file {}", memInfoFile_); } - void start() { + void checkMemoryConfigs() { // Check system-memory-gb < system-mem-limit-gb < actual total memory // capacity. auto* systemConfig = SystemConfig::instance(); int64_t systemMemoryInBytes = systemConfig->systemMemoryGb() << 30; - LOG(INFO) << fmt::format("System memory in bytes: {}", systemMemoryInBytes); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("System memory in bytes: {}", systemMemoryInBytes); - LOG(INFO) << fmt::format( + PRESTO_STARTUP_LOG(INFO) << fmt::format( "System memory limit in bytes: {}", config_.systemMemLimitBytes); int64_t actualTotalMemory = getActualTotalMemory(); - LOG(INFO) << fmt::format( - "Actual total memory in bytes: {}", actualTotalMemory); + PRESTO_STARTUP_LOG(INFO) + << fmt::format("Actual total memory in bytes: {}", actualTotalMemory); VELOX_CHECK_LE( config_.systemMemLimitBytes, @@ -107,8 +112,6 @@ class LinuxMemoryChecker : public PeriodicMemoryChecker { LOG(WARNING) << "system-mem-limit-gb is smaller than system-memory-gb. " << "Expected: system-mem-limit-gb >= system-memory-gb."; } - - PeriodicMemoryChecker::start(); } int64_t getActualTotalMemory() {