提交 d3d4691c 编写于 作者: S Shengliang Guan

TD-1550

上级 33d14c1b
...@@ -262,7 +262,9 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) { ...@@ -262,7 +262,9 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) {
if (pIMem != NULL) { if (pIMem != NULL) {
ASSERT(pRepo->commit); ASSERT(pRepo->commit);
tsdbDebug("vgId:%d waiting for the commit thread", REPO_ID(pRepo));
code = pthread_join(pRepo->commitThread, NULL); code = pthread_join(pRepo->commitThread, NULL);
tsdbDebug("vgId:%d commit thread is finished", REPO_ID(pRepo));
if (code != 0) { if (code != 0) {
tsdbError("vgId:%d failed to thread join since %s", REPO_ID(pRepo), strerror(errno)); tsdbError("vgId:%d failed to thread join since %s", REPO_ID(pRepo), strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
......
...@@ -22,8 +22,8 @@ IF (TD_LINUX) ...@@ -22,8 +22,8 @@ IF (TD_LINUX)
#add_executable(importOneRow importOneRow.c) #add_executable(importOneRow importOneRow.c)
#target_link_libraries(importOneRow taos_static pthread) #target_link_libraries(importOneRow taos_static pthread)
#add_executable(importPerTable importPerTable.c) add_executable(importPerTable importPerTable.c)
#target_link_libraries(importPerTable taos_static pthread) target_link_libraries(importPerTable taos_static pthread)
#add_executable(hashPerformance hashPerformance.c) #add_executable(hashPerformance hashPerformance.c)
#target_link_libraries(hashPerformance taos_static tutil common pthread) #target_link_libraries(hashPerformance taos_static tutil common pthread)
...@@ -37,10 +37,10 @@ IF (TD_LINUX) ...@@ -37,10 +37,10 @@ IF (TD_LINUX)
#add_executable(queryPerformance queryPerformance.c) #add_executable(queryPerformance queryPerformance.c)
#target_link_libraries(queryPerformance taos_static tutil common pthread) #target_link_libraries(queryPerformance taos_static tutil common pthread)
add_executable(httpTest httpTest.c) #add_executable(httpTest httpTest.c)
target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) #target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4)
add_executable(cacheTest cacheTest.c) #add_executable(cacheTest cacheTest.c)
target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) #target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4)
ENDIF() ENDIF()
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ttimer.h" #include "ttimer.h"
#include "tutil.h" #include "tutil.h"
#include "tglobal.h" #include "tglobal.h"
#include "osTime.h"
#define MAX_RANDOM_POINTS 20000 #define MAX_RANDOM_POINTS 20000
#define GREEN "\033[1;32m" #define GREEN "\033[1;32m"
...@@ -43,14 +44,16 @@ void createDbAndTable(); ...@@ -43,14 +44,16 @@ void createDbAndTable();
void insertData(); void insertData();
int32_t randomData[MAX_RANDOM_POINTS]; int32_t randomData[MAX_RANDOM_POINTS];
int64_t rowsPerTable = 10000; int64_t rowsPerTable = 1000000;
int64_t pointsPerTable = 1; int64_t pointsPerTable = 1;
int64_t numOfThreads = 1; int64_t numOfThreads = 10;
int64_t numOfTablesPerThread = 1; int64_t numOfTablesPerThread = 100;
char dbName[32] = "db"; char dbName[32] = "db";
char stableName[64] = "st"; char stableName[64] = "st";
int32_t cache = 16384; int64_t totalUs = 0;
int32_t tables = 1000; int64_t reqNum = 0;
int64_t maxUs = 0;
int64_t minUs = 100000000;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
shellParseArgument(argc, argv); shellParseArgument(argc, argv);
...@@ -58,6 +61,38 @@ int main(int argc, char *argv[]) { ...@@ -58,6 +61,38 @@ int main(int argc, char *argv[]) {
taos_init(); taos_init();
createDbAndTable(); createDbAndTable();
insertData(); insertData();
int64_t avgUs = totalUs / reqNum;
pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs, reqNum, NC);
}
int32_t query(void *con, char *qstr) {
int64_t begin = taosGetTimestampUs();
TAOS_RES *pSql = taos_query(con, qstr);
int32_t code = taos_errno(pSql);
if (code != 0) {
pError("failed to exec sql:%s, code:%d reason:%s", qstr, taos_errno(con), taos_errstr(con));
exit(0);
}
taos_free_result(pSql);
int64_t us = taosGetTimestampUs() - begin;
maxUs = MAX(us, maxUs);
minUs = MIN(us, minUs);
atomic_add_fetch_64(&totalUs, us);
atomic_add_fetch_64(&reqNum, 1);
if (reqNum > 100000) {
int64_t avgUs = totalUs / reqNum;
if (us > avgUs * 100) {
pError("sql:%s", qstr);
pError("%s totalUs:%ld, avgUs:%ld maxUs:%ld minUs:%ld reqNum:%ld %s\n", GREEN, totalUs, avgUs, maxUs, minUs,
reqNum, NC);
taosMsleep(1000);
exit(0);
}
}
return code;
} }
void createDbAndTable() { void createDbAndTable() {
...@@ -79,14 +114,14 @@ void createDbAndTable() { ...@@ -79,14 +114,14 @@ void createDbAndTable() {
exit(1); exit(1);
} }
sprintf(qstr, "create database if not exists %s cache %d tables %d", dbName, cache, tables); sprintf(qstr, "create database if not exists %s", dbName);
if (taos_query(con, qstr)) { if (query(con, qstr)) {
pError("failed to create database:%s, code:%d reason:%s", dbName, taos_errno(con), taos_errstr(con)); pError("failed to create database:%s, code:%d reason:%s", dbName, taos_errno(con), taos_errstr(con));
exit(0); exit(0);
} }
sprintf(qstr, "use %s", dbName); sprintf(qstr, "use %s", dbName);
if (taos_query(con, qstr)) { if (query(con, qstr)) {
pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con)); pError("failed to use db, code:%d reason:%s", taos_errno(con), taos_errstr(con));
exit(0); exit(0);
} }
...@@ -102,14 +137,14 @@ void createDbAndTable() { ...@@ -102,14 +137,14 @@ void createDbAndTable() {
} }
sprintf(qstr + len, ") tags(t int)"); sprintf(qstr + len, ") tags(t int)");
if (taos_query(con, qstr)) { if (query(con, qstr)) {
pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con)); pError("failed to create stable, code:%d reason:%s", taos_errno(con), taos_errstr(con));
exit(0); exit(0);
} }
for (int64_t t = 0; t < totalTables; ++t) { for (int64_t t = 0; t < totalTables; ++t) {
sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t);
if (taos_query(con, qstr)) { if (query(con, qstr)) {
pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con));
exit(0); exit(0);
} }
...@@ -122,7 +157,7 @@ void createDbAndTable() { ...@@ -122,7 +157,7 @@ void createDbAndTable() {
} }
sprintf(qstr + len, ")"); sprintf(qstr + len, ")");
if (taos_query(con, qstr)) { if (query(con, qstr)) {
pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con)); pError("failed to create table %s%ld, reason:%s", stableName, t, taos_errstr(con));
exit(0); exit(0);
} }
...@@ -207,7 +242,7 @@ void *syncTest(void *param) { ...@@ -207,7 +242,7 @@ void *syncTest(void *param) {
} }
sprintf(qstr, "use %s", pInfo->dbName); sprintf(qstr, "use %s", pInfo->dbName);
taos_query(con, qstr); query(con, qstr);
gettimeofday(&systemTime, NULL); gettimeofday(&systemTime, NULL);
st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; st = systemTime.tv_sec * 1000000 + systemTime.tv_usec;
...@@ -229,7 +264,7 @@ void *syncTest(void *param) { ...@@ -229,7 +264,7 @@ void *syncTest(void *param) {
} }
len += sprintf(sql + len, ")"); len += sprintf(sql + len, ")");
if (len > maxBytes) { if (len > maxBytes) {
if (taos_query(con, qstr)) { if (query(con, qstr)) {
pError("thread:%d, failed to import table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName, pError("thread:%d, failed to import table:%s%ld row:%ld, reason:%s", pInfo->threadIndex, pInfo->stableName,
table, row, taos_errstr(con)); table, row, taos_errstr(con));
} }
...@@ -246,7 +281,7 @@ void *syncTest(void *param) { ...@@ -246,7 +281,7 @@ void *syncTest(void *param) {
} }
if (len != strlen(inserStr)) { if (len != strlen(inserStr)) {
taos_query(con, qstr); query(con, qstr);
} }
gettimeofday(&systemTime, NULL); gettimeofday(&systemTime, NULL);
...@@ -284,10 +319,6 @@ void printHelp() { ...@@ -284,10 +319,6 @@ void printHelp() {
printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of threads to be used, default is ", numOfThreads); printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of threads to be used, default is ", numOfThreads);
printf("%s%s\n", indent, "-n"); printf("%s%s\n", indent, "-n");
printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of tables per thread, default is ", numOfTablesPerThread); printf("%s%s%s%" PRId64 "\n", indent, indent, "Number of tables per thread, default is ", numOfTablesPerThread);
printf("%s%s\n", indent, "-tables");
printf("%s%s%s%d\n", indent, indent, "Database parameters tables, default is ", tables);
printf("%s%s\n", indent, "-cache");
printf("%s%s%s%d\n", indent, indent, "Database parameters cache, default is ", cache);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
...@@ -311,10 +342,6 @@ void shellParseArgument(int argc, char *argv[]) { ...@@ -311,10 +342,6 @@ void shellParseArgument(int argc, char *argv[]) {
numOfThreads = atoi(argv[++i]); numOfThreads = atoi(argv[++i]);
} else if (strcmp(argv[i], "-n") == 0) { } else if (strcmp(argv[i], "-n") == 0) {
numOfTablesPerThread = atoi(argv[++i]); numOfTablesPerThread = atoi(argv[++i]);
} else if (strcmp(argv[i], "-tables") == 0) {
tables = atoi(argv[++i]);
} else if (strcmp(argv[i], "-cache") == 0) {
cache = atoi(argv[++i]);
} else { } else {
} }
} }
...@@ -323,8 +350,6 @@ void shellParseArgument(int argc, char *argv[]) { ...@@ -323,8 +350,6 @@ void shellParseArgument(int argc, char *argv[]) {
pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC);
pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC);
pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC);
pPrint("%scache:%d%s", GREEN, cache, NC);
pPrint("%stables:%d%s", GREEN, tables, NC);
pPrint("%sdbName:%s%s", GREEN, dbName, NC); pPrint("%sdbName:%s%s", GREEN, dbName, NC);
pPrint("%stableName:%s%s", GREEN, stableName, NC); pPrint("%stableName:%s%s", GREEN, stableName, NC);
pPrint("%sstart to run%s", GREEN, NC); pPrint("%sstart to run%s", GREEN, NC);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册