Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
45f97506
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
45f97506
编写于
1月 09, 2020
作者:
C
chenchanglong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change size method
上级
55ce6b6c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
58 deletion
+56
-58
db/version_set.cc
db/version_set.cc
+47
-50
db/version_set.h
db/version_set.h
+9
-8
未找到文件。
db/version_set.cc
浏览文件 @
45f97506
...
...
@@ -969,10 +969,10 @@ uint64_t VersionStorageInfo::GetEstimatedActiveKeys() const {
// (1) there exist merge keys
// (2) keys are directly overwritten
// (3) deletion on non-existing keys
if
(
actual_accumulated_num_entries_
<=
actual_accumulated
_num_deletions_
)
{
if
(
lsm_num_entries_
<=
lsm
_num_deletions_
)
{
return
0
;
}
return
accumulated_num_entries_
-
actual_accumulated
_num_deletions_
;
return
lsm_num_entries_
-
lsm
_num_deletions_
;
}
double
VersionStorageInfo
::
GetEstimatedCompressionRatioAtLevel
(
...
...
@@ -985,9 +985,8 @@ double VersionStorageInfo::GetEstimatedCompressionRatioAtLevel(
void
*
args
;
}
get_file_info
;
auto
get_file_size_lambda
=
[
this
,
&
get_file_info
](
const
FileMetaData
*
f
,
uint64_t
file_number
=
uint64_t
(
-
1
))
->
std
::
pair
<
uint64_t
,
uint64_t
>
{
const
FileMetaData
*
f
,
uint64_t
file_number
=
uint64_t
(
-
1
))
->
std
::
pair
<
uint64_t
,
uint64_t
>
{
if
(
f
==
nullptr
)
{
auto
find
=
dependence_map_
.
find
(
file_number
);
if
(
find
==
dependence_map_
.
end
())
{
...
...
@@ -1171,11 +1170,12 @@ VersionStorageInfo::VersionStorageInfo(
compaction_score_
(
num_levels_
),
compaction_level_
(
num_levels_
),
l0_delay_trigger_count_
(
0
),
accumulated_file_size_
(
0
),
accumulated_num_entries_
(
0
),
accumulated_num_deletions_
(
0
),
actual_accumulated_num_entries_
(
0
),
actual_accumulated_num_deletions_
(
0
),
blob_file_size_
(
0
),
blob_num_entries_
(
0
),
blob_num_antiquation_
(
0
),
actual_blob_file_size_
(
0
),
lsm_num_entries_
(
0
),
lsm_num_deletions_
(
0
),
estimated_compaction_needed_bytes_
(
0
),
total_garbage_ratio_
(
0
),
finalized_
(
false
),
...
...
@@ -1460,13 +1460,14 @@ void Version::PrepareApply(const MutableCFOptions& mutable_cf_options) {
}
void
VersionStorageInfo
::
UpdateAccumulatedStats
(
FileMetaData
*
file_meta
)
{
accumulated_file_size_
+=
file_meta
->
fd
.
GetFileSize
();
if
(
file_meta
->
is_skip_gc
)
{
actual_accumulated_num_entries_
+=
file_meta
->
prop
.
num_entries
;
actual_accumulated_num_deletions_
+=
file_meta
->
prop
.
num_deletions
;
actual_blob_file_size_
+=
file_meta
->
fd
.
GetFileSize
();
lsm_num_entries_
+=
file_meta
->
prop
.
num_entries
;
lsm_num_deletions_
+=
file_meta
->
prop
.
num_deletions
;
}
else
{
accumulated_num_entries_
+=
file_meta
->
prop
.
num_entries
;
accumulated_num_deletions_
+=
file_meta
->
prop
.
num_deletions
;
blob_file_size_
+=
file_meta
->
fd
.
GetFileSize
();
blob_num_entries_
+=
file_meta
->
prop
.
num_entries
;
blob_num_antiquation_
+=
file_meta
->
prop
.
num_antiquation
;
}
}
...
...
@@ -1478,10 +1479,10 @@ void VersionStorageInfo::ComputeCompensatedSizes() {
uint64_t
file_number
,
uint64_t
entry_count
);
void
*
args
;
}
compute_compensated_size
;
auto
compute_compensated_size_lambda
=
[
this
,
average_value_size
,
&
compute_compensated_size
](
const
FileMetaData
*
f
,
uint64_t
file_number
=
uint64_t
(
-
1
),
uint64_t
entry_count
=
0
)
->
uint64_t
{
auto
compute_compensated_size_lambda
=
[
this
,
average_value_size
,
&
compute_compensated_size
](
const
FileMetaData
*
f
,
uint64_t
file_number
=
uint64_t
(
-
1
),
uint64_t
entry_count
=
0
)
->
uint64_t
{
if
(
f
==
nullptr
)
{
auto
find
=
dependence_map_
.
find
(
file_number
);
if
(
find
==
dependence_map_
.
end
())
{
...
...
@@ -1834,17 +1835,16 @@ void VersionStorageInfo::AddFile(int level, FileMetaData* f,
bool
(
*
exists
)(
void
*
,
uint64_t
),
void
*
exists_args
,
Logger
*
info_log
)
{
auto
*
level_files
=
&
files_
[
level
];
// Must not overlap
// Must not overlap
#ifndef NDEBUG
if
(
level
>
0
&&
!
level_files
->
empty
()
&&
internal_comparator_
->
Compare
(
level_files
->
back
()
->
largest
,
f
->
smallest
)
>=
0
)
{
auto
*
f2
=
level_files
->
back
();
if
(
info_log
!=
nullptr
)
{
Error
(
info_log
,
"Adding new file %"
PRIu64
" range (%s, %s) to level %d but overlapping "
"with existing file %"
PRIu64
" %s %s"
,
Error
(
info_log
,
"Adding new file %"
PRIu64
" range (%s, %s) to level %d but overlapping "
"with existing file %"
PRIu64
" %s %s"
,
f
->
fd
.
GetNumber
(),
f
->
smallest
.
DebugString
(
true
).
c_str
(),
f
->
largest
.
DebugString
(
true
).
c_str
(),
level
,
f2
->
fd
.
GetNumber
(),
f2
->
smallest
.
DebugString
(
true
).
c_str
(),
...
...
@@ -2070,18 +2070,16 @@ void VersionStorageInfo::UpdateFilesByCompactionPri(
CompareCompensatedSizeDescending
);
break
;
case
kOldestLargestSeqFirst
:
std
::
sort
(
temp
.
begin
(),
temp
.
end
(),
[](
const
Fsize
&
f1
,
const
Fsize
&
f2
)
->
bool
{
return
f1
.
file
->
fd
.
largest_seqno
<
f2
.
file
->
fd
.
largest_seqno
;
});
std
::
sort
(
temp
.
begin
(),
temp
.
end
(),
[](
const
Fsize
&
f1
,
const
Fsize
&
f2
)
->
bool
{
return
f1
.
file
->
fd
.
largest_seqno
<
f2
.
file
->
fd
.
largest_seqno
;
});
break
;
case
kOldestSmallestSeqFirst
:
std
::
sort
(
temp
.
begin
(),
temp
.
end
(),
[](
const
Fsize
&
f1
,
const
Fsize
&
f2
)
->
bool
{
return
f1
.
file
->
fd
.
smallest_seqno
<
f2
.
file
->
fd
.
smallest_seqno
;
});
std
::
sort
(
temp
.
begin
(),
temp
.
end
(),
[](
const
Fsize
&
f1
,
const
Fsize
&
f2
)
->
bool
{
return
f1
.
file
->
fd
.
smallest_seqno
<
f2
.
file
->
fd
.
smallest_seqno
;
});
break
;
case
kMinOverlappingRatio
:
SortFileByOverlappingRatio
(
*
internal_comparator_
,
files_
[
level
],
...
...
@@ -2775,14 +2773,13 @@ void VersionStorageInfo::CalculateBaseBytes(const ImmutableCFOptions& ioptions,
uint64_t
VersionStorageInfo
::
EstimateLiveDataSize
()
const
{
// See VersionStorageInfo::GetEstimatedActiveKeys
if
(
actual_accumulated_num_entries_
+
accumulated_num_entries_
<=
actual_accumulated_num_deletions_
+
accumulated_num_deletions_
)
{
return
0
;
size_t
ret
=
lsm_file_size_
*
(
lsm_num_deletions_
)
/
(
lsm_num_entries_
+
lsm_num_deletions_
);
if
(
blob_num_entries_
>
blob_num_antiquation_
)
{
ret
+=
(
blob_num_entries_
-
blob_num_antiquation_
)
*
blob_file_size_
*
(
lsm_num_deletions_
)
/
(
lsm_num_entries_
+
lsm_num_deletions_
);
}
return
accumulated_file_size_
*
(
actual_accumulated_num_entries_
+
accumulated_num_entries_
-
actual_accumulated_num_deletions_
+
accumulated_num_deletions_
)
/
(
actual_accumulated_num_entries_
+
accumulated_num_entries_
);
return
ret
;
}
bool
VersionStorageInfo
::
RangeMightExistAfterSortedRun
(
...
...
@@ -3302,9 +3299,8 @@ Status VersionSet::ProcessManifestWrites(
delete
v
;
}
if
(
new_descriptor_log
)
{
ROCKS_LOG_INFO
(
db_options_
->
info_log
,
"Deleting manifest %"
PRIu64
" current manifest %"
PRIu64
"
\n
"
,
ROCKS_LOG_INFO
(
db_options_
->
info_log
,
"Deleting manifest %"
PRIu64
" current manifest %"
PRIu64
"
\n
"
,
manifest_file_number_
,
pending_manifest_file_number_
);
descriptor_log_
.
reset
();
env_
->
DeleteFile
(
...
...
@@ -3390,9 +3386,9 @@ Status VersionSet::LogAndApply(
first_writer
.
cv
.
Wait
();
}
if
(
first_writer
.
done
)
{
// All non-CF-manipulation operations can be grouped together and committed
// to MANIFEST. They should all have finished. The status code is stored in
// the first manifest writer.
// All non-CF-manipulation operations can be grouped together and committed
// to MANIFEST. They should all have finished. The status code is stored in
// the first manifest writer.
#ifndef NDEBUG
for
(
const
auto
&
writer
:
writers
)
{
assert
(
writer
.
done
);
...
...
@@ -4523,9 +4519,10 @@ InternalIterator* VersionSet::MakeInputIterator(
// Level-0 files have to be merged together. For other levels,
// we will make a concatenating iterator per level.
// TODO(opt): use concatenating iterator for level-0 if there is no overlap
const
size_t
space
=
(
c
->
level
()
<=
0
?
c
->
input_levels
(
0
)
->
num_files
+
c
->
num_input_levels
()
-
1
:
c
->
num_input_levels
());
const
size_t
space
=
(
c
->
level
()
<=
0
?
c
->
input_levels
(
0
)
->
num_files
+
c
->
num_input_levels
()
-
1
:
c
->
num_input_levels
());
InternalIterator
**
list
=
new
InternalIterator
*
[
space
];
auto
&
dependence_map
=
c
->
input_version
()
->
storage_info
()
->
dependence_map
();
size_t
num
=
0
;
...
...
db/version_set.h
浏览文件 @
45f97506
...
...
@@ -413,12 +413,12 @@ class VersionStorageInfo {
std
::
string
DebugString
(
bool
hex
=
false
)
const
;
uint64_t
GetAverageValueSize
()
const
{
if
(
accumulated
_num_entries_
==
0
||
accumulated
_num_entries_
==
accumulated_num_deletions_
)
{
if
(
blob
_num_entries_
==
0
||
blob
_num_entries_
==
accumulated_num_deletions_
)
{
return
0
;
}
return
accumulated_file_size_
/
(
accumulated
_num_entries_
-
accumulated_num_deletions_
);
(
blob
_num_entries_
-
accumulated_num_deletions_
);
}
uint64_t
GetEstimatedActiveKeys
()
const
;
...
...
@@ -562,11 +562,12 @@ class VersionStorageInfo {
int
l0_delay_trigger_count_
=
0
;
// Count used to trigger slow down and stop
// for number of L0 files.
uint64_t
accumulated_file_size_
;
uint64_t
accumulated_num_entries_
;
uint64_t
accumulated_num_deletions_
;
uint64_t
actual_accumulated_num_entries_
;
uint64_t
actual_accumulated_num_deletions_
;
uint64_t
blob_file_size_
;
uint64_t
blob_num_entries_
;
uint64_t
blob_num_antiquation_
;
uint64_t
lsm_file_size_
;
uint64_t
lsm_num_entries_
;
uint64_t
lsm_num_deletions_
;
// Estimated bytes needed to be compacted until all levels' size is down to
// target sizes.
uint64_t
estimated_compaction_needed_bytes_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录