Skip to content

Commit

Permalink
fix: conflicts benchData.c
Browse files Browse the repository at this point in the history
  • Loading branch information
DuanKuanJun committed Jun 12, 2024
2 parents e00fba3 + fd2ce98 commit 0b4fb8f
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 10 deletions.
2 changes: 2 additions & 0 deletions inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,8 @@ int32_t benchParseSingleOpt(int32_t key, char* arg);

void printErrCmdCodeStr(char *cmd, int32_t code, TAOS_RES *res);

int32_t benchGetTotalMemory(int64_t *totalKB);

#ifndef LINUX
int32_t benchParseArgsNoArgp(int argc, char* argv[]);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ IF(GIT_FOUND)
IF ("${TAOSDUMP_COMMIT_SHA1}" STREQUAL "")
SET(TAOSDUMP_COMMIT_SHA1 "unknown")
ELSE ()
STRING(SUBSTRING "${TAOSDUMP_COMMIT_SHA1}" 0 7 TAOSDUMP_COMMIT_SHA1)
STRING(SUBSTRING "${TAOSDUMP_COMMIT_SHA1}" 0 40 TAOSDUMP_COMMIT_SHA1)
STRING(STRIP "${TAOSDUMP_COMMIT_SHA1}" TAOSDUMP_COMMIT_SHA1)
ENDIF ()
IF ("${TAOSDUMP_TAG}" STREQUAL "")
Expand All @@ -139,7 +139,7 @@ IF(GIT_FOUND)
IF ("${TAOSBENCHMARK_COMMIT_SHA1}" STREQUAL "")
SET(TAOSBENCHMARK_COMMIT_SHA1 "unknown")
ELSE ()
STRING(SUBSTRING "${TAOSBENCHMARK_COMMIT_SHA1}" 0 7 TAOSBENCHMARK_COMMIT_SHA1)
STRING(SUBSTRING "${TAOSBENCHMARK_COMMIT_SHA1}" 0 40 TAOSBENCHMARK_COMMIT_SHA1)
STRING(STRIP "${TAOSBENCHMARK_COMMIT_SHA1}" TAOSBENCHMARK_COMMIT_SHA1)
ENDIF ()
IF ("${TAOSBENCHMARK_TAG}" STREQUAL "")
Expand Down
8 changes: 6 additions & 2 deletions src/benchCommandOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ extern char g_configDir[MAX_PATH_LEN];
#define TAOSBENCHMARK_STATUS "unknown"
#endif

#ifndef TD_PRODUCT_NAME
#define TD_PRODUCT_NAME "TDengine"
#endif

// libtaos.so
extern char buildinfo[];

