Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
67412e05
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,发现更多精彩内容 >>
提交
67412e05
编写于
3月 20, 2020
作者:
Z
ZhaoMing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable fiber compaction
上级
40c09e40
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
24 addition
and
32 deletion
+24
-32
db/c.cc
db/c.cc
+0
-2
db/compaction_job.cc
db/compaction_job.cc
+2
-4
db/db_impl.cc
db/db_impl.cc
+0
-2
db/db_impl_open.cc
db/db_impl_open.cc
+0
-6
include/rocksdb/options.h
include/rocksdb/options.h
+1
-1
monitoring/instrumented_mutex.cc
monitoring/instrumented_mutex.cc
+6
-3
monitoring/instrumented_mutex.h
monitoring/instrumented_mutex.h
+14
-12
util/threadpool_imp.cc
util/threadpool_imp.cc
+1
-2
未找到文件。
db/c.cc
浏览文件 @
67412e05
...
...
@@ -2473,8 +2473,6 @@ void rocksdb_options_set_max_background_jobs(rocksdb_options_t* opt, int n) {
}
void
rocksdb_options_set_max_task_per_thread
(
rocksdb_options_t
*
opt
,
int
n
)
{
// NOT released
n
=
1
;
opt
->
rep
.
max_task_per_thread
=
n
;
}
...
...
db/compaction_job.cc
浏览文件 @
67412e05
...
...
@@ -1332,8 +1332,7 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) {
size_t
yield_count
=
0
;
while
(
status
.
ok
()
&&
!
cfd
->
IsDropped
()
&&
c_iter
->
Valid
())
{
if
(
max_task_per_thread_
>
1
&&
++
yield_count
%
128
==
0
)
{
// NOT released
//boost::this_fiber::yield();
boost
::
this_fiber
::
yield
();
}
// Invariant: c_iter.status() is guaranteed to be OK if c_iter->Valid()
// returns true.
...
...
@@ -1652,8 +1651,7 @@ void CompactionJob::ProcessGarbageCollection(SubcompactionState* sub_compact) {
while
(
status
.
ok
()
&&
!
cfd
->
IsDropped
()
&&
input
->
Valid
())
{
++
counter
.
input
;
if
(
max_task_per_thread_
>
1
&&
counter
.
input
%
32
==
0
)
{
// NOT released
//boost::this_fiber::yield();
boost
::
this_fiber
::
yield
();
}
Slice
curr_key
=
input
->
key
();
uint64_t
curr_file_number
=
uint64_t
(
-
1
);
...
...
db/db_impl.cc
浏览文件 @
67412e05
...
...
@@ -912,8 +912,6 @@ Status DBImpl::SetDBOptions(
s
=
GetMutableDBOptionsFromStrings
(
mutable_db_options_
,
options_map
,
&
new_options
);
if
(
s
.
ok
())
{
// NOT released
new_options
.
max_task_per_thread
=
1
;
auto
bg_job_limits
=
DBImpl
::
GetBGJobLimits
(
immutable_db_options_
.
max_background_flushes
,
new_options
.
max_background_compactions
,
...
...
db/db_impl_open.cc
浏览文件 @
67412e05
...
...
@@ -70,8 +70,6 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) {
result
.
env
->
IncBackgroundThreadsIfNeeded
(
bg_job_limits
.
max_flushes
,
Env
::
Priority
::
HIGH
);
// NOT released
result
.
max_task_per_thread
=
1
;
if
(
result
.
max_task_per_thread
<
1
)
{
result
.
max_task_per_thread
=
1
;
}
...
...
@@ -218,10 +216,6 @@ static Status ValidateOptions(
"More than four DB paths are not supported yet. "
);
}
if
(
db_options
.
max_task_per_thread
!=
1
)
{
return
Status
::
InvalidArgument
(
"NOT released"
);
}
if
(
db_options
.
max_task_per_thread
>
4
||
db_options
.
max_task_per_thread
<
1
)
{
return
Status
::
InvalidArgument
(
...
...
include/rocksdb/options.h
浏览文件 @
67412e05
...
...
@@ -547,7 +547,7 @@ struct DBOptions {
int
max_background_jobs
=
2
;
// Max task per BG threads
// valid [1 ,
4
]
// valid [1 ,
8
]
int
max_task_per_thread
=
1
;
// NOT SUPPORTED ANYMORE: RocksDB automatically decides this based on the
...
...
monitoring/instrumented_mutex.cc
浏览文件 @
67412e05
...
...
@@ -31,7 +31,7 @@ void InstrumentedMutex::LockInternal() {
#ifndef NDEBUG
ThreadStatusUtil
::
TEST_StateDelay
(
ThreadStatus
::
STATE_MUTEX_WAIT
);
#endif
mutex_
.
L
ock
();
mutex_
.
l
ock
();
}
void
InstrumentedCondVar
::
Wait
()
{
...
...
@@ -45,7 +45,8 @@ void InstrumentedCondVar::WaitInternal() {
#ifndef NDEBUG
ThreadStatusUtil
::
TEST_StateDelay
(
ThreadStatus
::
STATE_MUTEX_WAIT
);
#endif
cond_
.
Wait
();
std
::
unique_lock
<
boost
::
fibers
::
mutex
>
lock
(
*
mutex_
);
cond_
.
wait
(
lock
);
}
bool
InstrumentedCondVar
::
TimedWait
(
uint64_t
abs_time_us
)
{
...
...
@@ -63,7 +64,9 @@ bool InstrumentedCondVar::TimedWaitInternal(uint64_t abs_time_us) {
TEST_SYNC_POINT_CALLBACK
(
"InstrumentedCondVar::TimedWaitInternal"
,
&
abs_time_us
);
return
cond_
.
TimedWait
(
abs_time_us
);
std
::
unique_lock
<
boost
::
fibers
::
mutex
>
lock
(
*
mutex_
);
return
cond_
.
wait_for
(
lock
,
std
::
chrono
::
microseconds
(
abs_time_us
))
==
boost
::
fibers
::
cv_status
::
timeout
;
}
}
// namespace rocksdb
monitoring/instrumented_mutex.h
浏览文件 @
67412e05
...
...
@@ -6,7 +6,7 @@
#pragma once
#include "monitoring/statistics.h"
#include
"port/port.h"
#include
<boost/fiber/all.hpp>
#include "rocksdb/env.h"
#include "rocksdb/statistics.h"
#include "rocksdb/thread_status.h"
...
...
@@ -19,30 +19,30 @@ class InstrumentedCondVar;
// for collecting stats and instrumentation.
class
InstrumentedMutex
{
public:
explicit
InstrumentedMutex
(
bool
adaptive
=
false
)
:
mutex_
(
adaptive
),
stats_
(
nullptr
),
env_
(
nullptr
),
explicit
InstrumentedMutex
(
bool
/*adaptive*/
=
false
)
:
mutex_
(),
stats_
(
nullptr
),
env_
(
nullptr
),
stats_code_
(
0
)
{}
InstrumentedMutex
(
Statistics
*
stats
,
Env
*
env
,
int
stats_code
,
bool
adaptive
=
false
)
:
mutex_
(
adaptive
),
stats_
(
stats
),
env_
(
env
),
int
stats_code
,
bool
/*adaptive*/
=
false
)
:
mutex_
(),
stats_
(
stats
),
env_
(
env
),
stats_code_
(
stats_code
)
{}
void
Lock
();
void
Unlock
()
{
mutex_
.
U
nlock
();
mutex_
.
u
nlock
();
}
void
AssertHeld
()
{
mutex_
.
AssertHeld
(
);
assert
(
!
mutex_
.
try_lock
()
);
}
private:
void
LockInternal
();
friend
class
InstrumentedCondVar
;
port
::
M
utex
mutex_
;
boost
::
fibers
::
m
utex
mutex_
;
Statistics
*
stats_
;
Env
*
env_
;
int
stats_code_
;
...
...
@@ -69,7 +69,8 @@ class InstrumentedMutexLock {
class
InstrumentedCondVar
{
public:
explicit
InstrumentedCondVar
(
InstrumentedMutex
*
instrumented_mutex
)
:
cond_
(
&
(
instrumented_mutex
->
mutex_
)),
:
cond_
(),
mutex_
(
&
instrumented_mutex
->
mutex_
),
stats_
(
instrumented_mutex
->
stats_
),
env_
(
instrumented_mutex
->
env_
),
stats_code_
(
instrumented_mutex
->
stats_code_
)
{}
...
...
@@ -79,17 +80,18 @@ class InstrumentedCondVar {
bool
TimedWait
(
uint64_t
abs_time_us
);
void
Signal
()
{
cond_
.
Signal
();
cond_
.
notify_one
();
}
void
SignalAll
()
{
cond_
.
SignalA
ll
();
cond_
.
notify_a
ll
();
}
private:
void
WaitInternal
();
bool
TimedWaitInternal
(
uint64_t
abs_time_us
);
port
::
CondVar
cond_
;
boost
::
fibers
::
condition_variable
cond_
;
boost
::
fibers
::
mutex
*
mutex_
;
Statistics
*
stats_
;
Env
*
env_
;
int
stats_code_
;
...
...
util/threadpool_imp.cc
浏览文件 @
67412e05
...
...
@@ -363,8 +363,7 @@ void ThreadPoolImpl::Impl::SetBackgroundThreadsInternal(
return
;
}
if
(
max_task_per_thread
>
0
)
{
// NOT released
//max_task_per_thread_ = max_task_per_thread;
max_task_per_thread_
=
max_task_per_thread
;
}
if
(
num
>=
0
&&
(
num
>
total_threads_limit_
||
(
num
<
total_threads_limit_
&&
allow_reduce
)))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录