Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8f61346d
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看板
提交
8f61346d
编写于
10月 10, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
meta/cache: separate entry cache to parepare for a new stats cache
上级
f0a74302
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
30 deletion
+37
-30
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+37
-30
未找到文件。
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
8f61346d
...
...
@@ -26,9 +26,12 @@ struct SMetaCacheEntry {
};
struct
SMetaCache
{
int32_t
nEntry
;
int32_t
nBucket
;
SMetaCacheEntry
**
aBucket
;
// child, normal, super, table entry cache
struct
SEntryCache
{
int32_t
nEntry
;
int32_t
nBucket
;
SMetaCacheEntry
**
aBucket
;
}
sEntryCache
;
};
int32_t
metaCacheOpen
(
SMeta
*
pMeta
)
{
...
...
@@ -41,10 +44,12 @@ int32_t metaCacheOpen(SMeta* pMeta) {
goto
_err
;
}
pCache
->
nEntry
=
0
;
pCache
->
nBucket
=
META_CACHE_BASE_BUCKET
;
pCache
->
aBucket
=
(
SMetaCacheEntry
**
)
taosMemoryCalloc
(
pCache
->
nBucket
,
sizeof
(
SMetaCacheEntry
*
));
if
(
pCache
->
aBucket
==
NULL
)
{
// open entry cache
pCache
->
sEntryCache
.
nEntry
=
0
;
pCache
->
sEntryCache
.
nBucket
=
META_CACHE_BASE_BUCKET
;
pCache
->
sEntryCache
.
aBucket
=
(
SMetaCacheEntry
**
)
taosMemoryCalloc
(
pCache
->
sEntryCache
.
nBucket
,
sizeof
(
SMetaCacheEntry
*
));
if
(
pCache
->
sEntryCache
.
aBucket
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
taosMemoryFree
(
pCache
);
goto
_err
;
...
...
@@ -62,15 +67,16 @@ _err:
void
metaCacheClose
(
SMeta
*
pMeta
)
{
if
(
pMeta
->
pCache
)
{
for
(
int32_t
iBucket
=
0
;
iBucket
<
pMeta
->
pCache
->
nBucket
;
iBucket
++
)
{
SMetaCacheEntry
*
pEntry
=
pMeta
->
pCache
->
aBucket
[
iBucket
];
// close entry cache
for
(
int32_t
iBucket
=
0
;
iBucket
<
pMeta
->
pCache
->
sEntryCache
.
nBucket
;
iBucket
++
)
{
SMetaCacheEntry
*
pEntry
=
pMeta
->
pCache
->
sEntryCache
.
aBucket
[
iBucket
];
while
(
pEntry
)
{
SMetaCacheEntry
*
tEntry
=
pEntry
->
next
;
taosMemoryFree
(
pEntry
);
pEntry
=
tEntry
;
}
}
taosMemoryFree
(
pMeta
->
pCache
->
aBucket
);
taosMemoryFree
(
pMeta
->
pCache
->
sEntryCache
.
aBucket
);
taosMemoryFree
(
pMeta
->
pCache
);
pMeta
->
pCache
=
NULL
;
}
...
...
@@ -81,9 +87,9 @@ static int32_t metaRehashCache(SMetaCache* pCache, int8_t expand) {
int32_t
nBucket
;
if
(
expand
)
{
nBucket
=
pCache
->
nBucket
*
2
;
nBucket
=
pCache
->
sEntryCache
.
nBucket
*
2
;
}
else
{
nBucket
=
pCache
->
nBucket
/
2
;
nBucket
=
pCache
->
sEntryCache
.
nBucket
/
2
;
}
SMetaCacheEntry
**
aBucket
=
(
SMetaCacheEntry
**
)
taosMemoryCalloc
(
nBucket
,
sizeof
(
SMetaCacheEntry
*
));
...
...
@@ -93,8 +99,8 @@ static int32_t metaRehashCache(SMetaCache* pCache, int8_t expand) {
}
// rehash
for
(
int32_t
iBucket
=
0
;
iBucket
<
pCache
->
nBucket
;
iBucket
++
)
{
SMetaCacheEntry
*
pEntry
=
pCache
->
aBucket
[
iBucket
];
for
(
int32_t
iBucket
=
0
;
iBucket
<
pCache
->
sEntryCache
.
nBucket
;
iBucket
++
)
{
SMetaCacheEntry
*
pEntry
=
pCache
->
sEntryCache
.
aBucket
[
iBucket
];
while
(
pEntry
)
{
SMetaCacheEntry
*
pTEntry
=
pEntry
->
next
;
...
...
@@ -107,9 +113,9 @@ static int32_t metaRehashCache(SMetaCache* pCache, int8_t expand) {
}
// final set
taosMemoryFree
(
pCache
->
aBucket
);
pCache
->
nBucket
=
nBucket
;
pCache
->
aBucket
=
aBucket
;
taosMemoryFree
(
pCache
->
sEntryCache
.
aBucket
);
pCache
->
sEntryCache
.
nBucket
=
nBucket
;
pCache
->
sEntryCache
.
aBucket
=
aBucket
;
_exit:
return
code
;
...
...
@@ -122,8 +128,8 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
// search
SMetaCache
*
pCache
=
pMeta
->
pCache
;
int32_t
iBucket
=
TABS
(
pInfo
->
uid
)
%
pCache
->
nBucket
;
SMetaCacheEntry
**
ppEntry
=
&
pCache
->
aBucket
[
iBucket
];
int32_t
iBucket
=
TABS
(
pInfo
->
uid
)
%
pCache
->
sEntryCache
.
nBucket
;
SMetaCacheEntry
**
ppEntry
=
&
pCache
->
sEntryCache
.
aBucket
[
iBucket
];
while
(
*
ppEntry
&&
(
*
ppEntry
)
->
info
.
uid
!=
pInfo
->
uid
)
{
ppEntry
=
&
(
*
ppEntry
)
->
next
;
}
...
...
@@ -135,11 +141,11 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
(
*
ppEntry
)
->
info
.
skmVer
=
pInfo
->
skmVer
;
}
}
else
{
// insert
if
(
pCache
->
nEntry
>=
pCache
->
nBucket
)
{
if
(
pCache
->
sEntryCache
.
nEntry
>=
pCache
->
sEntryCache
.
nBucket
)
{
code
=
metaRehashCache
(
pCache
,
1
);
if
(
code
)
goto
_exit
;
iBucket
=
TABS
(
pInfo
->
uid
)
%
pCache
->
nBucket
;
iBucket
=
TABS
(
pInfo
->
uid
)
%
pCache
->
sEntryCache
.
nBucket
;
}
SMetaCacheEntry
*
pEntryNew
=
(
SMetaCacheEntry
*
)
taosMemoryMalloc
(
sizeof
(
*
pEntryNew
));
...
...
@@ -149,9 +155,9 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
}
pEntryNew
->
info
=
*
pInfo
;
pEntryNew
->
next
=
pCache
->
aBucket
[
iBucket
];
pCache
->
aBucket
[
iBucket
]
=
pEntryNew
;
pCache
->
nEntry
++
;
pEntryNew
->
next
=
pCache
->
sEntryCache
.
aBucket
[
iBucket
];
pCache
->
sEntryCache
.
aBucket
[
iBucket
]
=
pEntryNew
;
pCache
->
sEntryCache
.
nEntry
++
;
}
_exit:
...
...
@@ -162,8 +168,8 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid) {
int32_t
code
=
0
;
SMetaCache
*
pCache
=
pMeta
->
pCache
;
int32_t
iBucket
=
TABS
(
uid
)
%
pCache
->
nBucket
;
SMetaCacheEntry
**
ppEntry
=
&
pCache
->
aBucket
[
iBucket
];
int32_t
iBucket
=
TABS
(
uid
)
%
pCache
->
sEntryCache
.
nBucket
;
SMetaCacheEntry
**
ppEntry
=
&
pCache
->
sEntryCache
.
aBucket
[
iBucket
];
while
(
*
ppEntry
&&
(
*
ppEntry
)
->
info
.
uid
!=
uid
)
{
ppEntry
=
&
(
*
ppEntry
)
->
next
;
}
...
...
@@ -172,8 +178,9 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid) {
if
(
pEntry
)
{
*
ppEntry
=
pEntry
->
next
;
taosMemoryFree
(
pEntry
);
pCache
->
nEntry
--
;
if
(
pCache
->
nEntry
<
pCache
->
nBucket
/
4
&&
pCache
->
nBucket
>
META_CACHE_BASE_BUCKET
)
{
pCache
->
sEntryCache
.
nEntry
--
;
if
(
pCache
->
sEntryCache
.
nEntry
<
pCache
->
sEntryCache
.
nBucket
/
4
&&
pCache
->
sEntryCache
.
nBucket
>
META_CACHE_BASE_BUCKET
)
{
code
=
metaRehashCache
(
pCache
,
0
);
if
(
code
)
goto
_exit
;
}
...
...
@@ -189,8 +196,8 @@ int32_t metaCacheGet(SMeta* pMeta, int64_t uid, SMetaInfo* pInfo) {
int32_t
code
=
0
;
SMetaCache
*
pCache
=
pMeta
->
pCache
;
int32_t
iBucket
=
TABS
(
uid
)
%
pCache
->
nBucket
;
SMetaCacheEntry
*
pEntry
=
pCache
->
aBucket
[
iBucket
];
int32_t
iBucket
=
TABS
(
uid
)
%
pCache
->
sEntryCache
.
nBucket
;
SMetaCacheEntry
*
pEntry
=
pCache
->
sEntryCache
.
aBucket
[
iBucket
];
while
(
pEntry
&&
pEntry
->
info
.
uid
!=
uid
)
{
pEntry
=
pEntry
->
next
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录