Skip to content

Commit

Permalink
Merge pull request #742 from taosdata/feat/TD-30092
Browse files Browse the repository at this point in the history
feat : add pre_load_tb_meta
  • Loading branch information
DuanKuanJun committed May 17, 2024
2 parents 572cd96 + 28e814c commit e754cc6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
1 change: 1 addition & 0 deletions inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ typedef struct SArguments_S {
enum CONTINUE_IF_FAIL_MODE continueIfFail;
bool mistMode;
bool escape_character;
bool pre_load_tb_meta;
} SArguments;

typedef struct SBenchConn {
Expand Down
45 changes: 40 additions & 5 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,38 @@ static int64_t getDisorderTs(SSuperTable *stbInfo, int *disorderRange) {
return disorderTs;
}

void loadChildTableInfo(threadInfo* pThreadInfo) {
SSuperTable *stbInfo = pThreadInfo->stbInfo;
if(!g_arguments->pre_load_tb_meta) {
return ;
}
if(pThreadInfo->conn == NULL) {
return ;
}

char *db = pThreadInfo->dbInfo->dbName;
int64_t cnt = pThreadInfo->end_table_to - pThreadInfo->start_table_from;

// 100k
int bufLen = 100 * 1024;
char *buf = benchCalloc(1, bufLen, false);
int pos = 0;
infoPrint("start load child tables(%"PRId64") info...\n", cnt);
int64_t start = toolsGetTimestampUs();
for(int64_t i = pThreadInfo->start_table_from; i < pThreadInfo->end_table_to; i++) {
SChildTable *childTbl = stbInfo->childTblArray[i];
pos += sprintf(buf + pos, ",%s.%s", db, childTbl->name);

if(pos >= bufLen - 256 || i + 1 == pThreadInfo->end_table_to) {
taos_load_table_info(pThreadInfo->conn, buf);
pos = 0;
}
}
infoPrint("end load child tables info. delay=%.2fs\n", (toolsGetTimestampUs() - start)/1E6);

tmfree(buf);
}

static void *syncWriteInterlace(void *sarg) {
threadInfo * pThreadInfo = (threadInfo *)sarg;
SDataBase * database = pThreadInfo->dbInfo;
Expand All @@ -1522,6 +1554,7 @@ static void *syncWriteInterlace(void *sarg) {
uint64_t tableSeq = pThreadInfo->start_table_from;
int disorderRange = stbInfo->disorderRange;

loadChildTableInfo(pThreadInfo);
// check if filling back mode
bool fillBack = false;
if(stbInfo->useNow && stbInfo->startFillbackTime) {
Expand Down Expand Up @@ -2341,6 +2374,8 @@ void *syncWriteProgressive(void *sarg) {
SDataBase * database = pThreadInfo->dbInfo;
SSuperTable *stbInfo = pThreadInfo->stbInfo;

loadChildTableInfo(pThreadInfo);

// special deal flow for TAOSC_IFACE
if (insertDataMix(pThreadInfo, database, stbInfo)) {
// request be dealt by this function , so return
Expand Down Expand Up @@ -3027,18 +3062,18 @@ static int printTotalDelay(SDataBase *database,

char subDelay[128] = "";
if(totalDelay1 + totalDelay2 + totalDelay3 > 0) {
sprintf(subDelay, "delay1=%.2f delay2=%.2f delay3=%.2f",
sprintf(subDelay, " stmt delay1=%.2fs delay2=%.2fs delay3=%.2fs",
totalDelay1/threads/1E6,
totalDelay2/threads/1E6,
totalDelay3/threads/1E6);
}

succPrint("Spent %.6f ( real %.6f %s) seconds to insert rows: %" PRIu64
" with %d thread(s) into %s %.2f (real %.2f) records/second\n",
(end - start)/1E6, totalDelay/threads/1E6, subDelay, totalInsertRows, threads,
succPrint("Spent %.6f (real %.6f) seconds to insert rows: %" PRIu64
" with %d thread(s) into %s %.2f (real %.2f) records/second%s\n",
(end - start)/1E6, totalDelay/threads/1E6, totalInsertRows, threads,
database->dbName,
(double)(totalInsertRows / ((end - start)/1E6)),
(double)(totalInsertRows / (totalDelay/threads/1E6)));
(double)(totalInsertRows / (totalDelay/threads/1E6)), subDelay);
if (!total_delay_list->size) {
return -1;
}
Expand Down
8 changes: 8 additions & 0 deletions src/benchJsonOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,14 @@ static int getMetaFromInsertJsonFile(tools_cJSON *json) {
}
}

g_arguments->pre_load_tb_meta = false;
tools_cJSON *preLoad = tools_cJSON_GetObjectItem(json, "pre_load_tb_meta");
if (tools_cJSON_IsString(preLoad)) {
if (0 == strcasecmp(preLoad->valuestring, "yes")) {
g_arguments->pre_load_tb_meta = true;
}
}

tools_cJSON *resultfile = tools_cJSON_GetObjectItem(json, "result_file");
if (resultfile && resultfile->type == tools_cJSON_String
&& resultfile->valuestring != NULL) {
Expand Down

0 comments on commit e754cc6

Please sign in to comment.