Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
742d0528
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,发现更多精彩内容 >>
提交
742d0528
编写于
12月 22, 2020
作者:
W
wangyi.ywq
提交者:
奏之章
2月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge ljc
上级
db110312
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
10 deletion
+70
-10
db/db_impl.cc
db/db_impl.cc
+41
-10
db/db_impl.h
db/db_impl.h
+3
-0
db/db_impl_gc_ttl_test.cc
db/db_impl_gc_ttl_test.cc
+26
-0
未找到文件。
db/db_impl.cc
浏览文件 @
742d0528
...
...
@@ -100,8 +100,6 @@
#if !defined(_MSC_VER) && !defined(__APPLE__)
#include <sys/unistd.h>
#endif
#include "utilities/util/valvec.hpp"
...
...
@@ -112,8 +110,9 @@
#ifdef WITH_TERARK_ZIP
#include <table/terark_zip_table.h>
#include <terark/util/fiber_pool.hpp>
#include <terark/thread/fiber_yield.hpp>
#include <terark/util/fiber_pool.hpp>
#endif
#ifdef BOOSTLIB
...
...
@@ -121,7 +120,6 @@
#endif
//#include <boost/context/pooled_fixedsize_stack.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
...
...
@@ -773,8 +771,41 @@ void DBImpl::StartTimedTasks() {
}
}
}
void
DBImpl
::
ScheduleGCTTL
()
{
uint64_t
mark_count
=
0
;
uint64_t
marked_count
=
0
;
uint64_t
nowSeconds
=
env_
->
NowMicros
()
/
1000000
;
auto
should_marked_for_compacted
=
[](
uint64_t
ratio_expire_time
,
uint64_t
scan_gap_expire_time
,
uint64_t
now
)
{
return
(
std
::
min
(
ratio_expire_time
,
scan_gap_expire_time
)
<
now
);
};
ROCKS_LOG_INFO
(
immutable_db_options_
.
info_log
,
"Start ScheduleGCTTL"
);
for
(
auto
cfd
:
*
versions_
->
GetColumnFamilySet
())
{
if
(
cfd
->
initialized
())
{
VersionStorageInfo
*
vsi
=
cfd
->
current
()
->
storage_info
();
for
(
int
l
=
0
;
l
<
vsi
->
num_levels
();
l
++
)
{
for
(
auto
sst
:
vsi
->
LevelFiles
(
l
))
{
if
(
sst
->
marked_for_compaction
)
marked_count
++
;
if
(
!
sst
->
marked_for_compaction
)
sst
->
marked_for_compaction
=
should_marked_for_compacted
(
sst
->
prop
.
ratio_expire_time
,
sst
->
prop
.
scan_gap_expire_time
,
nowSeconds
);
if
(
sst
->
marked_for_compaction
)
{
mark_count
++
;
}
}
}
}
}
ROCKS_LOG_INFO
(
immutable_db_options_
.
info_log
,
"marked for compact SST: %d,%d"
,
marked_count
,
mark_count
);
if
(
mark_count
>
0
)
{
MaybeScheduleFlushOrCompaction
();
}
}
void
DBImpl
::
DumpStats
()
{
ScheduleGCTTL
();
TEST_SYNC_POINT
(
"DBImpl::DumpStats:1"
);
#ifndef ROCKSDB_LITE
const
DBPropertyInfo
*
cf_property_info
=
...
...
@@ -1259,9 +1290,9 @@ void DBImpl::SchedulePurge() {
void
DBImpl
::
BackgroundCallPurge
()
{
mutex_
.
Lock
();
// We use one single loop to clear both queues so that after existing the
loop
//
both queues are empty. This is stricter than what is needed, but can make
// it easier for us to reason the correctness.
// We use one single loop to clear both queues so that after existing the
//
loop both queues are empty. This is stricter than what is needed, but can
//
make
it easier for us to reason the correctness.
while
(
!
purge_queue_
.
empty
()
|
!
superversion_to_free_queue_
.
empty
()
|
!
logs_to_free_queue_
.
empty
())
{
if
(
!
superversion_to_free_queue_
.
empty
())
{
...
...
@@ -2249,8 +2280,8 @@ Status DBImpl::NewIterators(
#endif
}
else
{
// Note: no need to consider the special case of
// last_seq_same_as_publish_seq_==false since NewIterators is overridden
in
// WritePreparedTxnDB
// last_seq_same_as_publish_seq_==false since NewIterators is overridden
//
in
WritePreparedTxnDB
auto
snapshot
=
read_options
.
snapshot
!=
nullptr
?
read_options
.
snapshot
->
GetSequenceNumber
()
:
versions_
->
LastSequence
();
...
...
db/db_impl.h
浏览文件 @
742d0528
...
...
@@ -1151,6 +1151,9 @@ class DBImpl : public DB {
// dump rocksdb.stats to LOG
void
DumpStats
();
//
void
ScheduleGCTTL
();
// Return the minimum empty level that could hold the total data in the
// input level. Return the input level, if such level could not be found.
int
FindMinimumEmptyLevelFitting
(
ColumnFamilyData
*
cfd
,
...
...
db/db_impl_gc_ttl_test.cc
浏览文件 @
742d0528
// Copyright (c) 2020-present, Bytedance Inc. All rights reserved.
// This source code is licensed under Apache 2.0 License.
#include "table/block_based_table_builder.h"
#include "include/rocksdb/ttl_extractor.h"
#include "util/testharness.h"
#include "util/testutil.h"
namespace
rocksdb
{
class
DBImplGCTTL_Test
:
public
testing
::
Test
{
//
private:
};
TEST_F
(
DBImplGCTTL_Test
,
OpenTest
)
{
}
}
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录