Limit server-threads to cores in the machine

Former-commit-id: be3ba1d53eb070719fd84c7573f665277a35b6f4
This commit is contained in:
John Sully 2019-03-06 16:39:02 -05:00
parent 6add662139
commit d94984f96c

View File

@ -35,7 +35,7 @@
#include "latency.h"
#include "atomicvar.h"
#include "storage.h"
#include <thread>
#include <time.h>
#include <signal.h>
#include <sys/wait.h>
@ -4986,11 +4986,17 @@ int main(int argc, char **argv) {
(int)getpid());
if (argc == 1) {
serverLog(LL_WARNING, "Warning: no config file specified, using the default config. In order to specify a config file use %s /path/to/%s.conf", argv[0], server.sentinel_mode ? "sentinel" : "redis");
serverLog(LL_WARNING, "WARNING: no config file specified, using the default config. In order to specify a config file use %s /path/to/%s.conf", argv[0], server.sentinel_mode ? "sentinel" : "redis");
} else {
serverLog(LL_WARNING, "Configuration loaded");
}
if (server.cthreads > (int)std::thread::hardware_concurrency()) {
serverLog(LL_WARNING, "WARNING: server-threads is greater than this machine's core count. Truncating to %u threads", std::thread::hardware_concurrency());
server.cthreads = (int)std::thread::hardware_concurrency();
server.cthreads = std::max(server.cthreads, 1); // in case of any weird sign overflows
}
server.supervised = redisIsSupervised(server.supervised_mode);
int background = server.daemonize && !server.supervised;
if (background) daemonize();