From 57104bf10fe61ad9790b57ee25b9980ed7634583 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 11 Dec 2020 14:50:13 +0800 Subject: [PATCH] [TD-2379]: configure the number of CPU cores available for query processing. --- packaging/cfg/taos.cfg | 9 +++++---- src/common/inc/tglobal.h | 2 +- src/common/src/tglobal.c | 10 +++++----- src/dnode/src/dnodeVRead.c | 5 ++++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 07a5fddda2..4cc871c0b1 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -30,10 +30,11 @@ # numOfThreadsPerCore 1.0 # the proportion of total CPU cores available for query processing -# 1.0: all CPU cores are available for query processing -# 0.5: only half of the CPU cores are available for query -# 0.0: only one core available -# ratioOfQueryThreads 1.0 +# 2.0: the query threads will be set to double of the CPU cores. +# 1.0: all CPU cores are available for query processing [default]. +# 0.5: only half of the CPU cores are available for query. +# 0.0: only one core available. +# tsRatioOfQueryCores 1.0 # number of management nodes in the system # numOfMnodes 3 diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index f17176fe98..db15bb8964 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -46,7 +46,7 @@ extern int32_t tsShellActivityTimer; extern uint32_t tsMaxTmrCtrl; extern float tsNumOfThreadsPerCore; extern int32_t tsNumOfCommitThreads; -extern float tsRatioOfQueryThreads; +extern float tsRatioOfQueryCores; extern int8_t tsDaylight; extern char tsTimezone[]; extern char tsLocale[]; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index b5bc3fb143..cadad3c5d8 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -52,7 +52,7 @@ int32_t tsMaxConnections = 5000; int32_t tsShellActivityTimer = 3; // second float tsNumOfThreadsPerCore = 1.0f; int32_t tsNumOfCommitThreads = 1; -float tsRatioOfQueryThreads = 1.0f; +float tsRatioOfQueryCores = 1.0f; int8_t tsDaylight = 0; char tsTimezone[TSDB_TIMEZONE_LEN] = {0}; char tsLocale[TSDB_LOCALE_LEN] = {0}; @@ -444,12 +444,12 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "ratioOfQueryThreads"; - cfg.ptr = &tsRatioOfQueryThreads; + cfg.option = "ratioOfQueryCores"; + cfg.ptr = &tsRatioOfQueryCores; cfg.valType = TAOS_CFG_VTYPE_FLOAT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; - cfg.minValue = 0.1f; - cfg.maxValue = 0.9f; + cfg.minValue = 0.0f; + cfg.maxValue = 2.0f; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c index 545f87fa42..3f31e49370 100644 --- a/src/dnode/src/dnodeVRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -28,9 +28,12 @@ static SWorkerPool tsVFetchWP; int32_t dnodeInitVRead() { const int32_t maxFetchThreads = 4; + // calculate the available query thread + float threadsForQuery = MAX(tsNumOfCores * tsRatioOfQueryCores, 1); + tsVQueryWP.name = "vquery"; tsVQueryWP.workerFp = dnodeProcessReadQueue; - tsVQueryWP.min = tsNumOfCores * tsRatioOfQueryThreads; + tsVQueryWP.min = (int32_t) threadsForQuery; tsVQueryWP.max = tsVQueryWP.min; if (tWorkerInit(&tsVQueryWP) != 0) return -1; -- GitLab