Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cd6532ca
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cd6532ca
编写于
1月 13, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(query): prepare the buffer on the stack, instead of heap.
上级
eea9d4f2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
29 deletion
+15
-29
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+15
-29
未找到文件。
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
cd6532ca
...
@@ -33,7 +33,8 @@ typedef struct SMetaStbStatsEntry {
...
@@ -33,7 +33,8 @@ typedef struct SMetaStbStatsEntry {
typedef
struct
STagFilterResEntry
{
typedef
struct
STagFilterResEntry
{
SList
list
;
// the linked list of md5 digest, extracted from the serialized tag query condition
SList
list
;
// the linked list of md5 digest, extracted from the serialized tag query condition
uint32_t
qTimes
;
// queried times for current super table
uint32_t
hitTimes
;
// queried times for current super table
uint32_t
accTime
;
}
STagFilterResEntry
;
}
STagFilterResEntry
;
struct
SMetaCache
{
struct
SMetaCache
{
...
@@ -54,6 +55,7 @@ struct SMetaCache {
...
@@ -54,6 +55,7 @@ struct SMetaCache {
// query cache
// query cache
struct
STagFilterResCache
{
struct
STagFilterResCache
{
TdThreadMutex
lock
;
TdThreadMutex
lock
;
uint32_t
accTimes
;
SHashObj
*
pTableEntry
;
SHashObj
*
pTableEntry
;
SLRUCache
*
pUidResCache
;
SLRUCache
*
pUidResCache
;
}
sTagFilterResCache
;
}
sTagFilterResCache
;
...
@@ -448,27 +450,6 @@ static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInv
...
@@ -448,27 +450,6 @@ static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInv
return
0
;
return
0
;
}
}
#define NEED_CHECK_CACHE_ITEM(_size, _acc_times) ((_size) >= 300 || (_acc_times) > 5000)
static
void
removeInvalidCacheItem
(
SArray
*
pInvalidRes
,
struct
STagFilterResEntry
*
pEntry
,
bool
triggerByGet
)
{
if
(
pInvalidRes
==
NULL
)
{
return
;
}
// remove the keys, of which query uid lists have been replaced already.
int32_t
s
=
taosArrayGetSize
(
pInvalidRes
);
for
(
int32_t
i
=
0
;
i
<
s
;
++
i
)
{
SListNode
**
p1
=
taosArrayGet
(
pInvalidRes
,
i
);
tdListPopNode
(
&
(
pEntry
->
list
),
*
p1
);
taosMemoryFree
(
*
p1
);
}
metaInfo
(
"clear %d items in cache, remain:%d, acctime:%d, trigger by get:%d"
,
s
,
listNEles
(
&
pEntry
->
list
),
pEntry
->
qTimes
,
triggerByGet
);
pEntry
->
qTimes
=
0
;
// reset the query times
taosArrayDestroy
(
pInvalidRes
);
}
int32_t
metaGetCachedTableUidList
(
SMeta
*
pMeta
,
tb_uid_t
suid
,
const
uint8_t
*
pKey
,
int32_t
keyLen
,
SArray
*
pList1
,
int32_t
metaGetCachedTableUidList
(
SMeta
*
pMeta
,
tb_uid_t
suid
,
const
uint8_t
*
pKey
,
int32_t
keyLen
,
SArray
*
pList1
,
bool
*
acquireRes
)
{
bool
*
acquireRes
)
{
// generate the composed key for LRU cache
// generate the composed key for LRU cache
...
@@ -485,6 +466,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
...
@@ -485,6 +466,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
memcpy
(
&
buf
[
2
],
pKey
,
keyLen
);
memcpy
(
&
buf
[
2
],
pKey
,
keyLen
);
taosThreadMutexLock
(
pLock
);
taosThreadMutexLock
(
pLock
);
pMeta
->
pCache
->
sTagFilterResCache
.
accTimes
+=
1
;
int32_t
len
=
keyLen
+
sizeof
(
uint64_t
)
*
2
;
int32_t
len
=
keyLen
+
sizeof
(
uint64_t
)
*
2
;
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
buf
,
len
);
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
buf
,
len
);
...
@@ -504,7 +486,13 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
...
@@ -504,7 +486,13 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
// set the result into the buffer
// set the result into the buffer
taosArrayAddBatch
(
pList1
,
p
+
sizeof
(
int32_t
),
size
);
taosArrayAddBatch
(
pList1
,
p
+
sizeof
(
int32_t
),
size
);
(
*
pEntry
)
->
qTimes
+=
1
;
(
*
pEntry
)
->
hitTimes
+=
1
;
int32_t
acc
=
pMeta
->
pCache
->
sTagFilterResCache
.
accTimes
;
if
((
*
pEntry
)
->
hitTimes
%
5000
==
8
&&
(
*
pEntry
)
->
hitTimes
>
0
)
{
metaInfo
(
"cache hit:%d, total acc:%d, rate:%.2f"
,
(
*
pEntry
)
->
hitTimes
,
acc
,
((
double
)(
*
pEntry
)
->
hitTimes
)
/
acc
);
}
taosLRUCacheRelease
(
pCache
,
pHandle
,
false
);
taosLRUCacheRelease
(
pCache
,
pHandle
,
false
);
// unlock meta
// unlock meta
...
@@ -539,8 +527,8 @@ static void freePayload(const void* key, size_t keyLen, void* value) {
...
@@ -539,8 +527,8 @@ static void freePayload(const void* key, size_t keyLen, void* value) {
tdListPopNode
(
&
((
*
pEntry
)
->
list
),
pNode
);
tdListPopNode
(
&
((
*
pEntry
)
->
list
),
pNode
);
int64_t
et
=
taosGetTimestampUs
();
int64_t
et
=
taosGetTimestampUs
();
metaInfo
(
"clear items in cache, remain cached item:%d, elapsed time:%.2fms
, acc count:%d
"
,
listNEles
(
&
((
*
pEntry
)
->
list
)),
metaInfo
(
"clear items in cache, remain cached item:%d, elapsed time:%.2fms"
,
listNEles
(
&
((
*
pEntry
)
->
list
)),
(
et
-
st
)
/
1000
.
0
,
(
*
pEntry
)
->
qTimes
);
(
et
-
st
)
/
1000
.
0
);
return
;
return
;
}
}
}
}
...
@@ -555,7 +543,7 @@ static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyL
...
@@ -555,7 +543,7 @@ static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyL
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
p
->
qTimes
=
1
;
p
->
hitTimes
=
0
;
tdListInit
(
&
p
->
list
,
keyLen
);
tdListInit
(
&
p
->
list
,
keyLen
);
taosHashPut
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
),
&
p
,
POINTER_BYTES
);
taosHashPut
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
),
&
p
,
POINTER_BYTES
);
tdListAppend
(
&
p
->
list
,
pKey
);
tdListAppend
(
&
p
->
list
,
pKey
);
...
@@ -605,8 +593,6 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -605,8 +593,6 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
}
}
}
else
{
}
else
{
// check if it exists or not
// check if it exists or not
(
*
pEntry
)
->
qTimes
+=
1
;
size_t
size
=
listNEles
(
&
(
*
pEntry
)
->
list
);
size_t
size
=
listNEles
(
&
(
*
pEntry
)
->
list
);
if
(
size
==
0
)
{
if
(
size
==
0
)
{
tdListAppend
(
&
(
*
pEntry
)
->
list
,
pKey
);
tdListAppend
(
&
(
*
pEntry
)
->
list
,
pKey
);
...
@@ -661,7 +647,7 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
...
@@ -661,7 +647,7 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) {
taosLRUCacheErase
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
,
p
,
keyLen
);
taosLRUCacheErase
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
,
p
,
keyLen
);
}
}
(
*
pEntry
)
->
q
Times
=
0
;
(
*
pEntry
)
->
hit
Times
=
0
;
tdListEmpty
(
&
(
*
pEntry
)
->
list
);
tdListEmpty
(
&
(
*
pEntry
)
->
list
);
taosThreadMutexUnlock
(
pLock
);
taosThreadMutexUnlock
(
pLock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录