This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.4.3
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.4.3 by this push:
new 796ca36 Issue 51072 - Set the default minimum worker threads
796ca36 is described below
commit 796ca36dd83096ce050d82c9948a8094c90b2302
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Thu Jun 11 16:28:17 2020 -0400
Issue 51072 - Set the default minimum worker threads
Description: Testing has shown that using current number of CPU cores
to set the thread number gives the best performance, but
when there are expensive operations total throughput drops.
We still need a minimum number of workers threads to handle
a wide range of operations. We decided for now that the
minimum should be 16 workers.
relates:
https://pagure.io/389-ds-base/issue/51072
Reviewed by: tbordaz & firstyear (Thanks!!)
Define MAX and MIN threads, and improve logging
---
ldap/servers/slapd/libglobs.c | 5 -----
ldap/servers/slapd/util.c | 45 +++++++++++++++++++++++++++++--------------
2 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index fbf90d9..d540d84 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -5905,11 +5905,6 @@ config_get_threadnumber(void)
retVal = util_get_hardware_threads();
}
- /* We *still* can't detect hardware threads. Okay, return 30 :( */
- if (retVal <= 0) {
- retVal = 30;
- }
-
return retVal;
}
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
index fc67d70..fda4fdf 100644
--- a/ldap/servers/slapd/util.c
+++ b/ldap/servers/slapd/util.c
@@ -26,6 +26,7 @@
#include "snmp_collator.h"
#include <sys/time.h>
#include <sys/resource.h>
+#include <errno.h>
#define UTIL_ESCAPE_NONE 0
#define UTIL_ESCAPE_HEX 1
@@ -40,6 +41,9 @@
#define FILTER_BUF 128 /* initial buffer size for attr value */
#define BUF_INCR 16 /* the amount to increase the FILTER_BUF once it fills up */
+#define MIN_THREADS 16
+#define MAX_THREADS 512
+
/* slapi-private contains the pal. */
#include <slapi-private.h>
@@ -1487,26 +1491,39 @@ util_is_cachesize_sane(slapi_pal_meminfo *mi, uint64_t
*cachesize)
long
util_get_hardware_threads(void)
{
+ long threads = MIN_THREADS;
#ifdef LINUX
long hw_threads = sysconf(_SC_NPROCESSORS_ONLN);
- long threads = 0;
- slapi_log_err(SLAPI_LOG_TRACE, "util_get_hardware_threads", "Detected
%lu hardware threads\n", threads);
- if (hw_threads == 0) {
- /* Error! */
- threads = -1;
- } else if (hw_threads < 512) {
- threads = hw_threads;
- } else {
- /* Cap at 512 for now ... */
- threads = 512;
+
+ slapi_log_err(SLAPI_LOG_TRACE, "util_get_hardware_threads",
+ "Detected %ld hardware threads\n", hw_threads);
+
+ if (hw_threads == -1) {
+ /* sysconf failed, use MIN_THREADS */
+ slapi_log_err(SLAPI_LOG_ERR, "util_get_hardware_threads",
+ "Failed to get hardware threads. Error (%d) %s\n",
+ errno, slapd_system_strerror(errno));
+ } else if (hw_threads == 0) {
+ /* sysconf failed to find any processors, use MIN_THREADS */
+ slapi_log_err(SLAPI_LOG_ERR, "util_get_hardware_threads",
+ "Cannot detect any hardware threads.\n");
+ } else if (hw_threads > MIN_THREADS) {
+ if (hw_threads < MAX_THREADS) {
+ threads = hw_threads;
+ } else {
+ /* Cap at 512 for now ... */
+ threads = MAX_THREADS;
+ }
}
- slapi_log_err(SLAPI_LOG_INFO, "util_get_hardware_threads",
"Automatically configuring %lu threads\n", threads);
+
+ slapi_log_err(SLAPI_LOG_INFO, "util_get_hardware_threads",
"Automatically configuring %ld threads\n", threads);
return threads;
#else
- slapi_log_err(SLAPI_LOG_ERR, "util_get_hardware_threads", "ERROR:
Cannot detect hardware threads on this platform. This is probably a bug!\n");
- /* Can't detect threads on this platform! */
- return -1;
+ slapi_log_err(SLAPI_LOG_ERR, "util_get_hardware_threads",
+ "ERROR: Cannot detect hardware threads on this platform. This is
probably a bug!\n");
+ /* Can't detect threads on this platform! Return the default thread number */
+ return threads;
#endif
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.