Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b0e06019
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b0e06019
编写于
9月 25, 2022
作者:
Z
zhihaop
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat, doc: improve the performance of sqlobjs merge, update docs of ABWD
上级
58392c19
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
58 addition
and
50 deletion
+58
-50
src/client/inc/tscBatchWrite.h
src/client/inc/tscBatchWrite.h
+7
-9
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-0
src/client/src/tscBatchMerge.c
src/client/src/tscBatchMerge.c
+8
-5
src/client/src/tscBatchWrite.c
src/client/src/tscBatchWrite.c
+5
-4
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+33
-25
src/common/src/tglobal.c
src/common/src/tglobal.c
+3
-7
未找到文件。
src/client/inc/tscBatchWrite.h
浏览文件 @
b0e06019
...
...
@@ -126,15 +126,14 @@ bool isShutdownSDispatcherTimeoutManager(SDispatcherTimeoutManager* manager);
void
shutdownSDispatcherTimeoutManager
(
SDispatcherTimeoutManager
*
manager
);
/**
* Merge
the statement
s into single SSqlObj.
* Merge
SSqlObj
s into single SSqlObj.
*
* @param fp the callback of SSqlObj.
* @param param the parameters of the callback.
* @param polls the array of SSqlObj*.
* @param nPolls the number of SSqlObj* in the array.
* @param batch the merged SSqlObj*.
* @return the merged SSqlObj.
*/
int32_t
dispatcherBatch
Merge
(
SSqlObj
**
polls
,
size_t
nPolls
,
SSqlObj
**
result
);
int32_t
dispatcherBatch
Builder
(
SSqlObj
**
polls
,
size_t
nPolls
,
SSqlObj
**
batch
);
/**
* Merge the sql statements and execute the merged sql statement.
...
...
@@ -147,11 +146,10 @@ void dispatcherExecute(SSqlObj** polls, size_t nPolls);
/**
* Create the async batch write dispatcher.
*
* @param batchSize When user submit an insert statement to `taos_query_ra`, the statement will be buffered
* asynchronously in the buffer instead of executing it. If the number of the buffered
* statements reach batchLen, all the statements in the buffer will be merged and sent to vnodes.
* @param timeout The statements will be sent to vnodes no more than timeout milliseconds. But the actual time
* vnodes received the statements depends on the network quality.
* @param batchSize When user submit an insert sql to `taos_query_a`, the SSqlObj* will be buffered instead of executing
* it. If the number of the buffered rows reach `batchSize`, all the SSqlObj* will be merged and sent to vnodes.
* @param timeout The SSqlObj* will be sent to vnodes no more than `timeout` milliseconds. But the actual time
* vnodes received the SSqlObj* depends on the network quality.
*/
SAsyncBatchWriteDispatcher
*
createSAsyncBatchWriteDispatcher
(
int32_t
batchSize
,
int32_t
timeoutMs
);
...
...
src/client/inc/tscUtil.h
浏览文件 @
b0e06019
...
...
@@ -144,6 +144,8 @@ void doRetrieveSubqueryData(SSchedMsg *pMsg);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
int16_t
bytes
,
uint32_t
offset
);
void
destroySTableDataBlocksList
(
SArray
*
pDataBlocks
);
void
destroySTableDataBlocks
(
STableDataBlocks
*
pDataBlocks
);
void
*
tscDestroyBlockArrayList
(
SSqlObj
*
pSql
,
SArray
*
pDataBlockList
);
void
*
tscDestroyUdfArrayList
(
SArray
*
pUdfList
);
void
*
tscDestroyBlockHashTable
(
SSqlObj
*
pSql
,
SHashObj
*
pBlockHashTable
,
bool
removeMeta
);
...
...
src/client/src/tscBatchMerge.c
浏览文件 @
b0e06019
...
...
@@ -171,13 +171,14 @@ size_t writeSSubmitBlkBuilder(SSubmitBlkBuilder* builder, SSubmitBlk* target, si
taosArraySort
(
builder
->
rows
,
compareSMemRow
);
// deep copy all the SMemRow to target.
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
builder
->
rows
);
++
i
)
{
size_t
nMemRows
=
taosArrayGetSize
(
builder
->
rows
);
for
(
int
i
=
0
;
i
<
nMemRows
;
++
i
)
{
char
*
pRow
=
taosArrayGetP
(
builder
->
rows
,
i
);
memcpy
(
POINTER_SHIFT
(
target
->
data
,
dataLen
),
pRow
,
memRowTLen
(
pRow
));
dataLen
+=
memRowTLen
(
pRow
);
}
*
nRows
=
taosArrayGetSize
(
builder
->
rows
)
;
*
nRows
=
nMemRows
;
target
->
schemaLen
=
0
;
target
->
dataLen
=
(
int32_t
)
htonl
(
dataLen
);
...
...
@@ -188,7 +189,8 @@ size_t writeSSubmitBlkBuilder(SSubmitBlkBuilder* builder, SSubmitBlk* target, si
size_t
nWriteSSubmitBlkBuilder
(
SSubmitBlkBuilder
*
builder
)
{
size_t
dataLen
=
0
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
builder
->
rows
);
++
i
)
{
size_t
nRows
=
taosArrayGetSize
(
builder
->
rows
);
for
(
int
i
=
0
;
i
<
nRows
;
++
i
)
{
char
*
pRow
=
taosArrayGetP
(
builder
->
rows
,
i
);
dataLen
+=
memRowTLen
(
pRow
);
}
...
...
@@ -485,8 +487,9 @@ int32_t tscMergeSSqlObjs(SSqlObj** polls, size_t nPolls, SSqlObj* result) {
assert
(
!
pInsertParam
->
schemaAttached
);
// append each vnode data block to the builder.
for
(
size_t
j
=
0
;
j
<
taosArrayGetSize
(
pInsertParam
->
pDataBlocks
);
++
j
)
{
STableDataBlocks
*
tableBlock
=
taosArrayGetP
(
pInsertParam
->
pDataBlocks
,
j
);
size_t
nBlocks
=
taosArrayGetSize
(
pInsertParam
->
pDataBlocks
);
for
(
size_t
j
=
0
;
j
<
nBlocks
;
++
j
)
{
STableDataBlocks
*
tableBlock
=
taosArrayGetP
(
pInsertParam
->
pDataBlocks
,
j
);
if
(
!
appendSTableDataBlocksListBuilder
(
builder
,
tableBlock
))
{
destroySTableDataBlocksListBuilder
(
builder
);
destroySTableNameListBuilder
(
nameListBuilder
);
...
...
src/client/src/tscBatchWrite.c
浏览文件 @
b0e06019
...
...
@@ -104,7 +104,7 @@ static void batchResultCallback(void* param, TAOS_RES* tres, int32_t code) {
free
(
context
);
}
int32_t
dispatcherBatch
Merge
(
SSqlObj
**
polls
,
size_t
nPolls
,
SSqlObj
**
result
)
{
int32_t
dispatcherBatch
Builder
(
SSqlObj
**
polls
,
size_t
nPolls
,
SSqlObj
**
batch
)
{
if
(
!
polls
||
!
nPolls
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -124,7 +124,7 @@ int32_t dispatcherBatchMerge(SSqlObj** polls, size_t nPolls, SSqlObj** result) {
context
->
handler
[
i
].
fp
=
pSql
->
fp
;
context
->
handler
[
i
].
param
=
pSql
->
param
;
}
// merge the statements into single one.
tscDebug
(
"start to merge %zu sql objs"
,
nPolls
);
SSqlObj
*
pFirst
=
polls
[
0
];
...
...
@@ -140,7 +140,7 @@ int32_t dispatcherBatchMerge(SSqlObj** polls, size_t nPolls, SSqlObj** result) {
pFirst
->
fp
=
batchResultCallback
;
pFirst
->
param
=
context
;
pFirst
->
fetchFp
=
pFirst
->
fp
;
*
result
=
pFirst
;
*
batch
=
pFirst
;
for
(
int
i
=
1
;
i
<
nPolls
;
++
i
)
{
SSqlObj
*
pSql
=
polls
[
i
];
...
...
@@ -249,7 +249,7 @@ void dispatcherExecute(SSqlObj** polls, size_t nPolls) {
// merge the statements into single one.
SSqlObj
*
merged
=
NULL
;
code
=
dispatcherBatch
Merge
(
polls
,
nPolls
,
&
merged
);
code
=
dispatcherBatch
Builder
(
polls
,
nPolls
,
&
merged
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -560,6 +560,7 @@ void shutdownSDispatcherTimeoutManager(SDispatcherTimeoutManager* manager) {
// make sure the timeout thread exit.
pthread_join
(
manager
->
background
,
NULL
);
}
bool
isShutdownSDispatcherTimeoutManager
(
SDispatcherTimeoutManager
*
manager
)
{
if
(
!
manager
)
{
return
true
;
...
...
src/client/src/tscUtil.c
浏览文件 @
b0e06019
...
...
@@ -1837,32 +1837,36 @@ void tscDestroyBoundColumnInfo(SParsedDataColInfo* pColInfo) {
tfree
(
pColInfo
->
colIdxInfo
);
}
void
tscDestroyDataBlock
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
)
{
if
(
pDataBlock
==
NULL
)
{
void
destroySTableDataBlocks
(
STableDataBlocks
*
pDataBlocks
)
{
if
(
!
pDataBlocks
)
{
return
;
}
tfree
(
pDataBlocks
->
pData
);
if
(
!
pDataBlocks
->
cloned
)
{
tfree
(
pDataBlocks
->
params
);
// free the refcount for metermeta
if
(
pDataBlocks
->
pTableMeta
!=
NULL
)
{
tfree
(
pDataBlocks
->
pTableMeta
);
}
tfree
(
pDataBlock
->
pData
);
tscDestroyBoundColumnInfo
(
&
pDataBlocks
->
boundColumnInfo
);
}
tfree
(
pDataBlocks
);
}
void
tscDestroyDataBlock
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
)
{
if
(
pDataBlock
==
NULL
)
{
return
;
}
if
(
removeMeta
)
{
char
name
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
&
pDataBlock
->
tableName
,
name
);
taosHashRemove
(
UTIL_GET_TABLEMETA
(
pSql
),
name
,
strnlen
(
name
,
TSDB_TABLE_FNAME_LEN
));
}
if
(
!
pDataBlock
->
cloned
)
{
tfree
(
pDataBlock
->
params
);
// free the refcount for metermeta
if
(
pDataBlock
->
pTableMeta
!=
NULL
)
{
tfree
(
pDataBlock
->
pTableMeta
);
}
tscDestroyBoundColumnInfo
(
&
pDataBlock
->
boundColumnInfo
);
}
tfree
(
pDataBlock
);
destroySTableDataBlocks
(
pDataBlock
);
}
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
int16_t
bytes
,
...
...
@@ -1889,18 +1893,22 @@ SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint
return
param
;
}
void
*
tscDestroyBlockArrayList
(
SSqlObj
*
pSql
,
SArray
*
pDataBlockList
)
{
if
(
pDataBlockList
==
NULL
)
{
return
NULL
;
void
destroySTableDataBlocksList
(
SArray
*
pDataBlocks
)
{
if
(
!
pDataBlocks
)
{
return
;
}
size_t
size
=
taosArrayGetSize
(
pDataBlockList
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
void
*
d
=
taosArrayGetP
(
pDataBlockList
,
i
);
tscDestroyDataBlock
(
pSql
,
d
,
false
);
size_t
nBlocks
=
taosArrayGetSize
(
pDataBlocks
);
for
(
size_t
i
=
0
;
i
<
nBlocks
;
++
i
)
{
STableDataBlocks
*
pDataBlock
=
taosArrayGetP
(
pDataBlocks
,
i
);
if
(
pDataBlock
)
{
destroySTableDataBlocks
(
pDataBlock
);
}
}
taosArrayDestroy
(
&
pDataBlocks
);
}
taosArrayDestroy
(
&
pDataBlockList
);
void
*
tscDestroyBlockArrayList
(
SSqlObj
*
pSql
,
SArray
*
pDataBlockList
)
{
destroySTableDataBlocksList
(
pDataBlockList
);
return
NULL
;
}
...
...
src/common/src/tglobal.c
浏览文件 @
b0e06019
...
...
@@ -127,15 +127,11 @@ int8_t tsSortWhenGroupBy = 1;
int32_t
tsProjectExecInterval
=
10000
;
// every 10sec, the projection will be executed once
int64_t
tsMaxRetentWindow
=
24
*
3600L
;
// maximum time window tolerance
// The async insertion batching feature.
// When user submit an insert statement to `taos_query_ra`, the statement will be buffered asynchronously instead of executing it.
// If the number of the buffered statements reach `tsAsyncBatchSize`, all the statements in the queue will be merged and sent to vnodes.
// The statements will be sent to vnodes no more than `tsAsyncBatchTimeout` milliseconds. But the actual time vnodes
// received the statements depends on the network quality.
// The taosc async insertion batching feature.
bool
tsAsyncBatchEnable
=
true
;
bool
tsAsyncBatchThreadLocal
=
true
;
// if thread local enable, each thread will allocate a dispatcher.
int32_t
tsAsyncBatchSize
=
96
;
int32_t
tsAsyncBatchTimeout
=
10
;
int32_t
tsAsyncBatchSize
=
96
;
// suggest: 64 - 512
int32_t
tsAsyncBatchTimeout
=
10
;
// suggest: 5 - 200 (unit: milliseconds)
// the maximum allowed query buffer size during query processing for each data node.
// -1 no limit (default)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录