Feature/sangshuduo/td 5875 taosdemo ue improve (#7560)

* [TD-5875]<featur>: taosdemo show progress

* empty commit for CI

* better msg for create child table.
This commit is contained in:
Shuduo Sang 2021-08-25 08:15:05 +08:00 committed by GitHub
parent 46b9c174a2
commit 3d06d17b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 19 deletions

View File

@ -443,6 +443,7 @@ typedef struct SThreadInfo_S {
uint64_t start_table_from; uint64_t start_table_from;
uint64_t end_table_to; uint64_t end_table_to;
int64_t ntables; int64_t ntables;
int64_t tables_created;
uint64_t data_of_rate; uint64_t data_of_rate;
int64_t start_time; int64_t start_time;
char* cols; char* cols;
@ -639,6 +640,7 @@ SArguments g_args = {
static SDbs g_Dbs; static SDbs g_Dbs;
static int64_t g_totalChildTables = 0; static int64_t g_totalChildTables = 0;
static int64_t g_actualChildTables = 0;
static SQueryMetaInfo g_queryInfo; static SQueryMetaInfo g_queryInfo;
static FILE * g_fpOfInsertResult = NULL; static FILE * g_fpOfInsertResult = NULL;
@ -964,6 +966,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
arguments->num_of_tables = atoi(argv[++i]); arguments->num_of_tables = atoi(argv[++i]);
g_totalChildTables = arguments->num_of_tables;
} else if (strcmp(argv[i], "-n") == 0) { } else if (strcmp(argv[i], "-n") == 0) {
if ((argc == i+1) || if ((argc == i+1) ||
(!isStringNumber(argv[i+1]))) { (!isStringNumber(argv[i+1]))) {
@ -3276,6 +3279,7 @@ static void* createTable(void *sarg)
pThreadInfo->db_name, pThreadInfo->db_name,
g_args.tb_prefix, i, g_args.tb_prefix, i,
pThreadInfo->cols); pThreadInfo->cols);
batchNum ++;
} else { } else {
if (stbInfo == NULL) { if (stbInfo == NULL) {
free(pThreadInfo->buffer); free(pThreadInfo->buffer);
@ -3330,6 +3334,7 @@ static void* createTable(void *sarg)
free(pThreadInfo->buffer); free(pThreadInfo->buffer);
return NULL; return NULL;
} }
pThreadInfo->tables_created += batchNum;
uint64_t currentPrintTime = taosGetTimestampMs(); uint64_t currentPrintTime = taosGetTimestampMs();
if (currentPrintTime - lastPrintTime > 30*1000) { if (currentPrintTime - lastPrintTime > 30*1000) {
@ -3401,6 +3406,7 @@ static int startMultiThreadCreateChildTable(
pThreadInfo->use_metric = true; pThreadInfo->use_metric = true;
pThreadInfo->cols = cols; pThreadInfo->cols = cols;
pThreadInfo->minDelay = UINT64_MAX; pThreadInfo->minDelay = UINT64_MAX;
pThreadInfo->tables_created = 0;
pthread_create(pids + i, NULL, createTable, pThreadInfo); pthread_create(pids + i, NULL, createTable, pThreadInfo);
} }
@ -3411,6 +3417,8 @@ static int startMultiThreadCreateChildTable(
for (int i = 0; i < threads; i++) { for (int i = 0; i < threads; i++) {
threadInfo *pThreadInfo = infos + i; threadInfo *pThreadInfo = infos + i;
taos_close(pThreadInfo->taos); taos_close(pThreadInfo->taos);
g_actualChildTables += pThreadInfo->tables_created;
} }
free(pids); free(pids);
@ -3437,7 +3445,6 @@ static void createChildTables() {
verbosePrint("%s() LN%d: %s\n", __func__, __LINE__, verbosePrint("%s() LN%d: %s\n", __func__, __LINE__,
g_Dbs.db[i].superTbls[j].colsOfCreateChildTable); g_Dbs.db[i].superTbls[j].colsOfCreateChildTable);
uint64_t startFrom = 0; uint64_t startFrom = 0;
g_totalChildTables += g_Dbs.db[i].superTbls[j].childTblCount;
verbosePrint("%s() LN%d: create %"PRId64" child tables from %"PRIu64"\n", verbosePrint("%s() LN%d: create %"PRId64" child tables from %"PRIu64"\n",
__func__, __LINE__, g_totalChildTables, startFrom); __func__, __LINE__, g_totalChildTables, startFrom);
@ -4232,6 +4239,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
goto PARSE_OVER; goto PARSE_OVER;
} }
g_Dbs.db[i].superTbls[j].childTblCount = count->valueint; g_Dbs.db[i].superTbls[j].childTblCount = count->valueint;
g_totalChildTables += g_Dbs.db[i].superTbls[j].childTblCount;
cJSON *dataSource = cJSON_GetObjectItem(stbInfo, "data_source"); cJSON *dataSource = cJSON_GetObjectItem(stbInfo, "data_source");
if (dataSource && dataSource->type == cJSON_String if (dataSource && dataSource->type == cJSON_String
@ -7932,18 +7940,30 @@ static int insertTestProcess() {
double start; double start;
double end; double end;
if (g_totalChildTables > 0) {
fprintf(stderr,
"creating %"PRId64" table(s) with %d thread(s)\n\n",
g_totalChildTables, g_Dbs.threadCountByCreateTbl);
if (g_fpOfInsertResult) {
fprintf(g_fpOfInsertResult,
"creating %"PRId64" table(s) with %d thread(s)\n\n",
g_totalChildTables, g_Dbs.threadCountByCreateTbl);
}
// create child tables // create child tables
start = taosGetTimestampMs(); start = taosGetTimestampMs();
createChildTables(); createChildTables();
end = taosGetTimestampMs(); end = taosGetTimestampMs();
if (g_totalChildTables > 0) { fprintf(stderr,
fprintf(stderr, "Spent %.4f seconds to create %"PRId64" tables with %d thread(s)\n\n", "Spent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n",
(end - start)/1000.0, g_totalChildTables, g_Dbs.threadCountByCreateTbl); (end - start)/1000.0, g_totalChildTables,
g_Dbs.threadCountByCreateTbl, g_actualChildTables);
if (g_fpOfInsertResult) { if (g_fpOfInsertResult) {
fprintf(g_fpOfInsertResult, fprintf(g_fpOfInsertResult,
"Spent %.4f seconds to create %"PRId64" tables with %d thread(s)\n\n", "Spent %.4f seconds to create %"PRId64" table(s) with %d thread(s), actual %"PRId64" table(s) created\n\n",
(end - start)/1000.0, g_totalChildTables, g_Dbs.threadCountByCreateTbl); (end - start)/1000.0, g_totalChildTables,
g_Dbs.threadCountByCreateTbl, g_actualChildTables);
} }
} }