提交 5d0074c4 编写于 作者: L Lei Jin

set bytes_per_sync to 1MB if rate limiter is enabled

Summary: as title

Test Plan: make all check

Reviewers: igor, yhchiang, sdong

Reviewed By: sdong

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D21201
上级 2fa64346
...@@ -271,6 +271,12 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) { ...@@ -271,6 +271,12 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) {
} }
} }
if (!result.rate_limiter) {
if (result.bytes_per_sync == 0) {
result.bytes_per_sync = 1024 * 1024;
}
}
if (result.wal_dir.empty()) { if (result.wal_dir.empty()) {
// Use dbname as default // Use dbname as default
result.wal_dir = dbname; result.wal_dir = dbname;
......
...@@ -636,6 +636,7 @@ struct DBOptions { ...@@ -636,6 +636,7 @@ struct DBOptions {
// Use to control write rate of flush and compaction. Flush has higher // Use to control write rate of flush and compaction. Flush has higher
// priority than compaction. Rate limiting is disabled if nullptr. // priority than compaction. Rate limiting is disabled if nullptr.
// If rate limiter is enabled, bytes_per_sync is set to 1MB by default.
// Default: nullptr // Default: nullptr
std::shared_ptr<RateLimiter> rate_limiter; std::shared_ptr<RateLimiter> rate_limiter;
...@@ -857,12 +858,6 @@ struct DBOptions { ...@@ -857,12 +858,6 @@ struct DBOptions {
// Default: false // Default: false
bool use_adaptive_mutex; bool use_adaptive_mutex;
// Allows OS to incrementally sync files to disk while they are being
// written, asynchronously, in the background.
// Issue one request for every bytes_per_sync written. 0 turns it off.
// Default: 0
uint64_t bytes_per_sync;
// Allow RocksDB to use thread local storage to optimize performance. // Allow RocksDB to use thread local storage to optimize performance.
// Default: true // Default: true
bool allow_thread_local; bool allow_thread_local;
...@@ -873,6 +868,16 @@ struct DBOptions { ...@@ -873,6 +868,16 @@ struct DBOptions {
explicit DBOptions(const Options& options); explicit DBOptions(const Options& options);
void Dump(Logger* log) const; void Dump(Logger* log) const;
// Allows OS to incrementally sync files to disk while they are being
// written, asynchronously, in the background.
// Issue one request for every bytes_per_sync written. 0 turns it off.
// Default: 0
//
// You may consider using rate_limiter to regulate write rate to device.
// When rate limiter is enabled, it automatically enables bytes_per_sync
// to 1MB.
uint64_t bytes_per_sync;
}; };
// Options to control the behavior of a database (passed to DB::Open) // Options to control the behavior of a database (passed to DB::Open)
......
...@@ -199,8 +199,8 @@ DBOptions::DBOptions() ...@@ -199,8 +199,8 @@ DBOptions::DBOptions()
advise_random_on_open(true), advise_random_on_open(true),
access_hint_on_compaction_start(NORMAL), access_hint_on_compaction_start(NORMAL),
use_adaptive_mutex(false), use_adaptive_mutex(false),
bytes_per_sync(0), allow_thread_local(true),
allow_thread_local(true) {} bytes_per_sync(0) {}
DBOptions::DBOptions(const Options& options) DBOptions::DBOptions(const Options& options)
: create_if_missing(options.create_if_missing), : create_if_missing(options.create_if_missing),
...@@ -243,8 +243,8 @@ DBOptions::DBOptions(const Options& options) ...@@ -243,8 +243,8 @@ DBOptions::DBOptions(const Options& options)
advise_random_on_open(options.advise_random_on_open), advise_random_on_open(options.advise_random_on_open),
access_hint_on_compaction_start(options.access_hint_on_compaction_start), access_hint_on_compaction_start(options.access_hint_on_compaction_start),
use_adaptive_mutex(options.use_adaptive_mutex), use_adaptive_mutex(options.use_adaptive_mutex),
bytes_per_sync(options.bytes_per_sync), allow_thread_local(options.allow_thread_local),
allow_thread_local(options.allow_thread_local) {} bytes_per_sync(options.bytes_per_sync) {}
static const char* const access_hints[] = { static const char* const access_hints[] = {
"NONE", "NORMAL", "SEQUENTIAL", "WILLNEED" "NONE", "NORMAL", "SEQUENTIAL", "WILLNEED"
...@@ -308,6 +308,8 @@ void DBOptions::Dump(Logger* log) const { ...@@ -308,6 +308,8 @@ void DBOptions::Dump(Logger* log) const {
access_hints[access_hint_on_compaction_start]); access_hints[access_hint_on_compaction_start]);
Log(log, " Options.use_adaptive_mutex: %d", Log(log, " Options.use_adaptive_mutex: %d",
use_adaptive_mutex); use_adaptive_mutex);
Log(log, " Options.rate_limiter: %p",
rate_limiter.get());
Log(log, " Options.bytes_per_sync: %lu", Log(log, " Options.bytes_per_sync: %lu",
(unsigned long)bytes_per_sync); (unsigned long)bytes_per_sync);
} // DBOptions::Dump } // DBOptions::Dump
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册