Skip to content

Commit

Permalink
Merge branch 'feat/TD-30092' into feat/TD-30077
Browse files Browse the repository at this point in the history
  • Loading branch information
DuanKuanJun committed May 28, 2024
2 parents 28ad4c5 + 221fb7b commit d290350
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ void printErrCmdCodeStr(char *cmd, int32_t code, TAOS_RES *res);
int32_t benchParseArgsNoArgp(int argc, char* argv[]);
#endif

int32_t execInsert(threadInfo *pThreadInfo, uint32_t k);
int32_t execInsert(threadInfo *pThreadInfo, uint32_t k, int64_t* delay3);
// if return true, timestmap must add timestap_step, else timestamp no need changed
bool needChangeTs(SSuperTable * stbInfo, int32_t *pkCur, int32_t *pkCnt);

Expand Down
2 changes: 1 addition & 1 deletion inc/benchData.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int generateRandData(SSuperTable *stbInfo, char *sampleDataBuf,
int prepareStmt(SSuperTable *stbInfo, TAOS_STMT *stmt, char* tagData, uint64_t tableSeq);
uint32_t bindParamBatch(threadInfo *pThreadInfo,
uint32_t batch, int64_t startTime,
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2, int64_t *delay3);
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2);
int prepareSampleData(SDataBase* database, SSuperTable* stbInfo);
void generateSmlJsonTags(tools_cJSON *tagsList,
char **sml_tags_json_array,
Expand Down
10 changes: 1 addition & 9 deletions src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ int64_t getTSRandTail(int64_t timeStampStep, int32_t seq, int disorderRatio,

uint32_t bindParamBatch(threadInfo *pThreadInfo,
uint32_t batch, int64_t startTime,
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2, int64_t *delay3) {
SChildTable *childTbl, int32_t *pkCur, int32_t *pkCnt, int32_t *n, int64_t *delay2) {
TAOS_STMT *stmt = pThreadInfo->conn->stmt;
SSuperTable *stbInfo = pThreadInfo->stbInfo;
uint32_t columnCount = stbInfo->cols->size;
Expand Down Expand Up @@ -1881,14 +1881,6 @@ uint32_t bindParamBatch(threadInfo *pThreadInfo,
tmfree(param->length);
}

// if msg > 3MB, break
start = toolsGetTimestampUs();
if (taos_stmt_add_batch(stmt)) {
errorPrint("taos_stmt_add_batch() failed! reason: %s\n",
taos_stmt_errstr(stmt));
return 0;
}
*delay3 += toolsGetTimestampUs() - start;
return batch;
}

Expand Down
25 changes: 19 additions & 6 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,12 +1238,13 @@ void postFreeResource() {
tools_cJSON_Delete(root);
}

int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) {
int32_t execInsert(threadInfo *pThreadInfo, uint32_t k, int64_t *delay3) {
SDataBase * database = pThreadInfo->dbInfo;
SSuperTable *stbInfo = pThreadInfo->stbInfo;
TAOS_RES * res = NULL;
int32_t code = 0;
uint16_t iface = stbInfo->iface;
int64_t start = 0;

int32_t trying = (stbInfo->keep_trying)?
stbInfo->keep_trying:g_arguments->keep_trying;
Expand Down Expand Up @@ -1297,6 +1298,18 @@ int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) {
break;

case STMT_IFACE:
// add batch
start = toolsGetTimestampUs();
if (taos_stmt_add_batch(pThreadInfo->conn->stmt) != 0) {
errorPrint("taos_stmt_add_batch() failed! reason: %s\n",
taos_stmt_errstr(pThreadInfo->conn->stmt));
return -1;
}
if(delay3) {
*delay3 += toolsGetTimestampUs() - start;
}

// execute
code = taos_stmt_execute(pThreadInfo->conn->stmt);
if (code) {
errorPrint(
Expand Down Expand Up @@ -1742,7 +1755,7 @@ static void *syncWriteInterlace(void *sarg) {

int32_t n = 0;
generated = bindParamBatch(pThreadInfo, interlaceRows,
childTbl->ts, childTbl, &childTbl->pkCur, &childTbl->pkCnt, &n, &delay2, &delay3);
childTbl->ts, childTbl, &childTbl->pkCur, &childTbl->pkCnt, &n, &delay2);

childTbl->ts += stbInfo->timestamp_step * n;
break;
Expand Down Expand Up @@ -1837,7 +1850,7 @@ static void *syncWriteInterlace(void *sarg) {
}

startTs = toolsGetTimestampUs();
if (execInsert(pThreadInfo, generated)) {
if (execInsert(pThreadInfo, generated, &delay3)) {
g_fail = true;
goto free_of_interlace;
}
Expand Down Expand Up @@ -1962,7 +1975,7 @@ static int32_t prepareProgressDataStmt(
(g_arguments->reqPerReq > (stbInfo->insertRows - i))
? (stbInfo->insertRows - i)
: g_arguments->reqPerReq,
*timestamp, childTbl, pkCur, pkCnt, &n, delay2, delay3);
*timestamp, childTbl, pkCur, pkCnt, &n, delay2);
*timestamp += n * stbInfo->timestamp_step;
return generated;
}
Expand Down Expand Up @@ -2526,7 +2539,7 @@ void *syncWriteProgressive(void *sarg) {
}
// only measure insert
startTs = toolsGetTimestampUs();
int code = execInsert(pThreadInfo, generated);
int code = execInsert(pThreadInfo, generated, &delay3);
if (code) {
if (NO_IF_FAILED == stbInfo->continueIfFail) {
warnPrint("The super table parameter "
Expand Down Expand Up @@ -2567,7 +2580,7 @@ void *syncWriteProgressive(void *sarg) {
w = 0;
}

code = execInsert(pThreadInfo, generated);
code = execInsert(pThreadInfo, generated, &delay3);
if (code) {
g_fail = true;
goto free_of_progressive;
Expand Down
4 changes: 2 additions & 2 deletions src/benchInsertMix.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ bool insertDataMix(threadInfo* info, SDataBase* db, SSuperTable* stb) {
int64_t startTs = toolsGetTimestampUs();
//g_arguments->debug_print = false;

if(execInsert(info, batchRows) != 0) {
if(execInsert(info, batchRows, NULL) != 0) {
FAILED_BREAK()
}
//g_arguments->debug_print = true;
Expand Down Expand Up @@ -893,7 +893,7 @@ bool insertDataMix(threadInfo* info, SDataBase* db, SSuperTable* stb) {
batTotal.delRows = genBatchDelSql(stb, &mixRatio, batStartTime, info->conn->taos, tbName, info->buffer, len, querySql);
if (batTotal.delRows > 0) {
// g_arguments->debug_print = false;
if (execInsert(info, batTotal.delRows) != 0) {
if (execInsert(info, batTotal.delRows, NULL) != 0) {
FAILED_BREAK()
}

Expand Down

0 comments on commit d290350

Please sign in to comment.