Skip to content

Commit

Permalink
Added logging of actual total memory and which cgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
minhancao committed Feb 4, 2025
1 parent 29dc3b5 commit 6b32567
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions presto-native-execution/presto_cpp/main/LinuxMemoryChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,34 @@ 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_);
} else if ((stat(kCgroupV2Path, &buffer) == 0)) {
statFile_ = kCgroupV2Path;
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_);
}
LOG(INFO) << fmt::format("Using memory stat file {}", statFile_);

// Set memMaxFile_ to:
// "/sys/fs/cgroup/memory/memory.limit_in_bytes" for cgroup v1
// or
// "/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_);
} else if ((stat(kCgroupV2MaxMemFilePath, &buffer) == 0)) {
memMaxFile_ = kCgroupV2MaxMemFilePath;
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_);
}
LOG(INFO) << fmt::format("Using memory max file {}", memMaxFile_);
}

~LinuxMemoryChecker() override {}
Expand Down Expand Up @@ -77,10 +86,12 @@ class LinuxMemoryChecker : public PeriodicMemoryChecker {
// Check system-memory-gb < system-mem-limit-gb < actual total memory
// capacity.
int64_t actualTotalMemory = getActualTotalMemory();
LOG(INFO) << fmt::format(
"Actual total memory in bytes: {}", actualTotalMemory);
VELOX_CHECK_LE(
config_.systemMemLimitBytes,
actualTotalMemory,
"system-mem-limit-gb = {} is higher than the actual total memory capacity {} gb.",
"system memory limit = {} bytes is higher than the actual total memory capacity = {} bytes.",
config_.systemMemLimitBytes,
actualTotalMemory);

Expand Down

0 comments on commit 6b32567

Please sign in to comment.