Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
47fa1dea
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
47fa1dea
编写于
12月 29, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2378]<enhance>: reduce table meta memory consumption.
上级
b64c30cf
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
49 addition
and
34 deletion
+49
-34
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+8
-8
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+38
-25
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-0
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
47fa1dea
...
...
@@ -494,7 +494,8 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
}
}
extern
SHashObj
*
tscHashMap
;
extern
int32_t
sentinel
;
extern
SHashObj
*
tscVgroupMap
;
extern
SHashObj
*
tscTableMetaInfo
;
extern
int
tscObjRef
;
...
...
src/client/src/tscServer.c
浏览文件 @
47fa1dea
...
...
@@ -121,7 +121,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
int32_t
vgId
=
pTableMetaInfo
->
pTableMeta
->
vgId
;
SNewVgroupInfo
vgroupInfo
=
{.
vgId
=
-
1
};
taosHashGetClone
(
tsc
Hash
Map
,
&
vgId
,
sizeof
(
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashGetClone
(
tsc
Vgroup
Map
,
&
vgId
,
sizeof
(
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
assert
(
vgroupInfo
.
numOfEps
>
0
&&
vgroupInfo
.
vgId
>
0
);
tscDebug
(
"before: Endpoint in use:%d, numOfEps:%d"
,
vgroupInfo
.
inUse
,
vgroupInfo
.
numOfEps
);
...
...
@@ -133,7 +133,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
}
tscDebug
(
"after: EndPoint in use:%d, numOfEps:%d"
,
vgroupInfo
.
inUse
,
vgroupInfo
.
numOfEps
);
taosHashPut
(
tsc
Hash
Map
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashPut
(
tsc
Vgroup
Map
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
}
void
tscProcessHeartBeatRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
...
...
@@ -553,7 +553,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSql
->
cmd
.
msgType
=
TSDB_MSG_TYPE_SUBMIT
;
SNewVgroupInfo
vgroupInfo
=
{
0
};
taosHashGetClone
(
tsc
Hash
Map
,
&
pTableMeta
->
vgId
,
sizeof
(
pTableMeta
->
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashGetClone
(
tsc
Vgroup
Map
,
&
pTableMeta
->
vgId
,
sizeof
(
pTableMeta
->
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
tscDumpEpSetFromVgroupInfo
(
&
pSql
->
epSet
,
&
vgroupInfo
);
tscDebug
(
"%p build submit msg, vgId:%d numOfTables:%d numberOfEP:%d"
,
pSql
,
pTableMeta
->
vgId
,
pSql
->
cmd
.
numOfTablesInSubmit
,
...
...
@@ -618,7 +618,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
vgId
=
pTableMeta
->
vgId
;
SNewVgroupInfo
vgroupInfo
=
{
0
};
taosHashGetClone
(
tsc
Hash
Map
,
&
pTableMeta
->
vgId
,
sizeof
(
pTableMeta
->
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashGetClone
(
tsc
Vgroup
Map
,
&
pTableMeta
->
vgId
,
sizeof
(
pTableMeta
->
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
tscDumpEpSetFromVgroupInfo
(
&
pSql
->
epSet
,
&
vgroupInfo
);
}
...
...
@@ -1459,7 +1459,7 @@ int tscBuildUpdateTagMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
;
SNewVgroupInfo
vgroupInfo
=
{.
vgId
=
-
1
};
taosHashGetClone
(
tsc
Hash
Map
,
&
pTableMeta
->
vgId
,
sizeof
(
pTableMeta
->
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashGetClone
(
tsc
Vgroup
Map
,
&
pTableMeta
->
vgId
,
sizeof
(
pTableMeta
->
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
assert
(
vgroupInfo
.
vgId
>
0
);
tscDumpEpSetFromVgroupInfo
(
&
pSql
->
epSet
,
&
vgroupInfo
);
...
...
@@ -1849,13 +1849,13 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
// update the vgroupInfo if needed
int32_t
vgId
=
pTableMeta
->
vgId
;
SNewVgroupInfo
vgroupInfo
=
{.
inUse
=
-
1
};
taosHashGetClone
(
tsc
Hash
Map
,
&
vgId
,
sizeof
(
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashGetClone
(
tsc
Vgroup
Map
,
&
vgId
,
sizeof
(
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
if
(((
vgroupInfo
.
inUse
>=
0
)
&&
!
vgroupInfoIdentical
(
&
vgroupInfo
,
&
pMetaMsg
->
vgroup
))
||
(
vgroupInfo
.
inUse
<
0
))
{
// vgroup info exists, compare with it
vgroupInfo
=
createNewVgroupInfo
(
&
pMetaMsg
->
vgroup
);
taosHashPut
(
tsc
Hash
Map
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
vgroupInfo
));
tscDebug
(
"add new VgroupInfo, vgId:%d, total:%d"
,
vgId
,
(
int32_t
)
taosHashGetSize
(
tsc
Hash
Map
));
taosHashPut
(
tsc
Vgroup
Map
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
vgroupInfo
));
tscDebug
(
"add new VgroupInfo, vgId:%d, total:%d"
,
vgId
,
(
int32_t
)
taosHashGetSize
(
tsc
Vgroup
Map
));
}
tscDebug
(
"%p recv table meta, uid:%"
PRId64
", tid:%d, name:%s"
,
pSql
,
pTableMeta
->
id
.
uid
,
pTableMeta
->
id
.
tid
,
pTableMetaInfo
->
name
);
...
...
src/client/src/tscSystem.c
浏览文件 @
47fa1dea
...
...
@@ -31,15 +31,20 @@
#include "tlocale.h"
// global, not configurable
SHashObj
*
tscHashMap
;
// hash map to keep the global vgroup info
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
int32_t
sentinel
=
TSC_VAR_NOT_RELEASE
;
SHashObj
*
tscVgroupMap
;
// hash map to keep the global vgroup info
SHashObj
*
tscTableMetaInfo
;
// table meta info
int
tscObjRef
=
-
1
;
int
32_t
tscObjRef
=
-
1
;
void
*
tscTmr
;
void
*
tscQhandle
;
void
*
tscCheckDiskUsageTmr
;
int
tscRefId
=
-
1
;
int
tscNumOfObj
=
0
;
// number of sqlObj in current process.
int32_t
tscRefId
=
-
1
;
int32_t
tscNumOfObj
=
0
;
// number of sqlObj in current process.
static
void
*
tscCheckDiskUsageTmr
;
static
pthread_once_t
tscinit
=
PTHREAD_ONCE_INIT
;
void
tscCheckDiskUsage
(
void
*
UNUSED_PARAM
(
para
),
void
*
UNUSED_PARAM
(
param
))
{
...
...
@@ -131,7 +136,7 @@ void taos_init_imp(void) {
if
(
tscTableMetaInfo
==
NULL
)
{
tscObjRef
=
taosOpenRef
(
40960
,
tscFreeRegisteredSqlObj
);
tsc
HashMap
=
taosHashInit
(
1024
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
tsc
VgroupMap
=
taosHashInit
(
256
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
tscTableMetaInfo
=
taosHashInit
(
1024
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
tscDebug
(
"TableMeta:%p"
,
tscTableMetaInfo
);
}
...
...
@@ -151,30 +156,38 @@ void taos_init() { pthread_once(&tscinit, taos_init_imp); }
void
taos_cleanup
(
void
)
{
tscDebug
(
"start to cleanup client environment"
);
void
*
m
=
tscTableMetaInfo
;
if
(
m
!=
NULL
&&
atomic_val_compare_exchange_ptr
(
&
tscTableMetaInfo
,
m
,
0
)
==
m
)
{
taosCacheCleanup
(
m
);
if
(
atomic_val_compare_exchange_32
(
&
sentinel
,
TSC_VAR_NOT_RELEASE
,
TSC_VAR_RELEASED
)
!=
TSC_VAR_NOT_RELEASE
)
{
return
;
}
int
refId
=
atomic_exchange_32
(
&
tscObjRef
,
-
1
);
if
(
refId
!=
-
1
)
{
taosCloseRef
(
refId
);
}
taosHashCleanup
(
tscTableMetaInfo
);
tscTableMetaInfo
=
NULL
;
m
=
tscQhandle
;
if
(
m
!=
NULL
&&
atomic_val_compare_exchange_ptr
(
&
tscQhandle
,
m
,
0
)
==
m
)
{
taosCleanUpScheduler
(
m
);
}
taosHashCleanup
(
tscVgroupMap
);
tscVgroupMap
=
NULL
;
int32_t
id
=
tscObjRef
;
tscObjRef
=
-
1
;
taosCloseRef
(
id
);
void
*
p
=
tscQhandle
;
tscQhandle
=
NULL
;
taosCleanUpScheduler
(
p
);
id
=
tscRefId
;
tscRefId
=
-
1
;
taosCloseRef
(
id
);
taosCloseRef
(
tscRefId
);
taosCleanupKeywordsTable
();
taosCloseLog
();
if
(
tscEmbedded
==
0
)
rpcCleanup
();
m
=
tscTmr
;
if
(
m
!=
NULL
&&
atomic_val_compare_exchange_ptr
(
&
tscTmr
,
m
,
0
)
==
m
)
{
taosTmrCleanUp
(
m
);
if
(
tscEmbedded
==
0
)
{
rpcCleanup
();
}
p
=
tscTmr
;
tscTmr
=
NULL
;
taosTmrCleanUp
(
p
);
}
static
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
pStr
)
{
...
...
src/client/src/tscUtil.c
浏览文件 @
47fa1dea
...
...
@@ -883,6 +883,7 @@ void tscCloseTscObj(void *param) {
rpcClose
(
pObj
->
pDnodeConn
);
pObj
->
pDnodeConn
=
NULL
;
}
tfree
(
pObj
->
tscCorMgmtEpSet
);
pthread_mutex_destroy
(
&
pObj
->
mutex
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录