Skip to content

Commit

Permalink
Merge pull request #13 from meitu/fix/typo
Browse files Browse the repository at this point in the history
FIX: typo, GetPerlog => GetPerfLog
  • Loading branch information
karelrooted authored Aug 29, 2019
2 parents 24ce852 + b07ad01 commit acf0aa9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(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") {
Expand Down
2 changes: 1 addition & 1 deletion src/redis_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
6 changes: 3 additions & 3 deletions src/redis_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(duration/1000) < threshold) {
rocksdb::SetPerfLevel(rocksdb::PerfLevel::kDisable);
Expand All @@ -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});
}

Expand Down Expand Up @@ -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<std::chrono::microseconds>(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<uint64_t>(duration), conn->current_cmd_->Name());
svr_->FeedMonitorConns(conn, cmd_tokens);
Expand Down
2 changes: 1 addition & 1 deletion src/redis_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
12 changes: 6 additions & 6 deletions tests/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit acf0aa9

Please sign in to comment.