Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeale Ferguson <neale@sinenomine.net>2022-01-25 20:29:02 +0300
committerGitHub <noreply@github.com>2022-01-25 20:29:02 +0300
commit04859508c54a7ac25547bc5bcf4a019f0517aa0b (patch)
tree5cf0e785602867159040b5b2ce0bcabb7edf596f /mono/metadata/threadpool.c
parent95229aaa2ec642449aea4eba44fc717ca74786ab (diff)
Determine any memory/CPU limitations from sysfs cgroup (#21280)
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 mono in a container as the current limitations being discovered by mono are purely for the machine and not in a container which may have lower quotas. * mono/utils/Makefile.am - Add new file to build * mono/utils/memfuncs.c - Call `getRestrictedPhysicalMemoryLimit()` or `getPhyscalMemoryAvail()` * mono/utils/memfuncs.h - Add prototypes for the new APIs * mono/utils/mono-cgroup.c - Code adapted from coreCLR to interrogate sysfs to determine any limitations on memory or CPU * mono/utils/mono-proclib.c - Add call to `getCpuLimit()` * mono/utils/mono-proclib.h - Add prototype for the new API
Diffstat (limited to 'mono/metadata/threadpool.c')
-rw-r--r--mono/metadata/threadpool.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c
index cc669e9e132..dc7bd6070f5 100644
--- a/mono/metadata/threadpool.c
+++ b/mono/metadata/threadpool.c
@@ -145,7 +145,7 @@ initialize (void)
threadpool.domains = g_ptr_array_new ();
mono_coop_mutex_init (&threadpool.domains_lock);
- threadpool.limit_io_min = mono_cpu_count ();
+ threadpool.limit_io_min = mono_cpu_limit ();
threadpool.limit_io_max = CLAMP (threadpool.limit_io_min * 100, MIN (threadpool.limit_io_min, 200), MAX (threadpool.limit_io_min, 200));
mono_threadpool_worker_init (worker_callback);
@@ -712,7 +712,7 @@ ves_icall_System_Threading_ThreadPool_SetMaxThreadsNative (gint32 worker_threads
worker_threads = MIN (worker_threads, MAX_POSSIBLE_THREADS);
completion_port_threads = MIN (completion_port_threads, MAX_POSSIBLE_THREADS);
- gint cpu_count = mono_cpu_count ();
+ gint cpu_count = mono_cpu_limit ();
if (completion_port_threads < threadpool.limit_io_min || completion_port_threads < cpu_count)
return FALSE;