|
14 | 14 | */ |
15 | 15 |
|
16 | 16 | #define _DEFAULT_SOURCE |
17 | | -#include "tglobal.h" |
18 | 17 | #include "cJSON.h" |
19 | 18 | #include "defines.h" |
20 | 19 | #include "os.h" |
21 | 20 | #include "osString.h" |
22 | 21 | #include "tconfig.h" |
| 22 | +#include "tglobal.h" |
23 | 23 | #include "tgrant.h" |
24 | 24 | #include "tjson.h" |
25 | 25 | #include "tlog.h" |
@@ -500,7 +500,9 @@ int32_t taosSetS3Cfg(SConfig *pCfg) { |
500 | 500 | TAOS_RETURN(TSDB_CODE_SUCCESS); |
501 | 501 | } |
502 | 502 |
|
503 | | -struct SConfig *taosGetCfg() { return tsCfg; } |
| 503 | +struct SConfig *taosGetCfg() { |
| 504 | + return tsCfg; |
| 505 | +} |
504 | 506 |
|
505 | 507 | static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile, |
506 | 508 | char *apolloUrl) { |
@@ -818,8 +820,13 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { |
818 | 820 | tsNumOfSnodeWriteThreads = tsNumOfCores / 4; |
819 | 821 | tsNumOfSnodeWriteThreads = TRANGE(tsNumOfSnodeWriteThreads, 2, 4); |
820 | 822 |
|
821 | | - tsQueueMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1; |
822 | | - tsQueueMemoryAllowed = TRANGE(tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL); |
| 823 | + tsQueueMemoryAllowed = tsTotalMemoryKB * 1024 * RPC_MEMORY_USAGE_RATIO * QUEUE_MEMORY_USAGE_RATIO; |
| 824 | + tsQueueMemoryAllowed = TRANGE(tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * QUEUE_MEMORY_USAGE_RATIO * 10LL, |
| 825 | + TSDB_MAX_MSG_SIZE * QUEUE_MEMORY_USAGE_RATIO * 10000LL); |
| 826 | + |
| 827 | + tsApplyMemoryAllowed = tsTotalMemoryKB * 1024 * RPC_MEMORY_USAGE_RATIO * (1 - QUEUE_MEMORY_USAGE_RATIO); |
| 828 | + tsApplyMemoryAllowed = TRANGE(tsApplyMemoryAllowed, TSDB_MAX_MSG_SIZE * (1 - QUEUE_MEMORY_USAGE_RATIO) * 10LL, |
| 829 | + TSDB_MAX_MSG_SIZE * (1 - QUEUE_MEMORY_USAGE_RATIO) * 10000LL); |
823 | 830 |
|
824 | 831 | tsLogBufferMemoryAllowed = tsTotalMemoryKB * 1024 * 0.1; |
825 | 832 | tsLogBufferMemoryAllowed = TRANGE(tsLogBufferMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL); |
@@ -857,7 +864,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { |
857 | 864 |
|
858 | 865 | TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeSharedThreads", tsNumOfSnodeStreamThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL)); |
859 | 866 | TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "numOfSnodeUniqueThreads", tsNumOfSnodeWriteThreads, 2, 1024, CFG_SCOPE_SERVER, CFG_DYN_SERVER_LAZY,CFG_CATEGORY_LOCAL)); |
860 | | - TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL)); |
| 867 | + TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * RPC_MEMORY_USAGE_RATIO * 10L, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_SERVER,CFG_CATEGORY_GLOBAL)); |
861 | 868 | TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL)); |
862 | 869 | TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL)); |
863 | 870 | TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, CFG_SCOPE_SERVER, CFG_DYN_NONE,CFG_CATEGORY_GLOBAL)); |
@@ -1572,7 +1579,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { |
1572 | 1579 | tsNumOfSnodeWriteThreads = pItem->i32; |
1573 | 1580 |
|
1574 | 1581 | TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "rpcQueueMemoryAllowed"); |
1575 | | - tsQueueMemoryAllowed = pItem->i64; |
| 1582 | + tsQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64 * QUEUE_MEMORY_USAGE_RATIO; |
| 1583 | + tsApplyMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64 * (1 - QUEUE_MEMORY_USAGE_RATIO); |
1576 | 1584 |
|
1577 | 1585 | TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "simdEnable"); |
1578 | 1586 | tsSIMDEnable = (bool)pItem->bval; |
@@ -2395,6 +2403,12 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) { |
2395 | 2403 | code = TSDB_CODE_SUCCESS; |
2396 | 2404 | goto _exit; |
2397 | 2405 | } |
| 2406 | + if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) { |
| 2407 | + tsQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64 * QUEUE_MEMORY_USAGE_RATIO; |
| 2408 | + tsApplyMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64 * (1 - QUEUE_MEMORY_USAGE_RATIO); |
| 2409 | + code = TSDB_CODE_SUCCESS; |
| 2410 | + goto _exit; |
| 2411 | + } |
2398 | 2412 |
|
2399 | 2413 | if (strcasecmp(name, "numOfCompactThreads") == 0) { |
2400 | 2414 | #ifdef TD_ENTERPRISE |
@@ -2500,7 +2514,6 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) { |
2500 | 2514 | {"experimental", &tsExperimental}, |
2501 | 2515 |
|
2502 | 2516 | {"numOfRpcSessions", &tsNumOfRpcSessions}, |
2503 | | - {"rpcQueueMemoryAllowed", &tsQueueMemoryAllowed}, |
2504 | 2517 | {"shellActivityTimer", &tsShellActivityTimer}, |
2505 | 2518 | {"readTimeout", &tsReadTimeout}, |
2506 | 2519 | {"safetyCheckLevel", &tsSafetyCheckLevel}, |
|
0 commit comments