Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4503901f
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看板
提交
4503901f
编写于
12月 13, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
c0e308f2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
37 deletion
+33
-37
include/util/tdlist.h
include/util/tdlist.h
+11
-11
source/dnode/vnode/impl/inc/vnodeMemAllocator.h
source/dnode/vnode/impl/inc/vnodeMemAllocator.h
+6
-5
source/dnode/vnode/impl/src/vnodeArenaMAImpl.c
source/dnode/vnode/impl/src/vnodeArenaMAImpl.c
+16
-21
未找到文件。
include/util/tdlist.h
浏览文件 @
4503901f
...
...
@@ -23,23 +23,23 @@ extern "C" {
// Single linked list
#define TD_SLIST_NODE(TYPE) \
struct { \
struct
type
*sl_next_; \
struct
TYPE
*sl_next_; \
}
#define TD_SLIST(TYPE)
\
struct {
\
struct TYPE *sl_
dl_
head_; \
int sl_
dl_
neles_; \
#define TD_SLIST(TYPE) \
struct { \
struct TYPE *sl_head_; \
int sl_neles_; \
}
#define TD_SLIST_HEAD(sl) ((sl)->sl_
dl_
head_)
#define TD_SLIST_NELES(sl) ((sl)->sl_
dl_
neles_)
#define TD_SLIST_HEAD(sl) ((sl)->sl_head_)
#define TD_SLIST_NELES(sl) ((sl)->sl_neles_)
#define TD_SLIST_NODE_NEXT(sln) ((sln)->sl_next_)
#define tSListInit(sl)
\
do {
\
(sl)->sl_
dl_
head_ = NULL; \
(sl)->sl_
dl_
neles_ = 0; \
#define tSListInit(sl) \
do { \
(sl)->sl_head_ = NULL; \
(sl)->sl_neles_ = 0; \
} while (0)
#define tSListPush(sl, sln) \
...
...
source/dnode/vnode/impl/inc/vnodeMemAllocator.h
浏览文件 @
4503901f
...
...
@@ -26,7 +26,7 @@ typedef struct SVArenaNode SVArenaNode;
typedef
struct
SVMemAllocator
SVMemAllocator
;
struct
SVArenaNode
{
TD_
D
LIST_NODE
(
SVArenaNode
);
TD_
S
LIST_NODE
(
SVArenaNode
);
uint64_t
size
;
// current node size
void
*
ptr
;
char
data
[];
...
...
@@ -34,10 +34,11 @@ struct SVArenaNode {
struct
SVMemAllocator
{
TD_DLIST_NODE
(
SVMemAllocator
);
uint64_t
capacity
;
uint64_t
ssize
;
uint64_t
lsize
;
TD_DLIST
(
SVArenaNode
)
nlist
;
uint64_t
capacity
;
uint64_t
ssize
;
uint64_t
lsize
;
SVArenaNode
*
pNode
;
TD_SLIST
(
SVArenaNode
)
nlist
;
};
SVMemAllocator
*
vmaCreate
(
uint64_t
capacity
,
uint64_t
ssize
,
uint64_t
lsize
);
...
...
source/dnode/vnode/impl/src/vnodeArenaMAImpl.c
浏览文件 @
4503901f
...
...
@@ -27,30 +27,25 @@ SVMemAllocator *vmaCreate(uint64_t capacity, uint64_t ssize, uint64_t lsize) {
pVMA
->
capacity
=
capacity
;
pVMA
->
ssize
=
ssize
;
pVMA
->
lsize
=
lsize
;
t
D
ListInit
(
&
(
pVMA
->
nlist
));
t
S
ListInit
(
&
(
pVMA
->
nlist
));
SVArenaNode
*
pNode
=
vArenaNodeNew
(
capacity
);
if
(
pNode
==
NULL
)
{
pVMA
->
pNode
=
vArenaNodeNew
(
capacity
);
if
(
p
VMA
->
p
Node
==
NULL
)
{
free
(
pVMA
);
return
NULL
;
}
t
DListAppend
(
&
(
pVMA
->
nlist
),
pNode
);
t
SListPush
(
&
(
pVMA
->
nlist
),
pVMA
->
pNode
);
return
pVMA
;
}
void
vmaDestroy
(
SVMemAllocator
*
pVMA
)
{
if
(
pVMA
)
{
while
(
true
)
{
SVArenaNode
*
pNode
=
TD_DLIST_TAIL
(
&
(
pVMA
->
nlist
));
if
(
pNode
)
{
tDListPop
(
&
(
pVMA
->
nlist
),
pNode
);
vArenaNodeFree
(
pNode
);
}
else
{
break
;
}
while
(
TD_SLIST_NELES
(
&
(
pVMA
->
nlist
))
>
1
)
{
SVArenaNode
*
pNode
=
TD_SLIST_HEAD
(
&
(
pVMA
->
nlist
));
tSListPop
(
&
(
pVMA
->
nlist
));
vArenaNodeFree
(
pNode
);
}
free
(
pVMA
);
...
...
@@ -58,18 +53,18 @@ void vmaDestroy(SVMemAllocator *pVMA) {
}
void
vmaReset
(
SVMemAllocator
*
pVMA
)
{
while
(
TD_
D
LIST_NELES
(
&
(
pVMA
->
nlist
))
>
1
)
{
SVArenaNode
*
pNode
=
TD_
DLIST_TAIL
(
&
(
pVMA
->
nlist
));
t
DListPop
(
&
(
pVMA
->
nlist
),
pNode
);
while
(
TD_
S
LIST_NELES
(
&
(
pVMA
->
nlist
))
>
1
)
{
SVArenaNode
*
pNode
=
TD_
SLIST_HEAD
(
&
(
pVMA
->
nlist
));
t
SListPop
(
&
(
pVMA
->
nlist
)
);
vArenaNodeFree
(
pNode
);
}
SVArenaNode
*
pNode
=
TD_
D
LIST_HEAD
(
&
(
pVMA
->
nlist
));
SVArenaNode
*
pNode
=
TD_
S
LIST_HEAD
(
&
(
pVMA
->
nlist
));
pNode
->
ptr
=
pNode
->
data
;
}
void
*
vmaMalloc
(
SVMemAllocator
*
pVMA
,
uint64_t
size
)
{
SVArenaNode
*
pNode
=
TD_
DLIST_TAIL
(
&
(
pVMA
->
nlist
));
SVArenaNode
*
pNode
=
TD_
SLIST_HEAD
(
&
(
pVMA
->
nlist
));
void
*
ptr
;
if
(
pNode
->
size
<
POINTER_DISTANCE
(
pNode
->
ptr
,
pNode
->
data
)
+
size
)
{
...
...
@@ -80,7 +75,7 @@ void *vmaMalloc(SVMemAllocator *pVMA, uint64_t size) {
return
NULL
;
}
t
DListAppend
(
&
(
pVMA
->
nlist
),
pNode
);
t
SListPush
(
&
(
pVMA
->
nlist
),
pNode
);
}
ptr
=
pNode
->
ptr
;
...
...
@@ -94,9 +89,9 @@ void vmaFree(SVMemAllocator *pVMA, void *ptr) {
}
bool
vmaIsFull
(
SVMemAllocator
*
pVMA
)
{
SVArenaNode
*
pNode
=
TD_
DLIST_TAIL
(
&
(
pVMA
->
nlist
));
SVArenaNode
*
pNode
=
TD_
SLIST_HEAD
(
&
(
pVMA
->
nlist
));
return
(
TD_
D
LIST_NELES
(
&
(
pVMA
->
nlist
))
>
1
)
||
return
(
TD_
S
LIST_NELES
(
&
(
pVMA
->
nlist
))
>
1
)
||
(
pNode
->
size
<
POINTER_DISTANCE
(
pNode
->
ptr
,
pNode
->
data
)
+
pVMA
->
lsize
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录