Skip to content

Commit

Permalink
set bytes_per_sync to 1MB if rate limiter is enabled
Browse files Browse the repository at this point in the history
Summary: as title

Test Plan: make all check

Reviewers: igor, yhchiang, sdong

Reviewed By: sdong

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D21201
  • Loading branch information
Lei Jin committed Aug 12, 2014
1 parent 2fa6434 commit 5d0074c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
// Use dbname as default
result.wal_dir = dbname;
Expand Down
17 changes: 11 additions & 6 deletions include/rocksdb/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ struct DBOptions {

// Use to control write rate of flush and compaction. Flush has higher
// 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
std::shared_ptr<RateLimiter> rate_limiter;

Expand Down Expand Up @@ -857,12 +858,6 @@ struct DBOptions {
// Default: false
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.
// Default: true
bool allow_thread_local;
Expand All @@ -873,6 +868,16 @@ struct DBOptions {
explicit DBOptions(const Options& options);

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)
Expand Down
10 changes: 6 additions & 4 deletions util/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ DBOptions::DBOptions()
advise_random_on_open(true),
access_hint_on_compaction_start(NORMAL),
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)
: create_if_missing(options.create_if_missing),
Expand Down Expand Up @@ -243,8 +243,8 @@ DBOptions::DBOptions(const Options& options)
advise_random_on_open(options.advise_random_on_open),
access_hint_on_compaction_start(options.access_hint_on_compaction_start),
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[] = {
"NONE", "NORMAL", "SEQUENTIAL", "WILLNEED"
Expand Down Expand Up @@ -308,6 +308,8 @@ void DBOptions::Dump(Logger* log) const {
access_hints[access_hint_on_compaction_start]);
Log(log, " Options.use_adaptive_mutex: %d",
use_adaptive_mutex);
Log(log, " Options.rate_limiter: %p",
rate_limiter.get());
Log(log, " Options.bytes_per_sync: %lu",
(unsigned long)bytes_per_sync);
} // DBOptions::Dump
Expand Down

0 comments on commit 5d0074c

Please sign in to comment.