Skip to content
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

Get accuracy memory and cpu limits inside container #817

Open
0xyjk opened this issue Mar 25, 2024 · 0 comments
Open

Get accuracy memory and cpu limits inside container #817

0xyjk opened this issue Mar 25, 2024 · 0 comments

Comments

@0xyjk
Copy link

0xyjk commented Mar 25, 2024

Context

Problems

if program running in a docker container with cgroup limits, the way to get CPU/Memory limits is not accuracy which potentially will cause OOM

Solution

Get Memory Limit

try get memory limit from /sys/fs/cgroup/memory/memory.limit_in_bytes, if the value is 0 or large than /proc/meminfo, fallback to use the mem info inside /proc/meminfo

Get CPU Limit

try to caculate CPU Core number from /sys/fs/cgroup/cpu/cpu.cfs_quota_us Div /sys/fs/cgroup/cpu/cpu.cfs_period_us, if it's not a valid number, then fallback to omp_get_num_procs()

Refs

@0xyjk 0xyjk changed the title Read memory and cpu limits inside container get accuracy memory and cpu limits inside container Mar 25, 2024
@0xyjk 0xyjk changed the title get accuracy memory and cpu limits inside container Get accuracy memory and cpu limits inside container Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant