diff --git a/conf/pika.conf b/conf/pika.conf index 04a7dd2e5e..5ab58621c9 100644 --- a/conf/pika.conf +++ b/conf/pika.conf @@ -56,3 +56,7 @@ db_sync_speed : -1 binlog_file_size : 104857600 # Compression compression : snappy +# max_background_flushes: default is 1, limited in [1, 4] +max_background_flushes : 1 +# max_background_compactions: default is 1, limited in [1, 4] +max_background_compactions : 1 diff --git a/include/pika_conf.h b/include/pika_conf.h index 5610e1308a..aeeece7299 100644 --- a/include/pika_conf.h +++ b/include/pika_conf.h @@ -44,6 +44,8 @@ class PikaConf : public slash::BaseConf { } std::string compression() { RWLock l(&rwlock_, false); return compression_; } int target_file_size_base() { RWLock l(&rwlock_, false); return target_file_size_base_; } + int max_background_flushes() { RWLock l(&rwlock_, false); return max_background_flushes_; } + int max_background_compactions() { RWLock l(&rwlock_, false); return max_background_compactions_; } int expire_logs_nums() { RWLock l(&rwlock_, false); return expire_logs_nums_; } int expire_logs_days() { RWLock l(&rwlock_, false); return expire_logs_days_; } std::string conf_path() { RWLock l(&rwlock_, false); return conf_path_; } @@ -145,6 +147,9 @@ class PikaConf : public slash::BaseConf { int expire_logs_nums_; bool readonly_; std::string conf_path_; + int max_background_flushes_; + int max_background_compactions_; + //char username_[30]; //char password_[30]; diff --git a/src/pika_admin.cc b/src/pika_admin.cc index 3871a74d9a..7a995e48c6 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -709,6 +709,14 @@ void ConfigCmd::ConfigGet(std::string &ret) { ret = "*2\r\n"; EncodeString(&ret, "target_file_size_base"); EncodeInt32(&ret, g_pika_conf->target_file_size_base()); + } else if (get_item == "max_background_flushes") { + ret = "*2\r\n"; + EncodeString(&ret, "max_background_flushes"); + EncodeInt32(&ret, g_pika_conf->max_background_flushes()); + } else if (get_item == "max_background_compactions") { + ret = "*2\r\n"; + EncodeString(&ret, "max_background_compactions"); + EncodeInt32(&ret, g_pika_conf->max_background_compactions()); } else if (get_item == "expire_logs_days") { ret = "*2\r\n"; EncodeString(&ret, "expire_logs_days"); @@ -742,7 +750,7 @@ void ConfigCmd::ConfigGet(std::string &ret) { EncodeString(&ret, "no"); } } else if (get_item == "*") { - ret = "*28\r\n"; + ret = "*30\r\n"; EncodeString(&ret, "port"); EncodeString(&ret, "thread_num"); EncodeString(&ret, "sync_thread_num"); @@ -762,6 +770,8 @@ void ConfigCmd::ConfigGet(std::string &ret) { EncodeString(&ret, "pidfile"); EncodeString(&ret, "maxconnection"); EncodeString(&ret, "target_file_size_base"); + EncodeString(&ret, "max_background_flushes"); + EncodeString(&ret, "max_background_compactions"); EncodeString(&ret, "expire_logs_days"); EncodeString(&ret, "expire_logs_nums"); EncodeString(&ret, "root_connection_num"); diff --git a/src/pika_conf.cc b/src/pika_conf.cc index cd885a4d09..f57ab3ebb8 100644 --- a/src/pika_conf.cc +++ b/src/pika_conf.cc @@ -98,6 +98,24 @@ int PikaConf::Load() target_file_size_base_ = 1048576; // 10M } + max_background_flushes_ = 1; + GetConfInt("max_background_flushes", &max_background_flushes_); + if (max_background_flushes_ <= 0) { + max_background_flushes_ = 1; + } + if (max_background_flushes_ >= 4) { + max_background_flushes_ = 4; + } + + max_background_compactions_ = 1; + GetConfInt("max_background_compactions", &max_background_compactions_); + if (max_background_compactions_ <= 0) { + max_background_compactions_ = 1; + } + if (max_background_compactions_ >= 4) { + max_background_compactions_ = 4; + } + // daemonize std::string dmz; GetConfStr("daemonize", &dmz); @@ -142,6 +160,8 @@ int PikaConf::ConfigRewrite() { SetConfInt("root_connection_num", root_connection_num_); SetConfInt("slowlog_log_slower_than", slowlog_log_slower_than_); SetConfInt("target_file_size_base", target_file_size_base_); + SetConfInt("max_background_flushes", max_background_flushes_); + SetConfInt("max_background_compactions", max_background_compactions_); SetConfInt("expire_logs_nums", expire_logs_nums_); SetConfInt("expire_logs_days", expire_logs_days_); SetConfBool("slave_read_only", readonly_); diff --git a/src/pika_server.cc b/src/pika_server.cc index a328fff486..7a2475cc70 100644 --- a/src/pika_server.cc +++ b/src/pika_server.cc @@ -41,6 +41,8 @@ PikaServer::PikaServer() : option.write_buffer_size = g_pika_conf->write_buffer_size(); option.target_file_size_base = g_pika_conf->target_file_size_base(); + option.max_background_flushes = g_pika_conf->max_background_flushes(); + option.max_background_compactions = g_pika_conf->max_background_compactions(); if (g_pika_conf->compression() == "none") { option.compression = false; } diff --git a/third/nemo b/third/nemo index 78d0c69e42..d2253ffb5a 160000 --- a/third/nemo +++ b/third/nemo @@ -1 +1 @@ -Subproject commit 78d0c69e4283a52183f8e2d8a53c563749a38238 +Subproject commit d2253ffb5a5b7eff85c74dd95b433330945716e1