Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
soremi
oceanbase
提交
0c2eb7a6
O
oceanbase
项目概览
soremi
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0c2eb7a6
编写于
7月 08, 2022
作者:
N
nroskill
提交者:
wangzelin.wzl
7月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CP] fix memory leak in ObLinearHashMap
上级
9a79be65
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
29 deletion
+35
-29
deps/oblib/src/lib/hash/ob_linear_hash_map.h
deps/oblib/src/lib/hash/ob_linear_hash_map.h
+35
-29
未找到文件。
deps/oblib/src/lib/hash/ob_linear_hash_map.h
浏览文件 @
0c2eb7a6
...
...
@@ -1331,17 +1331,10 @@ void ObLinearHashMap<Key, Value, MemMgrTag>::load_factor_ctrl_(const uint64_t se
int
err
=
ES_INVALID
;
// Refresh load factor in 1/LOAD_FCT_REFR_LMT odd.
/* There are bad cases. Deprecated. */
// It's based on seed, which is key's hash value.
// if (0 == (seed % LOAD_FCT_REFR_LMT)) {
// load_factor_ = (double)do_cnt_() / (double)bkt_cnt_();
//}
/* Use counter instead. */
UNUSED
(
seed
);
int64_t
thread_id
=
get_thread_id_
();
if
(
cnter_
.
op_and_test_lmt
(
LOAD_FCT_REFR_LMT
,
thread_id
))
{
load_factor_
=
static_cast
<
double
>
(
do_cnt_
())
/
static_cast
<
double
>
(
bkt_cnt_
()
);
load_factor_
=
get_load_factor
(
);
}
if
(
load_factor_
>
load_factor_u_limit_
)
{
...
...
@@ -1406,32 +1399,45 @@ int ObLinearHashMap<Key, Value, MemMgrTag>::shrink_()
{
int
ret
=
ES_SUCCESS
;
if
(
es_trylock_
())
{
uint64_t
bucket_cnt
=
bkt_cnt_
();
uint64_t
cnt
=
load_factor_
*
bucket_cnt
;
uint64_t
target_bucket_cnt
=
cnt
/
load_factor_l_limit_
+
1
;
uint64_t
L
=
0
;
uint64_t
p
=
0
;
load_Lp_
(
L
,
p
);
if
(
L
==
0
&&
p
==
0
)
{
ret
=
ES_REACH_LIMIT
;
}
else
if
(
L
==
foreach_L_lmt_
&&
p
==
0
)
{
// Give up so that for_each() has at least N*(2^foreach_L_lmt_) buckets to work with.
ret
=
ES_REACH_FOREACH_LIMIT
;
}
else
{
uint64_t
newL
=
(
p
==
0
)
?
(
L
-
1
)
:
L
;
uint64_t
newp
=
(
p
==
0
)
?
((
L0_bkt_n_
<<
newL
)
-
1
)
:
(
p
-
1
);
Bucket
*
src_bkt
=
NULL
;
Bucket
*
dst_bkt
=
NULL
;
// Shrink.
load_shrink_d_seg_bkts_
(
newL
,
newp
,
src_bkt
,
dst_bkt
);
if
(
ES_SUCCESS
==
(
ret
=
unite_shrink_d_seg_bkts_
(
src_bkt
,
dst_bkt
)))
{
set_Lp_
(
newL
,
newp
);
unload_shrink_d_seg_bkts_
(
src_bkt
,
dst_bkt
,
true
);
// Evict empty seg.
if
(
seg_bkt_idx_
((
L0_bkt_n_
<<
newL
)
+
newp
)
==
0
)
{
des_seg_
(
wait_evict_haz_seg_
(
dir_
[
seg_idx_
((
L0_bkt_n_
<<
newL
)
+
newp
)]));
}
uint64_t
newL
=
L
;
uint64_t
newp
=
p
;
uint64_t
shrink_cnt
=
0
;
// shrink bkt_cnt / 16 bucket at most, 1 bucket at least.
do
{
if
(
newL
==
0
&&
newp
==
0
)
{
ret
=
ES_REACH_LIMIT
;
break
;
}
else
if
(
newL
==
foreach_L_lmt_
&&
newp
==
0
)
{
// Give up so that for_each() has at least N*(2^foreach_L_lmt_) buckets to work with.
ret
=
ES_REACH_FOREACH_LIMIT
;
break
;
}
else
{
unload_shrink_d_seg_bkts_
(
src_bkt
,
dst_bkt
,
false
);
newL
=
(
newp
==
0
)
?
(
newL
-
1
)
:
newL
;
newp
=
(
newp
==
0
)
?
((
L0_bkt_n_
<<
newL
)
-
1
)
:
(
newp
-
1
);
Bucket
*
src_bkt
=
nullptr
;
Bucket
*
dst_bkt
=
nullptr
;
// Shrink.
load_shrink_d_seg_bkts_
(
newL
,
newp
,
src_bkt
,
dst_bkt
);
if
(
ES_SUCCESS
==
(
ret
=
unite_shrink_d_seg_bkts_
(
src_bkt
,
dst_bkt
)))
{
set_Lp_
(
newL
,
newp
);
unload_shrink_d_seg_bkts_
(
src_bkt
,
dst_bkt
,
true
);
// Evict empty seg.
if
(
seg_bkt_idx_
((
L0_bkt_n_
<<
newL
)
+
newp
)
==
0
)
{
des_seg_
(
wait_evict_haz_seg_
(
dir_
[
seg_idx_
((
L0_bkt_n_
<<
newL
)
+
newp
)]));
}
}
else
{
unload_shrink_d_seg_bkts_
(
src_bkt
,
dst_bkt
,
false
);
}
++
shrink_cnt
;
}
}
}
while
(
target_bucket_cnt
+
shrink_cnt
<
bucket_cnt
&&
shrink_cnt
<
(
bucket_cnt
>>
4
));
load_factor_
=
(
static_cast
<
double
>
(
cnt
)
/
static_cast
<
double
>
(
bucket_cnt
-
shrink_cnt
));
es_unlock_
();
}
else
{
ret
=
ES_TRYLOCK_FAILED
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录