提交 853891b9 编写于 作者: C chenchanglong

add flush pri fix and move SetSelfLowPriority into util/file_util.h

上级 6d84bd9b
......@@ -59,6 +59,7 @@
#include "util/coding.h"
#include "util/file_reader_writer.h"
#include "util/filename.h"
#include "util/file_util.h"
#include "util/log_buffer.h"
#include "util/logging.h"
#include "util/mutexlock.h"
......@@ -76,35 +77,6 @@
namespace rocksdb {
namespace {
void SetSelfThreadLowPriority() {
#ifdef OS_LINUX
setpriority(
PRIO_PROCESS,
// Current thread.
0,
// Lowest priority possible.
19);
#define IOPRIO_CLASS_SHIFT (13)
#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
// Put schedule into IOPRIO_CLASS_IDLE class (lowest)
// These system calls only have an effect when used in conjunction
// with an I/O scheduler that supports I/O priorities. As at
// kernel 2.6.17 the only such scheduler is the Completely
// Fair Queuing (CFQ) I/O scheduler.
// To change scheduler:
// echo cfq > /sys/block/<device_name>/queue/schedule
// Tunables to consider:
// /sys/block/<device_name>/queue/slice_idle
// /sys/block/<device_name>/queue/slice_sync
syscall(SYS_ioprio_set, 1, // IOPRIO_WHO_PROCESS
// Current thread.
0,
IOPRIO_PRIO_VALUE(3, 0));
#endif
};
}
const char* GetCompactionReasonString(CompactionReason compaction_reason) {
switch (compaction_reason) {
case CompactionReason::kUnknown:
......
......@@ -290,6 +290,7 @@ void FlushJob::Cancel() {
}
Status FlushJob::WriteLevel0Table() {
SetSelfThreadLowPriority();
AutoThreadOperationStageUpdater stage_updater(
ThreadStatus::STAGE_FLUSH_WRITE_L0);
db_mutex_->AssertHeld();
......
......@@ -8,6 +8,11 @@
#include <string>
#include <algorithm>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include "rocksdb/env.h"
#include "util/sst_file_manager_impl.h"
#include "util/file_reader_writer.h"
......@@ -111,4 +116,31 @@ Status DeleteDBFile(const ImmutableDBOptions* db_options,
#endif
}
void SetSelfThreadLowPriority() {
#ifdef OS_LINUX
setpriority(
PRIO_PROCESS,
// Current thread.
0,
// Lowest priority possible.
19);
#define IOPRIO_CLASS_SHIFT (13)
#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data)
// Put schedule into IOPRIO_CLASS_IDLE class (lowest)
// These system calls only have an effect when used in conjunction
// with an I/O scheduler that supports I/O priorities. As at
// kernel 2.6.17 the only such scheduler is the Completely
// Fair Queuing (CFQ) I/O scheduler.
// To change scheduler:
// echo cfq > /sys/block/<device_name>/queue/schedule
// Tunables to consider:
// /sys/block/<device_name>/queue/slice_idle
// /sys/block/<device_name>/queue/slice_sync
syscall(SYS_ioprio_set, 1, // IOPRIO_WHO_PROCESS
// Current thread.
0,
IOPRIO_PRIO_VALUE(3, 0));
#endif
}
} // namespace rocksdb
......@@ -30,4 +30,6 @@ extern Status DeleteDBFile(const ImmutableDBOptions* db_options,
const std::string& path_to_sync,
const bool force_bg);
extern void SetSelfThreadLowPriority();
} // namespace rocksdb
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册