-
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
Add containerized linux memory manager #22997
base: master
Are you sure you want to change the base?
Conversation
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 for adding this!
presto-native-execution/presto_cpp/main/PeriodicMemoryChecker.cpp
Outdated
Show resolved
Hide resolved
a36acf4
to
dbd7e48
Compare
53b5e8e
to
772fd86
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.
Thank you. Please squash the commits into a single commit and rebase.
presto-native-execution/presto_cpp/main/PeriodicMemoryChecker.cpp
Outdated
Show resolved
Hide resolved
233ea59
to
0007587
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.
@majetideepak Can you please also take a look when you get a chance?
b2d95cd
to
10b65f5
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 and @mohsaka. Have some comments related to this code.
6c27e02
to
f4a03c4
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 for the doc! Only a few nits of suggested formatting and phrasing.
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.
LGTM! (docs)
Pull updated branch, new doc build. Thanks!
I have some feedback on this. I will complete the review by EOD. |
@minhancao Can you please squash the commits into a single commit? |
664dd0d
to
2928a7e
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.
One more minor fix in the doc. Rest looks good.
51639a8
to
fc98629
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.
Looks good. Thanks!
@bikramSingh91 The comments are all now addressed and is ready to merge. Please take another look when you can, thanks! |
Looks good to me! |
@xiaoxmeng, @bikramSingh91 can you please import this again? |
@majetideepak @bikramSingh91 will take care once this change is landed on github. |
@tdcmeehan can you please approve and help land this? It looks like a committer approval is needed. Thanks. |
@xiaoxmeng You need to import it to get this to land. A required CI test is failing |
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.
We saw an issue with this internally. I will update once this is fixed.
fc98629
to
290a656
Compare
Please also rebase this PR. |
1b93112
to
1b03a96
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.
Thank you!
if (boost::regex_match(line.data(), match, regex)) { | ||
if (match.size() > 1) { | ||
std::string numStr(match[1].str()); | ||
return std::stoul(numStr); |
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 is incorrect. This will return a 32-bit integer which will overflow and is limited. Errno could be set to indicate a truncation warning.
It either needs to be std::stroull
or use the original folly::to<size_t>(numStr);
.
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 for the catch! Changing to use folly::to<size_t>(numStr);
1ea7b0a
to
40a3a63
Compare
Co-authored-by: Minhan Cao <minhan.duc.cao@gmail.com>
Description
This PR helps shrink memory usage when we detect at the system level that Prestissimo is running out of
memory.
This PR implements a LinuxMemoryChecker which can be enabled by setting the CMake flag
PRESTO_MEMORY_CHECKER_TYPE=LINUX_MEMORY_CHECKER
.We currently are using this memory manager for our deployments to prevent OOMKills. It has been well tested on CentOS.
Note that mallocBytes, periodicCb, heapDumpCb, removeDumpFile are not supported.
LinuxMemoryChecker:
We are currently using inactive_anon + active_anon to track the current system memory usage.
Our first attempt was using memInfo memTotal - memAvailable. However memInfo is not containerized so we reserve this as a last resort.
Next we tried to use what docker/kubernetes uses for their calculation. cgroup usage_in_bytes - total_inactive_files. However we found out that usage_in_bytes is a fuzz value and has a chance for the sync to occur after the shrink polling interval. This would result in double shrinks.
Therefore we decided on values from the memory.stat file that are real time statistics. At first we tried to use the calculation suggested by the kernel team RSS+CACHE(+SWAP). However we noticed that this value was not closely related to the value in usage_in_bytes which is used to OOMKill. We then looked at all of the values in the stat file and decided that inactive_anon + active_anon moves closest to that of usage_in_bytes
NOTE: We do not know if cgroup V2 memory.current is a fuzz value. It may be better than what we currently use. For consistency we will match cgroup V1 and change if necessary.
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
If release note is NOT required, use: