|
|
a26cad |
From 2be9d1b4332d3b9b55a2d285e9610813100e235f Mon Sep 17 00:00:00 2001
|
|
|
a26cad |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
a26cad |
Date: Mon, 22 Jun 2020 17:49:10 -0400
|
|
|
a26cad |
Subject: [PATCH] Issue 49256 - log warning when thread number is very
|
|
|
a26cad |
different from autotuned value
|
|
|
a26cad |
|
|
|
a26cad |
Description: To help prevent customers from setting incorrect values for
|
|
|
a26cad |
the thread number it would be useful to warn them that the
|
|
|
a26cad |
configured value is either way too low or way too high.
|
|
|
a26cad |
|
|
|
a26cad |
relates: https://pagure.io/389-ds-base/issue/49256
|
|
|
a26cad |
|
|
|
a26cad |
Reviewed by: firstyear(Thanks!)
|
|
|
a26cad |
---
|
|
|
a26cad |
.../tests/suites/config/autotuning_test.py | 28 +++++++++++++++
|
|
|
a26cad |
ldap/servers/slapd/libglobs.c | 34 ++++++++++++++++++-
|
|
|
a26cad |
ldap/servers/slapd/slap.h | 3 ++
|
|
|
a26cad |
3 files changed, 64 insertions(+), 1 deletion(-)
|
|
|
a26cad |
|
|
|
a26cad |
diff --git a/dirsrvtests/tests/suites/config/autotuning_test.py b/dirsrvtests/tests/suites/config/autotuning_test.py
|
|
|
a26cad |
index d1c751444..540761250 100644
|
|
|
a26cad |
--- a/dirsrvtests/tests/suites/config/autotuning_test.py
|
|
|
a26cad |
+++ b/dirsrvtests/tests/suites/config/autotuning_test.py
|
|
|
a26cad |
@@ -43,6 +43,34 @@ def test_threads_basic(topo):
|
|
|
a26cad |
assert topo.standalone.config.get_attr_val_int("nsslapd-threadnumber") > 0
|
|
|
a26cad |
|
|
|
a26cad |
|
|
|
a26cad |
+def test_threads_warning(topo):
|
|
|
a26cad |
+ """Check that we log a warning if the thread number is too high or low
|
|
|
a26cad |
+
|
|
|
a26cad |
+ :id: db92412b-2812-49de-84b0-00f452cd254f
|
|
|
a26cad |
+ :setup: Standalone Instance
|
|
|
a26cad |
+ :steps:
|
|
|
a26cad |
+ 1. Get autotuned thread number
|
|
|
a26cad |
+ 2. Set threads way higher than hw threads, and find a warning in the log
|
|
|
a26cad |
+ 3. Set threads way lower than hw threads, and find a warning in the log
|
|
|
a26cad |
+ :expectedresults:
|
|
|
a26cad |
+ 1. Success
|
|
|
a26cad |
+ 2. Success
|
|
|
a26cad |
+ 3. Success
|
|
|
a26cad |
+ """
|
|
|
a26cad |
+ topo.standalone.config.set("nsslapd-threadnumber", "-1")
|
|
|
a26cad |
+ autotuned_value = topo.standalone.config.get_attr_val_utf8("nsslapd-threadnumber")
|
|
|
a26cad |
+
|
|
|
a26cad |
+ topo.standalone.config.set("nsslapd-threadnumber", str(int(autotuned_value) * 4))
|
|
|
a26cad |
+ time.sleep(.5)
|
|
|
a26cad |
+ assert topo.standalone.ds_error_log.match('.*higher.*hurt server performance.*')
|
|
|
a26cad |
+
|
|
|
a26cad |
+ if int(autotuned_value) > 1:
|
|
|
a26cad |
+ # If autotuned is 1, there isn't anything to test here
|
|
|
a26cad |
+ topo.standalone.config.set("nsslapd-threadnumber", "1")
|
|
|
a26cad |
+ time.sleep(.5)
|
|
|
a26cad |
+ assert topo.standalone.ds_error_log.match('.*lower.*hurt server performance.*')
|
|
|
a26cad |
+
|
|
|
a26cad |
+
|
|
|
a26cad |
@pytest.mark.parametrize("invalid_value", ('-2', '0', 'invalid'))
|
|
|
a26cad |
def test_threads_invalid_value(topo, invalid_value):
|
|
|
a26cad |
"""Check nsslapd-threadnumber for an invalid values
|
|
|
a26cad |
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
|
|
|
a26cad |
index fbf90d92d..88676a303 100644
|
|
|
a26cad |
--- a/ldap/servers/slapd/libglobs.c
|
|
|
a26cad |
+++ b/ldap/servers/slapd/libglobs.c
|
|
|
a26cad |
@@ -4374,6 +4374,7 @@ config_set_threadnumber(const char *attrname, char *value, char *errorbuf, int a
|
|
|
a26cad |
{
|
|
|
a26cad |
int retVal = LDAP_SUCCESS;
|
|
|
a26cad |
int32_t threadnum = 0;
|
|
|
a26cad |
+ int32_t hw_threadnum = 0;
|
|
|
a26cad |
char *endp = NULL;
|
|
|
a26cad |
|
|
|
a26cad |
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
|
|
|
a26cad |
@@ -4386,8 +4387,39 @@ config_set_threadnumber(const char *attrname, char *value, char *errorbuf, int a
|
|
|
a26cad |
threadnum = strtol(value, &endp, 10);
|
|
|
a26cad |
|
|
|
a26cad |
/* Means we want to re-run the hardware detection. */
|
|
|
a26cad |
+ hw_threadnum = util_get_hardware_threads();
|
|
|
a26cad |
if (threadnum == -1) {
|
|
|
a26cad |
- threadnum = util_get_hardware_threads();
|
|
|
a26cad |
+ threadnum = hw_threadnum;
|
|
|
a26cad |
+ } else {
|
|
|
a26cad |
+ /*
|
|
|
a26cad |
+ * Log a message if the user defined thread number is very different
|
|
|
a26cad |
+ * from the hardware threads as this is probably not the optimal
|
|
|
a26cad |
+ * value.
|
|
|
a26cad |
+ */
|
|
|
a26cad |
+ if (threadnum >= hw_threadnum) {
|
|
|
a26cad |
+ if (threadnum > MIN_THREADS && threadnum / hw_threadnum >= 4) {
|
|
|
a26cad |
+ /* We're over the default minimum and way higher than the hw
|
|
|
a26cad |
+ * threads. */
|
|
|
a26cad |
+ slapi_log_err(SLAPI_LOG_NOTICE, "config_set_threadnumber",
|
|
|
a26cad |
+ "The configured thread number (%d) is significantly "
|
|
|
a26cad |
+ "higher than the number of hardware threads (%d). "
|
|
|
a26cad |
+ "This can potentially hurt server performance. If "
|
|
|
a26cad |
+ "you are unsure how to tune \"nsslapd-threadnumber\" "
|
|
|
a26cad |
+ "then set it to \"-1\" and the server will tune it "
|
|
|
a26cad |
+ "according to the system hardware\n",
|
|
|
a26cad |
+ threadnum, hw_threadnum);
|
|
|
a26cad |
+ }
|
|
|
a26cad |
+ } else if (threadnum < MIN_THREADS) {
|
|
|
a26cad |
+ /* The thread number should never be less than the minimum and
|
|
|
a26cad |
+ * hardware threads. */
|
|
|
a26cad |
+ slapi_log_err(SLAPI_LOG_WARNING, "config_set_threadnumber",
|
|
|
a26cad |
+ "The configured thread number (%d) is lower than the number "
|
|
|
a26cad |
+ "of hardware threads (%d). This will hurt server performance. "
|
|
|
a26cad |
+ "If you are unsure how to tune \"nsslapd-threadnumber\" then "
|
|
|
a26cad |
+ "set it to \"-1\" and the server will tune it according to the "
|
|
|
a26cad |
+ "system hardware\n",
|
|
|
a26cad |
+ threadnum, hw_threadnum);
|
|
|
a26cad |
+ }
|
|
|
a26cad |
}
|
|
|
a26cad |
|
|
|
a26cad |
if (*endp != '\0' || errno == ERANGE || threadnum < 1 || threadnum > 65535) {
|
|
|
a26cad |
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
|
|
|
a26cad |
index 8e76393c3..894efd29c 100644
|
|
|
a26cad |
--- a/ldap/servers/slapd/slap.h
|
|
|
a26cad |
+++ b/ldap/servers/slapd/slap.h
|
|
|
a26cad |
@@ -403,6 +403,9 @@ typedef void (*VFPV)(); /* takes undefined arguments */
|
|
|
a26cad |
#define SLAPD_DEFAULT_PW_MAX_CLASS_CHARS_ATTRIBUTE 0
|
|
|
a26cad |
#define SLAPD_DEFAULT_PW_MAX_CLASS_CHARS_ATTRIBUTE_STR "0"
|
|
|
a26cad |
|
|
|
a26cad |
+#define MIN_THREADS 16
|
|
|
a26cad |
+#define MAX_THREADS 512
|
|
|
a26cad |
+
|
|
|
a26cad |
|
|
|
a26cad |
/* Default password values. */
|
|
|
a26cad |
|
|
|
a26cad |
--
|
|
|
a26cad |
2.26.2
|
|
|
a26cad |
|