From fb01cc3766be9131402b82730adfa0e45e6e3511 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 9 Nov 2018 14:38:22 +1100 Subject: my_getncpus based on threads available Detecting the cpus based on sysconf of the online CPUs can significantly over estimate the number of cpus available. Wheither via numactl, cgroups, taskset, systemd constraints, docker containers and probably other mechanisms, the number of threads mysqld can be run on can be quite less. As such we use the pthread_getaffinity_np function on Linux and FreeBSD (identical API) to get the number of CPUs. The number of CPUs is the default for the thread_pool_size and a too high default will resulting in large memory usage and high context switching overhead. Closes PR #922 --- config.h.cmake | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config.h.cmake') diff --git a/config.h.cmake b/config.h.cmake index 6e4af65c40e..fdaba640ad6 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -200,6 +200,9 @@ #cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1 #cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1 +#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 +#cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1 +#cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KILL 1 #cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1 -- cgit v1.2.1 From 0d1dd2e79d4411ef8aaac9e789569253061caec9 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Thu, 20 Feb 2020 09:25:05 +0100 Subject: Clean wrong cherry-pick from previous commit - Delete variable HAVE_PTHREAD_CONDATTR_SETCLOCK and check - Delete second HAVE_PTHREAD_KEY_DELETE --- config.h.cmake | 2 -- 1 file changed, 2 deletions(-) (limited to 'config.h.cmake') diff --git a/config.h.cmake b/config.h.cmake index fdaba640ad6..170bb80b691 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -200,10 +200,8 @@ #cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1 #cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1 -#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 #cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1 -#cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KILL 1 #cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1 #cmakedefine HAVE_PTHREAD_SIGMASK 1 -- cgit v1.2.1