Expand All @@ -48,9 +52,9 @@ void printVersion() {
char taosBenchmark_status[] = TAOSBENCHMARK_STATUS;

// version
printf("version: %s\ngitinfo: %s\n", taosBenchmark_ver, taosBenchmark_commit);
printf("%s\ntaosBenchmark version: %s\ngit: %s\n", TD_PRODUCT_NAME, taosBenchmark_ver, taosBenchmark_commit);
#ifdef LINUX
printf("buildInfo: %s\n ", buildinfo);
printf("build: %s\n ", buildinfo);
#endif
if (strlen(taosBenchmark_status) > 0) {
printf("status: %s\n", taosBenchmark_status);
Expand Down
4 changes: 4 additions & 0 deletions src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ static int generateSampleFromCsv(char *buffer, char* file, FILE* fp, int32_t len

if (file != NULL && fp == NULL) {
fp = fopen(file, "r");
if (fp == NULL) {
errorPrint("open csv file failed. file=%s\n", file);
return -1;
}
needClose = true;
}

Expand Down
27 changes: 27 additions & 0 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,31 @@ int32_t getVgroupsOfDb(SBenchConn *conn, SDataBase *database) {
return vgroups;
}

int32_t toolsGetDefaultVGroups() {
int32_t cores = toolsGetNumberOfCores();
if (cores < 3 ) {
return 1;
}

int64_t MemKB = 0;
benchGetTotalMemory(&MemKB);

infoPrint("check local machine CPU: %d Memory:%d MB \n", cores, (int32_t)(MemKB/1024));
if (MemKB <= 2*1024*1024) { // 2G
return 1;
} else if (MemKB <= 4*1024*1024) { // 4G
return 2;
} else if (MemKB <= 8*1024*1024) { // 8G
return 3;
} else if (MemKB <= 16*1024*1024) { // 16G
return 4;
} else if (MemKB <= 32*1024*1024) { // 32G
return 5;
} else {
return cores / 2;
}
}

int geneDbCreateCmd(SDataBase *database, char *command, int remainVnodes) {
int dataLen = 0;
int n;
Expand Down Expand Up @@ -3768,6 +3793,8 @@ int32_t exitInsertThread(SDataBase* database, SSuperTable* stbInfo, int32_t nthr
closeBenchConn(pThreadInfo->conn);
pThreadInfo->conn = NULL;
}


}

// calculate result
Expand Down
24 changes: 21 additions & 3 deletions src/benchJsonOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,13 +931,23 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) {
if (tools_cJSON_IsNumber(childTbl_to)) {
superTable->childTblTo = childTbl_to->valueint;
if (superTable->childTblTo < superTable->childTblFrom) {
errorPrint("child table _to_ is invalid number,"
errorPrint("json config invalid. child table _to_ is invalid number,"
"%"PRId64" < %"PRId64"\n",
superTable->childTblTo, superTable->childTblFrom);
return -1;
}
}

// check childtable_from and childtable_to valid
if (superTable->childTblFrom >= superTable->childTblCount) {
errorPrint("json config invalid. childtable_from(%"PRId64") is equal or large than childtable_count(%"PRId64")\n", superTable->childTblFrom, superTable->childTblCount);
return -1;
}
if (superTable->childTblTo > superTable->childTblCount) {
errorPrint("json config invalid. childtable_to(%"PRId64") is large than childtable_count(%"PRId64")\n", superTable->childTblTo, superTable->childTblCount);
return -1;
}

tools_cJSON *continueIfFail =
tools_cJSON_GetObjectItem(stbInfo, "continue_if_fail"); // yes, no,
if (tools_cJSON_IsString(continueIfFail)) {
Expand Down Expand Up @@ -1381,12 +1391,20 @@ static int getMetaFromCommonJsonFile(tools_cJSON *json) {

tools_cJSON *host = tools_cJSON_GetObjectItem(json, "host");
if (host && host->type == tools_cJSON_String && host->valuestring != NULL) {
g_arguments->host = host->valuestring;
if(g_arguments->host && strlen(g_arguments->host) > 0) {
warnPrint("command line already pass host is %s, json config host(%s) had been ignored.\n", g_arguments->host, host->valuestring);
} else {
g_arguments->host = host->valuestring;
}
}

tools_cJSON *port = tools_cJSON_GetObjectItem(json, "port");
if (port && port->type == tools_cJSON_Number) {
g_arguments->port = (uint16_t)port->valueint;
if(g_arguments->port != DEFAULT_PORT) {
warnPrint("command line already pass port is %d, json config port(%d) had been ignored.\n", g_arguments->port, (uint16_t)port->valueint);
} else {
g_arguments->port = (uint16_t)port->valueint;
}
}

tools_cJSON *user = tools_cJSON_GetObjectItem(json, "user");
Expand Down
2 changes: 1 addition & 1 deletion src/benchSys.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static struct argp_option bench_options[] = {
{"answer-yes", 'y', 0, 0, BENCH_YES},
{"disorder-range", 'R', "NUMBER", 0, BENCH_RANGE},
{"disorder", 'O', "NUMBER", 0, BENCH_DISORDER},
{"replia", 'a', "NUMBER", 0, BENCH_REPLICA},
{"replica", 'a', "NUMBER", 0, BENCH_REPLICA},
{"debug", 'g', 0, 0, BENCH_DEBUG},
{"performance", 'G', 0, 0, BENCH_PERFORMANCE},
{"prepared_rand", 'F', "NUMBER", 0, BENCH_PREPARE},
Expand Down
19 changes: 19 additions & 0 deletions src/benchUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,3 +1257,22 @@ FORCE_INLINE void printErrCmdCodeStr(char *cmd, int32_t code, TAOS_RES *res) {
taos_free_result(res);
}

int32_t benchGetTotalMemory(int64_t *totalKB) {
#ifdef WINDOWS
MEMORYSTATUSEX memsStat;
memsStat.dwLength = sizeof(memsStat);
if (!GlobalMemoryStatusEx(&memsStat)) {
return -1;
}

*totalKB = memsStat.ullTotalPhys / 1024;
return 0;
#elif defined(_TD_DARWIN_64)
*totalKB = 0;
return 0;
#else
int64_t tsPageSizeKB = sysconf(_SC_PAGESIZE) / 1024;
*totalKB = (int64_t)(sysconf(_SC_PHYS_PAGES) * tsPageSizeKB);
return 0;
#endif
}
7 changes: 5 additions & 2 deletions src/taosdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
#define TAOSDUMP_STATUS "unknown"
#endif

#ifndef TD_PRODUCT_NAME
#define TD_PRODUCT_NAME "TDengine"
#endif

// use 256 as normal buffer length
#define BUFFER_LEN 256
Expand Down Expand Up @@ -670,9 +673,9 @@ static void printVersion(FILE *file) {

char taosdump_commit[] = TAOSDUMP_COMMIT_SHA1;

fprintf(file,"version: %s\ngitinfo: %s\n", taostools_ver, taosdump_commit);
fprintf(file,"%s\ntaosdump version: %s\ngit: %s\n", TD_PRODUCT_NAME, taostools_ver, taosdump_commit);
#ifdef LINUX
printf("buildInfo: %s\n ", buildinfo);
printf("build: %s\n ", buildinfo);
#endif
if (strlen(taosdump_status) > 0) {
fprintf(file, "status:%s\n", taosdump_status);
Expand Down

0 comments on commit 0b4fb8f

Please sign in to comment.