mirror of https://github.com/yandex/odyssey.git
autoconfigure number of workers
This commit is contained in:
parent
d2a6612597
commit
a9e9ade846
|
@ -19,7 +19,7 @@ log_query yes
|
|||
log_stats yes
|
||||
stats_interval 60
|
||||
|
||||
workers 2
|
||||
workers "auto"
|
||||
resolvers 1
|
||||
|
||||
readahead 8192
|
||||
|
@ -175,7 +175,7 @@ database "postgres2" {
|
|||
log_debug no
|
||||
|
||||
ldap_endpoint_name "ldap1"
|
||||
enable_password_passthrough "yes"
|
||||
password_passthrough yes
|
||||
|
||||
quantiles "0.99,0.95,0.5"
|
||||
client_max 107
|
||||
|
|
|
@ -1541,12 +1541,29 @@ static int od_config_reader_parse(od_config_reader_t *reader,
|
|||
}
|
||||
continue;
|
||||
/* workers */
|
||||
case OD_LWORKERS:
|
||||
if (!od_config_reader_number(reader,
|
||||
&config->workers)) {
|
||||
case OD_LWORKERS: {
|
||||
od_token_t tok;
|
||||
int rc;
|
||||
rc = od_parser_next(&reader->parser, &tok);
|
||||
switch (rc) {
|
||||
case OD_PARSER_NUM: {
|
||||
config->workers = tok.value.num;
|
||||
} break;
|
||||
case OD_PARSER_STRING: {
|
||||
if (strncmp(tok.value.string.pointer, "auto",
|
||||
tok.value.string.size) == 0) {
|
||||
config->workers =
|
||||
(1 + od_get_ncpu()) >> 1;
|
||||
break;
|
||||
} /* else fallthrough default*/
|
||||
}
|
||||
default:
|
||||
od_config_reader_error(
|
||||
reader, &tok,
|
||||
"expected 'number' or '\"auto\"'");
|
||||
goto error;
|
||||
}
|
||||
|
||||
}
|
||||
continue;
|
||||
/* resolvers */
|
||||
case OD_LRESOLVERS:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "sources/macro.h"
|
||||
#include "sources/build.h"
|
||||
#include "sources/atomic.h"
|
||||
#include "sources/sysv.h"
|
||||
#include "sources/util.h"
|
||||
|
||||
#include "sources/debugprintf.h"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef ODYSSEY_SYSV_H
|
||||
#define ODYSSEY_SYSV_H
|
||||
|
||||
static inline size_t od_get_ncpu()
|
||||
{
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ODYSSEY_SYSV_H */
|
Loading…
Reference in New Issue