From d597ba8e71dca425146a6ccd18a0974dda209f97 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 24 Jul 2023 06:35:54 +0800 Subject: [PATCH] chore: code optimize --- include/os/osSysinfo.h | 3 +-- source/dnode/mgmt/mgmt_dnode/src/dmWorker.c | 11 ++--------- source/os/src/osSysinfo.c | 6 ++---- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index a8110ee06a..206dbecd21 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -18,8 +18,7 @@ #include "os.h" -// #include /* for _syscallX macros/related stuff */ -// #include /* for struct sysinfo */ + #ifdef __cplusplus diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index 5854450fc7..783babcb66 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -26,7 +26,6 @@ static void *dmStatusThreadFp(void *param) { int32_t trimCount = 0; int32_t upTimeCount = 0; int64_t upTime = 0; - int64_t thrdTime = 0; while (1) { taosMsleep(200); @@ -44,17 +43,11 @@ static void *dmStatusThreadFp(void *param) { taosMemoryTrim(0); } - if ((upTimeCount = (++upTimeCount & 7)) == 0) { + if ((upTimeCount = (++upTimeCount & 63)) == 0) { upTime = (taosGetOsUptime() - tsDndStartOsUptime) * 1000; + tsDndUpTime = TMAX(tsDndUpTime, upTime); } } - - thrdTime += 200; - cost = taosGetTimestampMs() - curTime; - if (cost > 0) thrdTime += cost; - tsDndUpTime = upTime > thrdTime ? upTime : thrdTime; - printf("upTime:%" PRIi64 " thrdTime:%" PRIi64 " tsDndUpTime:%" PRIi64 " delta:%" PRIi64 "\n", upTime, thrdTime, - tsDndUpTime, upTime - thrdTime); } return NULL; diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 1f631c7388..a29b96dd6f 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -963,16 +963,14 @@ char *taosGetCmdlineByPID(int pid) { int64_t taosGetOsUptime() { #ifdef WINDOWS - return 0; -// #else -// #elif defined(_TD_DARWIN_64) -// return 0; +#elif defined(_TD_DARWIN_64) #else struct sysinfo info; if (0 == sysinfo(&info)) { return info.uptime; }; #endif + return 0; } void taosSetCoreDump(bool enable) { -- GitLab