diff --git a/src/config.cc b/src/config.cc index 6a73ea71772..2541f9f5a0f 100644 --- a/src/config.cc +++ b/src/config.cc @@ -548,7 +548,7 @@ Status Config::Set(std::string key, const std::string &value, Server *svr) { auto s = Util::StringToNum(value, &i, 0, INT_MAX); if (!s.IsOK()) return s; profiling_sample_record_max_len = static_cast(i); - svr->GetPerLog()->SetMaxEntries(profiling_sample_record_max_len); + svr->GetPerfLog()->SetMaxEntries(profiling_sample_record_max_len); return Status::OK(); } if (key == "profiling-sample-commands") { diff --git a/src/redis_cmd.cc b/src/redis_cmd.cc index 6f677d70d35..f1e5e75b1da 100644 --- a/src/redis_cmd.cc +++ b/src/redis_cmd.cc @@ -2769,7 +2769,7 @@ class CommandPerfLog : public Commander { } Status Execute(Server *srv, Connection *conn, std::string *output) override { - auto perf_log = srv->GetPerLog(); + auto perf_log = srv->GetPerfLog(); if (subcommand_ == "len") { *output = Redis::Integer(perf_log->Len()); } else if (subcommand_ == "reset") { diff --git a/src/redis_request.cc b/src/redis_request.cc index 3754534af3f..d6cf171a018 100644 --- a/src/redis_request.cc +++ b/src/redis_request.cc @@ -114,7 +114,7 @@ bool Request::turnOnProfilingIfNeed(const std::string &cmd) { return false; } -void Request::recordProfilingIfNeed(const std::string &cmd, uint64_t duration) { +void Request::recordProfilingSampleIfNeed(const std::string &cmd, uint64_t duration) { int threshold = svr_->GetConfig()->profiling_sample_record_threshold_ms; if (threshold > 0 && static_cast(duration/1000) < threshold) { rocksdb::SetPerfLevel(rocksdb::PerfLevel::kDisable); @@ -124,7 +124,7 @@ void Request::recordProfilingIfNeed(const std::string &cmd, uint64_t duration) { std::string iostats_context = rocksdb::get_iostats_context()->ToString(true); rocksdb::SetPerfLevel(rocksdb::PerfLevel::kDisable); if (perf_context.empty()) return; // request without db operation - svr_->GetPerLog()->PushEntry({cmd, std::move(perf_context), + svr_->GetPerfLog()->PushEntry({cmd, std::move(perf_context), std::move(iostats_context), duration, 0}); } @@ -178,7 +178,7 @@ void Request::ExecuteCommands(Connection *conn) { svr_->DecrExecutingCommandNum(); auto end = std::chrono::high_resolution_clock::now(); uint64_t duration = std::chrono::duration_cast(end-start).count(); - if (is_profiling) recordProfilingIfNeed(conn->current_cmd_->Name(), duration); + if (is_profiling) recordProfilingSampleIfNeed(conn->current_cmd_->Name(), duration); svr_->SlowlogPushEntryIfNeeded(conn->current_cmd_->Args(), duration); svr_->stats_.IncrLatency(static_cast(duration), conn->current_cmd_->Name()); svr_->FeedMonitorConns(conn, cmd_tokens); diff --git a/src/redis_request.h b/src/redis_request.h index 2634699cd5a..7e7992eaa4a 100644 --- a/src/redis_request.h +++ b/src/redis_request.h @@ -38,7 +38,7 @@ class Request { Server *svr_; bool inCommandWhitelist(const std::string &command); bool turnOnProfilingIfNeed(const std::string &cmd); - void recordProfilingIfNeed(const std::string &cmd, uint64_t duration); + void recordProfilingSampleIfNeed(const std::string &cmd, uint64_t duration); }; } // namespace Redis diff --git a/src/server.h b/src/server.h index 44e0dcebf63..182e5aa8ef0 100644 --- a/src/server.h +++ b/src/server.h @@ -142,7 +142,7 @@ class Server { void KillClient(int64_t *killed, std::string addr, uint64_t id, bool skipme, Redis::Connection *conn); void SetReplicationRateLimit(uint64_t max_replication_mb); - PerfLog *GetPerLog() { return &perf_log_; } + PerfLog *GetPerfLog() { return &perf_log_; } Stats stats_; Engine::Storage *storage_; diff --git a/tests/config_test.cc b/tests/config_test.cc index f98bc680489..041649f0f74 100644 --- a/tests/config_test.cc +++ b/tests/config_test.cc @@ -40,13 +40,13 @@ TEST(Config, ProfilingMaxRecordLen) { Config config; config.profiling_sample_record_max_len = 1; Server srv(nullptr, &config); - srv.GetPerLog()->PushEntry(PerfEntry{}); - srv.GetPerLog()->PushEntry(PerfEntry{}); - EXPECT_EQ(srv.GetPerLog()->Len(), 1); + srv.GetPerfLog()->PushEntry(PerfEntry{}); + srv.GetPerfLog()->PushEntry(PerfEntry{}); + EXPECT_EQ(srv.GetPerfLog()->Len(), 1); config.Set("profiling-sample-record-max-len", "2", &srv); - srv.GetPerLog()->PushEntry(PerfEntry{}); - srv.GetPerLog()->PushEntry(PerfEntry{}); - EXPECT_EQ(srv.GetPerLog()->Len(), 2); + srv.GetPerfLog()->PushEntry(PerfEntry{}); + srv.GetPerfLog()->PushEntry(PerfEntry{}); + EXPECT_EQ(srv.GetPerfLog()->Len(), 2); } TEST(Namespace, Add) {