From d6cfd45d4cbef160a0e44e524e0bcdf0babd5817 Mon Sep 17 00:00:00 2001 From: Myth Date: Fri, 22 Oct 2021 09:14:45 +0800 Subject: [PATCH 1/5] Improve the description of Perflog in default config file --- kvrocks.conf | 57 +++++++++++++++++++++++++++++++++++--------------- src/config.cc | 9 +++++--- src/storage.cc | 2 +- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/kvrocks.conf b/kvrocks.conf index 6876adb4ff3..d72f965f8c9 100644 --- a/kvrocks.conf +++ b/kvrocks.conf @@ -213,23 +213,6 @@ max-backup-to-keep 1 # default: 1 day max-backup-keep-hours 24 -# Ratio of the samples would be recorded when the profiling was enabled. -# we simply use the rand to determine whether to record the sample or not. -# -# Default: 0 -profiling-sample-ratio 0 - -# There is no limit to this length. Just be aware that it will consume memory. -# You can reclaim memory used by the perf log with PERFLOG RESET. -# -# Default: 256 -profiling-sample-record-max-len 256 - -# profiling-sample-record-threshold-ms use to tell the kvrocks when to record. -# -# Default: 100 millisecond -profiling-sample-record-threshold-ms 100 - ################################## SLOW LOG ################################### # The Kvrocks Slow Log is a system to log queries that exceeded a specified @@ -265,6 +248,46 @@ slowlog-max-len 128 # They do not enable continuous liveness pings back to your supervisor. supervised no +################################## PERF LOG ################################### + +# The Kvrocks Perf Log is a system to log queries' performance context that +# exceeded a specified execution time. This mechanism uses rocksdb's +# Perf Context and IO Stats Context, Please see: +# https://github.com/facebook/rocksdb/wiki/Perf-Context-and-IO-Stats-Context +# +# This mechanism is enabled when profiling-sample-commands is not empty and +# profiling-sample-ratio greater than 0. +# It is important to note that this mechanism affects performance, but it is +# useful for troubleshooting performance bottlenecks, so it should only be +# enabled when performance problems occur. + +# The name of the commands you want to record. Must be original name of +# commands supported by Kvrocks. Use ',' to separate multiple commands and +# use '*' to record all commands supported by Kvrocks. +# Example: +# - Single command: profiling-sample-commands get +# - Multiple commands: profiling-sample-commands get,mget,hget +# +# Default: empty +# profiling-sample-commands "" + +# Ratio of the samples would be recorded. We simply use the rand to determine +# whether to record the sample or not. +# +# Default: 0 +profiling-sample-ratio 0 + +# There is no limit to this length. Just be aware that it will consume memory. +# You can reclaim memory used by the perf log with PERFLOG RESET. +# +# Default: 256 +profiling-sample-record-max-len 256 + +# profiling-sample-record-threshold-ms use to tell the kvrocks when to record. +# +# Default: 100 millisecond +profiling-sample-record-threshold-ms 100 + ################################## CRON ################################### # Compact Scheduler, auto compact at schedule time diff --git a/src/config.cc b/src/config.cc index 6b5677e0866..8c232449a55 100644 --- a/src/config.cc +++ b/src/config.cc @@ -267,10 +267,13 @@ void Config::initFieldCallback() { if (cmd == "*") { profiling_sample_all_commands = true; profiling_sample_commands.clear(); - } else if (Redis::IsCommandExists(cmd)) { - // profiling_sample_commands use command's original name, regardless of rename-command directive - profiling_sample_commands.insert(cmd); + return Status::OK(); } + if (!Redis::IsCommandExists(cmd)) { + return Status(Status::NotOK, cmd + " is not Kvrocks supported command"); + } + // profiling_sample_commands use command's original name, regardless of rename-command directive + profiling_sample_commands.insert(cmd); } return Status::OK(); }}, diff --git a/src/storage.cc b/src/storage.cc index 011dedac7c1..e49a203f783 100644 --- a/src/storage.cc +++ b/src/storage.cc @@ -76,7 +76,7 @@ void Storage::InitOptions(rocksdb::Options *options) { // NOTE: the overhead of statistics is 5%-10%, so it should be configurable in prod env // See: https://github.com/facebook/rocksdb/wiki/Statistics options->statistics = rocksdb::CreateDBStatistics(); - options->stats_dump_period_sec = 0; + options->stats_dump_period_sec = config_->RocksDB.stats_dump_period_sec; options->OptimizeLevelStyleCompaction(); options->max_open_files = config_->RocksDB.max_open_files; options->max_subcompactions = static_cast(config_->RocksDB.max_sub_compactions); From 7d826ac57d49e8840c54020ad2dcb7d572f1541c Mon Sep 17 00:00:00 2001 From: Myth Date: Fri, 22 Oct 2021 15:29:58 +0800 Subject: [PATCH 2/5] Fixed uninitialized command table bug in ut --- tests/config_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/config_test.cc b/tests/config_test.cc index b2ecce745b0..5fe837e1d81 100644 --- a/tests/config_test.cc +++ b/tests/config_test.cc @@ -9,6 +9,8 @@ TEST(Config, GetAndSet) { Config config; config.Load(path); + Redis::InitAllCommandsTable(); + Redis::PopulateCommands(); std::map mutable_cases = { {"timeout" , "1000"}, {"maxclients" , "2000"}, From f20c19e6725afc6fd95adbd4b422f47bf544aef3 Mon Sep 17 00:00:00 2001 From: Myth Date: Fri, 22 Oct 2021 15:53:22 +0800 Subject: [PATCH 3/5] Fixed spelling mistakes --- tests/config_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/config_test.cc b/tests/config_test.cc index 5fe837e1d81..b62edeeb1c5 100644 --- a/tests/config_test.cc +++ b/tests/config_test.cc @@ -9,7 +9,7 @@ TEST(Config, GetAndSet) { Config config; config.Load(path); - Redis::InitAllCommandsTable(); + Redis::InitCommandsTable(); Redis::PopulateCommands(); std::map mutable_cases = { {"timeout" , "1000"}, From 37a3be1817a8ae09862cd9c355d641731e246c4f Mon Sep 17 00:00:00 2001 From: Myth Date: Fri, 22 Oct 2021 16:28:02 +0800 Subject: [PATCH 4/5] Add some comments --- tests/config_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/config_test.cc b/tests/config_test.cc index b62edeeb1c5..b427bda8276 100644 --- a/tests/config_test.cc +++ b/tests/config_test.cc @@ -9,6 +9,8 @@ TEST(Config, GetAndSet) { Config config; config.Load(path); + // Config.Set need accessing commands, so we should init and populate + // the command table here. Redis::InitCommandsTable(); Redis::PopulateCommands(); std::map mutable_cases = { From 2096a0ed3991b8f8eb39714420c95dbb012bc616 Mon Sep 17 00:00:00 2001 From: Myth Date: Fri, 22 Oct 2021 17:10:24 +0800 Subject: [PATCH 5/5] Changed a little words --- kvrocks.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kvrocks.conf b/kvrocks.conf index d72f965f8c9..5eeac263af0 100644 --- a/kvrocks.conf +++ b/kvrocks.conf @@ -215,7 +215,7 @@ max-backup-keep-hours 24 ################################## SLOW LOG ################################### -# The Kvrocks Slow Log is a system to log queries that exceeded a specified +# The Kvrocks Slow Log is a mechanism to log queries that exceeded a specified # execution time. The execution time does not include the I/O operations # like talking with the client, sending the reply and so forth, # but just the time needed to actually execute the command (this is the only @@ -250,7 +250,7 @@ supervised no ################################## PERF LOG ################################### -# The Kvrocks Perf Log is a system to log queries' performance context that +# The Kvrocks Perf Log is a mechanism to log queries' performance context that # exceeded a specified execution time. This mechanism uses rocksdb's # Perf Context and IO Stats Context, Please see: # https://github.com/facebook/rocksdb/wiki/Perf-Context-and-IO-Stats-Context