Skip to content

Commit

Permalink
Made 'direct' the default WriteBuffer mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
goossaert committed Mar 31, 2015
1 parent 7b97e0a commit 61d5724
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions network/server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ int main(int argc, char** argv) {
kdb::DatabaseOptions::AddParametersToConfigParser(db_options, parser);
kdb::ServerOptions::AddParametersToConfigParser(server_options, parser);

// Overwrite the default value for the WriteBuffer mode
parser.SetDefaultValue("db.write-buffer.mode", "adaptive");

if (argc == 2 && (strncmp(argv[1], "--help", 6) == 0 || strncmp(argv[1], "-h", 2) == 0)) {
fprintf(stdout, "KingServer is a persisted key-value database server, which uses the KingDB library\nas a storage backend. For more information, visit http://kingdb.org\n");
fprintf(stdout, "KingServer version: %d.%d.%d\nKingDB version: %d.%d.%d\nData format version: %d.%d\n", kVersionServerMajor, kVersionServerMinor, kVersionServerRevision, kdb::kVersionMajor, kdb::kVersionMinor, kdb::kVersionRevision, kdb::kVersionDataFormatMajor, kdb::kVersionDataFormatMinor);
Expand Down
12 changes: 12 additions & 0 deletions util/config_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ class ConfigParser {
}
}

void SetDefaultValue(const std::string name, const std::string default_value) {
// This is used to change the default value of a parameter after
// the parameter was added to the parser.
auto it = parameters_.begin();
for (; it != parameters_.end(); ++it) {
if ((*it)->name == name) break;
}
if (it != parameters_.end()) {
(*it)->default_value = default_value;
}
}

bool FoundAllMandatoryParameters() {
return (mandatories_.size() == 0);
}
Expand Down
4 changes: 2 additions & 2 deletions util/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct DatabaseOptions {
hash(kxxHash_64),
compression(kLZ4Compression),
checksum(kCRC32C),
write_buffer__mode(kWriteBufferModeAdaptive) {
write_buffer__mode(kWriteBufferModeDirect) {
DatabaseOptions &db_options = *this;
ConfigParser parser;
AddParametersToConfigParser(db_options, parser);
Expand Down Expand Up @@ -153,7 +153,7 @@ struct DatabaseOptions {
"db.write-buffer.flush-timeout", "500 milliseconds", &db_options.write_buffer__flush_timeout, false,
"The timeout after which the write buffer will flush its cache."));
parser.AddParameter(new kdb::StringParameter(
"db.write-buffer.mode", "adaptive", &db_options.write_buffer__mode_str, false,
"db.write-buffer.mode", "direct", &db_options.write_buffer__mode_str, false,
"The mode with which the write buffer handles incoming traffic, can be 'direct' or 'adaptive'. With the 'direct' mode, once the Write Buffer is full other incoming Write and Delete operations will block until the buffer is persisted to secondary storage. The direct mode should be used when the clients are not subjects to timeouts. When choosing the 'adaptive' mode, incoming orders will be made slower, down to the speed of the writes on the secondary storage, so that they are almost just as fast as when using the direct mode, but are never blocking. The adaptive mode is expected to introduce a small performance decrease, but required for cases where clients timeouts must be avoided, for example when the database is used over a network."));
parser.AddParameter(new kdb::UnsignedInt64Parameter(
"db.storage.hstable-size", "32MB", &db_options.storage__hstable_size, false,
Expand Down

0 comments on commit 61d5724

Please sign in to comment.