-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[native] Add LinuxMemoryChecker check/warning to ensure system-mem-limit-gb is reasonably set #24149
base: master
Are you sure you want to change the base?
[native] Add LinuxMemoryChecker check/warning to ensure system-mem-limit-gb is reasonably set #24149
Conversation
4478ae1
to
15f55bb
Compare
15f55bb
to
7646600
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test with fake files again just like we did with the original tests for this class?
That way we can try the "max" value for cgv2, and gigantic values and reasonable values. Basically testing the various situations we saw when investigating this.
8da401b
to
4ae2cee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @minhancao, could you please squash the commits?
presto-native-execution/presto_cpp/main/tests/LinuxMemoryCheckerTest.cpp
Outdated
Show resolved
Hide resolved
std::string statFile_; | ||
std::string memInfoFile_ = "/proc/meminfo"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: const std::string kMemInfoFile_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to stay as a non-const variable since I need to change its path to point to the meminfo test file when I am running the LinuxMemoryCheckerTests.
85b3b9d
to
dab2335
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ideal if we can avoid checking in data files for testing.
We only need a few fields from the file for testing.
Can we write these required fields to a temporary file as part of the testing?
VELOX_CHECK_LE( | ||
config_.systemMemLimitBytes, | ||
getActualTotalMemory(), | ||
"system-mem-limit-gb is higher than the actual total memory capacity."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the actual numbers that were found if this fails? Especially because the total memory capacity doesn't come from the config but is determined.
// For cgroup v1, memory.limit_in_bytes can default to a really big numeric | ||
// value in bytes like 9223372036854771712 to represent that | ||
// memory.limit_in_bytes is not set to a value. The default value here is | ||
// set to PAGE_COUNTER_MAX, which is LONG_MAX/PAGE_SIZE on 64-bit platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "on the 64-bit platform".
@@ -0,0 +1 @@ | |||
9223372036854771712 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, lets not add example files but generate the content in memory.
The logic relies on reading files. So we could write to the temp dir path which is used in other tests and use those files for the test.
71c9fa9
to
89a50a8
Compare
…ystem-mem-limit-gb < actual total memory capacity.
89a50a8
to
163880b
Compare
Description
Add LinuxMemoryChecker check and warning to ensure system-memory-gb < system-mem-limit-gb < actual total memory capacity.
For cgroup v1:
Set actual total memory to be the smaller number between /proc/meminfo and memory.limit_in_bytes
For cgroup v2:
Set actual total memory to be the smaller number between /proc/meminfo and memory.max
If memory.max contains "max" string, then look at /proc/meminfo for the MemTotal, otherwise use the value in memory.max.
VELOX_CHECK_LT(system-mem-limit-gb, actual total memory capacity):
Warning to output to worker's log:
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.