Skip to content

Commit

Permalink
fix: taosbenchmark query times (#624)
Browse files Browse the repository at this point in the history
* fix: taosbenchmark total queried times incorrect

* fix: taosbenchmark query times incorrect
  • Loading branch information
sangshuduo committed Mar 17, 2023
1 parent ea02029 commit d11f210
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/3.0-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
|| github.event_name == 'push'
shell: alpine.sh --root {0}
run: |
git clone --branch fix/sangshuduo/TD-23043-windows-socket-close --depth 1 https://github.com/taosdata/TDengine > /dev/null || exit 1
git clone --branch fix/sangshuduo/TS-2902-taosbenchmark-query-times --depth 1 https://github.com/taosdata/TDengine > /dev/null || exit 1
cd TDengine && mkdir debug && cd debug && cmake .. -DBUILD_TOOLS=true -DTOOLS_BUILD_TYPE=${{env.TOOLS_BUILD_TYPE}} -DBUILD_HTTP=false && make -j8 && make install
if [[ ! -f /usr/local/taos/bin/taosd ]] || [[ ! -f /usr/local/taos/bin/taos ]]
then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/3.0-windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
with:
repository: 'taosdata/TDengine'
path: 'TDengine'
ref: 'chore/sangshuduo/TD-19593-gcc12-support'
ref: 'fix/sangshuduo/TS-2902-taosbenchmark-query-times'

- name: create debug directory
if: |
Expand Down
56 changes: 27 additions & 29 deletions src/benchQuery.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) {
return -1;
}
uint64_t query_times = g_queryInfo.specifiedQueryInfo.queryTimes;
uint64_t total_query_times = query_times * nConcurrent;
uint64_t totalQueryTimes = query_times * nConcurrent;
double avg_delay = 0.0;
for (int j = 0; j < nConcurrent; j++) {
uint64_t seq = i * nConcurrent + j;
Expand All @@ -470,7 +470,7 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) {
tmfree(pThreadInfo->query_delay_list);
}
avg_delay /= nConcurrent;
qsort(sql->delay_list, total_query_times,
qsort(sql->delay_list, g_queryInfo.specifiedQueryInfo.queryTimes,
sizeof(uint64_t), compare);
infoPrintNoTimestamp("complete query with %d threads and %"PRIu64
" query delay "
Expand All @@ -485,14 +485,13 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) {
nConcurrent, query_times,
avg_delay/1E6, /* avg */
sql->delay_list[0]/1E6, /* min */
sql->delay_list[(int32_t)
total_query_times - 1]/1E6, /* max */
sql->delay_list[(int32_t)
(total_query_times * 0.90)]/1E6, /* p90 */
sql->delay_list[(int32_t)
(total_query_times * 0.95)]/1E6, /* p95 */
sql->delay_list[(int32_t)
(total_query_times * 0.99)]/1E6, /* p88 */
sql->delay_list[totalQueryTimes - 1]/1E6, /* max */
/* p90 */
sql->delay_list[(uint64_t)(totalQueryTimes * 0.90)]/1E6,
/* p95 */
sql->delay_list[(uint64_t)(totalQueryTimes * 0.95)]/1E6,
/* p99 */
sql->delay_list[(uint64_t)(totalQueryTimes * 0.99)]/1E6,
sql->command);
infoPrintNoTimestampToFile(g_arguments->fpOfInsertResult,
"complete query with %d threads and %"PRIu64
Expand All @@ -508,20 +507,21 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) {
nConcurrent, query_times,
avg_delay/1E6, /* avg */
sql->delay_list[0]/1E6, /* min */
sql->delay_list[(int32_t)
total_query_times - 1]/1E6, /* max */
sql->delay_list[(int32_t)
(total_query_times * 0.90)]/1E6, /* p90 */
sql->delay_list[(int32_t)
(total_query_times * 0.95)]/1E6, /* p95 */
sql->delay_list[(int32_t)
(total_query_times * 0.99)]/1E6, /* p88 */
sql->delay_list[totalQueryTimes - 1]/1E6, /* max */
/* p90 */
sql->delay_list[(uint64_t)(totalQueryTimes * 0.90)]/1E6,
/* p95 */
sql->delay_list[(uint64_t)(totalQueryTimes * 0.95)]/1E6,
/* p99 */
sql->delay_list[(uint64_t)(totalQueryTimes * 0.99)]/1E6,
sql->command);
}
} else {
return 0;
}

g_queryInfo.specifiedQueryInfo.totalQueried =
g_queryInfo.specifiedQueryInfo.queryTimes * nConcurrent;
tmfree((char *)pids);
tmfree((char *)infos);
for (int i = 0; i < g_queryInfo.specifiedQueryInfo.sqls->size; ++i) {
Expand Down Expand Up @@ -777,9 +777,7 @@ int queryTestProcess() {
}
closeBenchConn(conn);
}

uint64_t startTs = toolsGetTimestampMs();

if (g_queryInfo.specifiedQueryInfo.mixed_query) {
if (multi_thread_specified_mixed_query(g_queryInfo.iface,
g_queryInfo.dbName)) {
Expand All @@ -791,21 +789,22 @@ int queryTestProcess() {
return -1;
}
}

if (multi_thread_super_table_query(g_queryInfo.iface,
g_queryInfo.dbName)) {
return -1;
}

// // workaround to use separate taos connection;
// workaround to use separate taos connection;
uint64_t endTs = toolsGetTimestampMs();

uint64_t totalQueried = g_queryInfo.specifiedQueryInfo.totalQueried
+ g_queryInfo.superQueryInfo.totalQueried;

int64_t t = endTs - startTs;
double tInS = (double)t / 1000.0;

if (g_queryInfo.specifiedQueryInfo.totalQueried)
infoPrint("Total specified queries: %" PRIu64 "\n",
g_queryInfo.specifiedQueryInfo.totalQueried);
if (g_queryInfo.superQueryInfo.totalQueried)
infoPrint("Total super queries: %" PRIu64 "\n",
g_queryInfo.superQueryInfo.totalQueried);
uint64_t totalQueried = g_queryInfo.specifiedQueryInfo.totalQueried
+ g_queryInfo.superQueryInfo.totalQueried;
infoPrint(
"Spend %.4f second completed total queries: %" PRIu64
", the QPS of all threads: %10.3f\n\n",
Expand All @@ -814,6 +813,5 @@ int queryTestProcess() {
"Spend %.4f second completed total queries: %" PRIu64
", the QPS of all threads: %10.3f\n\n",
tInS, totalQueried, (double)totalQueried / tInS);

return 0;
}

0 comments on commit d11f210

Please sign in to comment.