Uh oh!
There was an error while loading. Please reload this page.
Determine any memory/CPU limitations from sysfs cgroup - #74237
Conversation
Add capability to interrogate cgroup limitations when determining CP and memory limits This code has been adapted from coreCLR. It has been modified from C++ but uses the same naming conventions in the event of a unified mechanism that can be shared between both runtimes being developed. The code has been tested on Ubuntu 20.04 and CentOS 7 with cgroupv1 and cgroupv2. This code is required in the event of running runtime in a container as the current limitations being discovered by the mono runtime are purely for the machine and not in a container which may have lower quotas. * src/mono/CMakeLists.txt - Set the HAVE_CGROUP_SUPPORT for Linux hosts * src/mono/cmake/config.h.in - Place holder for HAVE_CGROU_SUPPORT definition * src/mono/mono/metadata/icall.c * src/mono/mono/sgen/sgen-marksweep.c * src/mono/mono/sgen/sgen-simple-nursery.c - Use mono_cpu_limit() instead of mono_cpu_count() * src/mono/mono/utils/CMakeLists.txt - Add mono-cgroup.c to the build * src/mono/mono/utils/memfuncs.c - Call `getRestrictedPhysicalMemoryLimit()` or `getPhyscalMemoryAvail()` * src/mono/mono/utils/memfuncs.h - Add prototypes for the new APIs * src/mono/mono/utils/mono-cgroup.c - Code adapted from coreCLR to interrogate sysfs to determine any limitations on memory or CPU * src/mono/mono/utils/mono-proclib.c - Add call to `getCpuLimit()` * src/mono/mono/utils/mono-proclib.h - Add prototype for the new API
Uh oh!
There was an error while loading. Please reload this page.
naricc
commented
Aug 23, 2022
If this code is adapated from CoreCLR, is there a plan to share the code eventually, or need it all be duplicated? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
lambdageek
left a comment
There was a problem hiding this comment.
@SamMonoRT I think we want to take a backport of this for net7. I don't think this will impact mobile or wasm. (But the "DOTNET_PROCESSOR_COUNT" support might be a nice thing to bring along on those platforms for diagnostic scenarios)
SamMonoRT
commented
Aug 25, 2022
Yes, once all suggestions are addressed and CI lanes look green, will issue a backport command. |
SamMonoRT
commented
Aug 26, 2022
@nealef - please let us know when all suggested changes are completed. |
nealef
commented
Aug 29, 2022
The only one missing is the explicit cast from |
- Adhere to call statement convention - Remove unnecessary cast * mono-proclib.c - Explicit cast
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
akoeplinger
commented
Aug 31, 2022
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/2965665895 |
Add capability to interrogate cgroup limitations when determining CP and memory limits
This code has been adapted from coreCLR. It has been modified from C++ but uses the same naming conventions in the event of a unified mechanism that can be shared between both runtimes being developed. The code has been tested on Ubuntu 20.04 and CentOS 7 with cgroupv1 and cgroupv2.
This code is required in the event of running runtime in a container as the current limitations being discovered by the mono runtime are purely for the machine and not in a container which may have lower quotas.
src/mono/CMakeLists.txt
src/mono/cmake/config.h.in
src/mono/mono/metadata/icall.c
src/mono/mono/sgen/sgen-marksweep.c
src/mono/mono/sgen/sgen-simple-nursery.c
src/mono/mono/utils/CMakeLists.txt
src/mono/mono/utils/memfuncs.c
getRestrictedPhysicalMemoryLimit()orgetPhyscalMemoryAvail()src/mono/mono/utils/memfuncs.h
src/mono/mono/utils/mono-cgroup.c
src/mono/mono/utils/mono-proclib.c
getCpuLimit()src/mono/mono/utils/mono-proclib.h